diff --git a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchAuditLogAdapter.ts b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchAuditLogAdapter.ts index 7029eddac..22e3ce7db 100644 --- a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchAuditLogAdapter.ts +++ b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchAuditLogAdapter.ts @@ -3,11 +3,11 @@ import type {Client} from '@elastic/elasticsearch'; import type {SortCombinations} from '@elastic/elasticsearch/lib/api/types'; import type {AuditLogSearchFilters, SearchableAuditLog} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {ElasticsearchFilter} from '../ElasticsearchFilterUtils'; -import {compactFilters, esTermFilter} from '../ElasticsearchFilterUtils'; -import {ELASTICSEARCH_INDEX_DEFINITIONS} from '../ElasticsearchIndexDefinitions'; -import type {ElasticsearchDistributedLock} from './ElasticsearchIndexAdapter'; -import {ElasticsearchIndexAdapter} from './ElasticsearchIndexAdapter'; +import type {ElasticsearchDistributedLock} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import {ElasticsearchIndexAdapter} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import type {ElasticsearchFilter} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import {compactFilters, esTermFilter} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import {ELASTICSEARCH_INDEX_DEFINITIONS} from '@pkgs/elasticsearch_search/src/ElasticsearchIndexDefinitions'; function buildAuditLogFilters(filters: AuditLogSearchFilters): Array { const clauses: Array = []; diff --git a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchGuildAdapter.ts b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchGuildAdapter.ts index 9a0a93a2b..68eff4eff 100644 --- a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchGuildAdapter.ts +++ b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchGuildAdapter.ts @@ -3,11 +3,11 @@ import type {Client} from '@elastic/elasticsearch'; import type {SortCombinations} from '@elastic/elasticsearch/lib/api/types'; import type {GuildSearchFilters, SearchableGuild} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {ElasticsearchFilter} from '../ElasticsearchFilterUtils'; -import {compactFilters, esAndTerms, esTermFilter} from '../ElasticsearchFilterUtils'; -import {ELASTICSEARCH_INDEX_DEFINITIONS} from '../ElasticsearchIndexDefinitions'; -import type {ElasticsearchDistributedLock} from './ElasticsearchIndexAdapter'; -import {ElasticsearchIndexAdapter} from './ElasticsearchIndexAdapter'; +import type {ElasticsearchDistributedLock} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import {ElasticsearchIndexAdapter} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import type {ElasticsearchFilter} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import {compactFilters, esAndTerms, esTermFilter} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import {ELASTICSEARCH_INDEX_DEFINITIONS} from '@pkgs/elasticsearch_search/src/ElasticsearchIndexDefinitions'; function buildGuildFilters(filters: GuildSearchFilters): Array { const clauses: Array = []; diff --git a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchGuildMemberAdapter.ts b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchGuildMemberAdapter.ts index 3c035501d..5d5808237 100644 --- a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchGuildMemberAdapter.ts +++ b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchGuildMemberAdapter.ts @@ -6,11 +6,17 @@ import type { GuildMemberSearchFilters, SearchableGuildMember, } from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {ElasticsearchFilter} from '../ElasticsearchFilterUtils'; -import {compactFilters, esAndTerms, esRangeFilter, esTermFilter, esTermsFilter} from '../ElasticsearchFilterUtils'; -import {ELASTICSEARCH_INDEX_DEFINITIONS} from '../ElasticsearchIndexDefinitions'; -import type {ElasticsearchDistributedLock} from './ElasticsearchIndexAdapter'; -import {ElasticsearchIndexAdapter} from './ElasticsearchIndexAdapter'; +import type {ElasticsearchDistributedLock} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import {ElasticsearchIndexAdapter} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import type {ElasticsearchFilter} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import { + compactFilters, + esAndTerms, + esRangeFilter, + esTermFilter, + esTermsFilter, +} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import {ELASTICSEARCH_INDEX_DEFINITIONS} from '@pkgs/elasticsearch_search/src/ElasticsearchIndexDefinitions'; function buildGuildMemberFilters(filters: GuildMemberSearchFilters): Array { const clauses: Array = []; diff --git a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter.ts b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter.ts index 5401d7caf..fe7999348 100644 --- a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter.ts +++ b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter.ts @@ -11,9 +11,9 @@ import type { SortResults, } from '@elastic/elasticsearch/lib/api/types'; import type {ISearchAdapter, SearchOptions, SearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; -import type {ElasticsearchFilter} from '../ElasticsearchFilterUtils'; -import {compactFilters} from '../ElasticsearchFilterUtils'; -import type {ElasticsearchIndexDefinition} from '../ElasticsearchIndexDefinitions'; +import type {ElasticsearchFilter} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import {compactFilters} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import type {ElasticsearchIndexDefinition} from '@pkgs/elasticsearch_search/src/ElasticsearchIndexDefinitions'; const ELASTICSEARCH_MAX_RESULT_WINDOW = 10000; const DEEP_PAGINATION_BATCH_SIZE = 1000; diff --git a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchMessageAdapter.ts b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchMessageAdapter.ts index 7b54d9fb3..f6586a13e 100644 --- a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchMessageAdapter.ts +++ b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchMessageAdapter.ts @@ -4,11 +4,17 @@ import type {Client} from '@elastic/elasticsearch'; import type {SortCombinations} from '@elastic/elasticsearch/lib/api/types'; import type {SearchOptions, SearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {MessageSearchFilters, SearchableMessage} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {ElasticsearchFilter} from '../ElasticsearchFilterUtils'; -import {compactFilters, esAndTerms, esExcludeAny, esTermFilter, esTermsFilter} from '../ElasticsearchFilterUtils'; -import {ELASTICSEARCH_INDEX_DEFINITIONS} from '../ElasticsearchIndexDefinitions'; -import type {ElasticsearchDistributedLock} from './ElasticsearchIndexAdapter'; -import {ElasticsearchIndexAdapter} from './ElasticsearchIndexAdapter'; +import type {ElasticsearchDistributedLock} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import {ElasticsearchIndexAdapter} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import type {ElasticsearchFilter} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import { + compactFilters, + esAndTerms, + esExcludeAny, + esTermFilter, + esTermsFilter, +} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import {ELASTICSEARCH_INDEX_DEFINITIONS} from '@pkgs/elasticsearch_search/src/ElasticsearchIndexDefinitions'; const HAS_FIELD_MAP: Record = { image: 'hasImage', diff --git a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchReportAdapter.ts b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchReportAdapter.ts index a15feaebc..c79870579 100644 --- a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchReportAdapter.ts +++ b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchReportAdapter.ts @@ -3,11 +3,16 @@ import type {Client} from '@elastic/elasticsearch'; import type {SortCombinations} from '@elastic/elasticsearch/lib/api/types'; import type {ReportSearchFilters, SearchableReport} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {ElasticsearchFilter} from '../ElasticsearchFilterUtils'; -import {compactFilters, esExistsFilter, esNotExistsFilter, esTermFilter} from '../ElasticsearchFilterUtils'; -import {ELASTICSEARCH_INDEX_DEFINITIONS} from '../ElasticsearchIndexDefinitions'; -import type {ElasticsearchDistributedLock} from './ElasticsearchIndexAdapter'; -import {ElasticsearchIndexAdapter} from './ElasticsearchIndexAdapter'; +import type {ElasticsearchDistributedLock} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import {ElasticsearchIndexAdapter} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import type {ElasticsearchFilter} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import { + compactFilters, + esExistsFilter, + esNotExistsFilter, + esTermFilter, +} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import {ELASTICSEARCH_INDEX_DEFINITIONS} from '@pkgs/elasticsearch_search/src/ElasticsearchIndexDefinitions'; function buildReportFilters(filters: ReportSearchFilters): Array { const clauses: Array = []; diff --git a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchUserAdapter.ts b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchUserAdapter.ts index 744b9de54..d57cb0e9d 100644 --- a/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchUserAdapter.ts +++ b/fluxer_api/pkgs/elasticsearch_search/src/adapters/ElasticsearchUserAdapter.ts @@ -3,7 +3,9 @@ import type {Client} from '@elastic/elasticsearch'; import type {SortCombinations} from '@elastic/elasticsearch/lib/api/types'; import type {SearchableUser, UserSearchFilters} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {ElasticsearchFilter} from '../ElasticsearchFilterUtils'; +import type {ElasticsearchDistributedLock} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import {ElasticsearchIndexAdapter} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; +import type {ElasticsearchFilter} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; import { compactFilters, esAndTerms, @@ -11,10 +13,8 @@ import { esNotExistsFilter, esRangeFilter, esTermFilter, -} from '../ElasticsearchFilterUtils'; -import {ELASTICSEARCH_INDEX_DEFINITIONS} from '../ElasticsearchIndexDefinitions'; -import type {ElasticsearchDistributedLock} from './ElasticsearchIndexAdapter'; -import {ElasticsearchIndexAdapter} from './ElasticsearchIndexAdapter'; +} from '@pkgs/elasticsearch_search/src/ElasticsearchFilterUtils'; +import {ELASTICSEARCH_INDEX_DEFINITIONS} from '@pkgs/elasticsearch_search/src/ElasticsearchIndexDefinitions'; function buildUserFilters(filters: UserSearchFilters): Array { const clauses: Array = []; diff --git a/fluxer_api/pkgs/email/src/email_i18n/EmailI18nLocales.ts b/fluxer_api/pkgs/email/src/email_i18n/EmailI18nLocales.ts index 269d2e0e1..e1c179e34 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/EmailI18nLocales.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/EmailI18nLocales.ts @@ -1,39 +1,39 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {EmailTemplate, EmailTemplateKey} from '@pkgs/email/src/email_i18n/EmailI18nTypes.generated'; -import EMAIL_I18N_AR_MESSAGES from './locales/ar'; -import EMAIL_I18N_BG_MESSAGES from './locales/bg'; -import EMAIL_I18N_CS_MESSAGES from './locales/cs'; -import EMAIL_I18N_DA_MESSAGES from './locales/da'; -import EMAIL_I18N_DE_MESSAGES from './locales/de'; -import EMAIL_I18N_EL_MESSAGES from './locales/el'; -import EMAIL_I18N_EN_GB_MESSAGES from './locales/en-GB'; -import EMAIL_I18N_ES_419_MESSAGES from './locales/es-419'; -import EMAIL_I18N_ES_ES_MESSAGES from './locales/es-ES'; -import EMAIL_I18N_FI_MESSAGES from './locales/fi'; -import EMAIL_I18N_FR_MESSAGES from './locales/fr'; -import EMAIL_I18N_HE_MESSAGES from './locales/he'; -import EMAIL_I18N_HI_MESSAGES from './locales/hi'; -import EMAIL_I18N_HR_MESSAGES from './locales/hr'; -import EMAIL_I18N_HU_MESSAGES from './locales/hu'; -import EMAIL_I18N_ID_MESSAGES from './locales/id'; -import EMAIL_I18N_IT_MESSAGES from './locales/it'; -import EMAIL_I18N_JA_MESSAGES from './locales/ja'; -import EMAIL_I18N_KO_MESSAGES from './locales/ko'; -import EMAIL_I18N_LT_MESSAGES from './locales/lt'; -import EMAIL_I18N_NL_MESSAGES from './locales/nl'; -import EMAIL_I18N_NO_MESSAGES from './locales/no'; -import EMAIL_I18N_PL_MESSAGES from './locales/pl'; -import EMAIL_I18N_PT_BR_MESSAGES from './locales/pt-BR'; -import EMAIL_I18N_RO_MESSAGES from './locales/ro'; -import EMAIL_I18N_RU_MESSAGES from './locales/ru'; -import EMAIL_I18N_SV_SE_MESSAGES from './locales/sv-SE'; -import EMAIL_I18N_TH_MESSAGES from './locales/th'; -import EMAIL_I18N_TR_MESSAGES from './locales/tr'; -import EMAIL_I18N_UK_MESSAGES from './locales/uk'; -import EMAIL_I18N_VI_MESSAGES from './locales/vi'; -import EMAIL_I18N_ZH_CN_MESSAGES from './locales/zh-CN'; -import EMAIL_I18N_ZH_TW_MESSAGES from './locales/zh-TW'; +import EMAIL_I18N_AR_MESSAGES from '@pkgs/email/src/email_i18n/locales/ar'; +import EMAIL_I18N_BG_MESSAGES from '@pkgs/email/src/email_i18n/locales/bg'; +import EMAIL_I18N_CS_MESSAGES from '@pkgs/email/src/email_i18n/locales/cs'; +import EMAIL_I18N_DA_MESSAGES from '@pkgs/email/src/email_i18n/locales/da'; +import EMAIL_I18N_DE_MESSAGES from '@pkgs/email/src/email_i18n/locales/de'; +import EMAIL_I18N_EL_MESSAGES from '@pkgs/email/src/email_i18n/locales/el'; +import EMAIL_I18N_EN_GB_MESSAGES from '@pkgs/email/src/email_i18n/locales/en-GB'; +import EMAIL_I18N_ES_419_MESSAGES from '@pkgs/email/src/email_i18n/locales/es-419'; +import EMAIL_I18N_ES_ES_MESSAGES from '@pkgs/email/src/email_i18n/locales/es-ES'; +import EMAIL_I18N_FI_MESSAGES from '@pkgs/email/src/email_i18n/locales/fi'; +import EMAIL_I18N_FR_MESSAGES from '@pkgs/email/src/email_i18n/locales/fr'; +import EMAIL_I18N_HE_MESSAGES from '@pkgs/email/src/email_i18n/locales/he'; +import EMAIL_I18N_HI_MESSAGES from '@pkgs/email/src/email_i18n/locales/hi'; +import EMAIL_I18N_HR_MESSAGES from '@pkgs/email/src/email_i18n/locales/hr'; +import EMAIL_I18N_HU_MESSAGES from '@pkgs/email/src/email_i18n/locales/hu'; +import EMAIL_I18N_ID_MESSAGES from '@pkgs/email/src/email_i18n/locales/id'; +import EMAIL_I18N_IT_MESSAGES from '@pkgs/email/src/email_i18n/locales/it'; +import EMAIL_I18N_JA_MESSAGES from '@pkgs/email/src/email_i18n/locales/ja'; +import EMAIL_I18N_KO_MESSAGES from '@pkgs/email/src/email_i18n/locales/ko'; +import EMAIL_I18N_LT_MESSAGES from '@pkgs/email/src/email_i18n/locales/lt'; +import EMAIL_I18N_NL_MESSAGES from '@pkgs/email/src/email_i18n/locales/nl'; +import EMAIL_I18N_NO_MESSAGES from '@pkgs/email/src/email_i18n/locales/no'; +import EMAIL_I18N_PL_MESSAGES from '@pkgs/email/src/email_i18n/locales/pl'; +import EMAIL_I18N_PT_BR_MESSAGES from '@pkgs/email/src/email_i18n/locales/pt-BR'; +import EMAIL_I18N_RO_MESSAGES from '@pkgs/email/src/email_i18n/locales/ro'; +import EMAIL_I18N_RU_MESSAGES from '@pkgs/email/src/email_i18n/locales/ru'; +import EMAIL_I18N_SV_SE_MESSAGES from '@pkgs/email/src/email_i18n/locales/sv-SE'; +import EMAIL_I18N_TH_MESSAGES from '@pkgs/email/src/email_i18n/locales/th'; +import EMAIL_I18N_TR_MESSAGES from '@pkgs/email/src/email_i18n/locales/tr'; +import EMAIL_I18N_UK_MESSAGES from '@pkgs/email/src/email_i18n/locales/uk'; +import EMAIL_I18N_VI_MESSAGES from '@pkgs/email/src/email_i18n/locales/vi'; +import EMAIL_I18N_ZH_CN_MESSAGES from '@pkgs/email/src/email_i18n/locales/zh-CN'; +import EMAIL_I18N_ZH_TW_MESSAGES from '@pkgs/email/src/email_i18n/locales/zh-TW'; export const EMAIL_I18N_LOCALE_MESSAGES = { ar: EMAIL_I18N_AR_MESSAGES, diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/ar.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/ar.ts index 3875a4124..e2b204752 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/ar.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/ar.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_AR_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/bg.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/bg.ts index 1126924f2..f01cb6b4c 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/bg.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/bg.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_BG_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/cs.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/cs.ts index be70988d9..1d4b934ef 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/cs.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/cs.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_CS_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/da.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/da.ts index 2d33ed4b5..f06d6cee1 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/da.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/da.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_DA_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/de.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/de.ts index 26aef3173..0dfa425a0 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/de.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/de.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_DE_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/el.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/el.ts index 08cef4449..f17b5f417 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/el.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/el.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_EL_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/en-GB.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/en-GB.ts index a5bee288a..e13edbbd1 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/en-GB.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/en-GB.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_EN_GB_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/es-419.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/es-419.ts index bf926eda0..6bd481c5f 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/es-419.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/es-419.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_ES_419_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/es-ES.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/es-ES.ts index 4810cda88..e3e5c9aa9 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/es-ES.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/es-ES.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_ES_ES_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/fi.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/fi.ts index 7a624decc..aa6de7984 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/fi.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/fi.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_FI_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/fr.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/fr.ts index bfe3066db..ad10f81ce 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/fr.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/fr.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_FR_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/he.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/he.ts index ee0d86812..3b4edb503 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/he.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/he.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_HE_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/hi.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/hi.ts index ecacdfd14..4b4cb48c9 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/hi.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/hi.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_HI_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/hr.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/hr.ts index b6d3b4e11..fb82af0ce 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/hr.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/hr.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_HR_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/hu.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/hu.ts index 061aa8faf..d5fe45e3a 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/hu.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/hu.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_HU_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/id.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/id.ts index 98f7e49ef..90a79d7a0 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/id.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/id.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_ID_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/it.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/it.ts index 3227a6e69..0426baea1 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/it.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/it.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_IT_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/ja.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/ja.ts index b93d2d7cf..d08082e8a 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/ja.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/ja.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_JA_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/ko.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/ko.ts index 5a804eca2..32265c1f0 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/ko.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/ko.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_KO_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/lt.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/lt.ts index 11edd284e..addc7a3cb 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/lt.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/lt.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_LT_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/nl.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/nl.ts index af74d5fa2..bb3d27c6b 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/nl.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/nl.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_NL_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/no.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/no.ts index ec792cf5a..d0742ed02 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/no.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/no.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_NO_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/pl.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/pl.ts index b74f6b265..642070320 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/pl.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/pl.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_PL_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/pt-BR.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/pt-BR.ts index 0e7f66ffb..0d8da4420 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/pt-BR.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/pt-BR.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_PT_BR_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/ro.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/ro.ts index e9572f3e1..fec174745 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/ro.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/ro.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_RO_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/ru.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/ru.ts index 9f42078a2..1cad38570 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/ru.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/ru.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_RU_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/sv-SE.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/sv-SE.ts index f21806933..34ef416b6 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/sv-SE.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/sv-SE.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_SV_SE_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/th.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/th.ts index 01cfef6a0..5d4d8bd1a 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/th.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/th.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_TH_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/tr.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/tr.ts index 85e676f04..72b08e2eb 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/tr.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/tr.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_TR_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/uk.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/uk.ts index bffa09361..cd6af9d8e 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/uk.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/uk.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_UK_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/vi.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/vi.ts index bff009a46..862aeeefc 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/vi.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/vi.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_VI_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/zh-CN.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/zh-CN.ts index 451e69503..7de7a65b5 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/zh-CN.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/zh-CN.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_ZH_CN_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/email/src/email_i18n/locales/zh-TW.ts b/fluxer_api/pkgs/email/src/email_i18n/locales/zh-TW.ts index 6562e2c94..805b82b85 100644 --- a/fluxer_api/pkgs/email/src/email_i18n/locales/zh-TW.ts +++ b/fluxer_api/pkgs/email/src/email_i18n/locales/zh-TW.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineEmailI18nLocaleMessages} from '../EmailI18nMessages'; +import {defineEmailI18nLocaleMessages} from '@pkgs/email/src/email_i18n/EmailI18nMessages'; const EMAIL_I18N_ZH_TW_MESSAGES = defineEmailI18nLocaleMessages({ "account_disabled_suspicious": { diff --git a/fluxer_api/pkgs/geoip/src/ResolveClientGeoip.ts b/fluxer_api/pkgs/geoip/src/ResolveClientGeoip.ts index 37a40dfc4..539230adc 100644 --- a/fluxer_api/pkgs/geoip/src/ResolveClientGeoip.ts +++ b/fluxer_api/pkgs/geoip/src/ResolveClientGeoip.ts @@ -3,7 +3,7 @@ import {AGE_BLOCKED_GEOS, AGE_RESTRICTED_GEOS} from '@fluxer/instance_bootstrap/src/AgeGeos'; import type {GeolocationResponse} from '@fluxer/instance_bootstrap/src/Types'; import {extractClientIp} from '@fluxer/ip_utils/src/ClientIp'; -import {lookupGeoipByIp} from './GeoipLookup'; +import {lookupGeoipByIp} from '@pkgs/geoip/src/GeoipLookup'; interface ResolveClientGeoipOptions { maxmindDbPath: string | undefined; diff --git a/fluxer_api/scripts/build.mjs b/fluxer_api/scripts/build.mjs index ad5af6bd8..0c743687e 100644 --- a/fluxer_api/scripts/build.mjs +++ b/fluxer_api/scripts/build.mjs @@ -1,38 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {existsSync, readFileSync, rmSync, statSync} from 'node:fs'; +import {readFileSync, rmSync} from 'node:fs'; import {isBuiltin} from 'node:module'; import {dirname, join, resolve} from 'node:path'; import {fileURLToPath} from 'node:url'; import {build} from 'esbuild'; const API_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..'); -const REPO_ROOT = resolve(API_ROOT, '..'); const OUT_DIR = join(API_ROOT, 'dist'); -const CANDIDATE_SUFFIXES = ['', '.ts', '.tsx', '.js', '.mjs', '/index.ts', '/index.tsx', '/index.js', '/src/index.ts']; - -const WORKSPACE_ROOTS = { - '@app/': join(API_ROOT, 'src'), - '@pkgs/': join(API_ROOT, 'pkgs'), - '@fluxer/': join(REPO_ROOT, 'packages'), -}; - -function resolveWorkspacePath(specifier) { - for (const [prefix, root] of Object.entries(WORKSPACE_ROOTS)) { - if (!specifier.startsWith(prefix)) { - continue; - } - const base = join(root, specifier.slice(prefix.length)); - for (const suffix of CANDIDATE_SUFFIXES) { - const candidate = `${base}${suffix}`; - if (existsSync(candidate) && statSync(candidate).isFile()) { - return candidate; - } - } - throw new Error(`Unable to resolve workspace import ${specifier}`); - } - return null; -} +const WORKSPACE_PREFIXES = ['@app/', '@pkgs/', '@fluxer/']; function packageNameOf(specifier) { const segments = specifier.split('/'); @@ -48,9 +24,8 @@ const workspacePlugin = { name: 'fluxer-workspace', setup(pluginBuild) { pluginBuild.onResolve({filter: /^[^./]/}, (args) => { - const workspacePath = resolveWorkspacePath(args.path); - if (workspacePath) { - return {path: workspacePath}; + if (WORKSPACE_PREFIXES.some((prefix) => args.path.startsWith(prefix))) { + return undefined; } const packageName = packageNameOf(args.path); if (!isBuiltin(args.path) && !declaredDependencies.has(packageName)) { diff --git a/fluxer_api/src/api/ApiContext.ts b/fluxer_api/src/api/ApiContext.ts index f98ff7bfd..1122ab3d8 100644 --- a/fluxer_api/src/api/ApiContext.ts +++ b/fluxer_api/src/api/ApiContext.ts @@ -1,24 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {InboundSmsChallengeService} from '@app/api/auth/services/InboundSmsChallengeService'; +import type {PhoneAttemptRiskService} from '@app/api/auth/services/PhoneAttemptRiskService'; +import type {IPhoneLookupRepository} from '@app/api/auth/services/PhoneLookupRepository'; +import type {Config} from '@app/api/Config'; +import type {IEmailDnsValidationService} from '@app/api/infrastructure/IEmailDnsValidationService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {BotMfaMirrorService} from '@app/api/oauth/BotMfaMirrorService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {UserActivityBuffer} from '@app/api/user/services/UserActivityBuffer'; +import type {UserContactChangeLogService} from '@app/api/user/services/UserContactChangeLogService'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {IEmailService} from '@pkgs/email/src/IEmailService'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; import type {ISmsService} from '@pkgs/sms/src/ISmsService'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import type {InboundSmsChallengeService} from './auth/services/InboundSmsChallengeService'; -import type {PhoneAttemptRiskService} from './auth/services/PhoneAttemptRiskService'; -import type {IPhoneLookupRepository} from './auth/services/PhoneLookupRepository'; -import type {Config} from './Config'; -import type {IEmailDnsValidationService} from './infrastructure/IEmailDnsValidationService'; -import type {IGatewayService} from './infrastructure/IGatewayService'; -import type {IMediaService} from './infrastructure/IMediaService'; -import type {ISnowflakeService} from './infrastructure/ISnowflakeService'; -import type {BotMfaMirrorService} from './oauth/BotMfaMirrorService'; -import type {IUserRepository} from './user/IUserRepository'; -import type {UserActivityBuffer} from './user/services/UserActivityBuffer'; -import type {UserContactChangeLogService} from './user/services/UserContactChangeLogService'; -import type {WorkerTaskName} from './worker/WorkerLaneConfig'; export interface ApiServices { users: IUserRepository; diff --git a/fluxer_api/src/api/App.ts b/fluxer_api/src/api/App.ts index 284961fe8..502b90304 100644 --- a/fluxer_api/src/api/App.ts +++ b/fluxer_api/src/api/App.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createInitializer, createShutdown} from '@app/api/app/APILifecycle'; +import {registerControllers} from '@app/api/app/ControllerRegistry'; +import {configureMiddleware} from '@app/api/app/MiddlewarePipeline'; +import type {APIConfig} from '@app/api/config/APIConfig'; +import type {ILogger} from '@app/api/ILogger'; +import {recordHttpClientError} from '@app/api/middleware/AbusiveIpAutoBanner'; +import type {HonoApp, HonoEnv} from '@app/api/types/HonoEnv'; import {AppErrorHandler, AppNotFoundHandler} from '@fluxer/errors/src/domains/core/ErrorHandlers'; import {IpBannedError} from '@fluxer/errors/src/domains/moderation/IpBannedError'; import {resolveErrorStatus} from '@fluxer/errors/src/error_handling/ErrorIntrospection'; @@ -8,13 +15,6 @@ import {LOCKED_DOWN_PERMISSIONS_POLICY, securityHeaders} from '@fluxer/hono/src/ import {setIsDevelopment} from '@fluxer/schema/src/primitives/UrlValidators'; import type {Context} from 'hono'; import {Hono} from 'hono'; -import {createInitializer, createShutdown} from './app/APILifecycle'; -import {registerControllers} from './app/ControllerRegistry'; -import {configureMiddleware} from './app/MiddlewarePipeline'; -import type {APIConfig} from './config/APIConfig'; -import type {ILogger} from './ILogger'; -import {recordHttpClientError} from './middleware/AbusiveIpAutoBanner'; -import type {HonoApp, HonoEnv} from './types/HonoEnv'; interface CreateAPIAppOptions { config: APIConfig; diff --git a/fluxer_api/src/api/Config.test.ts b/fluxer_api/src/api/Config.test.ts index ebaf216e5..3dd92bdb3 100644 --- a/fluxer_api/src/api/Config.test.ts +++ b/fluxer_api/src/api/Config.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {buildAPIConfigFromMaster, buildAPIServerOptions} from '@app/api/Config'; import {loadConfig, resetConfig} from '@fluxer/config/src/ConfigLoader'; import type {MasterConfig} from '@fluxer/config/src/MasterConfig'; import {createServer} from '@fluxer/hono/src/Server'; import {Hono} from 'hono'; import {afterAll, afterEach, beforeAll, describe, expect, it, test, vi} from 'vitest'; -import {buildAPIConfigFromMaster, buildAPIServerOptions} from './Config'; interface ListeningServer { close: (callback: () => void) => void; diff --git a/fluxer_api/src/api/Config.ts b/fluxer_api/src/api/Config.ts index 95d1fd511..de099e1b3 100644 --- a/fluxer_api/src/api/Config.ts +++ b/fluxer_api/src/api/Config.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {APIConfig, BlueskyOAuthConfig} from '@app/api/config/APIConfig'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import type {MasterConfig} from '@fluxer/config/src/MasterConfig'; import {resolveDownloadsProvider} from '@fluxer/config/src/S3DownloadsProvider'; import {parseIpAddress} from '@fluxer/ip_utils/src/IpAddress'; import {parseGeoipSourceConfig, resolveGeoipRuntimeSourceConfig} from '@pkgs/geoip/src/GeoipStartup'; -import type {APIConfig, BlueskyOAuthConfig} from './config/APIConfig'; -import type {WorkerTaskName} from './worker/WorkerLaneConfig'; function extractHostname(url: string): string { try { diff --git a/fluxer_api/src/api/CreateApiContext.ts b/fluxer_api/src/api/CreateApiContext.ts index d46f9d786..650f3c51d 100644 --- a/fluxer_api/src/api/CreateApiContext.ts +++ b/fluxer_api/src/api/CreateApiContext.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApiContext, ApiServices, RequestScope} from './ApiContext'; -import {CassandraPhoneLookupRepository} from './auth/services/PhoneLookupRepository'; -import {Config} from './Config'; -import {getInboundSmsChallengeServiceInstance} from './middleware/ServiceMiddleware'; +import type {ApiContext, ApiServices, RequestScope} from '@app/api/ApiContext'; +import {CassandraPhoneLookupRepository} from '@app/api/auth/services/PhoneLookupRepository'; +import {Config} from '@app/api/Config'; +import {getInboundSmsChallengeServiceInstance} from '@app/api/middleware/ServiceMiddleware'; import { getGatewayService, getKVClient, getMediaService, getSnowflakeService, getWorkerService, -} from './middleware/ServiceRegistry'; +} from '@app/api/middleware/ServiceRegistry'; import { getBotMfaMirrorService, getCacheService, @@ -22,7 +22,7 @@ import { getSmsService, getUserActivityBuffer, getUserRepository, -} from './middleware/ServiceSingletons'; +} from '@app/api/middleware/ServiceSingletons'; let cachedServices: ApiServices | null = null; let cachedConfigRef: typeof Config | null = null; diff --git a/fluxer_api/src/api/Logger.ts b/fluxer_api/src/api/Logger.ts index 9f7afacc3..e2a62338c 100644 --- a/fluxer_api/src/api/Logger.ts +++ b/fluxer_api/src/api/Logger.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ILogger} from './ILogger'; +import type {ILogger} from '@app/api/ILogger'; let _logger: ILogger | null = null; diff --git a/fluxer_api/src/api/RateLimitConfig.ts b/fluxer_api/src/api/RateLimitConfig.ts index 30825b936..2a17a0f1f 100644 --- a/fluxer_api/src/api/RateLimitConfig.ts +++ b/fluxer_api/src/api/RateLimitConfig.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {AdminRateLimitConfigs} from './rate_limit_configs/AdminRateLimitConfig'; -import {AuthRateLimitConfigs} from './rate_limit_configs/AuthRateLimitConfig'; -import {ChannelRateLimitConfigs} from './rate_limit_configs/ChannelRateLimitConfig'; -import {DiscoveryRateLimitConfigs} from './rate_limit_configs/DiscoveryRateLimitConfig'; -import {DonationRateLimitConfigs} from './rate_limit_configs/DonationRateLimitConfig'; -import {GuildRateLimitConfigs} from './rate_limit_configs/GuildRateLimitConfig'; -import {IntegrationRateLimitConfigs} from './rate_limit_configs/IntegrationRateLimitConfig'; -import {InviteRateLimitConfigs} from './rate_limit_configs/InviteRateLimitConfig'; -import {MiscRateLimitConfigs} from './rate_limit_configs/MiscRateLimitConfig'; -import {OAuthRateLimitConfigs} from './rate_limit_configs/OAuthRateLimitConfig'; -import type {RateLimitSection} from './rate_limit_configs/RateLimitHelpers'; -import {mergeRateLimitSections} from './rate_limit_configs/RateLimitHelpers'; -import {UserRateLimitConfigs} from './rate_limit_configs/UserRateLimitConfig'; -import {WebhookRateLimitConfigs} from './rate_limit_configs/WebhookRateLimitConfig'; +import {AdminRateLimitConfigs} from '@app/api/rate_limit_configs/AdminRateLimitConfig'; +import {AuthRateLimitConfigs} from '@app/api/rate_limit_configs/AuthRateLimitConfig'; +import {ChannelRateLimitConfigs} from '@app/api/rate_limit_configs/ChannelRateLimitConfig'; +import {DiscoveryRateLimitConfigs} from '@app/api/rate_limit_configs/DiscoveryRateLimitConfig'; +import {DonationRateLimitConfigs} from '@app/api/rate_limit_configs/DonationRateLimitConfig'; +import {GuildRateLimitConfigs} from '@app/api/rate_limit_configs/GuildRateLimitConfig'; +import {IntegrationRateLimitConfigs} from '@app/api/rate_limit_configs/IntegrationRateLimitConfig'; +import {InviteRateLimitConfigs} from '@app/api/rate_limit_configs/InviteRateLimitConfig'; +import {MiscRateLimitConfigs} from '@app/api/rate_limit_configs/MiscRateLimitConfig'; +import {OAuthRateLimitConfigs} from '@app/api/rate_limit_configs/OAuthRateLimitConfig'; +import type {RateLimitSection} from '@app/api/rate_limit_configs/RateLimitHelpers'; +import {mergeRateLimitSections} from '@app/api/rate_limit_configs/RateLimitHelpers'; +import {UserRateLimitConfigs} from '@app/api/rate_limit_configs/UserRateLimitConfig'; +import {WebhookRateLimitConfigs} from '@app/api/rate_limit_configs/WebhookRateLimitConfig'; const rateLimitSections = [ AuthRateLimitConfigs, diff --git a/fluxer_api/src/api/SearchFactory.ts b/fluxer_api/src/api/SearchFactory.ts index 4859ae93c..555ca92a2 100644 --- a/fluxer_api/src/api/SearchFactory.ts +++ b/fluxer_api/src/api/SearchFactory.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {ElasticsearchSearchProvider} from '@app/api/infrastructure/ElasticsearchSearchProvider'; +import {MeilisearchSearchProvider} from '@app/api/infrastructure/MeilisearchSearchProvider'; +import {NullSearchProvider} from '@app/api/infrastructure/NullSearchProvider'; +import {Logger} from '@app/api/Logger'; +import {getInjectedSearchProvider} from '@app/api/middleware/ServiceRegistry'; +import type {IAuditLogSearchService} from '@app/api/search/IAuditLogSearchService'; +import type {IGuildMemberSearchService} from '@app/api/search/IGuildMemberSearchService'; +import type {IGuildSearchService} from '@app/api/search/IGuildSearchService'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import type {IReportSearchService} from '@app/api/search/IReportSearchService'; +import type {ISearchProvider} from '@app/api/search/ISearchProvider'; +import type {IUserSearchService} from '@app/api/search/IUserSearchService'; import {DEFAULT_SEARCH_CLIENT_TIMEOUT_MS} from '@fluxer/constants/src/Timeouts'; import type {ElasticsearchDistributedLock} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; -import {Config} from './Config'; -import {ElasticsearchSearchProvider} from './infrastructure/ElasticsearchSearchProvider'; -import {MeilisearchSearchProvider} from './infrastructure/MeilisearchSearchProvider'; -import {NullSearchProvider} from './infrastructure/NullSearchProvider'; -import {Logger} from './Logger'; -import {getInjectedSearchProvider} from './middleware/ServiceRegistry'; -import type {IAuditLogSearchService} from './search/IAuditLogSearchService'; -import type {IGuildMemberSearchService} from './search/IGuildMemberSearchService'; -import type {IGuildSearchService} from './search/IGuildSearchService'; -import type {IMessageSearchService} from './search/IMessageSearchService'; -import type {IReportSearchService} from './search/IReportSearchService'; -import type {ISearchProvider} from './search/ISearchProvider'; -import type {IUserSearchService} from './search/IUserSearchService'; let searchProvider: ISearchProvider | null = null; diff --git a/fluxer_api/src/api/Tables.ts b/fluxer_api/src/api/Tables.ts index 122c76a1f..e047c146f 100644 --- a/fluxer_api/src/api/Tables.ts +++ b/fluxer_api/src/api/Tables.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID, ChannelID, GuildID, MemeID, PasswordResetToken, UserID} from './BrandedTypes'; -import {defineTable} from './database/CassandraTableDsl'; +import type {AttachmentID, ChannelID, GuildID, MemeID, PasswordResetToken, UserID} from '@app/api/BrandedTypes'; +import {defineTable} from '@app/api/database/CassandraTableDsl'; import { ADMIN_ARCHIVE_COLUMNS, ADMIN_ARCHIVE_INDEX_COLUMNS, @@ -31,19 +31,19 @@ import { type DisposableEmailDomainRow, SUSPICIOUS_EMAIL_DOMAIN_COLUMNS, type SuspiciousEmailDomainRow, -} from './database/types/AdminArchiveTypes'; +} from '@app/api/database/types/AdminArchiveTypes'; import { ADMIN_API_KEY_BY_CREATOR_COLUMNS, ADMIN_API_KEY_COLUMNS, type AdminApiKeyByCreatorRow, type AdminApiKeyRow, -} from './database/types/AdminAuthTypes'; +} from '@app/api/database/types/AdminAuthTypes'; import { ATTACHMENT_UPLOAD_TRACE_BY_ATTACHMENT_COLUMNS, ATTACHMENT_UPLOAD_TRACE_BY_KEY_COLUMNS, type AttachmentUploadTraceByAttachmentRow, type AttachmentUploadTraceByKeyRow, -} from './database/types/AttachmentUploadTypes'; +} from '@app/api/database/types/AttachmentUploadTypes'; import { AUTH_SESSION_COLUMNS, AUTH_SESSION_TOMBSTONE_COLUMNS, @@ -77,7 +77,7 @@ import { type UserSsoIdentityRow, WEBAUTHN_CREDENTIAL_COLUMNS, type WebAuthnCredentialRow, -} from './database/types/AuthTypes'; +} from '@app/api/database/types/AuthTypes'; import { BILLING_ACTION_INTENT_COLUMNS, BILLING_CHARGE_BY_CUSTOMER_COLUMNS, @@ -133,7 +133,7 @@ import { type BillingSubscriptionByCustomerRow, type BillingSubscriptionByUserRow, type BillingSubscriptionRow, -} from './database/types/BillingTypes'; +} from '@app/api/database/types/BillingTypes'; import { CHANNEL_COLUMNS, CHANNELS_BY_GUILD_COLUMNS, @@ -147,20 +147,20 @@ import { type PrivateChannelRow, WEBHOOK_COLUMNS, type WebhookRow, -} from './database/types/ChannelTypes'; -import {USER_CONNECTION_STORAGE_COLUMNS, type UserConnectionStorageRow} from './database/types/ConnectionTypes'; +} from '@app/api/database/types/ChannelTypes'; +import {USER_CONNECTION_STORAGE_COLUMNS, type UserConnectionStorageRow} from '@app/api/database/types/ConnectionTypes'; import { NCMEC_ATTACHMENT_SUBMISSION_COLUMNS, NCMEC_USER_WORKFLOW_COLUMNS, type NcmecAttachmentSubmissionRow, type NcmecUserWorkflowRow, -} from './database/types/CsamTypes'; +} from '@app/api/database/types/CsamTypes'; import { GUILD_DISCOVERY_BY_STATUS_COLUMNS, GUILD_DISCOVERY_COLUMNS, type GuildDiscoveryByStatusRow, type GuildDiscoveryRow, -} from './database/types/GuildDiscoveryTypes'; +} from '@app/api/database/types/GuildDiscoveryTypes'; import { GUILD_AUDIT_LOG_COLUMNS, GUILD_BAN_BY_EMAIL_COLUMNS, @@ -186,8 +186,11 @@ import { type GuildRoleRow, type GuildRow, type GuildStickerRow, -} from './database/types/GuildTypes'; -import {INSTANCE_CONFIGURATION_COLUMNS, type InstanceConfigurationRow} from './database/types/InstanceConfigTypes'; +} from '@app/api/database/types/GuildTypes'; +import { + INSTANCE_CONFIGURATION_COLUMNS, + type InstanceConfigurationRow, +} from '@app/api/database/types/InstanceConfigTypes'; import { JOB_ACTIVE_COLUMNS, JOB_BY_DAY_BUCKET_COLUMNS, @@ -195,7 +198,7 @@ import { type JobActiveRow, type JobByDayBucketRow, type JobByIdRow, -} from './database/types/JobLedgerTypes'; +} from '@app/api/database/types/JobLedgerTypes'; import { ATTACHMENT_LOOKUP_COLUMNS, type AttachmentLookupRow, @@ -213,7 +216,7 @@ import { type MessageByAuthorRow, type MessageReactionRow, type MessageRow, -} from './database/types/MessageTypes'; +} from '@app/api/database/types/MessageTypes'; import { APPLICATION_COLUMNS, type ApplicationByOwnerRow, @@ -226,7 +229,7 @@ import { type OAuth2AuthorizationCodeRow, type OAuth2RefreshTokenByUserRow, type OAuth2RefreshTokenRow, -} from './database/types/OAuth2Types'; +} from '@app/api/database/types/OAuth2Types'; import { GIFT_CODE_BY_CREATOR_COLUMNS, GIFT_CODE_BY_PAYMENT_INTENT_COLUMNS, @@ -246,7 +249,7 @@ import { type PaymentRow, VISIONARY_SLOT_COLUMNS, type VisionarySlotRow, -} from './database/types/PaymentTypes'; +} from '@app/api/database/types/PaymentTypes'; import { DSA_REPORT_EMAIL_VERIFICATION_COLUMNS, DSA_REPORT_TICKET_COLUMNS, @@ -256,7 +259,7 @@ import { type IARSubmissionRow, MESSAGE_REPORT_SUBMISSION_BY_REPORTER_COLUMNS, type MessageReportSubmissionByReporterRow, -} from './database/types/ReportTypes'; +} from '@app/api/database/types/ReportTypes'; import { INBOUND_SMS_CHALLENGE_BY_USER_COLUMNS, INBOUND_SMS_CHALLENGE_COLUMNS, @@ -290,7 +293,7 @@ import { type RiskOutcomeBySubnetRow, SUSPICIOUS_IP_COLUMNS, type SuspiciousIpRow, -} from './database/types/RiskTypes'; +} from '@app/api/database/types/RiskTypes'; import { FAVORITE_MEME_COLUMNS, type FavoriteMemeRow, @@ -336,8 +339,8 @@ import { type UserRow, type UserSettingsRow, type UsersPendingDeletionRow, -} from './database/types/UserTypes'; -import {ATTACHMENT_DECAY_COLUMNS, type AttachmentDecayRow} from './types/AttachmentDecayTypes'; +} from '@app/api/database/types/UserTypes'; +import {ATTACHMENT_DECAY_COLUMNS, type AttachmentDecayRow} from '@app/api/types/AttachmentDecayTypes'; export const Users = defineTable({ name: 'users', diff --git a/fluxer_api/src/api/Validator.ts b/fluxer_api/src/api/Validator.ts index c80916add..1cf7cf1d5 100644 --- a/fluxer_api/src/api/Validator.ts +++ b/fluxer_api/src/api/Validator.ts @@ -1,5 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireRequestJsonBody} from '@app/api/utils/RequestJsonBody'; +import {initializeFluxerErrorMap} from '@app/api/ZodErrorMap'; import type {ValidationErrorCode} from '@fluxer/constants/src/ValidationErrorCodes'; import {isValidationErrorCode, ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import { @@ -11,8 +13,6 @@ import {schemaMetadata} from '@fluxer/schema/src/SchemaMetadata'; import type {Context, Env, Input, MiddlewareHandler, TypedResponse, ValidationTargets} from 'hono'; import {getCookie} from 'hono/cookie'; import {type core, type input, type output, ZodObject, ZodOptional, type ZodSafeParseResult, type ZodType} from 'zod'; -import {requireRequestJsonBody} from './utils/RequestJsonBody'; -import {initializeFluxerErrorMap} from './ZodErrorMap'; initializeFluxerErrorMap(); diff --git a/fluxer_api/src/api/ZodErrorMap.test.ts b/fluxer_api/src/api/ZodErrorMap.test.ts index baa69afd2..6e95b1fa1 100644 --- a/fluxer_api/src/api/ZodErrorMap.test.ts +++ b/fluxer_api/src/api/ZodErrorMap.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {initializeFluxerErrorMap} from '@app/api/ZodErrorMap'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {beforeAll, describe, expect, it} from 'vitest'; import {z} from 'zod'; -import {initializeFluxerErrorMap} from './ZodErrorMap'; function firstIssueMessage(schema: z.ZodType, value: unknown): string | undefined { const result = schema.safeParse(value); diff --git a/fluxer_api/src/api/admin/AdminRepository.ts b/fluxer_api/src/api/admin/AdminRepository.ts index 52e95591d..818c1409a 100644 --- a/fluxer_api/src/api/admin/AdminRepository.ts +++ b/fluxer_api/src/api/admin/AdminRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress'; -import {createUserID} from '../BrandedTypes'; -import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../database/CassandraQueryExecution'; +import type {AdminAuditLog, BannedIpEntry, BannedIpKind, IAdminRepository} from '@app/api/admin/IAdminRepository'; +import {createUserID} from '@app/api/BrandedTypes'; +import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; import type { AdminAuditLogRow, BannedAvatarHashRow, @@ -11,9 +11,9 @@ import type { BannedProfileSubstringScope, BannedUrlDomainRow, BannedUrlRow, -} from '../database/types/AdminArchiveTypes'; -import {isAccountPolicyContactDomainReputationExempt} from '../risk/AccountPolicyService'; -import {isIpBanExempt} from '../risk/IpBanExemptions'; +} from '@app/api/database/types/AdminArchiveTypes'; +import {isAccountPolicyContactDomainReputationExempt} from '@app/api/risk/AccountPolicyService'; +import {isIpBanExempt} from '@app/api/risk/IpBanExemptions'; import { AdminAuditLogs, BannedAvatarHashes, @@ -27,10 +27,10 @@ import { BannedUrls, DisposableEmailDomains, SuspiciousEmailDomains, -} from '../Tables'; -import {parseIpBanEntry, tryParseSingleIp} from '../utils/IpRangeUtils'; -import {canonicalizeStoredPhrase} from '../utils/PhraseBlocklistNormalization'; -import type {AdminAuditLog, BannedIpEntry, BannedIpKind, IAdminRepository} from './IAdminRepository'; +} from '@app/api/Tables'; +import {parseIpBanEntry, tryParseSingleIp} from '@app/api/utils/IpRangeUtils'; +import {canonicalizeStoredPhrase} from '@app/api/utils/PhraseBlocklistNormalization'; +import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress'; const FETCH_AUDIT_LOG_BY_ID_QUERY = AdminAuditLogs.select({ where: AdminAuditLogs.where.eq('log_id'), diff --git a/fluxer_api/src/api/admin/AdminService.ts b/fluxer_api/src/api/admin/AdminService.ts index bae2dee81..f87d5e2a0 100644 --- a/fluxer_api/src/api/admin/AdminService.ts +++ b/fluxer_api/src/api/admin/AdminService.ts @@ -1,49 +1,49 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {SendSystemDmResponse} from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import type {IpInfoService} from '@pkgs/geoip/src/IpInfoService'; -import type Stripe from 'stripe'; -import type {ApiContext} from '../ApiContext'; -import type {UserID} from '../BrandedTypes'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import type {ChannelService} from '../channel/services/ChannelService'; -import type {IGuildRepositoryAggregate} from '../guild/repositories/IGuildRepositoryAggregate'; -import type {GuildService} from '../guild/services/GuildService'; -import type {IDiscriminatorService} from '../infrastructure/DiscriminatorService'; -import type {EntityAssetService} from '../infrastructure/EntityAssetService'; -import type {IAssetDeletionQueue} from '../infrastructure/IAssetDeletionQueue'; -import type {IStorageService} from '../infrastructure/IStorageService'; -import type {KVBulkMessageDeletionQueueService} from '../infrastructure/KVBulkMessageDeletionQueueService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {InviteRepository} from '../invite/InviteRepository'; -import type {IJobLedgerRepository} from '../jobs/IJobLedgerRepository'; -import {JobAdminService} from '../jobs/JobAdminService'; +import type {ApiContext} from '@app/api/ApiContext'; +import type {IAdminRepository} from '@app/api/admin/IAdminRepository'; +import {AdminApplicationService} from '@app/api/admin/services/AdminApplicationService'; +import {AdminAssetPurgeService} from '@app/api/admin/services/AdminAssetPurgeService'; +import {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {AdminBanManagementService} from '@app/api/admin/services/AdminBanManagementService'; +import {AdminCodeGenerationService} from '@app/api/admin/services/AdminCodeGenerationService'; +import {AdminGuildService} from '@app/api/admin/services/AdminGuildService'; +import {AdminMessageDeletionService} from '@app/api/admin/services/AdminMessageDeletionService'; +import {AdminMessageService} from '@app/api/admin/services/AdminMessageService'; +import {AdminMessageShredService} from '@app/api/admin/services/AdminMessageShredService'; +import {AdminReportService} from '@app/api/admin/services/AdminReportService'; +import {AdminSearchService} from '@app/api/admin/services/AdminSearchService'; +import {AdminUserRelationshipService} from '@app/api/admin/services/AdminUserRelationshipService'; +import {AdminUserService} from '@app/api/admin/services/AdminUserService'; +import {AdminVoiceService} from '@app/api/admin/services/AdminVoiceService'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import type {IAssetDeletionQueue} from '@app/api/infrastructure/IAssetDeletionQueue'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {KVBulkMessageDeletionQueueService} from '@app/api/infrastructure/KVBulkMessageDeletionQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {InviteRepository} from '@app/api/invite/InviteRepository'; +import type {IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; +import {JobAdminService} from '@app/api/jobs/JobAdminService'; import { getGuildDiscoveryRepository, getKVAccountDeletionQueue, getNcmecSubmissionService, -} from '../middleware/ServiceSingletons'; -import type {IApplicationRepository} from '../oauth/repositories/IApplicationRepository'; -import type {ReportService} from '../report/ReportService'; -import type {IRiskHistoryRepository} from '../risk/HistoricalOutcomeRepository'; -import type {ISuspiciousIpRepository} from '../risk/SuspiciousIpRepository'; -import type {UserService} from '../user/services/UserService'; -import type {VoiceRepository} from '../voice/VoiceRepository'; -import type {IAdminRepository} from './IAdminRepository'; -import {AdminApplicationService} from './services/AdminApplicationService'; -import {AdminAssetPurgeService} from './services/AdminAssetPurgeService'; -import {AdminAuditService} from './services/AdminAuditService'; -import {AdminBanManagementService} from './services/AdminBanManagementService'; -import {AdminCodeGenerationService} from './services/AdminCodeGenerationService'; -import {AdminGuildService} from './services/AdminGuildService'; -import {AdminMessageDeletionService} from './services/AdminMessageDeletionService'; -import {AdminMessageService} from './services/AdminMessageService'; -import {AdminMessageShredService} from './services/AdminMessageShredService'; -import {AdminReportService} from './services/AdminReportService'; -import {AdminSearchService} from './services/AdminSearchService'; -import {AdminUserRelationshipService} from './services/AdminUserRelationshipService'; -import {AdminUserService} from './services/AdminUserService'; -import {AdminVoiceService} from './services/AdminVoiceService'; +} from '@app/api/middleware/ServiceSingletons'; +import type {IApplicationRepository} from '@app/api/oauth/repositories/IApplicationRepository'; +import type {ReportService} from '@app/api/report/ReportService'; +import type {IRiskHistoryRepository} from '@app/api/risk/HistoricalOutcomeRepository'; +import type {ISuspiciousIpRepository} from '@app/api/risk/SuspiciousIpRepository'; +import type {UserService} from '@app/api/user/services/UserService'; +import type {VoiceRepository} from '@app/api/voice/VoiceRepository'; +import type {SendSystemDmResponse} from '@fluxer/schema/src/domains/admin/AdminSchemas'; +import type {IpInfoService} from '@pkgs/geoip/src/IpInfoService'; +import type Stripe from 'stripe'; export class AdminService { readonly auditService: AdminAuditService; diff --git a/fluxer_api/src/api/admin/IAdminRepository.ts b/fluxer_api/src/api/admin/IAdminRepository.ts index 2067bec2e..567cf7271 100644 --- a/fluxer_api/src/api/admin/IAdminRepository.ts +++ b/fluxer_api/src/api/admin/IAdminRepository.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; +import type {UserID} from '@app/api/BrandedTypes'; import type { AdminAuditLogRow, BannedAvatarHashRow, @@ -9,7 +9,7 @@ import type { BannedProfileSubstringScope, BannedUrlDomainRow, BannedUrlRow, -} from '../database/types/AdminArchiveTypes'; +} from '@app/api/database/types/AdminArchiveTypes'; export interface AdminAuditLog { logId: bigint; diff --git a/fluxer_api/src/api/admin/controllers/AdminApiKeyAdminController.ts b/fluxer_api/src/api/admin/controllers/AdminApiKeyAdminController.ts index 8b0e0d25f..8f2006ffe 100644 --- a/fluxer_api/src/api/admin/controllers/AdminApiKeyAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/AdminApiKeyAdminController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminApiKeyView} from '@app/api/admin/services/AdminApiKeyService'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import { AdminApiKeyListResponse, @@ -13,14 +20,6 @@ import { } from '@fluxer/schema/src/domains/admin/AdminSchemas'; import {KeyIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; -import type {AdminApiKeyView} from '../services/AdminApiKeyService'; - function toApiKeyResponse(key: AdminApiKeyView): ListAdminApiKeyResponseType { return { key_id: key.keyId, diff --git a/fluxer_api/src/api/admin/controllers/ApplicationAdminController.ts b/fluxer_api/src/api/admin/controllers/ApplicationAdminController.ts index cb5bf527c..bbfceaa2a 100644 --- a/fluxer_api/src/api/admin/controllers/ApplicationAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/ApplicationAdminController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createApplicationID, createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {requireAdminACL, requireAnyAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {MissingACLError} from '@fluxer/errors/src/domains/core/MissingACLError'; @@ -12,13 +19,6 @@ import { TransferApplicationOwnershipRequest, } from '@fluxer/schema/src/domains/admin/AdminApplicationSchemas'; import {UserIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createApplicationID, createGuildID, createUserID} from '../../BrandedTypes'; -import {requireAdminACL, requireAnyAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; function requireRequestAdminACL(granted: ReadonlySet, required: string): void { if (!granted.has(required) && !granted.has(AdminACLs.WILDCARD)) { diff --git a/fluxer_api/src/api/admin/controllers/ArchiveAdminController.ts b/fluxer_api/src/api/admin/controllers/ArchiveAdminController.ts index e18635d1a..cf001cba1 100644 --- a/fluxer_api/src/api/admin/controllers/ArchiveAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/ArchiveAdminController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {requireAdminACL, requireAnyAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {MissingACLError} from '@fluxer/errors/src/domains/core/MissingACLError'; import { @@ -14,13 +21,6 @@ import { ListArchivesResponseSchema, } from '@fluxer/schema/src/domains/admin/AdminSchemas'; import {ArchivePathParam, GuildIdParam, UserIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import {requireAdminACL, requireAnyAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; function canViewArchive(adminAcls: Set, subjectType: ArchiveSubjectType): boolean { if (adminAcls.has(AdminACLs.WILDCARD) || adminAcls.has(AdminACLs.ARCHIVE_VIEW_ALL)) return true; diff --git a/fluxer_api/src/api/admin/controllers/AssetAdminController.ts b/fluxer_api/src/api/admin/controllers/AssetAdminController.ts index b12056c98..9a37a8057 100644 --- a/fluxer_api/src/api/admin/controllers/AssetAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/AssetAdminController.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID} from '@app/api/BrandedTypes'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {AdminRateLimitConfigs} from '@app/api/rate_limit_configs/AdminRateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {PurgeGuildAssetsRequest, PurgeGuildAssetsResponseSchema} from '@fluxer/schema/src/domains/admin/AdminSchemas'; import {GuildIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createGuildID} from '../../BrandedTypes'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {AdminRateLimitConfigs} from '../../rate_limit_configs/AdminRateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function AssetAdminController(app: HonoApp) { app.delete( diff --git a/fluxer_api/src/api/admin/controllers/AuditLogAdminController.ts b/fluxer_api/src/api/admin/controllers/AuditLogAdminController.ts index 113166485..5c8e2db71 100644 --- a/fluxer_api/src/api/admin/controllers/AuditLogAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/AuditLogAdminController.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {NotFoundError} from '@fluxer/errors/src/domains/core/NotFoundError'; @@ -9,12 +15,6 @@ import { AuditLogsListResponseSchema, ListAdminAuditLogsQuery, } from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function AuditLogAdminController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/admin/controllers/BanAdminController.ts b/fluxer_api/src/api/admin/controllers/BanAdminController.ts index 8fa45b655..a00cd1aa3 100644 --- a/fluxer_api/src/api/admin/controllers/BanAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/BanAdminController.ts @@ -1,5 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireAdminACL, requireAnyAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {getWorkerService} from '@app/api/middleware/ServiceRegistry'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {requireRequestJsonBody} from '@app/api/utils/RequestJsonBody'; +import {inputValidationErrorFromZodIssues, Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {BadRequestError} from '@fluxer/errors/src/domains/core/BadRequestError'; @@ -40,14 +48,6 @@ import { } from '@fluxer/schema/src/domains/admin/AdminSchemas'; import {UserIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import type {ZodType} from 'zod'; -import {requireAdminACL, requireAnyAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {getWorkerService} from '../../middleware/ServiceRegistry'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {requireRequestJsonBody} from '../../utils/RequestJsonBody'; -import {inputValidationErrorFromZodIssues, Validator} from '../../Validator'; type ProfileSubstringScope = BanProfileSubstringRequest['scope']; diff --git a/fluxer_api/src/api/admin/controllers/BulkAdminController.ts b/fluxer_api/src/api/admin/controllers/BulkAdminController.ts index 24903bb17..57a60a3ac 100644 --- a/fluxer_api/src/api/admin/controllers/BulkAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/BulkAdminController.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {requireAnyAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {getWorkerService} from '@app/api/middleware/ServiceRegistry'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {MissingACLError} from '@fluxer/errors/src/domains/core/MissingACLError'; import {AdminBulkJobCreateRequest, AdminBulkTaskType} from '@fluxer/schema/src/domains/admin/AdminBulkSchemas'; import {BulkJobResponse} from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import type {UserID} from '../../BrandedTypes'; -import {requireAnyAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {getWorkerService} from '../../middleware/ServiceRegistry'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; const BULK_TASK_ACLS: Record = { [AdminBulkTaskType.UPDATE_USER_FLAGS]: AdminACLs.BULK_UPDATE_USER_FLAGS, diff --git a/fluxer_api/src/api/admin/controllers/CodesAdminController.ts b/fluxer_api/src/api/admin/controllers/CodesAdminController.ts index 83ae64540..cf8bd2b99 100644 --- a/fluxer_api/src/api/admin/controllers/CodesAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/CodesAdminController.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {FeatureNotAvailableSelfHostedError} from '@fluxer/errors/src/domains/core/FeatureNotAvailableSelfHostedError'; import {CodesResponse, GenerateGiftCodesRequest} from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import {Config} from '../../Config'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; function trimTrailingSlash(value: string): string { return value.endsWith('/') ? value.slice(0, -1) : value; diff --git a/fluxer_api/src/api/admin/controllers/DiscoveryAdminController.ts b/fluxer_api/src/api/admin/controllers/DiscoveryAdminController.ts index 588f95d1e..c260f9191 100644 --- a/fluxer_api/src/api/admin/controllers/DiscoveryAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/DiscoveryAdminController.ts @@ -1,5 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID} from '@app/api/BrandedTypes'; +import type {GuildDiscoveryRow} from '@app/api/database/types/GuildDiscoveryTypes'; +import {mapGuildFeatures} from '@app/api/guild/GuildFeatureUtils'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import type {User} from '@app/api/models/User'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {DiscoveryApplicationStatus, DiscoveryCategoryLabels} from '@fluxer/constants/src/DiscoveryConstants'; import {GuildIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; @@ -17,19 +29,6 @@ import { DiscoveryCategoryListResponse, } from '@fluxer/schema/src/domains/guild/GuildDiscoverySchemas'; -import {createGuildID} from '../../BrandedTypes'; -import type {GuildDiscoveryRow} from '../../database/types/GuildDiscoveryTypes'; -import {mapGuildFeatures} from '../../guild/GuildFeatureUtils'; -import type {GuildService} from '../../guild/services/GuildService'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import type {User} from '../../models/User'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {Validator} from '../../Validator'; - function mapRowToApplicationResponse(row: GuildDiscoveryRow) { return { guild_id: row.guild_id.toString(), diff --git a/fluxer_api/src/api/admin/controllers/GatewayAdminController.ts b/fluxer_api/src/api/admin/controllers/GatewayAdminController.ts index c9ac34122..56ae84fef 100644 --- a/fluxer_api/src/api/admin/controllers/GatewayAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/GatewayAdminController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID} from '@app/api/BrandedTypes'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {GetProcessMemoryStatsQuery} from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; import { @@ -9,13 +16,6 @@ import { ReloadAllGuildsResponse, ReloadGuildsRequest, } from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import {createGuildID} from '../../BrandedTypes'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function GatewayAdminController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/admin/controllers/GuildAdminController.ts b/fluxer_api/src/api/admin/controllers/GuildAdminController.ts index 378e4e2ce..a26f5752b 100644 --- a/fluxer_api/src/api/admin/controllers/GuildAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/GuildAdminController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID} from '@app/api/BrandedTypes'; +import {requireAdminACL, requireAnyAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {AdminRateLimitConfigs} from '@app/api/rate_limit_configs/AdminRateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {MissingACLError} from '@fluxer/errors/src/domains/core/MissingACLError'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; @@ -20,13 +27,6 @@ import { } from '@fluxer/schema/src/domains/admin/AdminSchemas'; import {GuildIdParam, GuildIdUserIdParam, SuccessResponse} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import {GuildAuditLogListQuery} from '@fluxer/schema/src/domains/guild/GuildAuditLogSchemas'; -import {createGuildID} from '../../BrandedTypes'; -import {requireAdminACL, requireAnyAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {AdminRateLimitConfigs} from '../../rate_limit_configs/AdminRateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; const GUILD_UPDATE_ACLS = [ AdminACLs.GUILD_UPDATE_NAME, diff --git a/fluxer_api/src/api/admin/controllers/InstanceConfigAdminController.ts b/fluxer_api/src/api/admin/controllers/InstanceConfigAdminController.ts index d795239a8..f3e3c21a5 100644 --- a/fluxer_api/src/api/admin/controllers/InstanceConfigAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/InstanceConfigAdminController.ts @@ -1,5 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import { + type InstancePolicyConfig, + REGISTRATION_PENDING_APPROVAL_TRAIT, + REGISTRATION_REJECTED_TRAIT, +} from '@app/api/instance/InstanceConfigRepository'; +import {deriveSsoRedirectUri, normalizeAndValidateSsoConfig} from '@app/api/instance/SsoConfigValidation'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {getGatewayRolloutConfigPublisher, getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp, HonoEnv} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {InstancePolicyTransitionNotAllowedError} from '@fluxer/errors/src/domains/core/InstancePolicyTransitionNotAllowedError'; import { @@ -21,21 +36,6 @@ import type {InstanceBranding} from '@fluxer/schema/src/domains/instance/Instanc import {SmtpEmailProvider} from '@pkgs/email/src/SmtpEmailProvider'; import type {Context} from 'hono'; import {createMiddleware} from 'hono/factory'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import { - type InstancePolicyConfig, - REGISTRATION_PENDING_APPROVAL_TRAIT, - REGISTRATION_REJECTED_TRAIT, -} from '../../instance/InstanceConfigRepository'; -import {deriveSsoRedirectUri, normalizeAndValidateSsoConfig} from '../../instance/SsoConfigValidation'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {getGatewayRolloutConfigPublisher, getInstanceConfigRepository} from '../../middleware/ServiceSingletons'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp, HonoEnv} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; const INSTANCE_BRANDING_ENTITY_ID = 0n; diff --git a/fluxer_api/src/api/admin/controllers/JobsAdminController.ts b/fluxer_api/src/api/admin/controllers/JobsAdminController.ts index be602e83b..f5f8ba3fd 100644 --- a/fluxer_api/src/api/admin/controllers/JobsAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/JobsAdminController.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import { ActiveJobsResponseSchema, @@ -10,12 +16,6 @@ import { ListJobsResponseSchema, } from '@fluxer/schema/src/domains/admin/JobsSchemas'; import {JobIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; function toListJobsRequest(query: ListJobsQuery): ListJobsRequest { return { diff --git a/fluxer_api/src/api/admin/controllers/LimitConfigAdminController.ts b/fluxer_api/src/api/admin/controllers/LimitConfigAdminController.ts index eead8d7f0..fb0485b16 100644 --- a/fluxer_api/src/api/admin/controllers/LimitConfigAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/LimitConfigAdminController.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {LIMIT_CATEGORY_LABELS, LIMIT_KEY_METADATA, LIMIT_KEYS} from '@fluxer/constants/src/LimitConfigMetadata'; import type {LimitConfigSnapshot} from '@fluxer/limits/src/LimitTypes'; import {LimitConfigGetResponse, LimitConfigUpdateRequest} from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import {Config} from '../../Config'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; function formatConfig(service: LimitConfigService) { const config = service.getConfigSnapshot(); diff --git a/fluxer_api/src/api/admin/controllers/MessageAdminController.ts b/fluxer_api/src/api/admin/controllers/MessageAdminController.ts index b7570397f..852b614be 100644 --- a/fluxer_api/src/api/admin/controllers/MessageAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/MessageAdminController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAttachmentID, createChannelID, createMessageID, createReportID} from '@app/api/BrandedTypes'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; @@ -29,13 +36,6 @@ import { ChannelIdParam, UserIdParam, } from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createAttachmentID, createChannelID, createMessageID, createReportID} from '../../BrandedTypes'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function MessageAdminController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/admin/controllers/ReportAdminController.ts b/fluxer_api/src/api/admin/controllers/ReportAdminController.ts index ffe71ec23..28f30995f 100644 --- a/fluxer_api/src/api/admin/controllers/ReportAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/ReportAdminController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createReportID} from '@app/api/BrandedTypes'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import { AdminReportListResponse, @@ -10,13 +17,6 @@ import { UpdateReportRequest, } from '@fluxer/schema/src/domains/admin/AdminSchemas'; import {ReportIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createReportID} from '../../BrandedTypes'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; const REPORT_STATUS_BY_FILTER = { pending: 0, diff --git a/fluxer_api/src/api/admin/controllers/SearchAdminController.ts b/fluxer_api/src/api/admin/controllers/SearchAdminController.ts index 0c2505895..6c3714da6 100644 --- a/fluxer_api/src/api/admin/controllers/SearchAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/SearchAdminController.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import { IndexRefreshStatusResponse, @@ -8,12 +14,6 @@ import { SearchIndexNameParam, SearchIndexRefreshIdParam, } from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function SearchAdminController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/admin/controllers/SystemAdminController.ts b/fluxer_api/src/api/admin/controllers/SystemAdminController.ts index 6e9c85ae6..65c228e98 100644 --- a/fluxer_api/src/api/admin/controllers/SystemAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/SystemAdminController.ts @@ -4,13 +4,13 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import {Readable} from 'node:stream'; import * as v8 from 'node:v8'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {HeapSnapshotResponse} from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; export function SystemAdminController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/admin/controllers/SystemDmAdminController.ts b/fluxer_api/src/api/admin/controllers/SystemDmAdminController.ts index b730d1fe7..f3b1aa701 100644 --- a/fluxer_api/src/api/admin/controllers/SystemDmAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/SystemDmAdminController.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {SendSystemDmRequest, SendSystemDmResponse} from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function SystemDmAdminController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/admin/controllers/UserAdminController.ts b/fluxer_api/src/api/admin/controllers/UserAdminController.ts index b794322b7..de2dc8a9b 100644 --- a/fluxer_api/src/api/admin/controllers/UserAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/UserAdminController.ts @@ -1,5 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapUserToAdminResponse} from '@app/api/admin/models/UserTypes'; +import {createUserID} from '@app/api/BrandedTypes'; +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {inputValidationErrorFromZodIssues, Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {MissingACLError} from '@fluxer/errors/src/domains/core/MissingACLError'; import {ListUserGuildsResponse} from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; @@ -41,14 +49,6 @@ import { } from '@fluxer/schema/src/domains/admin/AdminUserSchemas'; import {WebAuthnCredentialListResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {UserIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createUserID} from '../../BrandedTypes'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {inputValidationErrorFromZodIssues, Validator} from '../../Validator'; -import {mapUserToAdminResponse} from '../models/UserTypes'; function requireSelectorACL(granted: ReadonlySet, acl: string): void { if (!granted.has(acl) && !granted.has(AdminACLs.WILDCARD)) { diff --git a/fluxer_api/src/api/admin/controllers/VoiceAdminController.ts b/fluxer_api/src/api/admin/controllers/VoiceAdminController.ts index d88de5834..d78577989 100644 --- a/fluxer_api/src/api/admin/controllers/VoiceAdminController.ts +++ b/fluxer_api/src/api/admin/controllers/VoiceAdminController.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireAdminACL} from '@app/api/middleware/AdminMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp, HonoEnv} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import { CreateVoiceRegionRequest, @@ -24,12 +30,6 @@ import { VoiceServerIdParam, } from '@fluxer/schema/src/domains/admin/AdminVoiceSchemas'; import type {Context} from 'hono'; -import {requireAdminACL} from '../../middleware/AdminMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp, HonoEnv} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; function isPlainObject(value: unknown): value is Record { return typeof value === 'object' && value !== null && !Array.isArray(value); diff --git a/fluxer_api/src/api/admin/controllers/index.ts b/fluxer_api/src/api/admin/controllers/index.ts index 8c558a3c8..7e995a68a 100644 --- a/fluxer_api/src/api/admin/controllers/index.ts +++ b/fluxer_api/src/api/admin/controllers/index.ts @@ -1,27 +1,27 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {HonoApp} from '../../types/HonoEnv'; -import {AdminApiKeyAdminController} from './AdminApiKeyAdminController'; -import {ApplicationAdminController} from './ApplicationAdminController'; -import {ArchiveAdminController} from './ArchiveAdminController'; -import {AssetAdminController} from './AssetAdminController'; -import {AuditLogAdminController} from './AuditLogAdminController'; -import {BanAdminController} from './BanAdminController'; -import {BulkAdminController} from './BulkAdminController'; -import {CodesAdminController} from './CodesAdminController'; -import {DiscoveryAdminController} from './DiscoveryAdminController'; -import {GatewayAdminController} from './GatewayAdminController'; -import {GuildAdminController} from './GuildAdminController'; -import {InstanceConfigAdminController} from './InstanceConfigAdminController'; -import {JobsAdminController} from './JobsAdminController'; -import {LimitConfigAdminController} from './LimitConfigAdminController'; -import {MessageAdminController} from './MessageAdminController'; -import {ReportAdminController} from './ReportAdminController'; -import {SearchAdminController} from './SearchAdminController'; -import {SystemAdminController} from './SystemAdminController'; -import {SystemDmAdminController} from './SystemDmAdminController'; -import {UserAdminController} from './UserAdminController'; -import {VoiceAdminController} from './VoiceAdminController'; +import {AdminApiKeyAdminController} from '@app/api/admin/controllers/AdminApiKeyAdminController'; +import {ApplicationAdminController} from '@app/api/admin/controllers/ApplicationAdminController'; +import {ArchiveAdminController} from '@app/api/admin/controllers/ArchiveAdminController'; +import {AssetAdminController} from '@app/api/admin/controllers/AssetAdminController'; +import {AuditLogAdminController} from '@app/api/admin/controllers/AuditLogAdminController'; +import {BanAdminController} from '@app/api/admin/controllers/BanAdminController'; +import {BulkAdminController} from '@app/api/admin/controllers/BulkAdminController'; +import {CodesAdminController} from '@app/api/admin/controllers/CodesAdminController'; +import {DiscoveryAdminController} from '@app/api/admin/controllers/DiscoveryAdminController'; +import {GatewayAdminController} from '@app/api/admin/controllers/GatewayAdminController'; +import {GuildAdminController} from '@app/api/admin/controllers/GuildAdminController'; +import {InstanceConfigAdminController} from '@app/api/admin/controllers/InstanceConfigAdminController'; +import {JobsAdminController} from '@app/api/admin/controllers/JobsAdminController'; +import {LimitConfigAdminController} from '@app/api/admin/controllers/LimitConfigAdminController'; +import {MessageAdminController} from '@app/api/admin/controllers/MessageAdminController'; +import {ReportAdminController} from '@app/api/admin/controllers/ReportAdminController'; +import {SearchAdminController} from '@app/api/admin/controllers/SearchAdminController'; +import {SystemAdminController} from '@app/api/admin/controllers/SystemAdminController'; +import {SystemDmAdminController} from '@app/api/admin/controllers/SystemDmAdminController'; +import {UserAdminController} from '@app/api/admin/controllers/UserAdminController'; +import {VoiceAdminController} from '@app/api/admin/controllers/VoiceAdminController'; +import type {HonoApp} from '@app/api/types/HonoEnv'; export function registerAdminControllers(app: HonoApp) { AdminApiKeyAdminController(app); diff --git a/fluxer_api/src/api/admin/models/AdminArchiveModel.ts b/fluxer_api/src/api/admin/models/AdminArchiveModel.ts index 0dc0d6583..c2a504be2 100644 --- a/fluxer_api/src/api/admin/models/AdminArchiveModel.ts +++ b/fluxer_api/src/api/admin/models/AdminArchiveModel.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminArchiveRow} from '@app/api/database/types/AdminArchiveTypes'; import type {AdminArchiveResponse, ArchiveSubjectType} from '@fluxer/schema/src/domains/admin/AdminArchiveSchemas'; -import type {AdminArchiveRow} from '../../database/types/AdminArchiveTypes'; export class AdminArchive { subjectType: ArchiveSubjectType; diff --git a/fluxer_api/src/api/admin/models/GuildTypes.ts b/fluxer_api/src/api/admin/models/GuildTypes.ts index fd30da8e3..6d21264b0 100644 --- a/fluxer_api/src/api/admin/models/GuildTypes.ts +++ b/fluxer_api/src/api/admin/models/GuildTypes.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapGuildFeatures} from '@app/api/guild/GuildFeatureUtils'; +import type {Guild} from '@app/api/models/Guild'; +import type {User} from '@app/api/models/User'; import type {GuildAdminResponse, ListUserGuildsResponse} from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; -import {mapGuildFeatures} from '../../guild/GuildFeatureUtils'; -import type {Guild} from '../../models/Guild'; -import type {User} from '../../models/User'; function formatOwnerFields(ownerUser: User | null): { owner_username: string | null; diff --git a/fluxer_api/src/api/admin/models/UserTypes.ts b/fluxer_api/src/api/admin/models/UserTypes.ts index 109bf2588..5591f450a 100644 --- a/fluxer_api/src/api/admin/models/UserTypes.ts +++ b/fluxer_api/src/api/admin/models/UserTypes.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {User} from '@app/api/models/User'; +import {getIpAddressReverse, lookupGeoip} from '@app/api/utils/IpUtils'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {DEFERRED_PHONE_ON_COMMUNITY_JOIN} from '@fluxer/constants/src/UserConstants'; import type {UserAdminResponse} from '@fluxer/schema/src/domains/admin/AdminUserSchemas'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {formatGeoipLocation} from '@pkgs/geoip/src/GeoipLookup'; -import type {User} from '../../models/User'; -import {getIpAddressReverse, lookupGeoip} from '../../utils/IpUtils'; function hasAcl(acls: ReadonlySet, acl: string): boolean { return acls.has(acl) || acls.has(AdminACLs.WILDCARD); diff --git a/fluxer_api/src/api/admin/repositories/AdminApiKeyRepository.ts b/fluxer_api/src/api/admin/repositories/AdminApiKeyRepository.ts index 5be34f743..582191e25 100644 --- a/fluxer_api/src/api/admin/repositories/AdminApiKeyRepository.ts +++ b/fluxer_api/src/api/admin/repositories/AdminApiKeyRepository.ts @@ -1,13 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchManyInChunks, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import {Db} from '../../database/CassandraTypes'; -import type {AdminApiKeyByCreatorRow, AdminApiKeyRow} from '../../database/types/AdminAuthTypes'; -import {AdminApiKey} from '../../models/AdminApiKey'; -import {AdminApiKeys, AdminApiKeysByCreator} from '../../Tables'; -import {hashPassword} from '../../utils/PasswordUtils'; -import type {CreateAdminApiKeyData, IAdminApiKeyRepository, UpdateAdminApiKeyData} from './IAdminApiKeyRepository'; +import type { + CreateAdminApiKeyData, + IAdminApiKeyRepository, + UpdateAdminApiKeyData, +} from '@app/api/admin/repositories/IAdminApiKeyRepository'; +import type {UserID} from '@app/api/BrandedTypes'; +import { + BatchBuilder, + fetchMany, + fetchManyInChunks, + fetchOne, + upsertOne, +} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {AdminApiKeyByCreatorRow, AdminApiKeyRow} from '@app/api/database/types/AdminAuthTypes'; +import {AdminApiKey} from '@app/api/models/AdminApiKey'; +import {AdminApiKeys, AdminApiKeysByCreator} from '@app/api/Tables'; +import {hashPassword} from '@app/api/utils/PasswordUtils'; function computeTtlSeconds(expiresAt: Date): number { const diffSeconds = Math.floor((expiresAt.getTime() - Date.now()) / 1000); diff --git a/fluxer_api/src/api/admin/repositories/AdminArchiveRepository.ts b/fluxer_api/src/api/admin/repositories/AdminArchiveRepository.ts index fd0b7fbcb..f2f22e550 100644 --- a/fluxer_api/src/api/admin/repositories/AdminArchiveRepository.ts +++ b/fluxer_api/src/api/admin/repositories/AdminArchiveRepository.ts @@ -2,20 +2,20 @@ import assert from 'node:assert/strict'; import {randomUUID} from 'node:crypto'; -import type {ArchiveSubjectType} from '@fluxer/schema/src/domains/admin/AdminArchiveSchemas'; -import {ms} from 'itty-time'; -import {ArchiveAttemptSupersededError} from '../../archive/ArchiveAttemptSupersededError'; -import {BatchBuilder, executeConditional, fetchMany, fetchOne} from '../../database/CassandraQueryExecution'; -import {Db, type DbOp} from '../../database/CassandraTypes'; +import {AdminArchive} from '@app/api/admin/models/AdminArchiveModel'; +import {ArchiveAttemptSupersededError} from '@app/api/archive/ArchiveAttemptSupersededError'; +import {BatchBuilder, executeConditional, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {Db, type DbOp} from '@app/api/database/CassandraTypes'; import { ADMIN_ARCHIVE_INDEX_COLUMNS, type AdminArchiveIndexRow, type AdminArchiveRow, -} from '../../database/types/AdminArchiveTypes'; -import {Logger} from '../../Logger'; -import {AdminArchivesByRequester, AdminArchivesBySubject, AdminArchivesByType} from '../../Tables'; -import {mapWithConcurrency} from '../../utils/ConcurrencyUtils'; -import {AdminArchive} from '../models/AdminArchiveModel'; +} from '@app/api/database/types/AdminArchiveTypes'; +import {Logger} from '@app/api/Logger'; +import {AdminArchivesByRequester, AdminArchivesBySubject, AdminArchivesByType} from '@app/api/Tables'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; +import type {ArchiveSubjectType} from '@fluxer/schema/src/domains/admin/AdminArchiveSchemas'; +import {ms} from 'itty-time'; const RETENTION_DAYS = 365; const DEFAULT_RETENTION_MS = ms(`${RETENTION_DAYS} days`); diff --git a/fluxer_api/src/api/admin/repositories/IAdminApiKeyRepository.ts b/fluxer_api/src/api/admin/repositories/IAdminApiKeyRepository.ts index ea61a6143..9322ccb0d 100644 --- a/fluxer_api/src/api/admin/repositories/IAdminApiKeyRepository.ts +++ b/fluxer_api/src/api/admin/repositories/IAdminApiKeyRepository.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import type {AdminApiKey} from '../../models/AdminApiKey'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {AdminApiKey} from '@app/api/models/AdminApiKey'; export interface CreateAdminApiKeyData { name: string; diff --git a/fluxer_api/src/api/admin/services/AdminApiKeyService.ts b/fluxer_api/src/api/admin/services/AdminApiKeyService.ts index 2a512f6e4..83314cdea 100644 --- a/fluxer_api/src/api/admin/services/AdminApiKeyService.ts +++ b/fluxer_api/src/api/admin/services/AdminApiKeyService.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomInt} from 'node:crypto'; +import type {IAdminApiKeyRepository} from '@app/api/admin/repositories/IAdminApiKeyRepository'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {AdminApiKey} from '@app/api/models/AdminApiKey'; +import {verifyPassword} from '@app/api/utils/PasswordUtils'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {AdminApiKeyNotFoundError} from '@fluxer/errors/src/domains/admin/AdminApiKeyNotFoundError'; import {MissingACLError} from '@fluxer/errors/src/domains/core/MissingACLError'; import type {CreateAdminApiKeyRequest, UpdateAdminApiKeyRequest} from '@fluxer/schema/src/domains/admin/AdminSchemas'; import {ms} from 'itty-time'; -import type {UserID} from '../../BrandedTypes'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {AdminApiKey} from '../../models/AdminApiKey'; -import {verifyPassword} from '../../utils/PasswordUtils'; -import type {IAdminApiKeyRepository} from '../repositories/IAdminApiKeyRepository'; const ADMIN_KEY_PREFIX = 'fa_'; const RANDOM_KEY_LENGTH = 32; diff --git a/fluxer_api/src/api/admin/services/AdminApplicationService.ts b/fluxer_api/src/api/admin/services/AdminApplicationService.ts index 7387eee3d..12af16a2f 100644 --- a/fluxer_api/src/api/admin/services/AdminApplicationService.ts +++ b/fluxer_api/src/api/admin/services/AdminApplicationService.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {type ApplicationID, createApplicationID, createUserID, type GuildID, type UserID} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {Application} from '@app/api/models/Application'; +import type {IApplicationRepository} from '@app/api/oauth/repositories/IApplicationRepository'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import {UnknownApplicationError} from '@fluxer/errors/src/domains/oauth/UnknownApplicationError'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; @@ -9,12 +15,6 @@ import type { LookupApplicationResponse, TransferApplicationOwnershipRequest, } from '@fluxer/schema/src/domains/admin/AdminApplicationSchemas'; -import type {ApiContext} from '../../ApiContext'; -import {type ApplicationID, createApplicationID, createUserID, type GuildID, type UserID} from '../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {Application} from '../../models/Application'; -import type {IApplicationRepository} from '../../oauth/repositories/IApplicationRepository'; -import type {AdminAuditService} from './AdminAuditService'; interface AdminApplicationServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminArchiveService.ts b/fluxer_api/src/api/admin/services/AdminArchiveService.ts index 202f208f8..c313c612b 100644 --- a/fluxer_api/src/api/admin/services/AdminArchiveService.ts +++ b/fluxer_api/src/api/admin/services/AdminArchiveService.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminArchive} from '@app/api/admin/models/AdminArchiveModel'; +import type {AdminArchiveRepository} from '@app/api/admin/repositories/AdminArchiveRepository'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import {HarvestExpiredError} from '@fluxer/errors/src/domains/moderation/HarvestExpiredError'; @@ -10,15 +19,6 @@ import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError import type {AdminArchiveResponse, ArchiveSubjectType} from '@fluxer/schema/src/domains/admin/AdminArchiveSchemas'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import {ms, seconds} from 'itty-time'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {WorkerTaskName} from '../../worker/WorkerLaneConfig'; -import {AdminArchive} from '../models/AdminArchiveModel'; -import type {AdminArchiveRepository} from '../repositories/AdminArchiveRepository'; const ARCHIVE_RETENTION_DAYS = 365; const DOWNLOAD_LINK_DAYS = 7; diff --git a/fluxer_api/src/api/admin/services/AdminAssetPurgeService.ts b/fluxer_api/src/api/admin/services/AdminAssetPurgeService.ts index 2d9e7dbae..5cd14d75b 100644 --- a/fluxer_api/src/api/admin/services/AdminAssetPurgeService.ts +++ b/fluxer_api/src/api/admin/services/AdminAssetPurgeService.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {createEmojiID, createStickerID, type GuildID, type UserID} from '@app/api/BrandedTypes'; +import {mapGuildEmojiToResponse, mapGuildStickerToResponse} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {ExpressionAssetPurger} from '@app/api/guild/services/content/ExpressionAssetPurger'; +import type {IAssetDeletionQueue} from '@app/api/infrastructure/IAssetDeletionQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; import type {GuildNSFWLevelValue} from '@fluxer/constants/src/GuildConstants'; import type { PurgeGuildAssetError, PurgeGuildAssetResult, PurgeGuildAssetsResponse, } from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import {createEmojiID, createStickerID, type GuildID, type UserID} from '../../BrandedTypes'; -import {mapGuildEmojiToResponse, mapGuildStickerToResponse} from '../../guild/GuildModel'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import {ExpressionAssetPurger} from '../../guild/services/content/ExpressionAssetPurger'; -import type {IAssetDeletionQueue} from '../../infrastructure/IAssetDeletionQueue'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {AdminAuditService} from './AdminAuditService'; interface AdminAssetPurgeServiceDeps { guildRepository: IGuildRepositoryAggregate; diff --git a/fluxer_api/src/api/admin/services/AdminAuditService.ts b/fluxer_api/src/api/admin/services/AdminAuditService.ts index 1f0ed4a73..75acf84cd 100644 --- a/fluxer_api/src/api/admin/services/AdminAuditService.ts +++ b/fluxer_api/src/api/admin/services/AdminAuditService.ts @@ -1,5 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditLog, IAdminRepository} from '@app/api/admin/IAdminRepository'; +import type {UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createGuildID, createUserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import {Logger} from '@app/api/Logger'; +import type {Channel} from '@app/api/models/Channel'; +import type {Guild} from '@app/api/models/Guild'; +import type {User} from '@app/api/models/User'; +import {getAuditLogSearchService} from '@app/api/SearchFactory'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import type { AdminAuditLogChannelSummary, AdminAuditLogGuildSummary, @@ -7,18 +19,6 @@ import type { AdminAuditLogUserSummary, AuditLogsListResponse, } from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import type {UserID} from '../../BrandedTypes'; -import {createChannelID, createGuildID, createUserID} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import {Logger} from '../../Logger'; -import type {Channel} from '../../models/Channel'; -import type {Guild} from '../../models/Guild'; -import type {User} from '../../models/User'; -import {getAuditLogSearchService} from '../../SearchFactory'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {AdminAuditLog, IAdminRepository} from '../IAdminRepository'; interface CreateAdminAuditLogParams { adminUserId: UserID; diff --git a/fluxer_api/src/api/admin/services/AdminBanManagementService.ts b/fluxer_api/src/api/admin/services/AdminBanManagementService.ts index d80de5aad..ed01f29d1 100644 --- a/fluxer_api/src/api/admin/services/AdminBanManagementService.ts +++ b/fluxer_api/src/api/admin/services/AdminBanManagementService.ts @@ -1,15 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; -import {BadRequestError} from '@fluxer/errors/src/domains/core/BadRequestError'; -import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; -import {NotFoundError} from '@fluxer/errors/src/domains/core/NotFoundError'; -import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; -import type {AdminBlocklistListType} from '@fluxer/schema/src/domains/admin/AdminBlocklistSchemas'; -import type {IpInfoLookupResult, IpInfoService} from '@pkgs/geoip/src/IpInfoService'; -import type {ApiContext} from '../../ApiContext'; -import {createUserID, type UserID} from '../../BrandedTypes'; +import type {ApiContext} from '@app/api/ApiContext'; +import type {IAdminRepository} from '@app/api/admin/IAdminRepository'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; import { BANNED_AVATAR_HASHES_REFRESH_CHANNEL, BANNED_FILE_SHAS_REFRESH_CHANNEL, @@ -19,28 +13,34 @@ import { BANNED_URLS_REFRESH_CHANNEL, ContentBlocklistCategory, ContentBlocklistSeverity, -} from '../../constants/ContentModeration'; -import {IP_BAN_REFRESH_CHANNEL} from '../../constants/IpBan'; -import type {BannedProfileSubstringScope} from '../../database/types/AdminArchiveTypes'; -import {Logger} from '../../Logger'; -import {bannedAvatarHashCache} from '../../middleware/BannedAvatarHashCache'; -import {fileShaCache} from '../../middleware/FileShaCache'; -import {ipBanCache} from '../../middleware/IpBanMiddleware'; -import {phraseBlocklistCache} from '../../middleware/PhraseBlocklistCache'; -import {profileSubstringBlocklistCache} from '../../middleware/ProfileSubstringBlocklistCache'; -import {urlBlocklistCache} from '../../middleware/UrlBlocklistCache'; +} from '@app/api/constants/ContentModeration'; +import {IP_BAN_REFRESH_CHANNEL} from '@app/api/constants/IpBan'; +import type {BannedProfileSubstringScope} from '@app/api/database/types/AdminArchiveTypes'; +import {Logger} from '@app/api/Logger'; +import {bannedAvatarHashCache} from '@app/api/middleware/BannedAvatarHashCache'; +import {fileShaCache} from '@app/api/middleware/FileShaCache'; +import {ipBanCache} from '@app/api/middleware/IpBanMiddleware'; +import {phraseBlocklistCache} from '@app/api/middleware/PhraseBlocklistCache'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import {urlBlocklistCache} from '@app/api/middleware/UrlBlocklistCache'; import { getIpBanBlastRadiusVerdict, getSuspiciousIpSkipReason, isSingleIpBanCandidate, -} from '../../risk/IpBanCgnatGuard'; -import {isIpBanExempt} from '../../risk/IpBanExemptions'; -import type {ISuspiciousIpRepository} from '../../risk/SuspiciousIpRepository'; -import {tryParseSingleIp} from '../../utils/IpRangeUtils'; -import {canonicalizeStoredPhrase} from '../../utils/PhraseBlocklistNormalization'; -import {canonicalizeUrl} from '../../utils/UrlNormalizer'; -import type {IAdminRepository} from '../IAdminRepository'; -import type {AdminAuditService} from './AdminAuditService'; +} from '@app/api/risk/IpBanCgnatGuard'; +import {isIpBanExempt} from '@app/api/risk/IpBanExemptions'; +import type {ISuspiciousIpRepository} from '@app/api/risk/SuspiciousIpRepository'; +import {tryParseSingleIp} from '@app/api/utils/IpRangeUtils'; +import {canonicalizeStoredPhrase} from '@app/api/utils/PhraseBlocklistNormalization'; +import {canonicalizeUrl} from '@app/api/utils/UrlNormalizer'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; +import {BadRequestError} from '@fluxer/errors/src/domains/core/BadRequestError'; +import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; +import {NotFoundError} from '@fluxer/errors/src/domains/core/NotFoundError'; +import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; +import type {AdminBlocklistListType} from '@fluxer/schema/src/domains/admin/AdminBlocklistSchemas'; +import type {IpInfoLookupResult, IpInfoService} from '@pkgs/geoip/src/IpInfoService'; interface AdminBanManagementServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminCodeGenerationService.ts b/fluxer_api/src/api/admin/services/AdminCodeGenerationService.ts index 9d83a16a9..720785ddc 100644 --- a/fluxer_api/src/api/admin/services/AdminCodeGenerationService.ts +++ b/fluxer_api/src/api/admin/services/AdminCodeGenerationService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {SYSTEM_USER_ID} from '../../constants/Core'; -import type {GiftCodeDurationType, GiftCodeRow} from '../../database/types/PaymentTypes'; -import {mapGiftCodeDurationToMonths} from '../../models/GiftCode'; -import type {IUserRepository} from '../../user/IUserRepository'; -import * as RandomUtils from '../../utils/RandomUtils'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import type {GiftCodeDurationType, GiftCodeRow} from '@app/api/database/types/PaymentTypes'; +import {mapGiftCodeDurationToMonths} from '@app/api/models/GiftCode'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import * as RandomUtils from '@app/api/utils/RandomUtils'; const CODE_LENGTH = 32; const MAX_GENERATION_ATTEMPTS = 100; diff --git a/fluxer_api/src/api/admin/services/AdminGuildService.ts b/fluxer_api/src/api/admin/services/AdminGuildService.ts index 75720b4f5..ec2e88068 100644 --- a/fluxer_api/src/api/admin/services/AdminGuildService.ts +++ b/fluxer_api/src/api/admin/services/AdminGuildService.ts @@ -1,24 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {AdminGuildBulkService} from '@app/api/admin/services/guild/AdminGuildBulkService'; +import {AdminGuildLookupService} from '@app/api/admin/services/guild/AdminGuildLookupService'; +import {AdminGuildManagementService} from '@app/api/admin/services/guild/AdminGuildManagementService'; +import {AdminGuildMembershipService} from '@app/api/admin/services/guild/AdminGuildMembershipService'; +import {AdminGuildUpdatePropagator} from '@app/api/admin/services/guild/AdminGuildUpdatePropagator'; +import {AdminGuildUpdateService} from '@app/api/admin/services/guild/AdminGuildUpdateService'; +import {AdminGuildVanityService} from '@app/api/admin/services/guild/AdminGuildVanityService'; +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {IGuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {InviteRepository} from '@app/api/invite/InviteRepository'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import type {ListGuildAuditLogsRequest} from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {IGuildDiscoveryRepository} from '../../guild/repositories/GuildDiscoveryRepository'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {GuildService} from '../../guild/services/GuildService'; -import type {EntityAssetService} from '../../infrastructure/EntityAssetService'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {InviteRepository} from '../../invite/InviteRepository'; -import {createRequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {AdminAuditService} from './AdminAuditService'; -import {AdminGuildBulkService} from './guild/AdminGuildBulkService'; -import {AdminGuildLookupService} from './guild/AdminGuildLookupService'; -import {AdminGuildManagementService} from './guild/AdminGuildManagementService'; -import {AdminGuildMembershipService} from './guild/AdminGuildMembershipService'; -import {AdminGuildUpdatePropagator} from './guild/AdminGuildUpdatePropagator'; -import {AdminGuildUpdateService} from './guild/AdminGuildUpdateService'; -import {AdminGuildVanityService} from './guild/AdminGuildVanityService'; interface AdminGuildServiceDeps { guildRepository: IGuildRepositoryAggregate; diff --git a/fluxer_api/src/api/admin/services/AdminMessageDeletionService.ts b/fluxer_api/src/api/admin/services/AdminMessageDeletionService.ts index adbd5144e..959b4d3d0 100644 --- a/fluxer_api/src/api/admin/services/AdminMessageDeletionService.ts +++ b/fluxer_api/src/api/admin/services/AdminMessageDeletionService.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {AdminMessageShredService} from '@app/api/admin/services/AdminMessageShredService'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {createUserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {Logger} from '@app/api/Logger'; import type { DeleteAllUserMessagesRequest, DeleteAllUserMessagesResponse, } from '@fluxer/schema/src/domains/admin/AdminMessageSchemas'; -import type {ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import {createUserID} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import {Logger} from '../../Logger'; -import type {AdminAuditService} from './AdminAuditService'; -import type {AdminMessageShredService} from './AdminMessageShredService'; interface AdminMessageDeletionServiceDeps { channelRepository: IChannelRepository; diff --git a/fluxer_api/src/api/admin/services/AdminMessageService.ts b/fluxer_api/src/api/admin/services/AdminMessageService.ts index aac668e7f..b36f1961d 100644 --- a/fluxer_api/src/api/admin/services/AdminMessageService.ts +++ b/fluxer_api/src/api/admin/services/AdminMessageService.ts @@ -1,5 +1,32 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import { + type AttachmentID, + type ChannelID, + createAttachmentID, + createChannelID, + createMessageID, + createUserID, + type MessageID, + type UserID, +} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {purgeMessageAttachments} from '@app/api/channel/services/message/MessageHelpers'; +import { + createMessageResponseDataService, + type MessageResponseAccessContext, + messageResponseAccessForChannel, + messageResponseAccessForGuild, +} from '@app/api/channel/services/message/MessageResponseDataService'; +import type {NcmecAttachmentStatusResponse, NcmecSubmissionService} from '@app/api/csam/NcmecSubmissionService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {getPurgeQueue, getStorageService} from '@app/api/middleware/ServiceSingletons'; +import {getMessageSearchService} from '@app/api/SearchFactory'; +import {deleteMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import {searchExistingMessages} from '@app/api/search/MessageSearchResultReconciler'; +import {assertSafeByteSize} from '@app/api/utils/ByteSizeUtils'; import type { BrowseChannelRequest, SearchChannelMessagesRequest, @@ -10,33 +37,6 @@ import type { LookupMessageRequest, } from '@fluxer/schema/src/domains/admin/AdminMessageSchemas'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import type {ApiContext} from '../../ApiContext'; -import { - type AttachmentID, - type ChannelID, - createAttachmentID, - createChannelID, - createMessageID, - createUserID, - type MessageID, - type UserID, -} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import {purgeMessageAttachments} from '../../channel/services/message/MessageHelpers'; -import { - createMessageResponseDataService, - type MessageResponseAccessContext, - messageResponseAccessForChannel, - messageResponseAccessForGuild, -} from '../../channel/services/message/MessageResponseDataService'; -import type {NcmecAttachmentStatusResponse, NcmecSubmissionService} from '../../csam/NcmecSubmissionService'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import {getPurgeQueue, getStorageService} from '../../middleware/ServiceSingletons'; -import {getMessageSearchService} from '../../SearchFactory'; -import {deleteMessageSearchDocuments} from '../../search/MessageSearchIndexCleanup'; -import {searchExistingMessages} from '../../search/MessageSearchResultReconciler'; -import {assertSafeByteSize} from '../../utils/ByteSizeUtils'; -import type {AdminAuditService} from './AdminAuditService'; interface AdminMessageServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminMessageShredService.ts b/fluxer_api/src/api/admin/services/AdminMessageShredService.ts index dc5c26aaa..bf3ce9e63 100644 --- a/fluxer_api/src/api/admin/services/AdminMessageShredService.ts +++ b/fluxer_api/src/api/admin/services/AdminMessageShredService.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {UserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {MessageShredRequest} from '@fluxer/schema/src/domains/admin/AdminMessageSchemas'; import type {WorkerJobPayload} from '@pkgs/worker/src/contracts/WorkerTypes'; -import type {ApiContext} from '../../ApiContext'; -import type {UserID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; -import type {AdminAuditService} from './AdminAuditService'; type MessageShredStatusCacheEntry = { status: 'in_progress' | 'completed' | 'failed'; diff --git a/fluxer_api/src/api/admin/services/AdminReportService.ts b/fluxer_api/src/api/admin/services/AdminReportService.ts index 181df1f03..d0d403e9b 100644 --- a/fluxer_api/src/api/admin/services/AdminReportService.ts +++ b/fluxer_api/src/api/admin/services/AdminReportService.ts @@ -1,12 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; -import {FeatureTemporarilyDisabledError} from '@fluxer/errors/src/domains/core/FeatureTemporarilyDisabledError'; -import type {SearchReportsRequest} from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {getEmailTemplate} from '@pkgs/email/src/email_i18n/EmailI18n'; -import {seconds} from 'itty-time'; -import type {ApiContext} from '../../ApiContext'; +import type {ApiContext} from '@app/api/ApiContext'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; import { type ChannelID, createReportID, @@ -14,33 +9,38 @@ import { type GuildID, type ReportID, type UserID, -} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {ChannelService} from '../../channel/services/ChannelService'; -import {makeAttachmentCdnKey} from '../../channel/services/message/MessageHelpers'; +} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import {makeAttachmentCdnKey} from '@app/api/channel/services/message/MessageHelpers'; import { createMessageResponseDataService, type MessageResponseAccessContext, messageResponseAccessForChannel, messageResponseAccessForGuild, -} from '../../channel/services/message/MessageResponseDataService'; -import {SYSTEM_USER_ID} from '../../constants/Core'; -import type {NcmecAttachmentStatusResponse, NcmecSubmissionService} from '../../csam/NcmecSubmissionService'; -import type {MessageAttachment} from '../../database/types/MessageTypes'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {Logger} from '../../Logger'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import {createRequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {User} from '../../models/User'; -import type {IARMessageContext, IARSubmission} from '../../report/IReportRepository'; -import type {ReportService} from '../../report/ReportService'; -import {getReportSearchService} from '../../SearchFactory'; -import type {UserChannelService} from '../../user/services/UserChannelService'; -import {assertSafeByteSize} from '../../utils/ByteSizeUtils'; -import type {AdminAuditService} from './AdminAuditService'; +} from '@app/api/channel/services/message/MessageResponseDataService'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import type {NcmecAttachmentStatusResponse, NcmecSubmissionService} from '@app/api/csam/NcmecSubmissionService'; +import type {MessageAttachment} from '@app/api/database/types/MessageTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; +import type {IARMessageContext, IARSubmission} from '@app/api/report/IReportRepository'; +import type {ReportService} from '@app/api/report/ReportService'; +import {getReportSearchService} from '@app/api/SearchFactory'; +import type {UserChannelService} from '@app/api/user/services/UserChannelService'; +import {assertSafeByteSize} from '@app/api/utils/ByteSizeUtils'; +import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; +import {FeatureTemporarilyDisabledError} from '@fluxer/errors/src/domains/core/FeatureTemporarilyDisabledError'; +import type {SearchReportsRequest} from '@fluxer/schema/src/domains/admin/AdminSchemas'; +import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; +import {getEmailTemplate} from '@pkgs/email/src/email_i18n/EmailI18n'; +import {seconds} from 'itty-time'; interface AdminReportServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminSearchService.ts b/fluxer_api/src/api/admin/services/AdminSearchService.ts index 801b1c62c..0703247dd 100644 --- a/fluxer_api/src/api/admin/services/AdminSearchService.ts +++ b/fluxer_api/src/api/admin/services/AdminSearchService.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {mapGuildToAdminResponse} from '@app/api/admin/models/GuildTypes'; +import {mapUserToAdminResponse} from '@app/api/admin/models/UserTypes'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {createGuildID, createUserID, type UserID} from '@app/api/BrandedTypes'; +import {isSyntheticUserId} from '@app/api/constants/Core'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {Logger} from '@app/api/Logger'; +import {getGuildSearchService, getUserSearchService} from '@app/api/SearchFactory'; import {FeatureTemporarilyDisabledError} from '@fluxer/errors/src/domains/core/FeatureTemporarilyDisabledError'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {WorkerJobPayload} from '@pkgs/worker/src/contracts/WorkerTypes'; -import type {ApiContext} from '../../ApiContext'; -import {createGuildID, createUserID, type UserID} from '../../BrandedTypes'; -import {isSyntheticUserId} from '../../constants/Core'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import {Logger} from '../../Logger'; -import {getGuildSearchService, getUserSearchService} from '../../SearchFactory'; -import {mapGuildToAdminResponse} from '../models/GuildTypes'; -import {mapUserToAdminResponse} from '../models/UserTypes'; -import type {AdminAuditService} from './AdminAuditService'; interface RefreshSearchIndexJobPayload extends WorkerJobPayload { index_type: diff --git a/fluxer_api/src/api/admin/services/AdminUserBanService.ts b/fluxer_api/src/api/admin/services/AdminUserBanService.ts index 5c37f761c..706d79907 100644 --- a/fluxer_api/src/api/admin/services/AdminUserBanService.ts +++ b/fluxer_api/src/api/admin/services/AdminUserBanService.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {mapUserToAdminResponse} from '@app/api/admin/models/UserTypes'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {AdminUserUpdatePropagator} from '@app/api/admin/services/AdminUserUpdatePropagator'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import type {TempBanUserRequest} from '@fluxer/schema/src/domains/admin/AdminUserSchemas'; -import type {ApiContext} from '../../ApiContext'; -import * as AuthSession from '../../auth/AuthSession'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {mapUserToAdminResponse} from '../models/UserTypes'; -import type {AdminAuditService} from './AdminAuditService'; -import type {AdminUserUpdatePropagator} from './AdminUserUpdatePropagator'; interface AdminUserBanServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminUserDeletionService.ts b/fluxer_api/src/api/admin/services/AdminUserDeletionService.ts index 875fddcc6..13b7f4beb 100644 --- a/fluxer_api/src/api/admin/services/AdminUserDeletionService.ts +++ b/fluxer_api/src/api/admin/services/AdminUserDeletionService.ts @@ -1,5 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {mapUserToAdminResponse} from '@app/api/admin/models/UserTypes'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {AdminBanManagementService} from '@app/api/admin/services/AdminBanManagementService'; +import type {AdminUserUpdatePropagator} from '@app/api/admin/services/AdminUserUpdatePropagator'; +import {BulkCancelledError, type BulkProgressHelpers} from '@app/api/admin/services/BulkProgressHelpers'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import {createReportID, createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {BillingRepository} from '@app/api/billing/repositories/BillingRepository'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import {ReportStatus} from '@app/api/report/IReportRepository'; +import type {ReportService} from '@app/api/report/ReportService'; +import {getReportSearchService} from '@app/api/SearchFactory'; +import {clearPendingDeletion, reschedulePendingDeletion} from '@app/api/user/services/PendingDeletionCoordinator'; import {DeletionReasons} from '@fluxer/constants/src/Core'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {ReportAlreadyResolvedError} from '@fluxer/errors/src/domains/moderation/ReportAlreadyResolvedError'; @@ -9,22 +25,6 @@ import type { ScheduleAccountDeletionRequest, } from '@fluxer/schema/src/domains/admin/AdminUserSchemas'; import type Stripe from 'stripe'; -import type {ApiContext} from '../../ApiContext'; -import * as AuthSession from '../../auth/AuthSession'; -import {createReportID, createUserID, type UserID} from '../../BrandedTypes'; -import type {BillingRepository} from '../../billing/repositories/BillingRepository'; -import type {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import {Logger} from '../../Logger'; -import type {User} from '../../models/User'; -import {ReportStatus} from '../../report/IReportRepository'; -import type {ReportService} from '../../report/ReportService'; -import {getReportSearchService} from '../../SearchFactory'; -import {clearPendingDeletion, reschedulePendingDeletion} from '../../user/services/PendingDeletionCoordinator'; -import {mapUserToAdminResponse} from '../models/UserTypes'; -import type {AdminAuditService} from './AdminAuditService'; -import type {AdminBanManagementService} from './AdminBanManagementService'; -import type {AdminUserUpdatePropagator} from './AdminUserUpdatePropagator'; -import {BulkCancelledError, type BulkProgressHelpers} from './BulkProgressHelpers'; interface AdminUserDeletionServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminUserLookupService.ts b/fluxer_api/src/api/admin/services/AdminUserLookupService.ts index 2aacbfbcc..e52a2d826 100644 --- a/fluxer_api/src/api/admin/services/AdminUserLookupService.ts +++ b/fluxer_api/src/api/admin/services/AdminUserLookupService.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {mapUserToAdminResponse} from '@app/api/admin/models/UserTypes'; +import {createUserID} from '@app/api/BrandedTypes'; +import {isSyntheticUserId} from '@app/api/constants/Core'; +import {Logger} from '@app/api/Logger'; import type {LookupUserRequest} from '@fluxer/schema/src/domains/admin/AdminUserSchemas'; -import type {ApiContext} from '../../ApiContext'; -import {createUserID} from '../../BrandedTypes'; -import {isSyntheticUserId} from '../../constants/Core'; -import {Logger} from '../../Logger'; -import {mapUserToAdminResponse} from '../models/UserTypes'; interface AdminUserLookupServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminUserProfileService.ts b/fluxer_api/src/api/admin/services/AdminUserProfileService.ts index e439a6e6a..e8438c37b 100644 --- a/fluxer_api/src/api/admin/services/AdminUserProfileService.ts +++ b/fluxer_api/src/api/admin/services/AdminUserProfileService.ts @@ -1,5 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {mapUserToAdminResponse} from '@app/api/admin/models/UserTypes'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {AdminUserUpdatePropagator} from '@app/api/admin/services/AdminUserUpdatePropagator'; +import {EMAIL_CLEARABLE_SUSPICIOUS_ACTIVITY_FLAGS} from '@app/api/auth/AuthEmail'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {GuildMemberSearchIndexService} from '@app/api/guild/services/member/GuildMemberSearchIndexService'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {EntityAssetService, PreparedAssetUpload} from '@app/api/infrastructure/EntityAssetService'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {AccessDeniedError} from '@fluxer/errors/src/domains/core/AccessDeniedError'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; @@ -15,18 +27,6 @@ import type { VerifyUserEmailRequest, } from '@fluxer/schema/src/domains/admin/AdminUserSchemas'; import {types} from 'cassandra-driver'; -import type {ApiContext} from '../../ApiContext'; -import {EMAIL_CLEARABLE_SUSPICIOUS_ACTIVITY_FLAGS} from '../../auth/AuthEmail'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import {GuildMemberSearchIndexService} from '../../guild/services/member/GuildMemberSearchIndexService'; -import type {IDiscriminatorService} from '../../infrastructure/DiscriminatorService'; -import type {EntityAssetService, PreparedAssetUpload} from '../../infrastructure/EntityAssetService'; -import {Logger} from '../../Logger'; -import type {User} from '../../models/User'; -import {mapUserToAdminResponse} from '../models/UserTypes'; -import type {AdminAuditService} from './AdminAuditService'; -import type {AdminUserUpdatePropagator} from './AdminUserUpdatePropagator'; interface AdminUserProfileServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminUserRelationshipService.ts b/fluxer_api/src/api/admin/services/AdminUserRelationshipService.ts index 1659d9a8a..9ab508992 100644 --- a/fluxer_api/src/api/admin/services/AdminUserRelationshipService.ts +++ b/fluxer_api/src/api/admin/services/AdminUserRelationshipService.ts @@ -1,5 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {Relationship} from '@app/api/models/Relationship'; import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import type { @@ -11,10 +15,6 @@ import type { RemoveUserRelationshipsByCategoryRequest, RemoveUserRelationshipsResponse, } from '@fluxer/schema/src/domains/admin/AdminUserSchemas'; -import type {ApiContext} from '../../ApiContext'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import type {Relationship} from '../../models/Relationship'; -import type {AdminAuditService} from './AdminAuditService'; interface AdminUserRelationshipServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminUserSecurityService.ts b/fluxer_api/src/api/admin/services/AdminUserSecurityService.ts index 9f258055a..e90c0a6d4 100644 --- a/fluxer_api/src/api/admin/services/AdminUserSecurityService.ts +++ b/fluxer_api/src/api/admin/services/AdminUserSecurityService.ts @@ -1,5 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {mapUserToAdminResponse} from '@app/api/admin/models/UserTypes'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {AdminUserUpdatePropagator} from '@app/api/admin/services/AdminUserUpdatePropagator'; +import {BulkCancelledError, type BulkProgressHelpers} from '@app/api/admin/services/BulkProgressHelpers'; +import * as AuthEmail from '@app/api/auth/AuthEmail'; +import * as AuthMfa from '@app/api/auth/AuthMfa'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import * as AuthUtility from '@app/api/auth/AuthUtility'; +import {createPasswordResetToken, createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import type {IRiskHistoryRepository} from '@app/api/risk/HistoricalOutcomeRepository'; +import type {HistoricalOutcomeCode} from '@app/api/risk/RiskHistoryTypes'; +import {resolveAssignedTraits} from '@app/api/user/UserTraits'; +import {getIpAddressReverse, getLocationLabelFromIp} from '@app/api/utils/IpUtils'; +import {resolveSessionClientInfo} from '@app/api/utils/SessionClientIdentity'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import { @@ -34,24 +52,6 @@ import type { UpdateSuspiciousActivityFlagsRequest, } from '@fluxer/schema/src/domains/admin/AdminUserSchemas'; import type {WebAuthnCredentialListResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; -import type {ApiContext} from '../../ApiContext'; -import * as AuthEmail from '../../auth/AuthEmail'; -import * as AuthMfa from '../../auth/AuthMfa'; -import * as AuthSession from '../../auth/AuthSession'; -import * as AuthUtility from '../../auth/AuthUtility'; -import {createPasswordResetToken, createUserID, type UserID} from '../../BrandedTypes'; -import type {UserRow} from '../../database/types/UserTypes'; -import {Logger} from '../../Logger'; -import {getInstanceConfigRepository} from '../../middleware/ServiceSingletons'; -import type {IRiskHistoryRepository} from '../../risk/HistoricalOutcomeRepository'; -import type {HistoricalOutcomeCode} from '../../risk/RiskHistoryTypes'; -import {resolveAssignedTraits} from '../../user/UserTraits'; -import {getIpAddressReverse, getLocationLabelFromIp} from '../../utils/IpUtils'; -import {resolveSessionClientInfo} from '../../utils/SessionClientIdentity'; -import {mapUserToAdminResponse} from '../models/UserTypes'; -import type {AdminAuditService} from './AdminAuditService'; -import type {AdminUserUpdatePropagator} from './AdminUserUpdatePropagator'; -import {BulkCancelledError, type BulkProgressHelpers} from './BulkProgressHelpers'; interface AdminUserSecurityServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminUserService.ts b/fluxer_api/src/api/admin/services/AdminUserService.ts index 6b280addc..f557b133d 100644 --- a/fluxer_api/src/api/admin/services/AdminUserService.ts +++ b/fluxer_api/src/api/admin/services/AdminUserService.ts @@ -1,5 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {mapUserToAdminResponse} from '@app/api/admin/models/UserTypes'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {AdminBanManagementService} from '@app/api/admin/services/AdminBanManagementService'; +import {AdminUserBanService} from '@app/api/admin/services/AdminUserBanService'; +import {AdminUserDeletionService} from '@app/api/admin/services/AdminUserDeletionService'; +import {AdminUserLookupService} from '@app/api/admin/services/AdminUserLookupService'; +import {AdminUserProfileService} from '@app/api/admin/services/AdminUserProfileService'; +import {AdminUserSecurityService} from '@app/api/admin/services/AdminUserSecurityService'; +import {AdminUserUpdatePropagator} from '@app/api/admin/services/AdminUserUpdatePropagator'; +import {createChannelID, createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import type {KVBulkMessageDeletionQueueService} from '@app/api/infrastructure/KVBulkMessageDeletionQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import type {ReportService} from '@app/api/report/ReportService'; +import type {IRiskHistoryRepository} from '@app/api/risk/HistoricalOutcomeRepository'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {UserContactChangeLogService} from '@app/api/user/services/UserContactChangeLogService'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import type { @@ -10,29 +33,6 @@ import type { } from '@fluxer/schema/src/domains/admin/AdminUserSchemas'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type Stripe from 'stripe'; -import type {ApiContext} from '../../ApiContext'; -import {createChannelID, createUserID, type UserID} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {IDiscriminatorService} from '../../infrastructure/DiscriminatorService'; -import type {EntityAssetService} from '../../infrastructure/EntityAssetService'; -import type {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import type {KVBulkMessageDeletionQueueService} from '../../infrastructure/KVBulkMessageDeletionQueueService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import type {ReportService} from '../../report/ReportService'; -import type {IRiskHistoryRepository} from '../../risk/HistoricalOutcomeRepository'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {UserContactChangeLogService} from '../../user/services/UserContactChangeLogService'; -import {mapUserToAdminResponse} from '../models/UserTypes'; -import type {AdminAuditService} from './AdminAuditService'; -import type {AdminBanManagementService} from './AdminBanManagementService'; -import {AdminUserBanService} from './AdminUserBanService'; -import {AdminUserDeletionService} from './AdminUserDeletionService'; -import {AdminUserLookupService} from './AdminUserLookupService'; -import {AdminUserProfileService} from './AdminUserProfileService'; -import {AdminUserSecurityService} from './AdminUserSecurityService'; -import {AdminUserUpdatePropagator} from './AdminUserUpdatePropagator'; interface AdminUserServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/AdminUserUpdatePropagator.ts b/fluxer_api/src/api/admin/services/AdminUserUpdatePropagator.ts index 34874de70..ade3c25a6 100644 --- a/fluxer_api/src/api/admin/services/AdminUserUpdatePropagator.ts +++ b/fluxer_api/src/api/admin/services/AdminUserUpdatePropagator.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import {mapGuildMemberToResponse} from '../../guild/GuildModel'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {createRequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {BaseUserUpdatePropagator} from '../../user/services/BaseUserUpdatePropagator'; -import {hasPartialUserFieldsChanged} from '../../user/UserMappers'; +import type {UserID} from '@app/api/BrandedTypes'; +import {mapGuildMemberToResponse} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {BaseUserUpdatePropagator} from '@app/api/user/services/BaseUserUpdatePropagator'; +import {hasPartialUserFieldsChanged} from '@app/api/user/UserMappers'; interface AdminUserUpdatePropagatorDeps { userCacheService: UserCacheService; diff --git a/fluxer_api/src/api/admin/services/AdminVoiceService.ts b/fluxer_api/src/api/admin/services/AdminVoiceService.ts index 3783dae5e..75f14a5af 100644 --- a/fluxer_api/src/api/admin/services/AdminVoiceService.ts +++ b/fluxer_api/src/api/admin/services/AdminVoiceService.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {createGuildIDSet, createUserIDSet, type UserID} from '@app/api/BrandedTypes'; +import {VOICE_CONFIGURATION_CHANNEL} from '@app/api/voice/VoiceConstants'; +import type {VoiceRegionRecord, VoiceRegionWithServers, VoiceServerRecord} from '@app/api/voice/VoiceModel'; +import type {VoiceRepository} from '@app/api/voice/VoiceRepository'; import {UnknownVoiceRegionError} from '@fluxer/errors/src/domains/voice/UnknownVoiceRegionError'; import {UnknownVoiceServerError} from '@fluxer/errors/src/domains/voice/UnknownVoiceServerError'; import type { @@ -16,12 +22,6 @@ import type { VoiceRegionAdminResponse, VoiceServerAdminResponse, } from '@fluxer/schema/src/domains/admin/AdminVoiceSchemas'; -import type {ApiContext} from '../../ApiContext'; -import {createGuildIDSet, createUserIDSet, type UserID} from '../../BrandedTypes'; -import {VOICE_CONFIGURATION_CHANNEL} from '../../voice/VoiceConstants'; -import type {VoiceRegionRecord, VoiceRegionWithServers, VoiceServerRecord} from '../../voice/VoiceModel'; -import type {VoiceRepository} from '../../voice/VoiceRepository'; -import type {AdminAuditService} from './AdminAuditService'; interface AdminVoiceServiceDeps { apiContext: ApiContext; diff --git a/fluxer_api/src/api/admin/services/guild/AdminGuildBulkService.ts b/fluxer_api/src/api/admin/services/guild/AdminGuildBulkService.ts index 68fe1af60..c7e78ced4 100644 --- a/fluxer_api/src/api/admin/services/guild/AdminGuildBulkService.ts +++ b/fluxer_api/src/api/admin/services/guild/AdminGuildBulkService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {BulkCancelledError, type BulkProgressHelpers} from '@app/api/admin/services/BulkProgressHelpers'; +import type {AdminGuildUpdateService} from '@app/api/admin/services/guild/AdminGuildUpdateService'; +import {createGuildID, type UserID} from '@app/api/BrandedTypes'; import type {BulkUpdateGuildFeaturesRequest} from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; -import {createGuildID, type UserID} from '../../../BrandedTypes'; -import type {AdminAuditService} from '../AdminAuditService'; -import {BulkCancelledError, type BulkProgressHelpers} from '../BulkProgressHelpers'; -import type {AdminGuildUpdateService} from './AdminGuildUpdateService'; interface AdminGuildBulkServiceDeps { guildUpdateService: AdminGuildUpdateService; diff --git a/fluxer_api/src/api/admin/services/guild/AdminGuildLookupService.ts b/fluxer_api/src/api/admin/services/guild/AdminGuildLookupService.ts index 9a252c2fd..c582b3bc0 100644 --- a/fluxer_api/src/api/admin/services/guild/AdminGuildLookupService.ts +++ b/fluxer_api/src/api/admin/services/guild/AdminGuildLookupService.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapGuildsToAdminResponse} from '@app/api/admin/models/GuildTypes'; +import type {GuildID} from '@app/api/BrandedTypes'; +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {mapGuildFeatures} from '@app/api/guild/GuildFeatureUtils'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {MEDIA_PROXY_ICON_SIZE_DEFAULT} from '@fluxer/constants/src/MediaProxyAssetSizes'; import type {MediaProxyImageSize} from '@fluxer/constants/src/MediaProxyImageSizes'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; @@ -9,15 +18,6 @@ import type { LookupGuildRequest, } from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; import type {ListGuildEmojisResponse, ListGuildStickersResponse} from '@fluxer/schema/src/domains/admin/AdminSchemas'; -import type {GuildID} from '../../../BrandedTypes'; -import {createGuildID, createUserID} from '../../../BrandedTypes'; -import {Config} from '../../../Config'; -import type {IChannelRepository} from '../../../channel/IChannelRepository'; -import {mapGuildFeatures} from '../../../guild/GuildFeatureUtils'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {mapGuildsToAdminResponse} from '../../models/GuildTypes'; const ADMIN_STICKER_MEDIA_RUNG: MediaProxyImageSize = 320; diff --git a/fluxer_api/src/api/admin/services/guild/AdminGuildManagementService.ts b/fluxer_api/src/api/admin/services/guild/AdminGuildManagementService.ts index 667047f5e..fae09b10d 100644 --- a/fluxer_api/src/api/admin/services/guild/AdminGuildManagementService.ts +++ b/fluxer_api/src/api/admin/services/guild/AdminGuildManagementService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {createGuildID, type GuildID, type UserID} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import type {SuccessResponse} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createGuildID, type GuildID, type UserID} from '../../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {GuildService} from '../../../guild/services/GuildService'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {AdminAuditService} from '../AdminAuditService'; interface AdminGuildManagementServiceDeps { guildRepository: IGuildRepositoryAggregate; diff --git a/fluxer_api/src/api/admin/services/guild/AdminGuildMembershipService.ts b/fluxer_api/src/api/admin/services/guild/AdminGuildMembershipService.ts index a2cfb6ec7..499cad090 100644 --- a/fluxer_api/src/api/admin/services/guild/AdminGuildMembershipService.ts +++ b/fluxer_api/src/api/admin/services/guild/AdminGuildMembershipService.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {BulkCancelledError, type BulkProgressHelpers} from '@app/api/admin/services/BulkProgressHelpers'; +import {createGuildID, createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import {createRequestCache, type RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {JoinSourceTypes} from '@fluxer/constants/src/GuildConstants'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import type { @@ -9,12 +15,6 @@ import type { KickGuildMemberRequest, } from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; import type {SuccessResponse} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createGuildID, createUserID, type UserID} from '../../../BrandedTypes'; -import type {GuildService} from '../../../guild/services/GuildService'; -import {createRequestCache, type RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import type {AdminAuditService} from '../AdminAuditService'; -import {BulkCancelledError, type BulkProgressHelpers} from '../BulkProgressHelpers'; interface AdminGuildMembershipServiceDeps { userRepository: IUserRepository; diff --git a/fluxer_api/src/api/admin/services/guild/AdminGuildUpdatePropagator.ts b/fluxer_api/src/api/admin/services/guild/AdminGuildUpdatePropagator.ts index 7903ffcdd..ab927a5ba 100644 --- a/fluxer_api/src/api/admin/services/guild/AdminGuildUpdatePropagator.ts +++ b/fluxer_api/src/api/admin/services/guild/AdminGuildUpdatePropagator.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {mapGuildToGuildResponse} from '@app/api/guild/GuildModel'; +import type {IGuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import type {Guild} from '@app/api/models/Guild'; +import {getGuildSearchService} from '@app/api/SearchFactory'; +import type {GuildDiscoveryContext} from '@app/api/search/guild/GuildSearchSerializer'; import {DiscoveryApplicationStatus} from '@fluxer/constants/src/DiscoveryConstants'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; -import type {GuildID, UserID} from '../../../BrandedTypes'; -import {mapGuildToGuildResponse} from '../../../guild/GuildModel'; -import type {IGuildDiscoveryRepository} from '../../../guild/repositories/GuildDiscoveryRepository'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import {Logger} from '../../../Logger'; -import type {Guild} from '../../../models/Guild'; -import {getGuildSearchService} from '../../../SearchFactory'; -import type {GuildDiscoveryContext} from '../../../search/guild/GuildSearchSerializer'; interface AdminGuildUpdatePropagatorDeps { gatewayService: IGatewayService; diff --git a/fluxer_api/src/api/admin/services/guild/AdminGuildUpdateService.ts b/fluxer_api/src/api/admin/services/guild/AdminGuildUpdateService.ts index c213accef..6eed49710 100644 --- a/fluxer_api/src/api/admin/services/guild/AdminGuildUpdateService.ts +++ b/fluxer_api/src/api/admin/services/guild/AdminGuildUpdateService.ts @@ -1,5 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapGuildToAdminResponse} from '@app/api/admin/models/GuildTypes'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {AdminGuildUpdatePropagator} from '@app/api/admin/services/guild/AdminGuildUpdatePropagator'; +import {createGuildID, createUserID, type GuildID, type UserID} from '@app/api/BrandedTypes'; +import type {GuildRow} from '@app/api/database/types/GuildTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {EntityAssetService, PreparedAssetUpload} from '@app/api/infrastructure/EntityAssetService'; +import {Logger} from '@app/api/Logger'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import type { ClearGuildFieldsRequest, @@ -7,14 +15,6 @@ import type { UpdateGuildNameRequest, UpdateGuildSettingsRequest, } from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; -import {createGuildID, createUserID, type GuildID, type UserID} from '../../../BrandedTypes'; -import type {GuildRow} from '../../../database/types/GuildTypes'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {EntityAssetService, PreparedAssetUpload} from '../../../infrastructure/EntityAssetService'; -import {Logger} from '../../../Logger'; -import {mapGuildToAdminResponse} from '../../models/GuildTypes'; -import type {AdminAuditService} from '../AdminAuditService'; -import type {AdminGuildUpdatePropagator} from './AdminGuildUpdatePropagator'; interface AdminGuildUpdateServiceDeps { guildRepository: IGuildRepositoryAggregate; diff --git a/fluxer_api/src/api/admin/services/guild/AdminGuildVanityService.ts b/fluxer_api/src/api/admin/services/guild/AdminGuildVanityService.ts index 1b660636c..d188de904 100644 --- a/fluxer_api/src/api/admin/services/guild/AdminGuildVanityService.ts +++ b/fluxer_api/src/api/admin/services/guild/AdminGuildVanityService.ts @@ -1,22 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {InviteTypes} from '@fluxer/constants/src/ChannelConstants'; -import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; -import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; -import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; -import type {UpdateGuildVanityRequest} from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; +import {mapGuildToAdminResponse} from '@app/api/admin/models/GuildTypes'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {AdminGuildUpdatePropagator} from '@app/api/admin/services/guild/AdminGuildUpdatePropagator'; import { createGuildID, createInviteCode, createVanityURLCode, type UserID, vanityCodeToInviteCode, -} from '../../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {InviteRepository} from '../../../invite/InviteRepository'; -import {mapGuildToAdminResponse} from '../../models/GuildTypes'; -import type {AdminAuditService} from '../AdminAuditService'; -import type {AdminGuildUpdatePropagator} from './AdminGuildUpdatePropagator'; +} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {InviteRepository} from '@app/api/invite/InviteRepository'; +import {InviteTypes} from '@fluxer/constants/src/ChannelConstants'; +import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; +import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; +import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; +import type {UpdateGuildVanityRequest} from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; interface AdminGuildVanityServiceDeps { guildRepository: IGuildRepositoryAggregate; diff --git a/fluxer_api/src/api/admin/tests/AdminApiKeyACLValidation.test.ts b/fluxer_api/src/api/admin/tests/AdminApiKeyACLValidation.test.ts index dcd16ff17..2e6e17bc1 100644 --- a/fluxer_api/src/api/admin/tests/AdminApiKeyACLValidation.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminApiKeyACLValidation.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAdminApiKey, listAdminApiKeys} from '@app/api/admin/tests/AdminTestUtils'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAdminApiKey, listAdminApiKeys} from './AdminTestUtils'; describe('Admin API Key ACL Validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/admin/tests/AdminApiKeyAuthentication.test.ts b/fluxer_api/src/api/admin/tests/AdminApiKeyAuthentication.test.ts index b46950562..6cd867004 100644 --- a/fluxer_api/src/api/admin/tests/AdminApiKeyAuthentication.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminApiKeyAuthentication.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import type {TestAccount} from '../../auth/tests/AuthTestUtils'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface AdminApiKey { keyId: string; diff --git a/fluxer_api/src/api/admin/tests/AdminApiKeyAuthorization.test.ts b/fluxer_api/src/api/admin/tests/AdminApiKeyAuthorization.test.ts index 3f96f65bb..f6a47eac1 100644 --- a/fluxer_api/src/api/admin/tests/AdminApiKeyAuthorization.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminApiKeyAuthorization.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAdminApiKey} from '@app/api/admin/tests/AdminTestUtils'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAdminApiKey} from './AdminTestUtils'; describe('Admin API Key Authorization', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/admin/tests/AdminApiKeyLifecycle.test.ts b/fluxer_api/src/api/admin/tests/AdminApiKeyLifecycle.test.ts index c0ad6ac21..255d5d207 100644 --- a/fluxer_api/src/api/admin/tests/AdminApiKeyLifecycle.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminApiKeyLifecycle.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; import { createAdminApiKey, createAdminApiKeyWithDefaultACLs, listAdminApiKeys, revokeAdminApiKey, -} from './AdminTestUtils'; +} from '@app/api/admin/tests/AdminTestUtils'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; interface ApiKeyResponse { key_id: string; diff --git a/fluxer_api/src/api/admin/tests/AdminApiKeyManagement.test.ts b/fluxer_api/src/api/admin/tests/AdminApiKeyManagement.test.ts index c033835b4..3d1ffa8ff 100644 --- a/fluxer_api/src/api/admin/tests/AdminApiKeyManagement.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminApiKeyManagement.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; import { createAdminApiKey, createAdminApiKeyWithDefaultACLs, listAdminApiKeys, revokeAdminApiKey, -} from './AdminTestUtils'; +} from '@app/api/admin/tests/AdminTestUtils'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; interface ValidationErrorResponse { errors: Array<{ diff --git a/fluxer_api/src/api/admin/tests/AdminApiKeyRevocation.test.ts b/fluxer_api/src/api/admin/tests/AdminApiKeyRevocation.test.ts index 9855f8136..86f5d5626 100644 --- a/fluxer_api/src/api/admin/tests/AdminApiKeyRevocation.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminApiKeyRevocation.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAdminApiKeyWithDefaultACLs, listAdminApiKeys} from '@app/api/admin/tests/AdminTestUtils'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAdminApiKeyWithDefaultACLs, listAdminApiKeys} from './AdminTestUtils'; async function hasAdminAPIKeyId(harness: ApiTestHarness, token: string, keyId: string): Promise { const keys = await listAdminApiKeys(harness, token); diff --git a/fluxer_api/src/api/admin/tests/AdminApplications.test.ts b/fluxer_api/src/api/admin/tests/AdminApplications.test.ts index 36376295d..32d66072c 100644 --- a/fluxer_api/src/api/admin/tests/AdminApplications.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminApplications.test.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {createOAuth2Application, createUniqueApplicationName} from '@app/api/oauth/tests/OAuth2TestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {ADMIN_OAUTH2_APPLICATION_ID} from '@fluxer/constants/src/Core'; import type { @@ -8,11 +13,6 @@ import type { LookupApplicationResponse, } from '@fluxer/schema/src/domains/admin/AdminApplicationSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {createOAuth2Application, createUniqueApplicationName} from '../../oauth/tests/OAuth2TestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface AuditLogsResponse { logs: Array<{ diff --git a/fluxer_api/src/api/admin/tests/AdminArchiveRetryClearsFailure.test.ts b/fluxer_api/src/api/admin/tests/AdminArchiveRetryClearsFailure.test.ts index e63922df7..3c7d200ed 100644 --- a/fluxer_api/src/api/admin/tests/AdminArchiveRetryClearsFailure.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminArchiveRetryClearsFailure.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminArchive} from '@app/api/admin/models/AdminArchiveModel'; +import {AdminArchiveRepository} from '@app/api/admin/repositories/AdminArchiveRepository'; +import {createTestAccount, setUserACLs, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createTestGuild} from '@app/api/emoji/tests/EmojiTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {createTestGuild} from '../../emoji/tests/EmojiTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import type {AdminArchive} from '../models/AdminArchiveModel'; -import {AdminArchiveRepository} from '../repositories/AdminArchiveRepository'; interface ArchiveResponse { archive_id: string; diff --git a/fluxer_api/src/api/admin/tests/AdminArchivesList.test.ts b/fluxer_api/src/api/admin/tests/AdminArchivesList.test.ts index 0e73525ec..7242a0905 100644 --- a/fluxer_api/src/api/admin/tests/AdminArchivesList.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminArchivesList.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createTestGuild} from '@app/api/emoji/tests/EmojiTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {createTestGuild} from '../../emoji/tests/EmojiTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface ArchiveResponse { archive_id: string; diff --git a/fluxer_api/src/api/admin/tests/AdminBanManagementIpDecline.test.ts b/fluxer_api/src/api/admin/tests/AdminBanManagementIpDecline.test.ts index 7d15b22e7..89884d3d5 100644 --- a/fluxer_api/src/api/admin/tests/AdminBanManagementIpDecline.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminBanManagementIpDecline.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {IAdminRepository} from '@app/api/admin/IAdminRepository'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {AdminBanManagementService} from '@app/api/admin/services/AdminBanManagementService'; +import {createUserID} from '@app/api/BrandedTypes'; +import {getConfig} from '@app/api/Config'; +import {ipBanCache} from '@app/api/middleware/IpBanMiddleware'; +import {resetIpBanExemptionsForTesting} from '@app/api/risk/IpBanExemptions'; +import type {ISuspiciousIpRepository} from '@app/api/risk/SuspiciousIpRepository'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {BadRequestError} from '@fluxer/errors/src/domains/core/BadRequestError'; import type {IpInfoLookupResult, IpInfoService} from '@pkgs/geoip/src/IpInfoService'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiContext} from '../../ApiContext'; -import {createUserID} from '../../BrandedTypes'; -import {getConfig} from '../../Config'; -import {ipBanCache} from '../../middleware/IpBanMiddleware'; -import {resetIpBanExemptionsForTesting} from '../../risk/IpBanExemptions'; -import type {ISuspiciousIpRepository} from '../../risk/SuspiciousIpRepository'; -import type {IAdminRepository} from '../IAdminRepository'; -import type {AdminAuditService} from '../services/AdminAuditService'; -import {AdminBanManagementService} from '../services/AdminBanManagementService'; const ADMIN_ID = createUserID(42n); const EXEMPT_IP = '10.0.0.1'; diff --git a/fluxer_api/src/api/admin/tests/AdminBlocklistUrl.test.ts b/fluxer_api/src/api/admin/tests/AdminBlocklistUrl.test.ts index 2985ed53c..843041fe7 100644 --- a/fluxer_api/src/api/admin/tests/AdminBlocklistUrl.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminBlocklistUrl.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface ValidationErrorResponse { code: string; diff --git a/fluxer_api/src/api/admin/tests/AdminDeletionQueue.test.ts b/fluxer_api/src/api/admin/tests/AdminDeletionQueue.test.ts index 24ace8531..e859109d1 100644 --- a/fluxer_api/src/api/admin/tests/AdminDeletionQueue.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminDeletionQueue.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomInt} from 'node:crypto'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {setInjectedIpInfoService} from '@app/api/middleware/ServiceMiddleware'; +import {CassandraSuspiciousIpRepository} from '@app/api/risk/SuspiciousIpRepository'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import {DeletionReasons} from '@fluxer/constants/src/Core'; import type {IpInfoLookupResult} from '@pkgs/geoip/src/IpInfoService'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {setInjectedIpInfoService} from '../../middleware/ServiceMiddleware'; -import {CassandraSuspiciousIpRepository} from '../../risk/SuspiciousIpRepository'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../../user/repositories/UserRepository'; function createUniqueTestIp(): string { return `198.51.${randomInt(0, 256)}.${randomInt(1, 255)}`; diff --git a/fluxer_api/src/api/admin/tests/AdminEndpointsAuthorization.test.ts b/fluxer_api/src/api/admin/tests/AdminEndpointsAuthorization.test.ts index ddc3701b7..c3e6f1377 100644 --- a/fluxer_api/src/api/admin/tests/AdminEndpointsAuthorization.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminEndpointsAuthorization.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth, type TestRequestBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth, type TestRequestBuilder} from '../../test/TestRequestBuilder'; function withMethod(builder: TestRequestBuilder, method: string, path: string, body: unknown = {}): TestRequestBuilder { switch (method) { diff --git a/fluxer_api/src/api/admin/tests/AdminGuildApplications.test.ts b/fluxer_api/src/api/admin/tests/AdminGuildApplications.test.ts index a985fc1d4..d3c8268fd 100644 --- a/fluxer_api/src/api/admin/tests/AdminGuildApplications.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminGuildApplications.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/channel/tests/ChannelTestUtils'; +import {createOAuth2Application, createUniqueApplicationName} from '@app/api/oauth/tests/OAuth2TestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import type {ListApplicationsResponse} from '@fluxer/schema/src/domains/admin/AdminApplicationSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../channel/tests/ChannelTestUtils'; -import {createOAuth2Application, createUniqueApplicationName} from '../../oauth/tests/OAuth2TestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('Admin guild applications', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/admin/tests/AdminGuildRoutes.test.ts b/fluxer_api/src/api/admin/tests/AdminGuildRoutes.test.ts index 50691a17c..b49437c8c 100644 --- a/fluxer_api/src/api/admin/tests/AdminGuildRoutes.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminGuildRoutes.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface AdminGuildDetail { guild: { diff --git a/fluxer_api/src/api/admin/tests/AdminJobsAndBulkJobs.test.ts b/fluxer_api/src/api/admin/tests/AdminJobsAndBulkJobs.test.ts index 13ba83099..e2f548509 100644 --- a/fluxer_api/src/api/admin/tests/AdminJobsAndBulkJobs.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminJobsAndBulkJobs.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface JobEntry { job_id: string; diff --git a/fluxer_api/src/api/admin/tests/AdminLastActiveIpSearch.test.ts b/fluxer_api/src/api/admin/tests/AdminLastActiveIpSearch.test.ts index 88a7c8efb..39acab779 100644 --- a/fluxer_api/src/api/admin/tests/AdminLastActiveIpSearch.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminLastActiveIpSearch.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {getUserActivityBuffer} from '@app/api/middleware/ServiceSingletons'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {getUserActivityBuffer} from '../../middleware/ServiceSingletons'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface AdminUserSearchResponse { users: Array<{ diff --git a/fluxer_api/src/api/admin/tests/AdminOAuth2ApplicationRequirement.test.ts b/fluxer_api/src/api/admin/tests/AdminOAuth2ApplicationRequirement.test.ts index 187a69643..9bf9bdf61 100644 --- a/fluxer_api/src/api/admin/tests/AdminOAuth2ApplicationRequirement.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminOAuth2ApplicationRequirement.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAdminApiKey} from '@app/api/admin/tests/AdminTestUtils'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {ADMIN_OAUTH2_APPLICATION_ID} from '@fluxer/constants/src/Core'; import {beforeEach, describe, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAdminApiKey} from './AdminTestUtils'; interface OAuth2TokenResponse { token: string; diff --git a/fluxer_api/src/api/admin/tests/AdminRepositoryIpBans.test.ts b/fluxer_api/src/api/admin/tests/AdminRepositoryIpBans.test.ts index c3fc88448..ba7d665e4 100644 --- a/fluxer_api/src/api/admin/tests/AdminRepositoryIpBans.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminRepositoryIpBans.test.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {BannedIps} from '@app/api/Tables'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {upsertOne} from '../../database/CassandraQueryExecution'; -import {BannedIps} from '../../Tables'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {AdminRepository} from '../AdminRepository'; describe('AdminRepository IP ban canonicalization', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/admin/tests/AdminSearchEndpoints.test.ts b/fluxer_api/src/api/admin/tests/AdminSearchEndpoints.test.ts index 0879c43f6..285ec7dac 100644 --- a/fluxer_api/src/api/admin/tests/AdminSearchEndpoints.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminSearchEndpoints.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {createDmChannel, createFriendship, createGuild} from '@app/api/channel/tests/ChannelTestUtils'; +import {getUserActivityBuffer} from '@app/api/middleware/ServiceSingletons'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {createDmChannel, createFriendship, createGuild} from '../../channel/tests/ChannelTestUtils'; -import {getUserActivityBuffer} from '../../middleware/ServiceSingletons'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; async function setLastActiveIp(harness: ApiTestHarness, token: string, ip: string): Promise { await createBuilder(harness, `${token}`) diff --git a/fluxer_api/src/api/admin/tests/AdminSearchFieldCoverage.test.ts b/fluxer_api/src/api/admin/tests/AdminSearchFieldCoverage.test.ts index d7a0c1757..8139be16a 100644 --- a/fluxer_api/src/api/admin/tests/AdminSearchFieldCoverage.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminSearchFieldCoverage.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/channel/tests/ChannelTestUtils'; +import {getUserActivityBuffer} from '@app/api/middleware/ServiceSingletons'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import type {GuildAdminResponse} from '@fluxer/schema/src/domains/admin/AdminGuildSchemas'; import type {UserAdminResponse} from '@fluxer/schema/src/domains/admin/AdminUserSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../channel/tests/ChannelTestUtils'; -import {getUserActivityBuffer} from '../../middleware/ServiceSingletons'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; interface UserSearchResponse { users: Array; diff --git a/fluxer_api/src/api/admin/tests/AdminSetUserAclsValidation.test.ts b/fluxer_api/src/api/admin/tests/AdminSetUserAclsValidation.test.ts index 0f739f5af..11b2dac2d 100644 --- a/fluxer_api/src/api/admin/tests/AdminSetUserAclsValidation.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminSetUserAclsValidation.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface AdminUserMutationResponse { user: { diff --git a/fluxer_api/src/api/admin/tests/AdminSyntheticUserMutations.test.ts b/fluxer_api/src/api/admin/tests/AdminSyntheticUserMutations.test.ts index d1cf0b273..a3113b5e4 100644 --- a/fluxer_api/src/api/admin/tests/AdminSyntheticUserMutations.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminSyntheticUserMutations.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {DELETED_USER_ID} from '@fluxer/constants/src/UserConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../../user/repositories/UserRepository'; const SYNTHETIC_USER_IDS = ['0', String(DELETED_USER_ID)]; diff --git a/fluxer_api/src/api/admin/tests/AdminSyntheticUserServiceGuards.test.ts b/fluxer_api/src/api/admin/tests/AdminSyntheticUserServiceGuards.test.ts index 651e49a61..13cceb774 100644 --- a/fluxer_api/src/api/admin/tests/AdminSyntheticUserServiceGuards.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminSyntheticUserServiceGuards.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID, createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {UserMessageDeletionService} from '@app/api/channel/services/message/UserMessageDeletionService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {GuildMemberOperationsService} from '@app/api/guild/services/member/GuildMemberOperationsService'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; import {DELETED_USER_ID} from '@fluxer/constants/src/UserConstants'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import {describe, expect, test} from 'vitest'; -import {createGuildID, createUserID, type UserID} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import {UserMessageDeletionService} from '../../channel/services/message/UserMessageDeletionService'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import {GuildMemberOperationsService} from '../../guild/services/member/GuildMemberOperationsService'; -import type {IPurgeQueue} from '../../infrastructure/BunnyPurgeQueue'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {IStorageService} from '../../infrastructure/IStorageService'; const SYNTHETIC_USER_IDS: Array<[string, UserID]> = [ ['0', createUserID(0n)], diff --git a/fluxer_api/src/api/admin/tests/AdminTestUtils.ts b/fluxer_api/src/api/admin/tests/AdminTestUtils.ts index 5aabfb9d9..2582dacd4 100644 --- a/fluxer_api/src/api/admin/tests/AdminTestUtils.ts +++ b/fluxer_api/src/api/admin/tests/AdminTestUtils.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {TestAccount} from '../../auth/tests/AuthTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import type {TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; interface AdminApiKey { keyId: string; diff --git a/fluxer_api/src/api/admin/tests/AdminUserChangeLogAndFlags.test.ts b/fluxer_api/src/api/admin/tests/AdminUserChangeLogAndFlags.test.ts index 13ba4da26..5deb55e3d 100644 --- a/fluxer_api/src/api/admin/tests/AdminUserChangeLogAndFlags.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminUserChangeLogAndFlags.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_CREDENTIALS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {SuspiciousActivityFlags} from '@fluxer/constants/src/UserConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_CREDENTIALS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; interface ChangeLogResponse { entries: Array<{ diff --git a/fluxer_api/src/api/admin/tests/AdminUserDirectory.test.ts b/fluxer_api/src/api/admin/tests/AdminUserDirectory.test.ts index 71e8a7987..41873419f 100644 --- a/fluxer_api/src/api/admin/tests/AdminUserDirectory.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminUserDirectory.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {getUserActivityBuffer} from '@app/api/middleware/ServiceSingletons'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {getUserActivityBuffer} from '../../middleware/ServiceSingletons'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface AclListResponse { acls: Array; diff --git a/fluxer_api/src/api/admin/tests/AdminUserWebAuthnCredentialDelete.test.ts b/fluxer_api/src/api/admin/tests/AdminUserWebAuthnCredentialDelete.test.ts index c5360a4c7..9550c5f31 100644 --- a/fluxer_api/src/api/admin/tests/AdminUserWebAuthnCredentialDelete.test.ts +++ b/fluxer_api/src/api/admin/tests/AdminUserWebAuthnCredentialDelete.test.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; -import {UserAuthenticatorTypes} from '@fluxer/constants/src/UserConstants'; -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, createTotpSecret, generateTotpCode, setUserACLs} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount, createTotpSecret, generateTotpCode, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; import { createRegistrationResponse, createWebAuthnDevice, type WebAuthnCredentialMetadata, type WebAuthnRegistrationOptions, -} from '../../auth/tests/WebAuthnTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; +import {UserAuthenticatorTypes} from '@fluxer/constants/src/UserConstants'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; interface AdminLookupResponse { users: Array<{ diff --git a/fluxer_api/src/api/admin/tests/DiscoveryAdminOperations.test.ts b/fluxer_api/src/api/admin/tests/DiscoveryAdminOperations.test.ts index dc5641fc4..6ab5494c9 100644 --- a/fluxer_api/src/api/admin/tests/DiscoveryAdminOperations.test.ts +++ b/fluxer_api/src/api/admin/tests/DiscoveryAdminOperations.test.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuildID} from '@app/api/BrandedTypes'; +import {GuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import {createGuild, getGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_IDS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {DiscoveryApplicationStatus, DiscoveryCategories} from '@fluxer/constants/src/DiscoveryConstants'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; @@ -13,13 +20,6 @@ import type { import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; import type {z} from 'zod'; -import {createTestAccount, setUserACLs, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuildID} from '../../BrandedTypes'; -import {GuildDiscoveryRepository} from '../../guild/repositories/GuildDiscoveryRepository'; -import {createGuild, getGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_IDS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; async function setGuildMemberCount(harness: ApiTestHarness, guildId: string, memberCount: number): Promise { await createBuilder(harness, '') diff --git a/fluxer_api/src/api/admin/tests/GatewayAdminController.test.ts b/fluxer_api/src/api/admin/tests/GatewayAdminController.test.ts index 9b0950983..7c6ad396f 100644 --- a/fluxer_api/src/api/admin/tests/GatewayAdminController.test.ts +++ b/fluxer_api/src/api/admin/tests/GatewayAdminController.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {afterEach, beforeEach, describe, test} from 'vitest'; -import {createTestAccount, setUserACLs, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; async function createAdminWithAcls(harness: ApiTestHarness, acls: Array): Promise { const account = await createTestAccount(harness); diff --git a/fluxer_api/src/api/admin/tests/InstanceConfigPendingRegistrationApproval.test.ts b/fluxer_api/src/api/admin/tests/InstanceConfigPendingRegistrationApproval.test.ts index d05c90c60..8e71d98d0 100644 --- a/fluxer_api/src/api/admin/tests/InstanceConfigPendingRegistrationApproval.test.ts +++ b/fluxer_api/src/api/admin/tests/InstanceConfigPendingRegistrationApproval.test.ts @@ -1,14 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createTestAccount, + createUniqueEmail, + createUniqueUsername, + setUserACLs, +} from '@app/api/auth/tests/AuthTestUtils'; +import {setupTestGuildWithMembers} from '@app/api/guild/tests/GuildTestUtils'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount, createUniqueEmail, createUniqueUsername, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {setupTestGuildWithMembers} from '../../guild/tests/GuildTestUtils'; -import {getInstanceConfigRepository} from '../../middleware/ServiceSingletons'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; interface PendingRegistrationResponse { user_id: string; diff --git a/fluxer_api/src/api/admin/tests/InstanceConfigPendingRegistrationAudit.test.ts b/fluxer_api/src/api/admin/tests/InstanceConfigPendingRegistrationAudit.test.ts index b5b44d054..6a2c88493 100644 --- a/fluxer_api/src/api/admin/tests/InstanceConfigPendingRegistrationAudit.test.ts +++ b/fluxer_api/src/api/admin/tests/InstanceConfigPendingRegistrationAudit.test.ts @@ -1,12 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createTestAccount, + createUniqueEmail, + createUniqueUsername, + setUserACLs, +} from '@app/api/auth/tests/AuthTestUtils'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount, createUniqueEmail, createUniqueUsername, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {getInstanceConfigRepository} from '../../middleware/ServiceSingletons'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; interface PendingRegistrationResponse { user_id: string; diff --git a/fluxer_api/src/api/admin/tests/InstancePolicyDirectMessages.test.ts b/fluxer_api/src/api/admin/tests/InstancePolicyDirectMessages.test.ts index 407fb6845..c63e0592c 100644 --- a/fluxer_api/src/api/admin/tests/InstancePolicyDirectMessages.test.ts +++ b/fluxer_api/src/api/admin/tests/InstancePolicyDirectMessages.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {TestAccount} from '../../auth/tests/AuthTestUtils'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface InstanceConfigPolicyResponse { policy: { diff --git a/fluxer_api/src/api/admin/tests/SecurityAccessControl.test.ts b/fluxer_api/src/api/admin/tests/SecurityAccessControl.test.ts index c91b617e6..b41156bef 100644 --- a/fluxer_api/src/api/admin/tests/SecurityAccessControl.test.ts +++ b/fluxer_api/src/api/admin/tests/SecurityAccessControl.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; describe('Security Access Control', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/admin/tests/VoiceAdminController.test.ts b/fluxer_api/src/api/admin/tests/VoiceAdminController.test.ts index e4d9b0fed..660d8f137 100644 --- a/fluxer_api/src/api/admin/tests/VoiceAdminController.test.ts +++ b/fluxer_api/src/api/admin/tests/VoiceAdminController.test.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {VoiceRepository} from '@app/api/voice/VoiceRepository'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import type { @@ -14,11 +19,6 @@ import type { UpdateVoiceServerResponse, } from '@fluxer/schema/src/domains/admin/AdminVoiceSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {VoiceRepository} from '../../voice/VoiceRepository'; interface VoiceFixture { regionId: string; diff --git a/fluxer_api/src/api/app/APILifecycle.ts b/fluxer_api/src/api/app/APILifecycle.ts index 54b5142d5..7410f4051 100644 --- a/fluxer_api/src/api/app/APILifecycle.ts +++ b/fluxer_api/src/api/app/APILifecycle.ts @@ -1,19 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; -import {initCassandra, shutdownCassandra} from '@pkgs/cassandra/src/Client'; -import {ensureGeoipDatabaseOnStartup} from '@pkgs/geoip/src/GeoipStartup'; -import {JetStreamConnectionManager} from '@pkgs/nats/src/JetStreamConnectionManager'; -import {getDefaultPostgresClient, initPostgres, shutdownPostgres} from '@pkgs/postgres/src/Client'; -import type {APIConfig} from '../config/APIConfig'; -import {hasDatabaseQueryExecutor, setDatabaseQueryExecutor} from '../database/CassandraQueryExecution'; -import {ensurePostgresKvSchema, PostgresKvQueryExecutor} from '../database/PostgresKvQueryExecutor'; -import {GuildDataRepository} from '../guild/repositories/GuildDataRepository'; -import type {ILogger} from '../ILogger'; -import {JobLedgerRepository} from '../jobs/JobLedgerRepository'; -import {startAbuseReplicationSubscriber, stopAbuseReplicationSubscriber} from '../middleware/AbusiveIpAutoBanner'; -import {ipBanCache} from '../middleware/IpBanMiddleware'; -import {initializeServiceSingletons, shutdownReportService} from '../middleware/ServiceMiddleware'; +import {ensureDeletionQueueState} from '@app/api/app/DeletionQueueStartup'; +import type {APIConfig} from '@app/api/config/APIConfig'; +import {hasDatabaseQueryExecutor, setDatabaseQueryExecutor} from '@app/api/database/CassandraQueryExecution'; +import {ensurePostgresKvSchema, PostgresKvQueryExecutor} from '@app/api/database/PostgresKvQueryExecutor'; +import {GuildDataRepository} from '@app/api/guild/repositories/GuildDataRepository'; +import type {ILogger} from '@app/api/ILogger'; +import {JobLedgerRepository} from '@app/api/jobs/JobLedgerRepository'; +import {startAbuseReplicationSubscriber, stopAbuseReplicationSubscriber} from '@app/api/middleware/AbusiveIpAutoBanner'; +import {ipBanCache} from '@app/api/middleware/IpBanMiddleware'; +import {initializeServiceSingletons, shutdownReportService} from '@app/api/middleware/ServiceMiddleware'; import { closeOwnedKVClient, ensureVoiceResourcesInitialized, @@ -21,7 +18,7 @@ import { getSnowflakeService, setInjectedWorkerService, shutdownVoiceResources, -} from '../middleware/ServiceRegistry'; +} from '@app/api/middleware/ServiceRegistry'; import { getCacheService, getInstanceConfigRepository, @@ -30,16 +27,19 @@ import { getUserRepository, shutdownInstanceConfigRepository, shutdownServiceSingletons, -} from '../middleware/ServiceSingletons'; -import {torExitListCache} from '../middleware/TorExitListCache'; -import {ensureApnsSigningKey} from '../push/ApnsPushService'; -import {initializeSearch, shutdownSearch} from '../SearchFactory'; -import {warmupAdminSearchIndexes} from '../search/SearchWarmup'; -import {VisionarySlotInitializer} from '../stripe/VisionarySlotInitializer'; -import {VoiceDataInitializer} from '../voice/VoiceDataInitializer'; -import {JetStreamWorkerQueue} from '../worker/JetStreamWorkerQueue'; -import {WorkerService} from '../worker/WorkerService'; -import {ensureDeletionQueueState} from './DeletionQueueStartup'; +} from '@app/api/middleware/ServiceSingletons'; +import {torExitListCache} from '@app/api/middleware/TorExitListCache'; +import {ensureApnsSigningKey} from '@app/api/push/ApnsPushService'; +import {initializeSearch, shutdownSearch} from '@app/api/SearchFactory'; +import {warmupAdminSearchIndexes} from '@app/api/search/SearchWarmup'; +import {VisionarySlotInitializer} from '@app/api/stripe/VisionarySlotInitializer'; +import {VoiceDataInitializer} from '@app/api/voice/VoiceDataInitializer'; +import {JetStreamWorkerQueue} from '@app/api/worker/JetStreamWorkerQueue'; +import {WorkerService} from '@app/api/worker/WorkerService'; +import {initCassandra, shutdownCassandra} from '@pkgs/cassandra/src/Client'; +import {ensureGeoipDatabaseOnStartup} from '@pkgs/geoip/src/GeoipStartup'; +import {JetStreamConnectionManager} from '@pkgs/nats/src/JetStreamConnectionManager'; +import {getDefaultPostgresClient, initPostgres, shutdownPostgres} from '@pkgs/postgres/src/Client'; let jsConnectionManager: JetStreamConnectionManager | null = null; @@ -139,21 +139,21 @@ export function createInitializer(config: APIConfig, logger: ILogger): () => Pro torExitListCache.setKvClient(kvClient); await torExitListCache.initialize(); logger.info('Tor exit list cache initialized'); - const {urlBlocklistCache} = await import('../middleware/UrlBlocklistCache'); + const {urlBlocklistCache} = await import('@app/api/middleware/UrlBlocklistCache'); urlBlocklistCache.setRefreshSubscriber(kvClient); - const {getStorageService} = await import('../middleware/ServiceSingletons'); + const {getStorageService} = await import('@app/api/middleware/ServiceSingletons'); urlBlocklistCache.setStorageService(getStorageService()); await initializeRefreshCache(urlBlocklistCache, 'URL blocklist cache', logger); - const {fileShaCache} = await import('../middleware/FileShaCache'); + const {fileShaCache} = await import('@app/api/middleware/FileShaCache'); fileShaCache.setRefreshSubscriber(kvClient); await initializeRefreshCache(fileShaCache, 'File SHA blocklist cache', logger); - const {phraseBlocklistCache} = await import('../middleware/PhraseBlocklistCache'); + const {phraseBlocklistCache} = await import('@app/api/middleware/PhraseBlocklistCache'); phraseBlocklistCache.setRefreshSubscriber(kvClient); await initializeRefreshCache(phraseBlocklistCache, 'Phrase blocklist cache', logger); - const {bannedAvatarHashCache} = await import('../middleware/BannedAvatarHashCache'); + const {bannedAvatarHashCache} = await import('@app/api/middleware/BannedAvatarHashCache'); bannedAvatarHashCache.setRefreshSubscriber(kvClient); await initializeRefreshCache(bannedAvatarHashCache, 'Banned avatar hash cache', logger); - const {profileSubstringBlocklistCache} = await import('../middleware/ProfileSubstringBlocklistCache'); + const {profileSubstringBlocklistCache} = await import('@app/api/middleware/ProfileSubstringBlocklistCache'); profileSubstringBlocklistCache.setRefreshSubscriber(kvClient); await initializeRefreshCache(profileSubstringBlocklistCache, 'Profile substring blocklist cache', logger); await initializeServiceSingletons(); diff --git a/fluxer_api/src/api/app/ControllerRegistry.ts b/fluxer_api/src/api/app/ControllerRegistry.ts index 5d945d66c..868a841b3 100644 --- a/fluxer_api/src/api/app/ControllerRegistry.ts +++ b/fluxer_api/src/api/app/ControllerRegistry.ts @@ -1,43 +1,43 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {registerAdminControllers} from '../admin/controllers/index'; -import {AuthController} from '../auth/AuthController'; -import {BlueskyOAuthController} from '../bluesky/BlueskyOAuthController'; -import {Config} from '../Config'; -import {ChannelController} from '../channel/ChannelController'; -import type {APIConfig} from '../config/APIConfig'; -import {ConnectionController} from '../connection/ConnectionController'; -import {DonationController} from '../donation/DonationController'; -import {DownloadController} from '../download/DownloadController'; -import {ExperimentController} from '../experiment/ExperimentController'; -import {FavoriteGifController} from '../favorite_gif/FavoriteGifController'; -import {FavoriteMemeController} from '../favorite_meme/FavoriteMemeController'; -import {GatewayController} from '../gateway/GatewayController'; -import {GeolocationController} from '../geolocation/GeolocationController'; -import {GifController} from '../gif/GifController'; -import {GuildController} from '../guild/GuildController'; -import {InstanceController} from '../instance/InstanceController'; -import {InviteController} from '../invite/InviteController'; -import {Logger} from '../Logger'; -import {getInboundSmsChallengeServiceInstance, getUserRepositoryInstance} from '../middleware/ServiceMiddleware'; -import {getGatewayService} from '../middleware/ServiceRegistry'; -import {getCacheService} from '../middleware/ServiceSingletons'; -import {OAuth2ApplicationsController} from '../oauth/OAuth2ApplicationsController'; -import {OAuth2Controller} from '../oauth/OAuth2Controller'; -import {OpenAPIController} from '../openapi/OpenAPIController'; -import {PremiumController} from '../premium/PremiumController'; -import {ReadStateController} from '../read_state/ReadStateController'; -import {ReportController} from '../report/ReportController'; -import {installTwilioInboundSmsWebhook} from '../risk/TwilioInboundSmsWebhook'; -import {InternalRpcController} from '../rpc/InternalRpcController'; -import {SearchController} from '../search/controllers/SearchController'; -import {StripeController} from '../stripe/StripeController'; -import {TestHarnessController} from '../test/TestHarnessController'; -import {ThemeController} from '../theme/ThemeController'; -import type {HonoApp} from '../types/HonoEnv'; -import {UnfurlController} from '../unfurl/UnfurlController'; -import {UserController} from '../user/controllers/UserController'; -import {WebhookController} from '../webhook/WebhookController'; +import {registerAdminControllers} from '@app/api/admin/controllers/index'; +import {AuthController} from '@app/api/auth/AuthController'; +import {BlueskyOAuthController} from '@app/api/bluesky/BlueskyOAuthController'; +import {Config} from '@app/api/Config'; +import {ChannelController} from '@app/api/channel/ChannelController'; +import type {APIConfig} from '@app/api/config/APIConfig'; +import {ConnectionController} from '@app/api/connection/ConnectionController'; +import {DonationController} from '@app/api/donation/DonationController'; +import {DownloadController} from '@app/api/download/DownloadController'; +import {ExperimentController} from '@app/api/experiment/ExperimentController'; +import {FavoriteGifController} from '@app/api/favorite_gif/FavoriteGifController'; +import {FavoriteMemeController} from '@app/api/favorite_meme/FavoriteMemeController'; +import {GatewayController} from '@app/api/gateway/GatewayController'; +import {GeolocationController} from '@app/api/geolocation/GeolocationController'; +import {GifController} from '@app/api/gif/GifController'; +import {GuildController} from '@app/api/guild/GuildController'; +import {InstanceController} from '@app/api/instance/InstanceController'; +import {InviteController} from '@app/api/invite/InviteController'; +import {Logger} from '@app/api/Logger'; +import {getInboundSmsChallengeServiceInstance, getUserRepositoryInstance} from '@app/api/middleware/ServiceMiddleware'; +import {getGatewayService} from '@app/api/middleware/ServiceRegistry'; +import {getCacheService} from '@app/api/middleware/ServiceSingletons'; +import {OAuth2ApplicationsController} from '@app/api/oauth/OAuth2ApplicationsController'; +import {OAuth2Controller} from '@app/api/oauth/OAuth2Controller'; +import {OpenAPIController} from '@app/api/openapi/OpenAPIController'; +import {PremiumController} from '@app/api/premium/PremiumController'; +import {ReadStateController} from '@app/api/read_state/ReadStateController'; +import {ReportController} from '@app/api/report/ReportController'; +import {installTwilioInboundSmsWebhook} from '@app/api/risk/TwilioInboundSmsWebhook'; +import {InternalRpcController} from '@app/api/rpc/InternalRpcController'; +import {SearchController} from '@app/api/search/controllers/SearchController'; +import {StripeController} from '@app/api/stripe/StripeController'; +import {TestHarnessController} from '@app/api/test/TestHarnessController'; +import {ThemeController} from '@app/api/theme/ThemeController'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {UnfurlController} from '@app/api/unfurl/UnfurlController'; +import {UserController} from '@app/api/user/controllers/UserController'; +import {WebhookController} from '@app/api/webhook/WebhookController'; export function registerControllers(routes: HonoApp, config: APIConfig): void { InternalRpcController(routes); diff --git a/fluxer_api/src/api/app/DeletionQueueStartup.ts b/fluxer_api/src/api/app/DeletionQueueStartup.ts index 9bf65fbf0..e3be2b357 100644 --- a/fluxer_api/src/api/app/DeletionQueueStartup.ts +++ b/fluxer_api/src/api/app/DeletionQueueStartup.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ILogger} from '../ILogger'; -import type {KVAccountDeletionQueueService} from '../infrastructure/KVAccountDeletionQueueService'; +import type {ILogger} from '@app/api/ILogger'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; export async function ensureDeletionQueueState( deletionQueue: KVAccountDeletionQueueService, diff --git a/fluxer_api/src/api/app/MiddlewarePipeline.ts b/fluxer_api/src/api/app/MiddlewarePipeline.ts index 50adc5967..03bfba0fa 100644 --- a/fluxer_api/src/api/app/MiddlewarePipeline.ts +++ b/fluxer_api/src/api/app/MiddlewarePipeline.ts @@ -1,26 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ILogger} from '@app/api/ILogger'; +import {ClientErrorAbuseSignalMiddleware} from '@app/api/middleware/AbusiveIpAutoBanner'; +import {AuditLogMiddleware} from '@app/api/middleware/AuditLogMiddleware'; +import {ConcurrencyLimitMiddleware} from '@app/api/middleware/ConcurrencyLimitMiddleware'; +import ContentFilterMiddleware from '@app/api/middleware/ContentFilterMiddleware'; +import {GuildAvailabilityMiddleware} from '@app/api/middleware/GuildAvailabilityMiddleware'; +import {IpBanMiddleware} from '@app/api/middleware/IpBanMiddleware'; +import {LocaleMiddleware} from '@app/api/middleware/LocaleMiddleware'; +import {RequestCacheMiddleware} from '@app/api/middleware/RequestCacheMiddleware'; +import {RequireClientIpMiddleware} from '@app/api/middleware/RequireClientIpMiddleware'; +import {ServiceMiddleware} from '@app/api/middleware/ServiceMiddleware'; +import {TorExitMiddleware} from '@app/api/middleware/TorExitMiddleware'; +import {TrustedClientIpHeaderMiddleware} from '@app/api/middleware/TrustedClientIpHeaderMiddleware'; +import {UserMiddleware} from '@app/api/middleware/UserMiddleware'; +import type {HonoApp} from '@app/api/types/HonoEnv'; import {Headers as HttpHeaders} from '@fluxer/constants/src/Headers'; import {InvalidApiOriginError} from '@fluxer/errors/src/domains/core/InvalidApiOriginError'; import {cors} from '@fluxer/hono/src/middleware/Cors'; import {applyMiddlewareStack} from '@fluxer/hono/src/middleware/MiddlewareStack'; import {createInfoRequestLogger, requestLogger} from '@fluxer/hono/src/middleware/RequestLogger'; import {resolveClientIpHeaderName} from '@fluxer/ip_utils/src/ClientIp'; -import type {ILogger} from '../ILogger'; -import {ClientErrorAbuseSignalMiddleware} from '../middleware/AbusiveIpAutoBanner'; -import {AuditLogMiddleware} from '../middleware/AuditLogMiddleware'; -import {ConcurrencyLimitMiddleware} from '../middleware/ConcurrencyLimitMiddleware'; -import ContentFilterMiddleware from '../middleware/ContentFilterMiddleware'; -import {GuildAvailabilityMiddleware} from '../middleware/GuildAvailabilityMiddleware'; -import {IpBanMiddleware} from '../middleware/IpBanMiddleware'; -import {LocaleMiddleware} from '../middleware/LocaleMiddleware'; -import {RequestCacheMiddleware} from '../middleware/RequestCacheMiddleware'; -import {RequireClientIpMiddleware} from '../middleware/RequireClientIpMiddleware'; -import {ServiceMiddleware} from '../middleware/ServiceMiddleware'; -import {TorExitMiddleware} from '../middleware/TorExitMiddleware'; -import {TrustedClientIpHeaderMiddleware} from '../middleware/TrustedClientIpHeaderMiddleware'; -import {UserMiddleware} from '../middleware/UserMiddleware'; -import type {HonoApp} from '../types/HonoEnv'; interface MiddlewarePipelineOptions { logger: ILogger; diff --git a/fluxer_api/src/api/app/tests/DeletionQueueStartup.test.ts b/fluxer_api/src/api/app/tests/DeletionQueueStartup.test.ts index 0f0a5993f..8709b7b7d 100644 --- a/fluxer_api/src/api/app/tests/DeletionQueueStartup.test.ts +++ b/fluxer_api/src/api/app/tests/DeletionQueueStartup.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {ensureDeletionQueueState} from '@app/api/app/DeletionQueueStartup'; +import {createUserID} from '@app/api/BrandedTypes'; +import {EMPTY_USER_ROW} from '@app/api/database/types/UserTypes'; +import type {ILogger} from '@app/api/ILogger'; +import {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import {User} from '@app/api/models/User'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; import {describe, expect, it} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import {EMPTY_USER_ROW} from '../../database/types/UserTypes'; -import type {ILogger} from '../../ILogger'; -import {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import {User} from '../../models/User'; -import {MockKVProvider} from '../../test/mocks/MockKVProvider'; -import {NoopLogger} from '../../test/mocks/NoopLogger'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import {ensureDeletionQueueState} from '../DeletionQueueStartup'; const WORKER_PAGE_COUNT = 2; diff --git a/fluxer_api/src/api/archive/ArchiveTask.ts b/fluxer_api/src/api/archive/ArchiveTask.ts index 59c03d8ee..0e8981909 100644 --- a/fluxer_api/src/api/archive/ArchiveTask.ts +++ b/fluxer_api/src/api/archive/ArchiveTask.ts @@ -1,7 +1,7 @@ +import type {AdminArchive} from '@app/api/admin/models/AdminArchiveModel'; +import {ArchiveAttemptSupersededError} from '@app/api/archive/ArchiveAttemptSupersededError'; +import type {UserHarvest} from '@app/api/user/UserHarvestModel'; import type {WorkerTaskAttempt, WorkerTaskHandler, WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; -import type {AdminArchive} from '../admin/models/AdminArchiveModel'; -import type {UserHarvest} from '../user/UserHarvestModel'; -import {ArchiveAttemptSupersededError} from './ArchiveAttemptSupersededError'; export class ArchiveTaskDeferredError extends Error { constructor(cause: unknown) { diff --git a/fluxer_api/src/api/attachment/AttachmentDecayRepository.ts b/fluxer_api/src/api/attachment/AttachmentDecayRepository.ts index f5a929b46..8bab11284 100644 --- a/fluxer_api/src/api/attachment/AttachmentDecayRepository.ts +++ b/fluxer_api/src/api/attachment/AttachmentDecayRepository.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID, ChannelID, MessageID} from '../BrandedTypes'; +import type {AttachmentID, ChannelID, MessageID} from '@app/api/BrandedTypes'; import { BatchBuilder, deleteOneOrMany, fetchMany, fetchManyInChunks, fetchOne, -} from '../database/CassandraQueryExecution'; -import {AttachmentDecayByExpiry, AttachmentDecayById} from '../Tables'; -import type {AttachmentDecayRow} from '../types/AttachmentDecayTypes'; +} from '@app/api/database/CassandraQueryExecution'; +import {AttachmentDecayByExpiry, AttachmentDecayById} from '@app/api/Tables'; +import type {AttachmentDecayRow} from '@app/api/types/AttachmentDecayTypes'; interface AttachmentDecayExpiryRow { expiry_bucket: number; diff --git a/fluxer_api/src/api/attachment/AttachmentDecayService.ts b/fluxer_api/src/api/attachment/AttachmentDecayService.ts index 970195c24..b1d990971 100644 --- a/fluxer_api/src/api/attachment/AttachmentDecayService.ts +++ b/fluxer_api/src/api/attachment/AttachmentDecayService.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ms} from 'itty-time'; -import type {AttachmentID, ChannelID, MessageID} from '../BrandedTypes'; -import type {InstanceAttachmentDecayEffectiveConfig} from '../instance/InstanceConfigRepository'; -import type {AttachmentDecayRow} from '../types/AttachmentDecayTypes'; +import {AttachmentDecayRepository} from '@app/api/attachment/AttachmentDecayRepository'; +import type {AttachmentID, ChannelID, MessageID} from '@app/api/BrandedTypes'; +import type {InstanceAttachmentDecayEffectiveConfig} from '@app/api/instance/InstanceConfigRepository'; +import type {AttachmentDecayRow} from '@app/api/types/AttachmentDecayTypes'; import { type AttachmentDecayRules, computeCost, @@ -12,8 +12,8 @@ import { extendExpiry, getExpiryBucket, maybeRenewExpiry, -} from '../utils/AttachmentDecay'; -import {AttachmentDecayRepository} from './AttachmentDecayRepository'; +} from '@app/api/utils/AttachmentDecay'; +import {ms} from 'itty-time'; interface AttachmentDecayPayload { attachmentId: AttachmentID; @@ -28,7 +28,7 @@ interface AttachmentDecayPayload { type AttachmentDecayConfigResolver = () => Promise; async function resolveDefaultAttachmentDecayConfig(): Promise { - const {getInstanceConfigRepository} = await import('../middleware/ServiceSingletons'); + const {getInstanceConfigRepository} = await import('@app/api/middleware/ServiceSingletons'); return getInstanceConfigRepository().getEffectiveAttachmentDecayConfig(); } diff --git a/fluxer_api/src/api/auth/AuthController.ts b/fluxer_api/src/api/auth/AuthController.ts index 2ffb01a57..9cffc24ba 100644 --- a/fluxer_api/src/api/auth/AuthController.ts +++ b/fluxer_api/src/api/auth/AuthController.ts @@ -1,5 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireSudoMode} from '@app/api/auth/services/SudoVerificationService'; +import {Config} from '@app/api/Config'; +import {DefaultUserOnly, LoginRequiredAllowSuspicious} from '@app/api/middleware/AuthMiddleware'; +import {CaptchaMiddleware} from '@app/api/middleware/CaptchaMiddleware'; +import {LocalAuthMiddleware} from '@app/api/middleware/LocalAuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {SudoModeMiddleware} from '@app/api/middleware/SudoModeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {requireClientIp} from '@fluxer/ip_utils/src/ClientIp'; import { AuthLoginResponse, @@ -38,17 +49,6 @@ import { WebAuthnAuthenticationOptionsResponse, WebAuthnMfaRequest, } from '@fluxer/schema/src/domains/auth/AuthSchemas'; -import {Config} from '../Config'; -import {DefaultUserOnly, LoginRequiredAllowSuspicious} from '../middleware/AuthMiddleware'; -import {CaptchaMiddleware} from '../middleware/CaptchaMiddleware'; -import {LocalAuthMiddleware} from '../middleware/LocalAuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {SudoModeMiddleware} from '../middleware/SudoModeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; -import {requireSudoMode} from './services/SudoVerificationService'; export function AuthController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/auth/AuthEmail.ts b/fluxer_api/src/api/auth/AuthEmail.ts index eb7996109..ac81a89c0 100644 --- a/fluxer_api/src/api/auth/AuthEmail.ts +++ b/fluxer_api/src/api/auth/AuthEmail.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {createEmailVerificationToken} from '@app/api/BrandedTypes'; +import type {User} from '@app/api/models/User'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import * as RandomUtils from '@app/api/utils/RandomUtils'; import {SuspiciousActivityFlags, UserFlags} from '@fluxer/constants/src/UserConstants'; import {BotUserAuthEndpointAccessDeniedError} from '@fluxer/errors/src/domains/auth/BotUserAuthEndpointAccessDeniedError'; import {RateLimitError} from '@fluxer/errors/src/domains/core/RateLimitError'; import type {VerifyEmailRequest} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {ms} from 'itty-time'; -import type {ApiContext} from '../ApiContext'; -import {createEmailVerificationToken} from '../BrandedTypes'; -import type {User} from '../models/User'; -import {mapUserToPrivateResponse} from '../user/UserMappers'; -import * as RandomUtils from '../utils/RandomUtils'; export const EMAIL_CLEARABLE_SUSPICIOUS_ACTIVITY_FLAGS = SuspiciousActivityFlags.REQUIRE_VERIFIED_EMAIL | diff --git a/fluxer_api/src/api/auth/AuthEmailRevert.ts b/fluxer_api/src/api/auth/AuthEmailRevert.ts index d081f3ae7..1982df0f2 100644 --- a/fluxer_api/src/api/auth/AuthEmailRevert.ts +++ b/fluxer_api/src/api/auth/AuthEmailRevert.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthPassword from '@app/api/auth/AuthPassword'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import * as AuthUtility from '@app/api/auth/AuthUtility'; +import {createEmailRevertToken} from '@app/api/BrandedTypes'; +import type {User} from '@app/api/models/User'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {requireClientIp} from '@fluxer/ip_utils/src/ClientIp'; -import type {ApiContext} from '../ApiContext'; -import {createEmailRevertToken} from '../BrandedTypes'; -import type {User} from '../models/User'; -import {mapUserToPrivateResponse} from '../user/UserMappers'; -import * as AuthPassword from './AuthPassword'; -import * as AuthSession from './AuthSession'; -import * as AuthUtility from './AuthUtility'; interface IssueEmailRevertTokenParams { user: User; diff --git a/fluxer_api/src/api/auth/AuthLogin.ts b/fluxer_api/src/api/auth/AuthLogin.ts index 9a9090880..6a7d6593e 100644 --- a/fluxer_api/src/api/auth/AuthLogin.ts +++ b/fluxer_api/src/api/auth/AuthLogin.ts @@ -1,5 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthMfa from '@app/api/auth/AuthMfa'; +import * as AuthPassword from '@app/api/auth/AuthPassword'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import * as AuthUtility from '@app/api/auth/AuthUtility'; +import { + createInviteCode, + createIpAuthorizationTicket, + createIpAuthorizationToken, + createMfaTicket, + createUserID, +} from '@app/api/BrandedTypes'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import { + REGISTRATION_PENDING_APPROVAL_TRAIT, + REGISTRATION_REJECTED_TRAIT, +} from '@app/api/instance/InstanceConfigRepository'; +import type {InviteService} from '@app/api/invite/InviteService'; +import {Logger} from '@app/api/Logger'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import type {User} from '@app/api/models/User'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; +import {createRateLimitError} from '@app/api/utils/RateLimitUtils'; import {UserAuthenticatorTypes, UserFlags} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {IpAuthorizationRequiredError} from '@fluxer/errors/src/domains/auth/IpAuthorizationRequiredError'; @@ -15,27 +39,6 @@ import type {LoginRequest} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {formatGeoipLocation, UNKNOWN_LOCATION} from '@pkgs/geoip/src/GeoipLookup'; import type {AuthenticationResponseJSON} from '@simplewebauthn/server'; import {ms, seconds} from 'itty-time'; -import type {ApiContext} from '../ApiContext'; -import { - createInviteCode, - createIpAuthorizationTicket, - createIpAuthorizationToken, - createMfaTicket, - createUserID, -} from '../BrandedTypes'; -import type {KVAccountDeletionQueueService} from '../infrastructure/KVAccountDeletionQueueService'; -import {REGISTRATION_PENDING_APPROVAL_TRAIT, REGISTRATION_REJECTED_TRAIT} from '../instance/InstanceConfigRepository'; -import type {InviteService} from '../invite/InviteService'; -import {Logger} from '../Logger'; -import {createRequestCache} from '../middleware/RequestCacheMiddleware'; -import {getInstanceConfigRepository} from '../middleware/ServiceSingletons'; -import type {User} from '../models/User'; -import {lookupGeoip} from '../utils/IpUtils'; -import {createRateLimitError} from '../utils/RateLimitUtils'; -import * as AuthMfa from './AuthMfa'; -import * as AuthPassword from './AuthPassword'; -import * as AuthSession from './AuthSession'; -import * as AuthUtility from './AuthUtility'; const DUMMY_ARGON2_HASH = '$argon2id$v=19$m=65536,t=3,p=4$fT6tGpAyxFiz+n1RbkRqWQ$v05UT17QGeqhsgRjcVjIWcGw6gUDYeCcAA8FiZ63MtA'; diff --git a/fluxer_api/src/api/auth/AuthMfa.ts b/fluxer_api/src/api/auth/AuthMfa.ts index 0c29d9437..8bf355a19 100644 --- a/fluxer_api/src/api/auth/AuthMfa.ts +++ b/fluxer_api/src/api/auth/AuthMfa.ts @@ -1,6 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {timingSafeEqual} from 'node:crypto'; +import type {ApiContext} from '@app/api/ApiContext'; +import {deriveSudoMethods, userHasMfa} from '@app/api/auth/services/SudoMethods'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import type {WebAuthnCredential} from '@app/api/models/WebAuthnCredential'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import {TotpGenerator} from '@app/api/utils/TotpGenerator'; import {UserAuthenticatorTypes} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InvalidWebAuthnAuthenticationCounterError} from '@fluxer/errors/src/domains/auth/InvalidWebAuthnAuthenticationCounterError'; @@ -22,14 +30,6 @@ import { verifyRegistrationResponse, } from '@simplewebauthn/server'; import {ms, seconds} from 'itty-time'; -import type {ApiContext} from '../ApiContext'; -import {createUserID, type UserID} from '../BrandedTypes'; -import {Logger} from '../Logger'; -import type {User} from '../models/User'; -import type {WebAuthnCredential} from '../models/WebAuthnCredential'; -import {mapUserToPrivateResponse} from '../user/UserMappers'; -import {TotpGenerator} from '../utils/TotpGenerator'; -import {deriveSudoMethods, userHasMfa} from './services/SudoMethods'; type WebAuthnChallengeContext = 'registration' | 'discoverable' | 'mfa' | 'sudo'; diff --git a/fluxer_api/src/api/auth/AuthModel.ts b/fluxer_api/src/api/auth/AuthModel.ts index dd1976d33..42f8dba1c 100644 --- a/fluxer_api/src/api/auth/AuthModel.ts +++ b/fluxer_api/src/api/auth/AuthModel.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import type {AuthSession} from '@app/api/models/AuthSession'; +import {getLocationLabelFromIp} from '@app/api/utils/IpUtils'; +import {resolveSessionClientInfo} from '@app/api/utils/SessionClientIdentity'; import {maskIpForDisplay} from '@fluxer/ip_utils/src/IpAddress'; import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {uint8ArrayToBase64} from 'uint8array-extras'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import {getInstanceConfigRepository} from '../middleware/ServiceSingletons'; -import type {AuthSession} from '../models/AuthSession'; -import {getLocationLabelFromIp} from '../utils/IpUtils'; -import {resolveSessionClientInfo} from '../utils/SessionClientIdentity'; const DEV_FALLBACK_AUTH_SESSION_LOCATION = 'Stockholm, Stockholm County, Sweden'; diff --git a/fluxer_api/src/api/auth/AuthPassword.ts b/fluxer_api/src/api/auth/AuthPassword.ts index 48bfc1a62..d94a40c12 100644 --- a/fluxer_api/src/api/auth/AuthPassword.ts +++ b/fluxer_api/src/api/auth/AuthPassword.ts @@ -1,6 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import * as AuthUtility from '@app/api/auth/AuthUtility'; +import {createMfaTicket, createPasswordResetToken} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import {EXTERNAL_RESPONSE_LIMITS} from '@app/api/utils/ExternalResponseLimits'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; +import {hashPassword as hashPasswordUtil, verifyPassword as verifyPasswordUtil} from '@app/api/utils/PasswordUtils'; +import {createRateLimitError} from '@app/api/utils/RateLimitUtils'; import {FLUXER_USER_AGENT} from '@fluxer/constants/src/Core'; import {UserAuthenticatorTypes, UserFlags} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; @@ -9,16 +19,6 @@ import {requireClientIp} from '@fluxer/ip_utils/src/ClientIp'; import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress'; import type {ForgotPasswordRequest, ResetPasswordRequest} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {ms, seconds} from 'itty-time'; -import type {ApiContext} from '../ApiContext'; -import {createMfaTicket, createPasswordResetToken} from '../BrandedTypes'; -import {Logger} from '../Logger'; -import type {User} from '../models/User'; -import {EXTERNAL_RESPONSE_LIMITS} from '../utils/ExternalResponseLimits'; -import * as FetchUtils from '../utils/FetchUtils'; -import {hashPassword as hashPasswordUtil, verifyPassword as verifyPasswordUtil} from '../utils/PasswordUtils'; -import {createRateLimitError} from '../utils/RateLimitUtils'; -import * as AuthSession from './AuthSession'; -import * as AuthUtility from './AuthUtility'; const PWNED_PASSWORDS_TIMEOUT_MS = ms('5 seconds'); const PWNED_PASSWORD_CACHE_MAX_PREFIXES = 128; diff --git a/fluxer_api/src/api/auth/AuthPhone.ts b/fluxer_api/src/api/auth/AuthPhone.ts index 71c4ddf58..be36171e9 100644 --- a/fluxer_api/src/api/auth/AuthPhone.ts +++ b/fluxer_api/src/api/auth/AuthPhone.ts @@ -1,5 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {phonePrefixBanCache} from '@app/api/auth/PhonePrefixBanCache'; +import {requiresInboundPhoneVerification} from '@app/api/auth/PhoneVerificationPrefixPolicy'; +import {PhoneVerificationReuseStore} from '@app/api/auth/PhoneVerificationReuseStore'; +import type {IssuedChallenge} from '@app/api/auth/services/InboundSmsChallengeService'; +import type {PhoneAttemptInboundReason, PhoneAttemptRejectReason} from '@app/api/auth/services/PhoneLookupRepository'; +import type {UserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import {mapUserToPartialResponse, mapUserToPrivateResponse} from '@app/api/user/UserMappers'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {PHONE_ADD_CLEARABLE_FLAGS, UserFlags} from '@fluxer/constants/src/UserConstants'; import {BotUserAuthEndpointAccessDeniedError} from '@fluxer/errors/src/domains/auth/BotUserAuthEndpointAccessDeniedError'; @@ -29,16 +39,6 @@ import { } from '@pkgs/sms/src/PhoneLookupTypes'; import {SmsVerificationStartError, TwilioVerificationRateLimitError} from '@pkgs/sms/src/providers/TwilioSmsProvider'; import type {SmsVerificationStartOptions} from '@pkgs/sms/src/SmsVerificationTypes'; -import type {ApiContext} from '../ApiContext'; -import type {UserID} from '../BrandedTypes'; -import {Logger} from '../Logger'; -import type {User} from '../models/User'; -import {mapUserToPartialResponse, mapUserToPrivateResponse} from '../user/UserMappers'; -import {phonePrefixBanCache} from './PhonePrefixBanCache'; -import {requiresInboundPhoneVerification} from './PhoneVerificationPrefixPolicy'; -import {PhoneVerificationReuseStore} from './PhoneVerificationReuseStore'; -import type {IssuedChallenge} from './services/InboundSmsChallengeService'; -import type {PhoneAttemptInboundReason, PhoneAttemptRejectReason} from './services/PhoneLookupRepository'; const MINUTE_MS = 60_000; const HOUR_MS = 60 * MINUTE_MS; diff --git a/fluxer_api/src/api/auth/AuthRegistration.ts b/fluxer_api/src/api/auth/AuthRegistration.ts index a59ce1b21..24c56cd38 100644 --- a/fluxer_api/src/api/auth/AuthRegistration.ts +++ b/fluxer_api/src/api/auth/AuthRegistration.ts @@ -1,5 +1,43 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthPassword from '@app/api/auth/AuthPassword'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import * as AuthUtility from '@app/api/auth/AuthUtility'; +import type {IRegistrationRiskEvaluator} from '@app/api/auth/services/IRegistrationRiskEvaluator'; +import {createEmailVerificationToken, createInviteCode, createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {APIConfig} from '@app/api/config/APIConfig'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {KVActivityTracker} from '@app/api/infrastructure/KVActivityTracker'; +import { + type InstanceConfigRepository, + type InstanceRegistrationUrl, + REGISTRATION_PENDING_APPROVAL_TRAIT, +} from '@app/api/instance/InstanceConfigRepository'; +import type {SingleCommunityService} from '@app/api/instance/SingleCommunityService'; +import type {InviteService} from '@app/api/invite/InviteService'; +import {Logger} from '@app/api/Logger'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; +import {UserSettings} from '@app/api/models/UserSettings'; +import {countryRequiresInboundPhoneVerification} from '@app/api/risk/AbusePolicy'; +import { + type IAccountPolicyEvaluator, + isAssessmentThresholdAuditEvent, + normalizePolicyContactDomain, +} from '@app/api/risk/AccountPolicyEvaluator'; +import type {IRegistrationEventsRepository} from '@app/api/risk/adapters/VelocityAdapter'; +import {deferPhoneFlagsUntilCommunityJoin} from '@app/api/risk/DeferredPhoneGate'; +import type {IRiskHistoryRepository} from '@app/api/risk/HistoricalOutcomeRepository'; +import type {IRiskAssessmentRepository} from '@app/api/risk/RiskAssessmentRepository'; +import {deriveLatestRiskContext} from '@app/api/risk/RiskHistoryContext'; +import * as AgeUtils from '@app/api/utils/AgeUtils'; +import {extractEmailDomain} from '@app/api/utils/EmailDomainUtils'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; +import {createRateLimitError} from '@app/api/utils/RateLimitUtils'; +import {generateRandomUsername} from '@app/api/utils/UsernameGenerator'; +import {deriveUsernameFromDisplayName} from '@app/api/utils/UsernameSuggestionUtils'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {ProfileFieldPrivacyFlags, UserFlags} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; @@ -13,44 +51,6 @@ import type {RegisterRequest} from '@fluxer/schema/src/domains/auth/AuthSchemas' import {parseAcceptLanguage} from '@pkgs/locale/src/LocaleService'; import {types} from 'cassandra-driver'; import {ms} from 'itty-time'; -import type {ApiContext} from '../ApiContext'; -import {createEmailVerificationToken, createInviteCode, createUserID, type UserID} from '../BrandedTypes'; -import type {APIConfig} from '../config/APIConfig'; -import type {IDiscriminatorService} from '../infrastructure/DiscriminatorService'; -import type {KVActivityTracker} from '../infrastructure/KVActivityTracker'; -import { - type InstanceConfigRepository, - type InstanceRegistrationUrl, - REGISTRATION_PENDING_APPROVAL_TRAIT, -} from '../instance/InstanceConfigRepository'; -import type {SingleCommunityService} from '../instance/SingleCommunityService'; -import type {InviteService} from '../invite/InviteService'; -import {Logger} from '../Logger'; -import {profileSubstringBlocklistCache} from '../middleware/ProfileSubstringBlocklistCache'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {User} from '../models/User'; -import {UserSettings} from '../models/UserSettings'; -import {countryRequiresInboundPhoneVerification} from '../risk/AbusePolicy'; -import { - type IAccountPolicyEvaluator, - isAssessmentThresholdAuditEvent, - normalizePolicyContactDomain, -} from '../risk/AccountPolicyEvaluator'; -import type {IRegistrationEventsRepository} from '../risk/adapters/VelocityAdapter'; -import {deferPhoneFlagsUntilCommunityJoin} from '../risk/DeferredPhoneGate'; -import type {IRiskHistoryRepository} from '../risk/HistoricalOutcomeRepository'; -import type {IRiskAssessmentRepository} from '../risk/RiskAssessmentRepository'; -import {deriveLatestRiskContext} from '../risk/RiskHistoryContext'; -import * as AgeUtils from '../utils/AgeUtils'; -import {extractEmailDomain} from '../utils/EmailDomainUtils'; -import {lookupGeoip} from '../utils/IpUtils'; -import {createRateLimitError} from '../utils/RateLimitUtils'; -import {generateRandomUsername} from '../utils/UsernameGenerator'; -import {deriveUsernameFromDisplayName} from '../utils/UsernameSuggestionUtils'; -import * as AuthPassword from './AuthPassword'; -import * as AuthSession from './AuthSession'; -import * as AuthUtility from './AuthUtility'; -import type {IRegistrationRiskEvaluator} from './services/IRegistrationRiskEvaluator'; const DEFAULT_MINIMUM_AGE = 13; diff --git a/fluxer_api/src/api/auth/AuthRequestService.ts b/fluxer_api/src/api/auth/AuthRequestService.ts index 7572ad1f0..e81f3a3d9 100644 --- a/fluxer_api/src/api/auth/AuthRequestService.ts +++ b/fluxer_api/src/api/auth/AuthRequestService.ts @@ -1,5 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthEmail from '@app/api/auth/AuthEmail'; +import * as AuthEmailRevert from '@app/api/auth/AuthEmailRevert'; +import * as AuthLogin from '@app/api/auth/AuthLogin'; +import * as AuthMfa from '@app/api/auth/AuthMfa'; +import * as AuthPassword from '@app/api/auth/AuthPassword'; +import * as AuthRegistration from '@app/api/auth/AuthRegistration'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import type {DesktopHandoffService} from '@app/api/auth/services/DesktopHandoffService'; +import type {SsoService} from '@app/api/auth/services/SsoService'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import type {User} from '@app/api/models/User'; +import {mapUserToPartialResponse} from '@app/api/user/UserMappers'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; +import {parseJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; +import {resolveSessionClientInfo} from '@app/api/utils/SessionClientIdentity'; +import {generateUsernameSuggestions} from '@app/api/utils/UsernameSuggestionUtils'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {UnauthorizedError} from '@fluxer/errors/src/domains/core/UnauthorizedError'; @@ -30,25 +49,6 @@ import type { WebAuthnMfaRequest, } from '@fluxer/schema/src/domains/auth/AuthSchemas'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import type {ApiContext} from '../ApiContext'; -import {createUserID, type UserID} from '../BrandedTypes'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import {getInstanceConfigRepository} from '../middleware/ServiceSingletons'; -import type {User} from '../models/User'; -import {mapUserToPartialResponse} from '../user/UserMappers'; -import {lookupGeoip} from '../utils/IpUtils'; -import {parseJsonRecord} from '../utils/JsonBoundaryUtils'; -import {resolveSessionClientInfo} from '../utils/SessionClientIdentity'; -import {generateUsernameSuggestions} from '../utils/UsernameSuggestionUtils'; -import * as AuthEmail from './AuthEmail'; -import * as AuthEmailRevert from './AuthEmailRevert'; -import * as AuthLogin from './AuthLogin'; -import * as AuthMfa from './AuthMfa'; -import * as AuthPassword from './AuthPassword'; -import * as AuthRegistration from './AuthRegistration'; -import * as AuthSession from './AuthSession'; -import type {DesktopHandoffService} from './services/DesktopHandoffService'; -import type {SsoService} from './services/SsoService'; interface AuthRegisterRequest { data: RegisterRequest; diff --git a/fluxer_api/src/api/auth/AuthSession.ts b/fluxer_api/src/api/auth/AuthSession.ts index 794327909..e42e9b7f3 100644 --- a/fluxer_api/src/api/auth/AuthSession.ts +++ b/fluxer_api/src/api/auth/AuthSession.ts @@ -1,5 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {mapAuthSessionsToResponse} from '@app/api/auth/AuthModel'; +import {revokeAllAuthSessions, revokeAuthSessions} from '@app/api/auth/AuthSessionRevocation'; +import * as AuthUtility from '@app/api/auth/AuthUtility'; +import type {UserID} from '@app/api/BrandedTypes'; +import { + REGISTRATION_PENDING_APPROVAL_TRAIT, + REGISTRATION_REJECTED_TRAIT, +} from '@app/api/instance/InstanceConfigRepository'; +import {Logger} from '@app/api/Logger'; +import type {AuthSession} from '@app/api/models/AuthSession'; +import type {User} from '@app/api/models/User'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; +import {isFluxerNativeUserAgent, parseReportedClientOs} from '@app/api/utils/SessionClientIdentity'; import {BotUserAuthSessionCreationDeniedError} from '@fluxer/errors/src/domains/auth/BotUserAuthSessionCreationDeniedError'; import {RegistrationPendingApprovalError} from '@fluxer/errors/src/domains/auth/RegistrationPendingApprovalError'; import {RegistrationRejectedError} from '@fluxer/errors/src/domains/auth/RegistrationRejectedError'; @@ -8,17 +22,6 @@ import {InvalidTokenError} from '@fluxer/errors/src/domains/core/InvalidTokenErr import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import {requireClientIp} from '@fluxer/ip_utils/src/ClientIp'; import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; -import type {ApiContext} from '../ApiContext'; -import type {UserID} from '../BrandedTypes'; -import {REGISTRATION_PENDING_APPROVAL_TRAIT, REGISTRATION_REJECTED_TRAIT} from '../instance/InstanceConfigRepository'; -import {Logger} from '../Logger'; -import type {AuthSession} from '../models/AuthSession'; -import type {User} from '../models/User'; -import {lookupGeoip} from '../utils/IpUtils'; -import {isFluxerNativeUserAgent, parseReportedClientOs} from '../utils/SessionClientIdentity'; -import {mapAuthSessionsToResponse} from './AuthModel'; -import {revokeAllAuthSessions, revokeAuthSessions} from './AuthSessionRevocation'; -import * as AuthUtility from './AuthUtility'; export interface SessionOrigin { ip: string; diff --git a/fluxer_api/src/api/auth/AuthSessionRevocation.ts b/fluxer_api/src/api/auth/AuthSessionRevocation.ts index 5dcc0de49..e53fe523b 100644 --- a/fluxer_api/src/api/auth/AuthSessionRevocation.ts +++ b/fluxer_api/src/api/auth/AuthSessionRevocation.ts @@ -1,7 +1,7 @@ -import type {UserID} from '../BrandedTypes'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {IUserRepositoryAggregate} from '../user/repositories/IUserRepositoryAggregate'; -import {runAllInOrder} from '../utils/ConcurrencyUtils'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IUserRepositoryAggregate} from '@app/api/user/repositories/IUserRepositoryAggregate'; +import {runAllInOrder} from '@app/api/utils/ConcurrencyUtils'; interface SessionRevocationDependencies { users: IUserRepositoryAggregate; diff --git a/fluxer_api/src/api/auth/AuthUtility.ts b/fluxer_api/src/api/auth/AuthUtility.ts index 930565fab..ac3110003 100644 --- a/fluxer_api/src/api/auth/AuthUtility.ts +++ b/fluxer_api/src/api/auth/AuthUtility.ts @@ -2,15 +2,15 @@ import crypto from 'node:crypto'; import {promisify} from 'node:util'; +import type {ApiContext} from '@app/api/ApiContext'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {User} from '@app/api/models/User'; +import * as AgeUtils from '@app/api/utils/AgeUtils'; +import * as RandomUtils from '@app/api/utils/RandomUtils'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {BotUserAuthEndpointAccessDeniedError} from '@fluxer/errors/src/domains/auth/BotUserAuthEndpointAccessDeniedError'; import {AccountPermanentlySuspendedError} from '@fluxer/errors/src/domains/user/AccountPermanentlySuspendedError'; import {AccountTemporarilySuspendedError} from '@fluxer/errors/src/domains/user/AccountTemporarilySuspendedError'; -import type {ApiContext} from '../ApiContext'; -import type {UserID} from '../BrandedTypes'; -import type {User} from '../models/User'; -import * as AgeUtils from '../utils/AgeUtils'; -import * as RandomUtils from '../utils/RandomUtils'; const randomBytesAsync = promisify(crypto.randomBytes); const ALPHANUMERIC_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; diff --git a/fluxer_api/src/api/auth/ISessionTerminator.ts b/fluxer_api/src/api/auth/ISessionTerminator.ts index 097d9c14b..61cf1de9a 100644 --- a/fluxer_api/src/api/auth/ISessionTerminator.ts +++ b/fluxer_api/src/api/auth/ISessionTerminator.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; +import type {UserID} from '@app/api/BrandedTypes'; export interface ISessionTerminator { terminateAllUserSessions(userId: UserID): Promise; diff --git a/fluxer_api/src/api/auth/PhonePrefixBanCache.ts b/fluxer_api/src/api/auth/PhonePrefixBanCache.ts index cdb65cbc2..2d2e70159 100644 --- a/fluxer_api/src/api/auth/PhonePrefixBanCache.ts +++ b/fluxer_api/src/api/auth/PhonePrefixBanCache.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import {PHONE_PREFIX_BAN_REFRESH_CHANNEL} from '@app/api/constants/PhonePrefixBan'; +import {Logger} from '@app/api/Logger'; +import {RefreshSubscription} from '@app/api/utils/RefreshSubscription'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {AdminRepository} from '../admin/AdminRepository'; -import {PHONE_PREFIX_BAN_REFRESH_CHANNEL} from '../constants/PhonePrefixBan'; -import {Logger} from '../Logger'; -import {RefreshSubscription} from '../utils/RefreshSubscription'; const BUILT_IN_BANNED_PHONE_PREFIXES: ReadonlyArray = [ '+93', diff --git a/fluxer_api/src/api/auth/PhoneVerificationPrefixPolicy.ts b/fluxer_api/src/api/auth/PhoneVerificationPrefixPolicy.ts index f75bfdfe3..5809564bb 100644 --- a/fluxer_api/src/api/auth/PhoneVerificationPrefixPolicy.ts +++ b/fluxer_api/src/api/auth/PhoneVerificationPrefixPolicy.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {phoneRequiresInboundVerification} from '../risk/AbusePolicy'; +import {phoneRequiresInboundVerification} from '@app/api/risk/AbusePolicy'; export function requiresInboundPhoneVerification(phone: string, prefixes?: ReadonlyArray): boolean { return phoneRequiresInboundVerification(phone, prefixes); diff --git a/fluxer_api/src/api/auth/PhoneVerificationReuseStore.ts b/fluxer_api/src/api/auth/PhoneVerificationReuseStore.ts index 5d1716b18..10e85f3f3 100644 --- a/fluxer_api/src/api/auth/PhoneVerificationReuseStore.ts +++ b/fluxer_api/src/api/auth/PhoneVerificationReuseStore.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createCipheriv, createHmac, randomBytes, randomUUID} from 'node:crypto'; +import {Logger} from '@app/api/Logger'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {seconds} from 'itty-time'; -import {Logger} from '../Logger'; const KEY_STATE_CACHE_KEY = 'phone-verification:reuse-key-state'; const KEY_ROTATION_LOCK = 'phone-verification-reuse-key-rotation'; diff --git a/fluxer_api/src/api/auth/__tests__/PhoneGateCodeCoverage.test.ts b/fluxer_api/src/api/auth/__tests__/PhoneGateCodeCoverage.test.ts index 4fa4a1e3b..6b040f316 100644 --- a/fluxer_api/src/api/auth/__tests__/PhoneGateCodeCoverage.test.ts +++ b/fluxer_api/src/api/auth/__tests__/PhoneGateCodeCoverage.test.ts @@ -3,12 +3,12 @@ import {readFileSync} from 'node:fs'; import path from 'node:path'; import {fileURLToPath} from 'node:url'; +import {errorForPhoneRejectReason} from '@app/api/auth/AuthPhone'; +import type {PhoneAttemptRejectReason} from '@app/api/auth/services/PhoneLookupRepository'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {ErrorCodeToI18nKey} from '@fluxer/errors/src/i18n/ErrorCodeMappings'; import {getErrorMessageUnsafe} from '@fluxer/errors/src/i18n/ErrorI18n'; import {describe, expect, it} from 'vitest'; -import {errorForPhoneRejectReason} from '../AuthPhone'; -import type {PhoneAttemptRejectReason} from '../services/PhoneLookupRepository'; const ALL_REJECT_REASONS: ReadonlyArray = [ 'invalid_format', diff --git a/fluxer_api/src/api/auth/__tests__/PhoneGateOutcomes.test.ts b/fluxer_api/src/api/auth/__tests__/PhoneGateOutcomes.test.ts index c752ff1e5..041a104fa 100644 --- a/fluxer_api/src/api/auth/__tests__/PhoneGateOutcomes.test.ts +++ b/fluxer_api/src/api/auth/__tests__/PhoneGateOutcomes.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {errorForPhoneRejectReason, sendPhoneVerificationCode, verifyPhoneCode} from '@app/api/auth/AuthPhone'; +import {phonePrefixBanCache} from '@app/api/auth/PhonePrefixBanCache'; +import type {PhoneAttemptInboundReason, PhoneAttemptRejectReason} from '@app/api/auth/services/PhoneLookupRepository'; +import type {UserID} from '@app/api/BrandedTypes'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import type {FluxerError} from '@fluxer/errors/src/FluxerError'; import type {PhoneLineType, PhoneLookupResult} from '@pkgs/sms/src/PhoneLookupTypes'; import {afterEach, describe, expect, it, vi} from 'vitest'; -import type {ApiContext} from '../../ApiContext'; -import type {UserID} from '../../BrandedTypes'; -import {errorForPhoneRejectReason, sendPhoneVerificationCode, verifyPhoneCode} from '../AuthPhone'; -import {phonePrefixBanCache} from '../PhonePrefixBanCache'; -import type {PhoneAttemptInboundReason, PhoneAttemptRejectReason} from '../services/PhoneLookupRepository'; const USER_ID = 1n as UserID; const MOBILE_US = '+15125550123'; diff --git a/fluxer_api/src/api/auth/__tests__/PhonePrefixBanCache.test.ts b/fluxer_api/src/api/auth/__tests__/PhonePrefixBanCache.test.ts index 9d8acda66..b7f288e87 100644 --- a/fluxer_api/src/api/auth/__tests__/PhonePrefixBanCache.test.ts +++ b/fluxer_api/src/api/auth/__tests__/PhonePrefixBanCache.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {PhonePrefixBanCache} from '@app/api/auth/PhonePrefixBanCache'; import {beforeEach, describe, expect, it} from 'vitest'; -import {PhonePrefixBanCache} from '../PhonePrefixBanCache'; describe('PhonePrefixBanCache', () => { let cache: PhonePrefixBanCache; diff --git a/fluxer_api/src/api/auth/__tests__/PhoneRejectionErrors.test.ts b/fluxer_api/src/api/auth/__tests__/PhoneRejectionErrors.test.ts index 711495e61..79741c87d 100644 --- a/fluxer_api/src/api/auth/__tests__/PhoneRejectionErrors.test.ts +++ b/fluxer_api/src/api/auth/__tests__/PhoneRejectionErrors.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {errorForPhoneRejectReason} from '@app/api/auth/AuthPhone'; +import type {PhoneAttemptRejectReason} from '@app/api/auth/services/PhoneLookupRepository'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {describe, expect, it} from 'vitest'; -import {errorForPhoneRejectReason} from '../AuthPhone'; -import type {PhoneAttemptRejectReason} from '../services/PhoneLookupRepository'; const EXPECTED_CODES: ReadonlyArray<[PhoneAttemptRejectReason, string]> = [ ['invalid_format', APIErrorCodes.INVALID_PHONE_NUMBER], diff --git a/fluxer_api/src/api/auth/__tests__/PhoneVerificationPrefixPolicy.test.ts b/fluxer_api/src/api/auth/__tests__/PhoneVerificationPrefixPolicy.test.ts index 2218019e3..000931127 100644 --- a/fluxer_api/src/api/auth/__tests__/PhoneVerificationPrefixPolicy.test.ts +++ b/fluxer_api/src/api/auth/__tests__/PhoneVerificationPrefixPolicy.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requiresInboundPhoneVerification} from '@app/api/auth/PhoneVerificationPrefixPolicy'; import {describe, expect, it} from 'vitest'; -import {requiresInboundPhoneVerification} from '../PhoneVerificationPrefixPolicy'; describe('PhoneVerificationPrefixPolicy', () => { const configuredPrefixes = ['+101', '+202', '+3034']; diff --git a/fluxer_api/src/api/auth/services/DesktopHandoffService.ts b/fluxer_api/src/api/auth/services/DesktopHandoffService.ts index 87a2367fa..dcc62e348 100644 --- a/fluxer_api/src/api/auth/services/DesktopHandoffService.ts +++ b/fluxer_api/src/api/auth/services/DesktopHandoffService.ts @@ -1,6 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash, randomBytes, timingSafeEqual} from 'node:crypto'; +import type {ApiContext} from '@app/api/ApiContext'; +import type {SessionOrigin} from '@app/api/auth/AuthSession'; import {HandoffCodeExpiredError} from '@fluxer/errors/src/domains/auth/HandoffCodeExpiredError'; import {InvalidHandoffCodeError} from '@fluxer/errors/src/domains/auth/InvalidHandoffCodeError'; import { @@ -10,8 +12,6 @@ import { parseDesktopHandoffCode, } from '@fluxer/schema/src/domains/auth/DesktopHandoffCode'; import {ms, seconds} from 'itty-time'; -import type {ApiContext} from '../../ApiContext'; -import type {SessionOrigin} from '../AuthSession'; const HANDOFF_CODE_PREFIX = 'desktop-handoff-v2:'; const HANDOFF_TOKEN_PREFIX = 'desktop-handoff-token:'; diff --git a/fluxer_api/src/api/auth/services/IRegistrationRiskEvaluator.ts b/fluxer_api/src/api/auth/services/IRegistrationRiskEvaluator.ts index 3c13bca2c..f04c8b37e 100644 --- a/fluxer_api/src/api/auth/services/IRegistrationRiskEvaluator.ts +++ b/fluxer_api/src/api/auth/services/IRegistrationRiskEvaluator.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {RecommendedAction, RiskAssessment, RiskLevel} from '../../risk/RiskTypes'; +import type {RecommendedAction, RiskAssessment, RiskLevel} from '@app/api/risk/RiskTypes'; export interface RegistrationRiskParams { email: string | null; diff --git a/fluxer_api/src/api/auth/services/InboundSmsChallengeService.ts b/fluxer_api/src/api/auth/services/InboundSmsChallengeService.ts index c8452fc01..b4db5d40b 100644 --- a/fluxer_api/src/api/auth/services/InboundSmsChallengeService.ts +++ b/fluxer_api/src/api/auth/services/InboundSmsChallengeService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {InboundSmsChallengeRow} from '@app/api/database/types/RiskTypes'; +import {InboundSmsChallenges, InboundSmsChallengesByUser} from '@app/api/Tables'; +import {randomNumericCode} from '@app/api/utils/RandomUtils'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {UserID} from '../../BrandedTypes'; -import {BatchBuilder, fetchOne} from '../../database/CassandraQueryExecution'; -import {Db} from '../../database/CassandraTypes'; -import type {InboundSmsChallengeRow} from '../../database/types/RiskTypes'; -import {InboundSmsChallenges, InboundSmsChallengesByUser} from '../../Tables'; -import {randomNumericCode} from '../../utils/RandomUtils'; interface IssueChallengeParams { userId: UserID; diff --git a/fluxer_api/src/api/auth/services/PhoneAttemptRiskService.ts b/fluxer_api/src/api/auth/services/PhoneAttemptRiskService.ts index ff4bb7aa7..2e2351444 100644 --- a/fluxer_api/src/api/auth/services/PhoneAttemptRiskService.ts +++ b/fluxer_api/src/api/auth/services/PhoneAttemptRiskService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHmac, randomBytes, randomUUID} from 'node:crypto'; +import {Logger} from '@app/api/Logger'; import {getSameIpDecisionKey, getSubnet} from '@fluxer/ip_utils/src/IpAddress'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {Logger} from '../../Logger'; const WINDOW_SECONDS = 24 * 60 * 60; const HARD_BLOCK_TTL_SECONDS = 24 * 60 * 60; diff --git a/fluxer_api/src/api/auth/services/PhoneFraudGraphService.ts b/fluxer_api/src/api/auth/services/PhoneFraudGraphService.ts index 179702a6e..062b33101 100644 --- a/fluxer_api/src/api/auth/services/PhoneFraudGraphService.ts +++ b/fluxer_api/src/api/auth/services/PhoneFraudGraphService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {UserID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; -import type {IUserRepository} from '../../user/IUserRepository'; const COHORT_KEY_PREFIX = 'auth:ip24-cohort:'; const COHORT_TTL_SECONDS = 7 * 24 * 60 * 60; diff --git a/fluxer_api/src/api/auth/services/PhoneLookupRepository.ts b/fluxer_api/src/api/auth/services/PhoneLookupRepository.ts index 7bf3f7ccf..a978fbf42 100644 --- a/fluxer_api/src/api/auth/services/PhoneLookupRepository.ts +++ b/fluxer_api/src/api/auth/services/PhoneLookupRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {executeQuery, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import type {PhoneLookupCacheRow, PhoneVerificationAttemptRow} from '@app/api/database/types/RiskTypes'; +import {PhoneLookupCache, PhoneVerificationAttempts} from '@app/api/Tables'; import {createLogger} from '@fluxer/logger/src/Logger'; import type {LoggerInterface} from '@fluxer/logger/src/LoggerInterface'; import type {PhoneLookupResult} from '@pkgs/sms/src/PhoneLookupTypes'; -import {executeQuery, fetchOne} from '../../database/CassandraQueryExecution'; -import type {PhoneLookupCacheRow, PhoneVerificationAttemptRow} from '../../database/types/RiskTypes'; -import {PhoneLookupCache, PhoneVerificationAttempts} from '../../Tables'; const CACHE_TTL_SECONDS = 7 * 24 * 60 * 60; const ATTEMPT_TTL_SECONDS = 90 * 24 * 60 * 60; diff --git a/fluxer_api/src/api/auth/services/RegistrationRiskEvaluator.ts b/fluxer_api/src/api/auth/services/RegistrationRiskEvaluator.ts index 2610da6d1..90549ae66 100644 --- a/fluxer_api/src/api/auth/services/RegistrationRiskEvaluator.ts +++ b/fluxer_api/src/api/auth/services/RegistrationRiskEvaluator.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Logger} from '../../Logger'; -import type {DeterministicRiskEngine} from '../../risk/DeterministicRiskEngine'; -import {RecommendedAction, RiskConfidence, RiskDecisionMethod, RiskLevel} from '../../risk/RiskTypes'; import type { IRegistrationRiskEvaluator, RegistrationRiskParams, RegistrationRiskResult, -} from './IRegistrationRiskEvaluator'; +} from '@app/api/auth/services/IRegistrationRiskEvaluator'; +import {Logger} from '@app/api/Logger'; +import type {DeterministicRiskEngine} from '@app/api/risk/DeterministicRiskEngine'; +import {RecommendedAction, RiskConfidence, RiskDecisionMethod, RiskLevel} from '@app/api/risk/RiskTypes'; export class RegistrationRiskEvaluator implements IRegistrationRiskEvaluator { constructor(private readonly riskEngine: Pick) {} diff --git a/fluxer_api/src/api/auth/services/SsoIdentityRepository.ts b/fluxer_api/src/api/auth/services/SsoIdentityRepository.ts index 6c9d85cb1..6288ac3a7 100644 --- a/fluxer_api/src/api/auth/services/SsoIdentityRepository.ts +++ b/fluxer_api/src/api/auth/services/SsoIdentityRepository.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import {deleteOneOrMany, executeQuery, fetchOne} from '../../database/CassandraQueryExecution'; -import type {UserSsoIdentityRow} from '../../database/types/AuthTypes'; -import {UserSsoIdentities} from '../../Tables'; +import type {UserID} from '@app/api/BrandedTypes'; +import {deleteOneOrMany, executeQuery, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import type {UserSsoIdentityRow} from '@app/api/database/types/AuthTypes'; +import {UserSsoIdentities} from '@app/api/Tables'; interface ConditionalInsertResult { '[applied]': boolean; diff --git a/fluxer_api/src/api/auth/services/SsoService.ts b/fluxer_api/src/api/auth/services/SsoService.ts index 86330b3ac..62016bfa9 100644 --- a/fluxer_api/src/api/auth/services/SsoService.ts +++ b/fluxer_api/src/api/auth/services/SsoService.ts @@ -1,6 +1,38 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash, randomBytes} from 'node:crypto'; +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import {SsoIdentityRepository} from '@app/api/auth/services/SsoIdentityRepository'; +import { + parseTokenEndpointResponse, + sanitizeSsoRedirectTo, + tryDiscoverOidcProviderMetadata, +} from '@app/api/auth/services/SsoUtils'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {ILogger} from '@app/api/ILogger'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {KVActivityTracker} from '@app/api/infrastructure/KVActivityTracker'; +import { + type InstanceConfigRepository, + type InstanceSsoConfig, + REGISTRATION_PENDING_APPROVAL_TRAIT, +} from '@app/api/instance/InstanceConfigRepository'; +import { + deriveSsoRedirectUri, + getSsoRequestUrlPolicy, + isTestSsoProvider, + validateSsoPublicOutboundUrl, +} from '@app/api/instance/SsoConfigValidation'; +import {Logger} from '@app/api/Logger'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import type {User} from '@app/api/models/User'; +import {UserSettings} from '@app/api/models/UserSettings'; +import {EXTERNAL_RESPONSE_LIMITS} from '@app/api/utils/ExternalResponseLimits'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; +import {isJsonRecord, parseJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; +import {generateRandomUsername} from '@app/api/utils/UsernameGenerator'; +import {deriveUsernameFromDisplayName} from '@app/api/utils/UsernameSuggestionUtils'; import {ProfileFieldPrivacyFlags} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {RegistrationClosedError} from '@fluxer/errors/src/domains/auth/RegistrationClosedError'; @@ -23,34 +55,6 @@ import { type JWTPayload, jwtVerify, } from 'jose'; -import type {ApiContext} from '../../ApiContext'; -import type {UserID} from '../../BrandedTypes'; -import type {ILogger} from '../../ILogger'; -import type {IDiscriminatorService} from '../../infrastructure/DiscriminatorService'; -import type {KVActivityTracker} from '../../infrastructure/KVActivityTracker'; -import { - type InstanceConfigRepository, - type InstanceSsoConfig, - REGISTRATION_PENDING_APPROVAL_TRAIT, -} from '../../instance/InstanceConfigRepository'; -import { - deriveSsoRedirectUri, - getSsoRequestUrlPolicy, - isTestSsoProvider, - validateSsoPublicOutboundUrl, -} from '../../instance/SsoConfigValidation'; -import {Logger} from '../../Logger'; -import {profileSubstringBlocklistCache} from '../../middleware/ProfileSubstringBlocklistCache'; -import type {User} from '../../models/User'; -import {UserSettings} from '../../models/UserSettings'; -import {EXTERNAL_RESPONSE_LIMITS} from '../../utils/ExternalResponseLimits'; -import * as FetchUtils from '../../utils/FetchUtils'; -import {isJsonRecord, parseJsonRecord, parseJsonWithGuard} from '../../utils/JsonBoundaryUtils'; -import {generateRandomUsername} from '../../utils/UsernameGenerator'; -import {deriveUsernameFromDisplayName} from '../../utils/UsernameSuggestionUtils'; -import * as AuthSession from '../AuthSession'; -import {SsoIdentityRepository} from './SsoIdentityRepository'; -import {parseTokenEndpointResponse, sanitizeSsoRedirectTo, tryDiscoverOidcProviderMetadata} from './SsoUtils'; interface SsoStatePayload { codeVerifier: string; diff --git a/fluxer_api/src/api/auth/services/SsoUtils.ts b/fluxer_api/src/api/auth/services/SsoUtils.ts index 9358d18c3..791919d47 100644 --- a/fluxer_api/src/api/auth/services/SsoUtils.ts +++ b/fluxer_api/src/api/auth/services/SsoUtils.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Logger} from '@app/api/Logger'; +import {EXTERNAL_RESPONSE_LIMITS} from '@app/api/utils/ExternalResponseLimits'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; +import {parseJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; import {formatUrlForDiagnostics} from '@pkgs/http_client/src/HttpClientDiagnostics'; import {ms} from 'itty-time'; -import {Logger} from '../../Logger'; -import {EXTERNAL_RESPONSE_LIMITS} from '../../utils/ExternalResponseLimits'; -import * as FetchUtils from '../../utils/FetchUtils'; -import {parseJsonRecord} from '../../utils/JsonBoundaryUtils'; interface DiscoveredOidcProviderMetadata { issuer: string; diff --git a/fluxer_api/src/api/auth/services/SudoModeService.ts b/fluxer_api/src/api/auth/services/SudoModeService.ts index 9a36c051c..f04d1d32b 100644 --- a/fluxer_api/src/api/auth/services/SudoModeService.ts +++ b/fluxer_api/src/api/auth/services/SudoModeService.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; import {seconds} from 'itty-time'; import {jwtVerify, SignJWT} from 'jose'; -import type {UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; class SudoModeService { private readonly secret: Uint8Array; diff --git a/fluxer_api/src/api/auth/services/SudoVerificationService.ts b/fluxer_api/src/api/auth/services/SudoVerificationService.ts index 1fd98a95a..5e952c4f1 100644 --- a/fluxer_api/src/api/auth/services/SudoVerificationService.ts +++ b/fluxer_api/src/api/auth/services/SudoVerificationService.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import * as AuthMfa from '@app/api/auth/AuthMfa'; +import * as AuthPassword from '@app/api/auth/AuthPassword'; +import {deriveSudoMethods, userHasMfa} from '@app/api/auth/services/SudoMethods'; +import {getSudoModeService} from '@app/api/auth/services/SudoModeService'; +import {SUDO_MODE_HEADER} from '@app/api/middleware/SudoModeMiddleware'; +import type {User} from '@app/api/models/User'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {SudoModeRequiredError} from '@fluxer/errors/src/domains/auth/SudoModeRequiredError'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {AuthenticationResponseJSON} from '@simplewebauthn/server'; import type {Context} from 'hono'; -import * as AuthMfa from '../../auth/AuthMfa'; -import * as AuthPassword from '../../auth/AuthPassword'; -import {SUDO_MODE_HEADER} from '../../middleware/SudoModeMiddleware'; -import type {User} from '../../models/User'; -import type {HonoEnv} from '../../types/HonoEnv'; -import {deriveSudoMethods, userHasMfa} from './SudoMethods'; -import {getSudoModeService} from './SudoModeService'; export interface SudoVerificationBody { password?: string; diff --git a/fluxer_api/src/api/auth/tests/AppStoreReviewerBypass.test.ts b/fluxer_api/src/api/auth/tests/AppStoreReviewerBypass.test.ts index 06f370b27..3b71edf24 100644 --- a/fluxer_api/src/api/auth/tests/AppStoreReviewerBypass.test.ts +++ b/fluxer_api/src/api/auth/tests/AppStoreReviewerBypass.test.ts @@ -1,9 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createAuthHarness, + createUniqueEmail, + createUniqueUsername, + loginUser, + registerUser, +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createUniqueEmail, createUniqueUsername, loginUser, registerUser} from './AuthTestUtils'; async function setUserSecurityFlags(harness: ApiTestHarness, userId: string, setFlags: Array): Promise { await createBuilderWithoutAuth(harness) diff --git a/fluxer_api/src/api/auth/tests/AppStoreReviewerMultiFlag.test.ts b/fluxer_api/src/api/auth/tests/AppStoreReviewerMultiFlag.test.ts index 64ed7071a..7b865a61b 100644 --- a/fluxer_api/src/api/auth/tests/AppStoreReviewerMultiFlag.test.ts +++ b/fluxer_api/src/api/auth/tests/AppStoreReviewerMultiFlag.test.ts @@ -1,9 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createAuthHarness, + createUniqueEmail, + createUniqueUsername, + loginUser, + registerUser, +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createUniqueEmail, createUniqueUsername, loginUser, registerUser} from './AuthTestUtils'; async function setUserSecurityFlags(harness: ApiTestHarness, userId: string, setFlags: Array): Promise { await createBuilderWithoutAuth(harness) diff --git a/fluxer_api/src/api/auth/tests/AuthSessionCacheInvalidation.test.ts b/fluxer_api/src/api/auth/tests/AuthSessionCacheInvalidation.test.ts index 48baca9ee..163c7a45c 100644 --- a/fluxer_api/src/api/auth/tests/AuthSessionCacheInvalidation.test.ts +++ b/fluxer_api/src/api/auth/tests/AuthSessionCacheInvalidation.test.ts @@ -1,10 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; -import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; import { createAuthHarness, createFakeAuthToken, @@ -12,7 +8,11 @@ import { loginAccount, setUserACLs, type TestAccount, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; function authSessionCacheKey(token: string): string { return `auth:session:${createHash('sha256').update(token).digest('base64url')}`; diff --git a/fluxer_api/src/api/auth/tests/AuthSudoPasswordVerification.test.ts b/fluxer_api/src/api/auth/tests/AuthSudoPasswordVerification.test.ts index 583b64cd8..e770fd050 100644 --- a/fluxer_api/src/api/auth/tests/AuthSudoPasswordVerification.test.ts +++ b/fluxer_api/src/api/auth/tests/AuthSudoPasswordVerification.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, type TestAccount} from './AuthTestUtils'; describe('Auth sudo password verification', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/AuthSudoRequiredOperations.test.ts b/fluxer_api/src/api/auth/tests/AuthSudoRequiredOperations.test.ts index 8a16108bc..8ca5a0768 100644 --- a/fluxer_api/src/api/auth/tests/AuthSudoRequiredOperations.test.ts +++ b/fluxer_api/src/api/auth/tests/AuthSudoRequiredOperations.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomBytes} from 'node:crypto'; +import {createAuthHarness, createTestAccount, loginAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {TotpGenerator} from '@app/api/utils/TotpGenerator'; import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {TotpGenerator} from '../../utils/TotpGenerator'; -import {createAuthHarness, createTestAccount, loginAccount, type TestAccount} from './AuthTestUtils'; interface BackupCodesResponse { backup_codes: Array<{ diff --git a/fluxer_api/src/api/auth/tests/AuthSudoTOTPVerification.test.ts b/fluxer_api/src/api/auth/tests/AuthSudoTOTPVerification.test.ts index c7f1f42c8..28c9f8f0e 100644 --- a/fluxer_api/src/api/auth/tests/AuthSudoTOTPVerification.test.ts +++ b/fluxer_api/src/api/auth/tests/AuthSudoTOTPVerification.test.ts @@ -1,10 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createAuthHarness, + createTestAccount, + createTotpSecret, + type TestAccount, + totpCodeNow, +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, createTotpSecret, type TestAccount, totpCodeNow} from './AuthTestUtils'; interface BackupCodesResponse { backup_codes: Array<{ diff --git a/fluxer_api/src/api/auth/tests/AuthTestUtils.ts b/fluxer_api/src/api/auth/tests/AuthTestUtils.ts index c6f906aec..b232b3895 100644 --- a/fluxer_api/src/api/auth/tests/AuthTestUtils.ts +++ b/fluxer_api/src/api/auth/tests/AuthTestUtils.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHmac, randomBytes, randomUUID} from 'node:crypto'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {TEST_CREDENTIALS, TEST_USER_DATA} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {decode as base32Decode, encode as base32Encode} from 'hi-base32'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {TEST_CREDENTIALS, TEST_USER_DATA} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface RegisterResponse { user_id: string; diff --git a/fluxer_api/src/api/auth/tests/BouncedEmailRecoveryFlow.test.ts b/fluxer_api/src/api/auth/tests/BouncedEmailRecoveryFlow.test.ts index 5c945270e..c1d41885f 100644 --- a/fluxer_api/src/api/auth/tests/BouncedEmailRecoveryFlow.test.ts +++ b/fluxer_api/src/api/auth/tests/BouncedEmailRecoveryFlow.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -10,7 +7,10 @@ import { findLastTestEmail, listTestEmails, type TestAccount, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface BouncedEmailRequestNewResponse { ticket: string; diff --git a/fluxer_api/src/api/auth/tests/CaptchaBypassFlags.test.ts b/fluxer_api/src/api/auth/tests/CaptchaBypassFlags.test.ts index db84dcb19..c7c390b61 100644 --- a/fluxer_api/src/api/auth/tests/CaptchaBypassFlags.test.ts +++ b/fluxer_api/src/api/auth/tests/CaptchaBypassFlags.test.ts @@ -1,12 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createAuthHarness, + createUniqueEmail, + createUniqueUsername, + registerUser, +} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {Config} from '../../Config'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createUniqueEmail, createUniqueUsername, registerUser} from './AuthTestUtils'; async function withCaptchaEnabled(run: () => Promise): Promise { const previousEnabled = Config.captcha.enabled; diff --git a/fluxer_api/src/api/auth/tests/CaseInsensitiveEmail.test.ts b/fluxer_api/src/api/auth/tests/CaseInsensitiveEmail.test.ts index 2873b849c..493afd4b5 100644 --- a/fluxer_api/src/api/auth/tests/CaseInsensitiveEmail.test.ts +++ b/fluxer_api/src/api/auth/tests/CaseInsensitiveEmail.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { createAuthHarness, createUniqueEmail, @@ -11,7 +8,10 @@ import { type LoginSuccessResponse, loginUser, registerUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Auth case-insensitive email', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/ConcurrentSessions.test.ts b/fluxer_api/src/api/auth/tests/ConcurrentSessions.test.ts index 30ca04be6..3abd00516 100644 --- a/fluxer_api/src/api/auth/tests/ConcurrentSessions.test.ts +++ b/fluxer_api/src/api/auth/tests/ConcurrentSessions.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, loginAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, loginAccount} from './AuthTestUtils'; describe('Auth concurrent sessions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/DeferredPhoneGate.test.ts b/fluxer_api/src/api/auth/tests/DeferredPhoneGate.test.ts index 75200f0a3..45332e3c6 100644 --- a/fluxer_api/src/api/auth/tests/DeferredPhoneGate.test.ts +++ b/fluxer_api/src/api/auth/tests/DeferredPhoneGate.test.ts @@ -1,31 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import { - DEFERRED_PHONE_ON_COMMUNITY_JOIN, - PHONE_GATE_PROMOTED_FROM_DEFERRAL, - SuspiciousActivityFlags, -} from '@fluxer/constants/src/UserConstants'; -import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import {afterAll, beforeAll, beforeEach, describe, expect, it, vi} from 'vitest'; -import {setInjectedRegistrationRiskEvaluator} from '../../middleware/ServiceMiddleware'; -import {getInstanceConfigRepository} from '../../middleware/ServiceSingletons'; -import { - authorizeOAuth2, - createOAuth2Application, - exchangeOAuth2AuthorizationCode, -} from '../../oauth/tests/OAuthTestUtils'; -import {PHONE_GATE_ESCAPE_MAX_GUILDS} from '../../risk/DeferredPhoneGate'; -import { - RecommendedAction, - RiskConfidence, - RiskDecisionMethod, - RiskLevel, - type RiskLevel as RiskLevelType, -} from '../../risk/RiskTypes'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {NoopGatewayService} from '../../test/NoopGatewayService'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import type {IRegistrationRiskEvaluator} from '../services/IRegistrationRiskEvaluator'; +import type {IRegistrationRiskEvaluator} from '@app/api/auth/services/IRegistrationRiskEvaluator'; import { createAuthHarness, createTestAccount, @@ -33,7 +8,32 @@ import { createUniqueUsername, loginAccount, registerUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import {setInjectedRegistrationRiskEvaluator} from '@app/api/middleware/ServiceMiddleware'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import { + authorizeOAuth2, + createOAuth2Application, + exchangeOAuth2AuthorizationCode, +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {PHONE_GATE_ESCAPE_MAX_GUILDS} from '@app/api/risk/DeferredPhoneGate'; +import { + RecommendedAction, + RiskConfidence, + RiskDecisionMethod, + RiskLevel, + type RiskLevel as RiskLevelType, +} from '@app/api/risk/RiskTypes'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {NoopGatewayService} from '@app/api/test/NoopGatewayService'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import { + DEFERRED_PHONE_ON_COMMUNITY_JOIN, + PHONE_GATE_PROMOTED_FROM_DEFERRAL, + SuspiciousActivityFlags, +} from '@fluxer/constants/src/UserConstants'; +import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; +import {afterAll, beforeAll, beforeEach, describe, expect, it, vi} from 'vitest'; function phoneRiskEvaluator(level: RiskLevelType, riskScore: number): IRegistrationRiskEvaluator { return { @@ -79,15 +79,15 @@ async function createGuildWithInvite(harness: ApiTestHarness): Promise<{guildId: } async function readFlags(userId: string): Promise { - const {UserRepository} = await import('../../user/repositories/UserRepository'); - const {createUserID} = await import('../../BrandedTypes'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); + const {createUserID} = await import('@app/api/BrandedTypes'); const user = await new UserRepository().findUnique(createUserID(BigInt(userId))); return user?.suspiciousActivityFlags ?? 0; } async function readGuildIds(userId: string): Promise> { - const {GuildRepository} = await import('../../guild/repositories/GuildRepository'); - const {createUserID} = await import('../../BrandedTypes'); + const {GuildRepository} = await import('@app/api/guild/repositories/GuildRepository'); + const {createUserID} = await import('@app/api/BrandedTypes'); const guilds = await new GuildRepository().listUserGuilds(createUserID(BigInt(userId))); return guilds.map((guild) => guild.id.toString()); } diff --git a/fluxer_api/src/api/auth/tests/DesktopHandoffCodeNormalization.test.ts b/fluxer_api/src/api/auth/tests/DesktopHandoffCodeNormalization.test.ts index 955fa1f51..d9846f6a9 100644 --- a/fluxer_api/src/api/auth/tests/DesktopHandoffCodeNormalization.test.ts +++ b/fluxer_api/src/api/auth/tests/DesktopHandoffCodeNormalization.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, loginAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, loginAccount} from './AuthTestUtils'; interface HandoffInitiateResponse { code: string; diff --git a/fluxer_api/src/api/auth/tests/DesktopHandoffFlow.test.ts b/fluxer_api/src/api/auth/tests/DesktopHandoffFlow.test.ts index 2503f3ca2..7ec6786bd 100644 --- a/fluxer_api/src/api/auth/tests/DesktopHandoffFlow.test.ts +++ b/fluxer_api/src/api/auth/tests/DesktopHandoffFlow.test.ts @@ -1,13 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, fetchMe, loginAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {maskIpForDisplay} from '@fluxer/ip_utils/src/IpAddress'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; - -import {createAuthHarness, createTestAccount, fetchMe, loginAccount} from './AuthTestUtils'; interface HandoffInitiateResponse { code: string; diff --git a/fluxer_api/src/api/auth/tests/DesktopHandoffNegative.test.ts b/fluxer_api/src/api/auth/tests/DesktopHandoffNegative.test.ts index 281bf9ddf..bb7f6b6cf 100644 --- a/fluxer_api/src/api/auth/tests/DesktopHandoffNegative.test.ts +++ b/fluxer_api/src/api/auth/tests/DesktopHandoffNegative.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, loginAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, loginAccount} from './AuthTestUtils'; interface HandoffInitiateResponse { code: string; diff --git a/fluxer_api/src/api/auth/tests/DesktopHandoffUsage.test.ts b/fluxer_api/src/api/auth/tests/DesktopHandoffUsage.test.ts index 49082fc8e..3719d093d 100644 --- a/fluxer_api/src/api/auth/tests/DesktopHandoffUsage.test.ts +++ b/fluxer_api/src/api/auth/tests/DesktopHandoffUsage.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, loginAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, loginAccount} from './AuthTestUtils'; interface HandoffInitiateResponse { code: string; diff --git a/fluxer_api/src/api/auth/tests/EmailChangeFlow.test.ts b/fluxer_api/src/api/auth/tests/EmailChangeFlow.test.ts index 614f856b7..f6406a632 100644 --- a/fluxer_api/src/api/auth/tests/EmailChangeFlow.test.ts +++ b/fluxer_api/src/api/auth/tests/EmailChangeFlow.test.ts @@ -1,10 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {setInjectedRegistrationRiskEvaluator} from '../../middleware/ServiceMiddleware'; -import {RecommendedAction, RiskConfidence, RiskDecisionMethod, RiskLevel} from '../../risk/RiskTypes'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -15,7 +10,12 @@ import { listTestEmails, loginUser, type TestAccount, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import {setInjectedRegistrationRiskEvaluator} from '@app/api/middleware/ServiceMiddleware'; +import {RecommendedAction, RiskConfidence, RiskDecisionMethod, RiskLevel} from '@app/api/risk/RiskTypes'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface EmailChangeStartResponse { ticket: string; diff --git a/fluxer_api/src/api/auth/tests/EmailRevertFlow.test.ts b/fluxer_api/src/api/auth/tests/EmailRevertFlow.test.ts index b207bacf1..6c0eb8e5f 100644 --- a/fluxer_api/src/api/auth/tests/EmailRevertFlow.test.ts +++ b/fluxer_api/src/api/auth/tests/EmailRevertFlow.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -11,7 +8,10 @@ import { listTestEmails, loginUser, type TestAccount, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface EmailChangeStartResponse { ticket: string; diff --git a/fluxer_api/src/api/auth/tests/EmailVerificationFlow.test.ts b/fluxer_api/src/api/auth/tests/EmailVerificationFlow.test.ts index fd57ac6d4..96648ca11 100644 --- a/fluxer_api/src/api/auth/tests/EmailVerificationFlow.test.ts +++ b/fluxer_api/src/api/auth/tests/EmailVerificationFlow.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -10,7 +7,10 @@ import { findLastTestEmail, listTestEmails, loginAccount, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface UserPrivateResponse { verified: boolean; diff --git a/fluxer_api/src/api/auth/tests/EmailVerificationSuspiciousFlags.test.ts b/fluxer_api/src/api/auth/tests/EmailVerificationSuspiciousFlags.test.ts index 8d1d5e249..3e5b224ce 100644 --- a/fluxer_api/src/api/auth/tests/EmailVerificationSuspiciousFlags.test.ts +++ b/fluxer_api/src/api/auth/tests/EmailVerificationSuspiciousFlags.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {SuspiciousActivityFlags} from '@fluxer/constants/src/UserConstants'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, createTestAccount, findLastTestEmail, listTestEmails, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {SuspiciousActivityFlags} from '@fluxer/constants/src/UserConstants'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface SuspiciousActivityErrorResponse { error: string; diff --git a/fluxer_api/src/api/auth/tests/EmailVerificationUtils.test.ts b/fluxer_api/src/api/auth/tests/EmailVerificationUtils.test.ts index 3855de6ea..053868c9c 100644 --- a/fluxer_api/src/api/auth/tests/EmailVerificationUtils.test.ts +++ b/fluxer_api/src/api/auth/tests/EmailVerificationUtils.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type EmailVerificationRequiredReason, requireEmailVerified} from '@app/api/auth/EmailVerificationUtils'; import {type APIErrorCode, APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {describe, expect, it} from 'vitest'; -import {type EmailVerificationRequiredReason, requireEmailVerified} from '../EmailVerificationUtils'; const ReasonCodeCases: Array<[EmailVerificationRequiredReason, APIErrorCode]> = [ ['direct_message', APIErrorCodes.DIRECT_MESSAGE_EMAIL_VERIFICATION_REQUIRED], diff --git a/fluxer_api/src/api/auth/tests/IPAuthBypassFlags.test.ts b/fluxer_api/src/api/auth/tests/IPAuthBypassFlags.test.ts index 4bcad6adc..f6099b6c0 100644 --- a/fluxer_api/src/api/auth/tests/IPAuthBypassFlags.test.ts +++ b/fluxer_api/src/api/auth/tests/IPAuthBypassFlags.test.ts @@ -1,9 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createAuthHarness, + createUniqueEmail, + createUniqueUsername, + registerUser, +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createUniqueEmail, createUniqueUsername, registerUser} from './AuthTestUtils'; describe('Auth IP Authorization Bypass Flags', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/IPAuthFlow.test.ts b/fluxer_api/src/api/auth/tests/IPAuthFlow.test.ts index 90705a3b8..e8a0be7be 100644 --- a/fluxer_api/src/api/auth/tests/IPAuthFlow.test.ts +++ b/fluxer_api/src/api/auth/tests/IPAuthFlow.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -11,7 +8,10 @@ import { findLastTestEmail, listTestEmails, registerUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Auth IP Authorization Flow', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/IPAuthMultipleIPs.test.ts b/fluxer_api/src/api/auth/tests/IPAuthMultipleIPs.test.ts index 51f5dd5bc..b01d4410e 100644 --- a/fluxer_api/src/api/auth/tests/IPAuthMultipleIPs.test.ts +++ b/fluxer_api/src/api/auth/tests/IPAuthMultipleIPs.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -10,7 +7,10 @@ import { createUniqueUsername, listTestEmails, registerUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Auth IP Authorization Multiple IPs', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/IPAuthPoll.test.ts b/fluxer_api/src/api/auth/tests/IPAuthPoll.test.ts index cb2eb56b6..c07db02ef 100644 --- a/fluxer_api/src/api/auth/tests/IPAuthPoll.test.ts +++ b/fluxer_api/src/api/auth/tests/IPAuthPoll.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { createAuthHarness, createUniqueEmail, createUniqueTestId, createUniqueUsername, registerUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Auth IP Authorization Poll', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/IPAuthResend.test.ts b/fluxer_api/src/api/auth/tests/IPAuthResend.test.ts index 9be62c92d..c9d070c2e 100644 --- a/fluxer_api/src/api/auth/tests/IPAuthResend.test.ts +++ b/fluxer_api/src/api/auth/tests/IPAuthResend.test.ts @@ -1,10 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -12,7 +7,12 @@ import { createUniqueUsername, listTestEmails, registerUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; const HTTP_TOO_MANY_REQUESTS = 429; diff --git a/fluxer_api/src/api/auth/tests/IPAuthStream.test.ts b/fluxer_api/src/api/auth/tests/IPAuthStream.test.ts index 7cedd9a48..dfcc00623 100644 --- a/fluxer_api/src/api/auth/tests/IPAuthStream.test.ts +++ b/fluxer_api/src/api/auth/tests/IPAuthStream.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { createAuthHarness, createUniqueEmail, createUniqueTestId, createUniqueUsername, registerUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Auth IP Authorization Poll', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/IPAuthTicket.test.ts b/fluxer_api/src/api/auth/tests/IPAuthTicket.test.ts index 978f5cbb6..7dab7e024 100644 --- a/fluxer_api/src/api/auth/tests/IPAuthTicket.test.ts +++ b/fluxer_api/src/api/auth/tests/IPAuthTicket.test.ts @@ -1,9 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createAuthHarness, + createUniqueEmail, + createUniqueUsername, + registerUser, +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createUniqueEmail, createUniqueUsername, registerUser} from './AuthTestUtils'; describe('Auth IP Authorization Ticket', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/IPAuthTokenValidation.test.ts b/fluxer_api/src/api/auth/tests/IPAuthTokenValidation.test.ts index c07a72782..d07610407 100644 --- a/fluxer_api/src/api/auth/tests/IPAuthTokenValidation.test.ts +++ b/fluxer_api/src/api/auth/tests/IPAuthTokenValidation.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -10,7 +7,10 @@ import { createUniqueUsername, listTestEmails, registerUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Auth IP Authorization Token Validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/InboundChallengeUnconfigured.test.ts b/fluxer_api/src/api/auth/tests/InboundChallengeUnconfigured.test.ts index 77a3f2313..01045ed34 100644 --- a/fluxer_api/src/api/auth/tests/InboundChallengeUnconfigured.test.ts +++ b/fluxer_api/src/api/auth/tests/InboundChallengeUnconfigured.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {getConfig} from '@app/api/Config'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {getConfig} from '../../Config'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; describe('Inbound SMS challenge without a receiving number', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/LoginAndSessions.test.ts b/fluxer_api/src/api/auth/tests/LoginAndSessions.test.ts index 5bfa4f1d3..17dbbc0d3 100644 --- a/fluxer_api/src/api/auth/tests/LoginAndSessions.test.ts +++ b/fluxer_api/src/api/auth/tests/LoginAndSessions.test.ts @@ -1,9 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { createAuthHarness, createFakeAuthToken, @@ -11,7 +7,11 @@ import { loginAccount, type TestAccount, type UserMeResponse, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Auth login and sessions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/LoginDisabledFlagRecovery.test.ts b/fluxer_api/src/api/auth/tests/LoginDisabledFlagRecovery.test.ts index 696414ef6..c41d3af3d 100644 --- a/fluxer_api/src/api/auth/tests/LoginDisabledFlagRecovery.test.ts +++ b/fluxer_api/src/api/auth/tests/LoginDisabledFlagRecovery.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; interface DataExistsResponse { user_exists: boolean; diff --git a/fluxer_api/src/api/auth/tests/LoginInvalidCredentials.test.ts b/fluxer_api/src/api/auth/tests/LoginInvalidCredentials.test.ts index c545433e1..12fe9429f 100644 --- a/fluxer_api/src/api/auth/tests/LoginInvalidCredentials.test.ts +++ b/fluxer_api/src/api/auth/tests/LoginInvalidCredentials.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; describe('Auth login invalid credentials', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/LoginInviteAutoJoin.test.ts b/fluxer_api/src/api/auth/tests/LoginInviteAutoJoin.test.ts index 924e17f5c..39a157c14 100644 --- a/fluxer_api/src/api/auth/tests/LoginInviteAutoJoin.test.ts +++ b/fluxer_api/src/api/auth/tests/LoginInviteAutoJoin.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, loginAccount, loginUser} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, loginAccount, loginUser} from './AuthTestUtils'; describe('Auth login with invite code auto-join', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/LoginInviteInvalidCode.test.ts b/fluxer_api/src/api/auth/tests/LoginInviteInvalidCode.test.ts index 1a1023a91..37916e7d0 100644 --- a/fluxer_api/src/api/auth/tests/LoginInviteInvalidCode.test.ts +++ b/fluxer_api/src/api/auth/tests/LoginInviteInvalidCode.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, loginUser} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, loginUser} from './AuthTestUtils'; describe('Auth login with invalid invite code', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/LoginSelfDeletedRecovery.test.ts b/fluxer_api/src/api/auth/tests/LoginSelfDeletedRecovery.test.ts index 444ac48b2..3a83e67ef 100644 --- a/fluxer_api/src/api/auth/tests/LoginSelfDeletedRecovery.test.ts +++ b/fluxer_api/src/api/auth/tests/LoginSelfDeletedRecovery.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; interface DataExistsResponse { user_exists: boolean; diff --git a/fluxer_api/src/api/auth/tests/MfaBackupCodeLogin.test.ts b/fluxer_api/src/api/auth/tests/MfaBackupCodeLogin.test.ts index a9f47c945..e24ace50e 100644 --- a/fluxer_api/src/api/auth/tests/MfaBackupCodeLogin.test.ts +++ b/fluxer_api/src/api/auth/tests/MfaBackupCodeLogin.test.ts @@ -1,9 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { createAuthHarness, createTestAccount, @@ -12,7 +8,11 @@ import { loginUser, type TestAccount, totpCodeNow, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface BackupCodeEntry { code: string; diff --git a/fluxer_api/src/api/auth/tests/MfaConsistency.test.ts b/fluxer_api/src/api/auth/tests/MfaConsistency.test.ts index 6221d33a2..3970ab55c 100644 --- a/fluxer_api/src/api/auth/tests/MfaConsistency.test.ts +++ b/fluxer_api/src/api/auth/tests/MfaConsistency.test.ts @@ -1,12 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../../user/repositories/UserRepository'; -import {createTestAccount, createTotpSecret, generateTotpCode, type TestAccount} from './AuthTestUtils'; +import { + createTestAccount, + createTotpSecret, + generateTotpCode, + type TestAccount, +} from '@app/api/auth/tests/AuthTestUtils'; import { createAuthenticationResponse, createRegistrationResponse, @@ -14,7 +13,13 @@ import { type WebAuthnAuthenticationOptions, type WebAuthnDevice, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; interface BackupCodesResponse { backup_codes: Array<{ diff --git a/fluxer_api/src/api/auth/tests/MfaEmailVerificationRequired.test.ts b/fluxer_api/src/api/auth/tests/MfaEmailVerificationRequired.test.ts index b634c359e..723b7d0f6 100644 --- a/fluxer_api/src/api/auth/tests/MfaEmailVerificationRequired.test.ts +++ b/fluxer_api/src/api/auth/tests/MfaEmailVerificationRequired.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, createTotpSecret, totpCodeNow} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, createTotpSecret, totpCodeNow} from './AuthTestUtils'; interface ErrorResponse { code: string; diff --git a/fluxer_api/src/api/auth/tests/MfaEndpoints.test.ts b/fluxer_api/src/api/auth/tests/MfaEndpoints.test.ts index f8479610d..1ab4f6739 100644 --- a/fluxer_api/src/api/auth/tests/MfaEndpoints.test.ts +++ b/fluxer_api/src/api/auth/tests/MfaEndpoints.test.ts @@ -1,9 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { type BackupCodesResponse, createAuthHarness, @@ -11,7 +7,11 @@ import { createTotpSecret, totpCodeNow, type UserMeResponse, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface ValidationErrorResponse { code: string; diff --git a/fluxer_api/src/api/auth/tests/MfaTotpFlag.test.ts b/fluxer_api/src/api/auth/tests/MfaTotpFlag.test.ts index 96495ff31..8dd414bc1 100644 --- a/fluxer_api/src/api/auth/tests/MfaTotpFlag.test.ts +++ b/fluxer_api/src/api/auth/tests/MfaTotpFlag.test.ts @@ -1,9 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + type BackupCodesResponse, + createAuthHarness, + createTestAccount, + totpCodeNow, +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {type BackupCodesResponse, createAuthHarness, createTestAccount, totpCodeNow} from './AuthTestUtils'; describe('Auth MFA TOTP flag matches authenticator types', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/MfaTotpWithoutSecret.test.ts b/fluxer_api/src/api/auth/tests/MfaTotpWithoutSecret.test.ts index dcf3d56dc..610d8a04f 100644 --- a/fluxer_api/src/api/auth/tests/MfaTotpWithoutSecret.test.ts +++ b/fluxer_api/src/api/auth/tests/MfaTotpWithoutSecret.test.ts @@ -1,11 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createAuthHarness, + createTestAccount, + createTotpSecret, + generateTotpCode, + seedMfaTicket, +} from '@app/api/auth/tests/AuthTestUtils'; +import { + createRegistrationResponse, + createWebAuthnDevice, + type WebAuthnRegistrationOptions, +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, createTotpSecret, generateTotpCode, seedMfaTicket} from './AuthTestUtils'; -import {createRegistrationResponse, createWebAuthnDevice, type WebAuthnRegistrationOptions} from './WebAuthnTestUtils'; describe('Auth MFA TOTP without secret', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/PasswordChange.test.ts b/fluxer_api/src/api/auth/tests/PasswordChange.test.ts index bab8e80ac..d2bf0d889 100644 --- a/fluxer_api/src/api/auth/tests/PasswordChange.test.ts +++ b/fluxer_api/src/api/auth/tests/PasswordChange.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -11,7 +8,10 @@ import { listTestEmails, loginAccount, loginUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface ValidationErrorResponse { code: string; diff --git a/fluxer_api/src/api/auth/tests/PasswordReset.test.ts b/fluxer_api/src/api/auth/tests/PasswordReset.test.ts index e7b573c6d..505dc3f1c 100644 --- a/fluxer_api/src/api/auth/tests/PasswordReset.test.ts +++ b/fluxer_api/src/api/auth/tests/PasswordReset.test.ts @@ -1,9 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {generateUniquePassword, HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -12,7 +8,11 @@ import { type LoginSuccessResponse, listTestEmails, loginUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {generateUniquePassword, HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Password reset flow', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/PhoneVerificationFlow.test.ts b/fluxer_api/src/api/auth/tests/PhoneVerificationFlow.test.ts index b4de62d39..550a6219d 100644 --- a/fluxer_api/src/api/auth/tests/PhoneVerificationFlow.test.ts +++ b/fluxer_api/src/api/auth/tests/PhoneVerificationFlow.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, createTotpSecret, totpCodeNow} from '@app/api/auth/tests/AuthTestUtils'; +import {getConfig} from '@app/api/Config'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {PublicUserFlags, SuspiciousActivityFlags, UserFlags} from '@fluxer/constants/src/UserConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {getConfig} from '../../Config'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, createTotpSecret, totpCodeNow} from './AuthTestUtils'; describe('Phone verification flow', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/PwnedPasswordCheck.test.ts b/fluxer_api/src/api/auth/tests/PwnedPasswordCheck.test.ts index f5b141925..e25546ded 100644 --- a/fluxer_api/src/api/auth/tests/PwnedPasswordCheck.test.ts +++ b/fluxer_api/src/api/auth/tests/PwnedPasswordCheck.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; +import type {ApiContext} from '@app/api/ApiContext'; +import {isPasswordPwned, resetPwnedPasswordCacheForTesting} from '@app/api/auth/AuthPassword'; +import {server} from '@app/api/test/msw/server'; import {delay, HttpResponse, http} from 'msw'; import {beforeEach, describe, expect, test} from 'vitest'; -import type {ApiContext} from '../../ApiContext'; -import {server} from '../../test/msw/server'; -import {isPasswordPwned, resetPwnedPasswordCacheForTesting} from '../AuthPassword'; const PWNED_PASSWORD = 'fluxer-prefix-592'; const SAFE_PASSWORD_SAME_PREFIX = 'fluxer-prefix-837'; diff --git a/fluxer_api/src/api/auth/tests/Registration.test.ts b/fluxer_api/src/api/auth/tests/Registration.test.ts index f6525ce47..220bc16ea 100644 --- a/fluxer_api/src/api/auth/tests/Registration.test.ts +++ b/fluxer_api/src/api/auth/tests/Registration.test.ts @@ -1,14 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; -import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import {getConfig} from '../../Config'; -import {getInstanceConfigRepository, getUserRepository} from '../../middleware/ServiceSingletons'; -import {torExitListCache} from '../../middleware/TorExitListCache'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { createAuthHarness, createUniqueEmail, @@ -18,7 +10,15 @@ import { registerUser, titleCaseEmail, type UserMeResponse, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {getConfig} from '@app/api/Config'; +import {getInstanceConfigRepository, getUserRepository} from '@app/api/middleware/ServiceSingletons'; +import {torExitListCache} from '@app/api/middleware/TorExitListCache'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; function bootstrapRegistrationBody(prefix: string): Record { return { diff --git a/fluxer_api/src/api/auth/tests/RegistrationInviteAutoJoin.test.ts b/fluxer_api/src/api/auth/tests/RegistrationInviteAutoJoin.test.ts index 6926856e8..7d86c1482 100644 --- a/fluxer_api/src/api/auth/tests/RegistrationInviteAutoJoin.test.ts +++ b/fluxer_api/src/api/auth/tests/RegistrationInviteAutoJoin.test.ts @@ -1,18 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {setInjectedRegistrationRiskEvaluator} from '../../middleware/ServiceMiddleware'; -import { - RecommendedAction, - RiskConfidence, - RiskDecisionMethod, - RiskLevel, - type RiskLevel as RiskLevelType, -} from '../../risk/RiskTypes'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import type {IRegistrationRiskEvaluator} from '../services/IRegistrationRiskEvaluator'; +import type {IRegistrationRiskEvaluator} from '@app/api/auth/services/IRegistrationRiskEvaluator'; import { createAuthHarness, createTestAccount, @@ -20,7 +8,19 @@ import { createUniqueUsername, loginAccount, registerUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import {setInjectedRegistrationRiskEvaluator} from '@app/api/middleware/ServiceMiddleware'; +import { + RecommendedAction, + RiskConfidence, + RiskDecisionMethod, + RiskLevel, + type RiskLevel as RiskLevelType, +} from '@app/api/risk/RiskTypes'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; function createStaticRiskEvaluator(params: { level: RiskLevelType; diff --git a/fluxer_api/src/api/auth/tests/RegistrationPolicy.test.ts b/fluxer_api/src/api/auth/tests/RegistrationPolicy.test.ts index 671fd4aaa..c16a28c87 100644 --- a/fluxer_api/src/api/auth/tests/RegistrationPolicy.test.ts +++ b/fluxer_api/src/api/auth/tests/RegistrationPolicy.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createUniqueEmail, createUniqueUsername} from '@app/api/auth/tests/AuthTestUtils'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {getInstanceConfigRepository} from '../../middleware/ServiceSingletons'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createUniqueEmail, createUniqueUsername} from './AuthTestUtils'; interface PendingRegistrationResponse { registration_pending_approval: true; diff --git a/fluxer_api/src/api/auth/tests/RegistrationValidation.test.ts b/fluxer_api/src/api/auth/tests/RegistrationValidation.test.ts index 574ac3389..abdef0e53 100644 --- a/fluxer_api/src/api/auth/tests/RegistrationValidation.test.ts +++ b/fluxer_api/src/api/auth/tests/RegistrationValidation.test.ts @@ -1,9 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createAuthHarness, + createTestAccount, + createUniqueEmail, + createUniqueUsername, +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, createUniqueEmail, createUniqueUsername} from './AuthTestUtils'; interface ValidationErrorResponse { code: string; diff --git a/fluxer_api/src/api/auth/tests/ResetPasswordRequiresMfa.test.ts b/fluxer_api/src/api/auth/tests/ResetPasswordRequiresMfa.test.ts index fa88b8da8..cd3b99887 100644 --- a/fluxer_api/src/api/auth/tests/ResetPasswordRequiresMfa.test.ts +++ b/fluxer_api/src/api/auth/tests/ResetPasswordRequiresMfa.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -11,7 +8,10 @@ import { listTestEmails, type TestEmailRecord, totpCodeNow, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface MfaRequiredResponse { mfa: true; diff --git a/fluxer_api/src/api/auth/tests/SecurityFlagsSuspiciousActivity.test.ts b/fluxer_api/src/api/auth/tests/SecurityFlagsSuspiciousActivity.test.ts index 618ee6c74..ee92f049e 100644 --- a/fluxer_api/src/api/auth/tests/SecurityFlagsSuspiciousActivity.test.ts +++ b/fluxer_api/src/api/auth/tests/SecurityFlagsSuspiciousActivity.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount, loginUser} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, loginUser} from './AuthTestUtils'; interface UserPrivateResponse { required_actions: Array | null; diff --git a/fluxer_api/src/api/auth/tests/SettingsDefaults.test.ts b/fluxer_api/src/api/auth/tests/SettingsDefaults.test.ts index 095f20757..46725626a 100644 --- a/fluxer_api/src/api/auth/tests/SettingsDefaults.test.ts +++ b/fluxer_api/src/api/auth/tests/SettingsDefaults.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; import { createAuthHarness, createTestAccount, @@ -9,7 +7,9 @@ import { createUniqueUsername, fetchSettings, registerUser, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('User settings defaults', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/SsoFlow.test.ts b/fluxer_api/src/api/auth/tests/SsoFlow.test.ts index 2b8e11227..489c5c16e 100644 --- a/fluxer_api/src/api/auth/tests/SsoFlow.test.ts +++ b/fluxer_api/src/api/auth/tests/SsoFlow.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; import { createAuthHarness, createTestAccount, @@ -11,7 +8,10 @@ import { enableSso, setUserACLs, type TestAccount, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface SsoStartResponse { authorization_url: string; diff --git a/fluxer_api/src/api/auth/tests/SudoModeNegativeCases.test.ts b/fluxer_api/src/api/auth/tests/SudoModeNegativeCases.test.ts index ba8c8b494..0322cd3dd 100644 --- a/fluxer_api/src/api/auth/tests/SudoModeNegativeCases.test.ts +++ b/fluxer_api/src/api/auth/tests/SudoModeNegativeCases.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomBytes} from 'node:crypto'; +import {createAuthHarness, createTestAccount, loginUser, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {TotpGenerator} from '@app/api/utils/TotpGenerator'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {TotpGenerator} from '../../utils/TotpGenerator'; -import {createAuthHarness, createTestAccount, loginUser, type TestAccount} from './AuthTestUtils'; const SUDO_MODE_HEADER = 'X-Fluxer-Sudo-Mode-JWT'; diff --git a/fluxer_api/src/api/auth/tests/SudoVerificationCredentials.test.ts b/fluxer_api/src/api/auth/tests/SudoVerificationCredentials.test.ts index 55280e881..12402a10e 100644 --- a/fluxer_api/src/api/auth/tests/SudoVerificationCredentials.test.ts +++ b/fluxer_api/src/api/auth/tests/SudoVerificationCredentials.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {userHasMfa} from '@app/api/auth/services/SudoMethods'; +import {hasNoVerifiableCredential} from '@app/api/auth/services/SudoVerificationService'; +import {createUserID} from '@app/api/BrandedTypes'; +import {EMPTY_USER_ROW, type UserRow} from '@app/api/database/types/UserTypes'; +import {User} from '@app/api/models/User'; import {UserAuthenticatorTypes} from '@fluxer/constants/src/UserConstants'; import {describe, expect, it} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import {EMPTY_USER_ROW, type UserRow} from '../../database/types/UserTypes'; -import {User} from '../../models/User'; -import {userHasMfa} from '../services/SudoMethods'; -import {hasNoVerifiableCredential} from '../services/SudoVerificationService'; function createUser(overrides: Partial = {}): User { return new User({ diff --git a/fluxer_api/src/api/auth/tests/TokenValidation.test.ts b/fluxer_api/src/api/auth/tests/TokenValidation.test.ts index 8259e0280..00db9024e 100644 --- a/fluxer_api/src/api/auth/tests/TokenValidation.test.ts +++ b/fluxer_api/src/api/auth/tests/TokenValidation.test.ts @@ -1,10 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createAuthHarness, + createFakeAuthToken, + createTestAccount, + type UserMeResponse, +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createFakeAuthToken, createTestAccount, type UserMeResponse} from './AuthTestUtils'; describe('Auth token validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/UnclaimedAccountRestrictions.test.ts b/fluxer_api/src/api/auth/tests/UnclaimedAccountRestrictions.test.ts index 2d999f3f2..4d5c2b80e 100644 --- a/fluxer_api/src/api/auth/tests/UnclaimedAccountRestrictions.test.ts +++ b/fluxer_api/src/api/auth/tests/UnclaimedAccountRestrictions.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; -import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; +import {createTestAccount, unclaimAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannelInvite, @@ -11,11 +8,14 @@ import { createFriendship, createGuild, sendMessage, -} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createTestAccount, unclaimAccount} from './AuthTestUtils'; +} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; +import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; async function setBotFlag(harness: ApiTestHarness, userId: string, isBot: boolean): Promise { await createBuilder(harness, '').post(`/test/users/${userId}/set-bot-flag`).body({is_bot: isBot}).execute(); diff --git a/fluxer_api/src/api/auth/tests/UnclaimedClaimFlow.test.ts b/fluxer_api/src/api/auth/tests/UnclaimedClaimFlow.test.ts index 8ac9e8daf..d7f1b5759 100644 --- a/fluxer_api/src/api/auth/tests/UnclaimedClaimFlow.test.ts +++ b/fluxer_api/src/api/auth/tests/UnclaimedClaimFlow.test.ts @@ -1,9 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; import { clearTestEmails, createAuthHarness, @@ -12,7 +8,11 @@ import { findLastTestEmail, listTestEmails, unclaimAccount, -} from './AuthTestUtils'; +} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface EmailChangeStartResponse { ticket: string; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnAuthenticationReplay.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnAuthenticationReplay.test.ts index dde8bc374..453b49994 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnAuthenticationReplay.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnAuthenticationReplay.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createAuthenticationResponse, createRegistrationResponse, @@ -12,7 +9,10 @@ import { generateTotpCode, type WebAuthnAuthenticationOptions, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('WebAuthn authentication replay', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnAuthenticationWrongChallenge.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnAuthenticationWrongChallenge.test.ts index e13750bbb..741fee016 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnAuthenticationWrongChallenge.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnAuthenticationWrongChallenge.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createAuthenticationResponse, createRegistrationResponse, @@ -12,7 +9,10 @@ import { generateTotpCode, type WebAuthnAuthenticationOptions, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; describe('WebAuthn authentication wrong challenge', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnCredentialDelete.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnCredentialDelete.test.ts index ebb5eb430..3b6827203 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnCredentialDelete.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnCredentialDelete.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createAuthenticationResponse, createRegistrationResponse, @@ -13,7 +10,10 @@ import { type WebAuthnAuthenticationOptions, type WebAuthnCredentialMetadata, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('WebAuthn credential delete', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnCredentialList.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnCredentialList.test.ts index f3c47a7cc..9c572aea8 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnCredentialList.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnCredentialList.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createRegistrationResponse, createTotpSecret, @@ -11,7 +8,10 @@ import { generateTotpCode, type WebAuthnCredentialMetadata, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('WebAuthn credential list', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnCredentialRegister.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnCredentialRegister.test.ts index 1ffac58d3..c8e17e3ee 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnCredentialRegister.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnCredentialRegister.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createRegistrationResponse, createTotpSecret, @@ -11,7 +8,10 @@ import { generateTotpCode, type WebAuthnCredentialMetadata, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('WebAuthn credential registration', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnCredentialRename.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnCredentialRename.test.ts index 7f27a708b..854d8b5c8 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnCredentialRename.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnCredentialRename.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createRegistrationResponse, createTotpSecret, @@ -11,7 +8,10 @@ import { generateTotpCode, type WebAuthnCredentialMetadata, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('WebAuthn credential rename', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnErrorLocalization.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnErrorLocalization.test.ts index 9f974a4a7..f79e8c649 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnErrorLocalization.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnErrorLocalization.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createRegistrationResponse, createTotpSecret, createWebAuthnDevice, generateTotpCode, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('WebAuthn error localization', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnMfaConsistency.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnMfaConsistency.test.ts index 4e5efce46..9f358afff 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnMfaConsistency.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnMfaConsistency.test.ts @@ -1,10 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, createTotpSecret, generateTotpCode} from '@app/api/auth/tests/AuthTestUtils'; +import { + createAuthenticationResponse, + createRegistrationResponse, + createWebAuthnDevice, +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createTestAccount, createTotpSecret, generateTotpCode} from './AuthTestUtils'; -import {createAuthenticationResponse, createRegistrationResponse, createWebAuthnDevice} from './WebAuthnTestUtils'; interface BackupCodesResponse { backup_codes: Array<{ diff --git a/fluxer_api/src/api/auth/tests/WebAuthnMfaLogin.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnMfaLogin.test.ts index 2eca380d3..4266190e9 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnMfaLogin.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnMfaLogin.test.ts @@ -1,9 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount, type LoginMfaResponse, loginUser} from './AuthTestUtils'; +import { + createAuthHarness, + createTestAccount, + type LoginMfaResponse, + loginUser, +} from '@app/api/auth/tests/AuthTestUtils'; import { createAuthenticationResponse, createRegistrationResponse, @@ -12,7 +14,10 @@ import { generateTotpCode, type WebAuthnAuthenticationOptions, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('WebAuthn MFA login', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnPasswordlessLogin.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnPasswordlessLogin.test.ts index 92c878a97..b8ee45faf 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnPasswordlessLogin.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnPasswordlessLogin.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createAuthenticationResponse, createRegistrationResponse, @@ -12,7 +9,10 @@ import { generateTotpCode, type WebAuthnAuthenticationOptions, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('WebAuthn passwordless login', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnRegistrationUserHandle.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnRegistrationUserHandle.test.ts index 046c8f2c8..f05171752 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnRegistrationUserHandle.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnRegistrationUserHandle.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createTotpSecret, decodeBase64URL, generateTotpCode, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('WebAuthn registration user handle', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnUserVerificationRequired.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnUserVerificationRequired.test.ts index 380ce287c..161c8da5a 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnUserVerificationRequired.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnUserVerificationRequired.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createAuthHarness, createTestAccount} from './AuthTestUtils'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createAuthenticationResponseWithoutUV, createRegistrationResponse, @@ -12,7 +9,10 @@ import { generateTotpCode, type WebAuthnAuthenticationOptions, type WebAuthnRegistrationOptions, -} from './WebAuthnTestUtils'; +} from '@app/api/auth/tests/WebAuthnTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('WebAuthn user verification required', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/auth/tests/WebAuthnValidation.test.ts b/fluxer_api/src/api/auth/tests/WebAuthnValidation.test.ts index d24a0d8b5..6c2265d71 100644 --- a/fluxer_api/src/api/auth/tests/WebAuthnValidation.test.ts +++ b/fluxer_api/src/api/auth/tests/WebAuthnValidation.test.ts @@ -1,3 +1,4 @@ +import {Validator} from '@app/api/Validator'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import { WebAuthnAuthenticateRequest, @@ -11,7 +12,6 @@ import { import {Hono} from 'hono'; import {describe, expect, it} from 'vitest'; import type {ZodType} from 'zod'; -import {Validator} from '../../Validator'; const credential = { id: 'credential-id', diff --git a/fluxer_api/src/api/billing/mappers/StripeToBillingMapper.test.ts b/fluxer_api/src/api/billing/mappers/StripeToBillingMapper.test.ts index 259f8e31c..8ecace227 100644 --- a/fluxer_api/src/api/billing/mappers/StripeToBillingMapper.test.ts +++ b/fluxer_api/src/api/billing/mappers/StripeToBillingMapper.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type Stripe from 'stripe'; -import {describe, expect, it} from 'vitest'; import { computeStripeUpdatedAt, mapStripeChargeToRow, @@ -19,7 +17,9 @@ import { type StripeSubscriptionPayload, safeMetadata, unixToDate, -} from './StripeToBillingMapper'; +} from '@app/api/billing/mappers/StripeToBillingMapper'; +import type Stripe from 'stripe'; +import {describe, expect, it} from 'vitest'; const NOW_UNIX = 1700000000; diff --git a/fluxer_api/src/api/billing/mappers/StripeToBillingMapper.ts b/fluxer_api/src/api/billing/mappers/StripeToBillingMapper.ts index c0d98f45f..1fc603d54 100644 --- a/fluxer_api/src/api/billing/mappers/StripeToBillingMapper.ts +++ b/fluxer_api/src/api/billing/mappers/StripeToBillingMapper.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type Stripe from 'stripe'; import type { BillingChargeByCustomerRow, BillingChargeRow, @@ -28,7 +27,8 @@ import type { BillingSubscriptionByCustomerRow, BillingSubscriptionByUserRow, BillingSubscriptionRow, -} from '../../database/types/BillingTypes'; +} from '@app/api/database/types/BillingTypes'; +import type Stripe from 'stripe'; type BillingSubscriptionItemValue = NonNullable[number]; type BillingSubscriptionRowWithRawItems = Omit & { diff --git a/fluxer_api/src/api/billing/repositories/BillingActionIntentRepository.ts b/fluxer_api/src/api/billing/repositories/BillingActionIntentRepository.ts index d02bdb33a..45dfd05c4 100644 --- a/fluxer_api/src/api/billing/repositories/BillingActionIntentRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingActionIntentRepository.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; +import {fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; import type { BillingActionIntentRow, BillingActionIntentStatus, BillingActionType, -} from '../../database/types/BillingTypes'; -import {BILLING_ACTION_INTENT_COLUMNS} from '../../database/types/BillingTypes'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import {BillingActionIntents} from '../../Tables'; +} from '@app/api/database/types/BillingTypes'; +import {BILLING_ACTION_INTENT_COLUMNS} from '@app/api/database/types/BillingTypes'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import {BillingActionIntents} from '@app/api/Tables'; const FETCH_BY_ID = BillingActionIntents.selectCql({ where: BillingActionIntents.where.eq('intent_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingChargeRepository.ts b/fluxer_api/src/api/billing/repositories/BillingChargeRepository.ts index 3cc619f7b..329fa32c1 100644 --- a/fluxer_api/src/api/billing/repositories/BillingChargeRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingChargeRepository.ts @@ -1,11 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapStripeChargeToRow} from '@app/api/billing/mappers/StripeToBillingMapper'; +import {isExistingNewer} from '@app/api/billing/repositories/BillingRepoHelpers'; +import { + fetchMany, + fetchOne, + fetchPage, + type PagedQueryResult, + upsertOne, +} from '@app/api/database/CassandraQueryExecution'; +import type {BillingChargeRow} from '@app/api/database/types/BillingTypes'; +import {BillingCharges, BillingChargesByCustomer} from '@app/api/Tables'; import type Stripe from 'stripe'; -import {fetchMany, fetchOne, fetchPage, type PagedQueryResult, upsertOne} from '../../database/CassandraQueryExecution'; -import type {BillingChargeRow} from '../../database/types/BillingTypes'; -import {BillingCharges, BillingChargesByCustomer} from '../../Tables'; -import {mapStripeChargeToRow} from '../mappers/StripeToBillingMapper'; -import {isExistingNewer} from './BillingRepoHelpers'; const FETCH_BY_ID = BillingCharges.selectCql({ where: BillingCharges.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingCheckoutSessionRepository.ts b/fluxer_api/src/api/billing/repositories/BillingCheckoutSessionRepository.ts index 600d463d4..eb1f1c321 100644 --- a/fluxer_api/src/api/billing/repositories/BillingCheckoutSessionRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingCheckoutSessionRepository.ts @@ -1,11 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapStripeCheckoutSessionToRow} from '@app/api/billing/mappers/StripeToBillingMapper'; +import {isExistingNewer} from '@app/api/billing/repositories/BillingRepoHelpers'; +import { + fetchMany, + fetchOne, + fetchPage, + type PagedQueryResult, + upsertOne, +} from '@app/api/database/CassandraQueryExecution'; +import type {BillingCheckoutSessionRow} from '@app/api/database/types/BillingTypes'; +import {BillingCheckoutSessions, BillingCheckoutSessionsByCustomer} from '@app/api/Tables'; import type Stripe from 'stripe'; -import {fetchMany, fetchOne, fetchPage, type PagedQueryResult, upsertOne} from '../../database/CassandraQueryExecution'; -import type {BillingCheckoutSessionRow} from '../../database/types/BillingTypes'; -import {BillingCheckoutSessions, BillingCheckoutSessionsByCustomer} from '../../Tables'; -import {mapStripeCheckoutSessionToRow} from '../mappers/StripeToBillingMapper'; -import {isExistingNewer} from './BillingRepoHelpers'; const FETCH_BY_ID = BillingCheckoutSessions.selectCql({ where: BillingCheckoutSessions.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingCustomerRepository.ts b/fluxer_api/src/api/billing/repositories/BillingCustomerRepository.ts index dfa65ee8a..f14a19f64 100644 --- a/fluxer_api/src/api/billing/repositories/BillingCustomerRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingCustomerRepository.ts @@ -1,13 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapStripeCustomerToRow} from '@app/api/billing/mappers/StripeToBillingMapper'; +import { + buildPatchFromRow, + executeBillingVersionedUpdate, + isExistingNewer, + rowsEquivalent, +} from '@app/api/billing/repositories/BillingRepoHelpers'; +import {fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {BillingCustomerRow} from '@app/api/database/types/BillingTypes'; +import {BILLING_CUSTOMER_COLUMNS} from '@app/api/database/types/BillingTypes'; +import {BillingCustomers, BillingCustomersByUserId} from '@app/api/Tables'; import type Stripe from 'stripe'; -import {fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import {Db} from '../../database/CassandraTypes'; -import type {BillingCustomerRow} from '../../database/types/BillingTypes'; -import {BILLING_CUSTOMER_COLUMNS} from '../../database/types/BillingTypes'; -import {BillingCustomers, BillingCustomersByUserId} from '../../Tables'; -import {mapStripeCustomerToRow} from '../mappers/StripeToBillingMapper'; -import {buildPatchFromRow, executeBillingVersionedUpdate, isExistingNewer, rowsEquivalent} from './BillingRepoHelpers'; const FETCH_BY_ID = BillingCustomers.selectCql({ where: BillingCustomers.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingDisputeRepository.ts b/fluxer_api/src/api/billing/repositories/BillingDisputeRepository.ts index 54650dc63..9c0cfb6fb 100644 --- a/fluxer_api/src/api/billing/repositories/BillingDisputeRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingDisputeRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapStripeDisputeToRow} from '@app/api/billing/mappers/StripeToBillingMapper'; +import {isExistingNewer} from '@app/api/billing/repositories/BillingRepoHelpers'; +import {fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {BillingDisputeRow} from '@app/api/database/types/BillingTypes'; +import {BillingDisputes, BillingDisputesByCharge} from '@app/api/Tables'; import type Stripe from 'stripe'; -import {fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import type {BillingDisputeRow} from '../../database/types/BillingTypes'; -import {BillingDisputes, BillingDisputesByCharge} from '../../Tables'; -import {mapStripeDisputeToRow} from '../mappers/StripeToBillingMapper'; -import {isExistingNewer} from './BillingRepoHelpers'; const FETCH_BY_ID = BillingDisputes.selectCql({ where: BillingDisputes.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingInvoiceRepository.ts b/fluxer_api/src/api/billing/repositories/BillingInvoiceRepository.ts index 406fe41fd..18732ec16 100644 --- a/fluxer_api/src/api/billing/repositories/BillingInvoiceRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingInvoiceRepository.ts @@ -1,18 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type Stripe from 'stripe'; -import {fetchMany, fetchOne, fetchPage, type PagedQueryResult, upsertOne} from '../../database/CassandraQueryExecution'; -import type {BillingInvoiceRow} from '../../database/types/BillingTypes'; -import {BILLING_INVOICE_COLUMNS} from '../../database/types/BillingTypes'; +import {mapStripeInvoiceToRow} from '@app/api/billing/mappers/StripeToBillingMapper'; +import type {BillingPaymentRepository} from '@app/api/billing/repositories/BillingPaymentRepository'; +import { + buildPatchFromRow, + executeBillingVersionedUpdate, + isExistingNewer, + rowsEquivalent, +} from '@app/api/billing/repositories/BillingRepoHelpers'; +import { + fetchMany, + fetchOne, + fetchPage, + type PagedQueryResult, + upsertOne, +} from '@app/api/database/CassandraQueryExecution'; +import type {BillingInvoiceRow} from '@app/api/database/types/BillingTypes'; +import {BILLING_INVOICE_COLUMNS} from '@app/api/database/types/BillingTypes'; import { BillingCustomersByUserId, BillingInvoices, BillingInvoicesByCustomer, BillingInvoicesBySubscription, -} from '../../Tables'; -import {mapStripeInvoiceToRow} from '../mappers/StripeToBillingMapper'; -import type {BillingPaymentRepository} from './BillingPaymentRepository'; -import {buildPatchFromRow, executeBillingVersionedUpdate, isExistingNewer, rowsEquivalent} from './BillingRepoHelpers'; +} from '@app/api/Tables'; +import type Stripe from 'stripe'; const FETCH_BY_ID = BillingInvoices.selectCql({ where: BillingInvoices.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingPaymentIntentRepository.ts b/fluxer_api/src/api/billing/repositories/BillingPaymentIntentRepository.ts index 72f9b2623..43ccd7592 100644 --- a/fluxer_api/src/api/billing/repositories/BillingPaymentIntentRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingPaymentIntentRepository.ts @@ -1,16 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type Stripe from 'stripe'; -import {fetchMany, fetchOne, fetchPage, type PagedQueryResult, upsertOne} from '../../database/CassandraQueryExecution'; -import type {BillingPaymentIntentRow} from '../../database/types/BillingTypes'; +import {mapStripePaymentIntentToRow} from '@app/api/billing/mappers/StripeToBillingMapper'; +import {isExistingNewer} from '@app/api/billing/repositories/BillingRepoHelpers'; +import { + fetchMany, + fetchOne, + fetchPage, + type PagedQueryResult, + upsertOne, +} from '@app/api/database/CassandraQueryExecution'; +import type {BillingPaymentIntentRow} from '@app/api/database/types/BillingTypes'; import { BillingPaymentIntents, BillingPaymentIntentsByCustomer, BillingPayments, BillingPaymentsByInvoice, -} from '../../Tables'; -import {mapStripePaymentIntentToRow} from '../mappers/StripeToBillingMapper'; -import {isExistingNewer} from './BillingRepoHelpers'; +} from '@app/api/Tables'; +import type Stripe from 'stripe'; const FETCH_BY_ID = BillingPaymentIntents.selectCql({ where: BillingPaymentIntents.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingPaymentMethodRepository.ts b/fluxer_api/src/api/billing/repositories/BillingPaymentMethodRepository.ts index 3533f654b..ed719da64 100644 --- a/fluxer_api/src/api/billing/repositories/BillingPaymentMethodRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingPaymentMethodRepository.ts @@ -1,13 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapStripePaymentMethodToRow} from '@app/api/billing/mappers/StripeToBillingMapper'; +import { + buildPatchFromRow, + executeBillingVersionedUpdate, + isExistingNewer, + rowsEquivalent, +} from '@app/api/billing/repositories/BillingRepoHelpers'; +import {fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {BillingPaymentMethodRow} from '@app/api/database/types/BillingTypes'; +import {BILLING_PAYMENT_METHOD_COLUMNS} from '@app/api/database/types/BillingTypes'; +import {BillingPaymentMethods, BillingPaymentMethodsByCustomer} from '@app/api/Tables'; import type Stripe from 'stripe'; -import {fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import {Db} from '../../database/CassandraTypes'; -import type {BillingPaymentMethodRow} from '../../database/types/BillingTypes'; -import {BILLING_PAYMENT_METHOD_COLUMNS} from '../../database/types/BillingTypes'; -import {BillingPaymentMethods, BillingPaymentMethodsByCustomer} from '../../Tables'; -import {mapStripePaymentMethodToRow} from '../mappers/StripeToBillingMapper'; -import {buildPatchFromRow, executeBillingVersionedUpdate, isExistingNewer, rowsEquivalent} from './BillingRepoHelpers'; const FETCH_BY_ID = BillingPaymentMethods.selectCql({ where: BillingPaymentMethods.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingPaymentRepository.ts b/fluxer_api/src/api/billing/repositories/BillingPaymentRepository.ts index 74f494129..d882a0d10 100644 --- a/fluxer_api/src/api/billing/repositories/BillingPaymentRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingPaymentRepository.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import type {BillingPaymentByInvoiceRow, BillingPaymentRow} from '../../database/types/BillingTypes'; -import {BillingPayments, BillingPaymentsByInvoice} from '../../Tables'; -import {isExistingNewer} from './BillingRepoHelpers'; +import {isExistingNewer} from '@app/api/billing/repositories/BillingRepoHelpers'; +import {fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {BillingPaymentByInvoiceRow, BillingPaymentRow} from '@app/api/database/types/BillingTypes'; +import {BillingPayments, BillingPaymentsByInvoice} from '@app/api/Tables'; const FETCH_BY_ID = BillingPayments.selectCql({ where: BillingPayments.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingPriceRepository.ts b/fluxer_api/src/api/billing/repositories/BillingPriceRepository.ts index a989181a6..4a0366929 100644 --- a/fluxer_api/src/api/billing/repositories/BillingPriceRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingPriceRepository.ts @@ -1,12 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapStripePriceToRow} from '@app/api/billing/mappers/StripeToBillingMapper'; +import { + buildPatchFromRow, + executeBillingVersionedUpdate, + isExistingNewer, + rowsEquivalent, +} from '@app/api/billing/repositories/BillingRepoHelpers'; +import {fetchOne, fetchPage, type PagedQueryResult} from '@app/api/database/CassandraQueryExecution'; +import type {BillingPriceRow} from '@app/api/database/types/BillingTypes'; +import {BILLING_PRICE_COLUMNS} from '@app/api/database/types/BillingTypes'; +import {BillingPrices} from '@app/api/Tables'; import type Stripe from 'stripe'; -import {fetchOne, fetchPage, type PagedQueryResult} from '../../database/CassandraQueryExecution'; -import type {BillingPriceRow} from '../../database/types/BillingTypes'; -import {BILLING_PRICE_COLUMNS} from '../../database/types/BillingTypes'; -import {BillingPrices} from '../../Tables'; -import {mapStripePriceToRow} from '../mappers/StripeToBillingMapper'; -import {buildPatchFromRow, executeBillingVersionedUpdate, isExistingNewer, rowsEquivalent} from './BillingRepoHelpers'; const FETCH_BY_ID = BillingPrices.selectCql({ where: BillingPrices.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingProductRepository.ts b/fluxer_api/src/api/billing/repositories/BillingProductRepository.ts index a83b2ae6a..2f8b23986 100644 --- a/fluxer_api/src/api/billing/repositories/BillingProductRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingProductRepository.ts @@ -1,12 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapStripeProductToRow} from '@app/api/billing/mappers/StripeToBillingMapper'; +import { + buildPatchFromRow, + executeBillingVersionedUpdate, + isExistingNewer, + rowsEquivalent, +} from '@app/api/billing/repositories/BillingRepoHelpers'; +import {fetchOne, fetchPage, type PagedQueryResult} from '@app/api/database/CassandraQueryExecution'; +import type {BillingProductRow} from '@app/api/database/types/BillingTypes'; +import {BILLING_PRODUCT_COLUMNS} from '@app/api/database/types/BillingTypes'; +import {BillingProducts} from '@app/api/Tables'; import type Stripe from 'stripe'; -import {fetchOne, fetchPage, type PagedQueryResult} from '../../database/CassandraQueryExecution'; -import type {BillingProductRow} from '../../database/types/BillingTypes'; -import {BILLING_PRODUCT_COLUMNS} from '../../database/types/BillingTypes'; -import {BillingProducts} from '../../Tables'; -import {mapStripeProductToRow} from '../mappers/StripeToBillingMapper'; -import {buildPatchFromRow, executeBillingVersionedUpdate, isExistingNewer, rowsEquivalent} from './BillingRepoHelpers'; const FETCH_BY_ID = BillingProducts.selectCql({ where: BillingProducts.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingRefundRepository.ts b/fluxer_api/src/api/billing/repositories/BillingRefundRepository.ts index 3c42999f7..8a59ac3ea 100644 --- a/fluxer_api/src/api/billing/repositories/BillingRefundRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingRefundRepository.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type Stripe from 'stripe'; -import {fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import type {BillingRefundRow} from '../../database/types/BillingTypes'; +import {mapStripeRefundToRow} from '@app/api/billing/mappers/StripeToBillingMapper'; +import {isExistingNewer} from '@app/api/billing/repositories/BillingRepoHelpers'; +import {fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {BillingRefundRow} from '@app/api/database/types/BillingTypes'; import { BillingRefunds, BillingRefundsByCharge, BillingRefundsByInvoice, BillingRefundsByPaymentIntent, -} from '../../Tables'; -import {mapStripeRefundToRow} from '../mappers/StripeToBillingMapper'; -import {isExistingNewer} from './BillingRepoHelpers'; +} from '@app/api/Tables'; +import type Stripe from 'stripe'; const FETCH_BY_ID = BillingRefunds.selectCql({ where: BillingRefunds.where.eq('provider_id'), diff --git a/fluxer_api/src/api/billing/repositories/BillingRepoHelpers.ts b/fluxer_api/src/api/billing/repositories/BillingRepoHelpers.ts index bddf98b22..c886804a8 100644 --- a/fluxer_api/src/api/billing/repositories/BillingRepoHelpers.ts +++ b/fluxer_api/src/api/billing/repositories/BillingRepoHelpers.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {upsertOne} from '../../database/CassandraQueryExecution'; -import type {ColumnName, DbOp, PatchObject, RowValue, Table} from '../../database/CassandraTypes'; -import {Db} from '../../database/CassandraTypes'; -import {buildPatchFromData} from '../../database/CassandraVersionedUpdate'; +import {upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {ColumnName, DbOp, PatchObject, RowValue, Table} from '@app/api/database/CassandraTypes'; +import {Db} from '@app/api/database/CassandraTypes'; +import {buildPatchFromData} from '@app/api/database/CassandraVersionedUpdate'; function deepEqual(a: unknown, b: unknown): boolean { if (a === b) return true; diff --git a/fluxer_api/src/api/billing/repositories/BillingRepository.ts b/fluxer_api/src/api/billing/repositories/BillingRepository.ts index c6348c505..4686340a9 100644 --- a/fluxer_api/src/api/billing/repositories/BillingRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingRepository.ts @@ -1,21 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {BillingActionIntentRepository} from '@app/api/billing/repositories/BillingActionIntentRepository'; +import {BillingChargeRepository} from '@app/api/billing/repositories/BillingChargeRepository'; +import {BillingCheckoutSessionRepository} from '@app/api/billing/repositories/BillingCheckoutSessionRepository'; +import {BillingCustomerRepository} from '@app/api/billing/repositories/BillingCustomerRepository'; +import {BillingDisputeRepository} from '@app/api/billing/repositories/BillingDisputeRepository'; +import {BillingInvoiceRepository} from '@app/api/billing/repositories/BillingInvoiceRepository'; +import {BillingPaymentIntentRepository} from '@app/api/billing/repositories/BillingPaymentIntentRepository'; +import {BillingPaymentMethodRepository} from '@app/api/billing/repositories/BillingPaymentMethodRepository'; +import {BillingPaymentRepository} from '@app/api/billing/repositories/BillingPaymentRepository'; +import {BillingPriceRepository} from '@app/api/billing/repositories/BillingPriceRepository'; +import {BillingProductRepository} from '@app/api/billing/repositories/BillingProductRepository'; +import {BillingRefundRepository} from '@app/api/billing/repositories/BillingRefundRepository'; +import {BillingSubscriptionRepository} from '@app/api/billing/repositories/BillingSubscriptionRepository'; +import {BillingWebhookEventRepository} from '@app/api/billing/repositories/BillingWebhookEventRepository'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import {BillingActionIntentRepository} from './BillingActionIntentRepository'; -import {BillingChargeRepository} from './BillingChargeRepository'; -import {BillingCheckoutSessionRepository} from './BillingCheckoutSessionRepository'; -import {BillingCustomerRepository} from './BillingCustomerRepository'; -import {BillingDisputeRepository} from './BillingDisputeRepository'; -import {BillingInvoiceRepository} from './BillingInvoiceRepository'; -import {BillingPaymentIntentRepository} from './BillingPaymentIntentRepository'; -import {BillingPaymentMethodRepository} from './BillingPaymentMethodRepository'; -import {BillingPaymentRepository} from './BillingPaymentRepository'; -import {BillingPriceRepository} from './BillingPriceRepository'; -import {BillingProductRepository} from './BillingProductRepository'; -import {BillingRefundRepository} from './BillingRefundRepository'; -import {BillingSubscriptionRepository} from './BillingSubscriptionRepository'; -import {BillingWebhookEventRepository} from './BillingWebhookEventRepository'; export class BillingRepository { readonly customers: BillingCustomerRepository; diff --git a/fluxer_api/src/api/billing/repositories/BillingSubscriptionRepository.test.ts b/fluxer_api/src/api/billing/repositories/BillingSubscriptionRepository.test.ts index dfdd7728f..cc81ae23c 100644 --- a/fluxer_api/src/api/billing/repositories/BillingSubscriptionRepository.test.ts +++ b/fluxer_api/src/api/billing/repositories/BillingSubscriptionRepository.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {StripeSubscriptionPayload} from '@app/api/billing/mappers/StripeToBillingMapper'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import type {StripeSubscriptionPayload} from '../mappers/StripeToBillingMapper'; const DAY_SECONDS = 24 * 60 * 60; diff --git a/fluxer_api/src/api/billing/repositories/BillingSubscriptionRepository.ts b/fluxer_api/src/api/billing/repositories/BillingSubscriptionRepository.ts index 09b871481..d6abfc188 100644 --- a/fluxer_api/src/api/billing/repositories/BillingSubscriptionRepository.ts +++ b/fluxer_api/src/api/billing/repositories/BillingSubscriptionRepository.ts @@ -1,16 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import type {BillingSubscriptionRow} from '../../database/types/BillingTypes'; -import {BILLING_SUBSCRIPTION_COLUMNS} from '../../database/types/BillingTypes'; -import {BillingSubscriptions, BillingSubscriptionsByCustomer, BillingSubscriptionsByUser} from '../../Tables'; import { type MapStripeSubscriptionHints, mapStripeSubscriptionToRow, normalizeBillingSubscriptionRow, type StripeSubscriptionPayload, -} from '../mappers/StripeToBillingMapper'; -import {buildPatchFromRow, executeBillingVersionedUpdate, isExistingNewer, rowsEquivalent} from './BillingRepoHelpers'; +} from '@app/api/billing/mappers/StripeToBillingMapper'; +import { + buildPatchFromRow, + executeBillingVersionedUpdate, + isExistingNewer, + rowsEquivalent, +} from '@app/api/billing/repositories/BillingRepoHelpers'; +import {fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {BillingSubscriptionRow} from '@app/api/database/types/BillingTypes'; +import {BILLING_SUBSCRIPTION_COLUMNS} from '@app/api/database/types/BillingTypes'; +import {BillingSubscriptions, BillingSubscriptionsByCustomer, BillingSubscriptionsByUser} from '@app/api/Tables'; const FETCH_BY_ID = BillingSubscriptions.selectCql({ where: BillingSubscriptions.where.eq('provider_id'), diff --git a/fluxer_api/src/api/bluesky/BlueskyOAuthController.ts b/fluxer_api/src/api/bluesky/BlueskyOAuthController.ts index 28c752686..6b04f9721 100644 --- a/fluxer_api/src/api/bluesky/BlueskyOAuthController.ts +++ b/fluxer_api/src/api/bluesky/BlueskyOAuthController.ts @@ -1,22 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {BlueskyOAuthStateInvalidError, BlueskyOAuthStoreError} from '@app/api/bluesky/BlueskyOAuthStores'; +import {DisabledBlueskyOAuthService} from '@app/api/bluesky/DisabledBlueskyOAuthService'; +import type {BlueskyAuthorizeResult, IBlueskyOAuthService} from '@app/api/bluesky/IBlueskyOAuthService'; +import {Config} from '@app/api/Config'; +import {BlueskyOAuthAuthorizationFailedError} from '@app/api/connection/errors/BlueskyOAuthAuthorizationFailedError'; +import {BlueskyOAuthNotEnabledError} from '@app/api/connection/errors/BlueskyOAuthNotEnabledError'; +import {Logger} from '@app/api/Logger'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {ConnectionRateLimitConfigs} from '@app/api/rate_limit_configs/ConnectionRateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import { BlueskyAuthorizeRequest, BlueskyAuthorizeResponse, } from '@fluxer/schema/src/domains/connection/BlueskyOAuthSchemas'; -import {Config} from '../Config'; -import {BlueskyOAuthAuthorizationFailedError} from '../connection/errors/BlueskyOAuthAuthorizationFailedError'; -import {BlueskyOAuthNotEnabledError} from '../connection/errors/BlueskyOAuthNotEnabledError'; -import {Logger} from '../Logger'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {ConnectionRateLimitConfigs} from '../rate_limit_configs/ConnectionRateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; -import {BlueskyOAuthStateInvalidError, BlueskyOAuthStoreError} from './BlueskyOAuthStores'; -import {DisabledBlueskyOAuthService} from './DisabledBlueskyOAuthService'; -import type {BlueskyAuthorizeResult, IBlueskyOAuthService} from './IBlueskyOAuthService'; const BLUESKY_PROFILE_URL_RE = /^https?:\/\/bsky\.app\/profile\//i; type BlueskyCallbackPhase = 'callback' | 'connection'; diff --git a/fluxer_api/src/api/bluesky/BlueskyOAuthService.test.ts b/fluxer_api/src/api/bluesky/BlueskyOAuthService.test.ts index 72611ab93..c59b8d886 100644 --- a/fluxer_api/src/api/bluesky/BlueskyOAuthService.test.ts +++ b/fluxer_api/src/api/bluesky/BlueskyOAuthService.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {generateKeyPairSync} from 'node:crypto'; +import {BlueskyOAuthService} from '@app/api/bluesky/BlueskyOAuthService'; +import type {BlueskyOAuthConfig} from '@app/api/config/APIConfig'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; import {describe, expect, it} from 'vitest'; -import type {BlueskyOAuthConfig} from '../config/APIConfig'; -import {MockKVProvider} from '../test/mocks/MockKVProvider'; -import {BlueskyOAuthService} from './BlueskyOAuthService'; const API_PUBLIC_ENDPOINT = 'https://chat.example.com'; diff --git a/fluxer_api/src/api/bluesky/BlueskyOAuthService.ts b/fluxer_api/src/api/bluesky/BlueskyOAuthService.ts index 9659c6fc7..c4e5e530c 100644 --- a/fluxer_api/src/api/bluesky/BlueskyOAuthService.ts +++ b/fluxer_api/src/api/bluesky/BlueskyOAuthService.ts @@ -3,6 +3,22 @@ import {randomUUID} from 'node:crypto'; import {readFile} from 'node:fs/promises'; import {isAbsolute} from 'node:path'; +import type {UserID} from '@app/api/BrandedTypes'; +import { + BlueskyOAuthStateInvalidError, + BlueskyOAuthStoreError, + createSessionStore, + createStateStore, + validateBlueskyGrantOwner, +} from '@app/api/bluesky/BlueskyOAuthStores'; +import type { + BlueskyAuthorizeResult, + BlueskyCallbackResult, + BlueskyOAuthGrantOwner, + IBlueskyOAuthService, +} from '@app/api/bluesky/IBlueskyOAuthService'; +import type {BlueskyOAuthConfig, BlueskyOAuthKeyConfig} from '@app/api/config/APIConfig'; +import {ConnectionCredentialRepository} from '@app/api/connection/ConnectionCredentialRepository'; import {Agent} from '@atproto/api'; import {JoseKey} from '@bluesky-social/jwk-jose'; import { @@ -14,22 +30,6 @@ import { requestLocalLock, } from '@bluesky-social/oauth-client-node'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {UserID} from '../BrandedTypes'; -import type {BlueskyOAuthConfig, BlueskyOAuthKeyConfig} from '../config/APIConfig'; -import {ConnectionCredentialRepository} from '../connection/ConnectionCredentialRepository'; -import { - BlueskyOAuthStateInvalidError, - BlueskyOAuthStoreError, - createSessionStore, - createStateStore, - validateBlueskyGrantOwner, -} from './BlueskyOAuthStores'; -import type { - BlueskyAuthorizeResult, - BlueskyCallbackResult, - BlueskyOAuthGrantOwner, - IBlueskyOAuthService, -} from './IBlueskyOAuthService'; interface BlueskyClientConfiguration { clientMetadata: OAuthClientMetadataInput; diff --git a/fluxer_api/src/api/bluesky/BlueskyOAuthStores.ts b/fluxer_api/src/api/bluesky/BlueskyOAuthStores.ts index ebbbe0a01..dbcb566d0 100644 --- a/fluxer_api/src/api/bluesky/BlueskyOAuthStores.ts +++ b/fluxer_api/src/api/bluesky/BlueskyOAuthStores.ts @@ -1,5 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import type {BlueskyOAuthGrantOwner} from '@app/api/bluesky/IBlueskyOAuthService'; +import type {ConnectionCredentialRepository} from '@app/api/connection/ConnectionCredentialRepository'; import { type AtprotoDid, type AtprotoOAuthScope, @@ -15,9 +18,6 @@ import { import {SnowflakeType} from '@fluxer/schema/src/primitives/SchemaPrimitives'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {z} from 'zod'; -import {createUserID} from '../BrandedTypes'; -import type {ConnectionCredentialRepository} from '../connection/ConnectionCredentialRepository'; -import type {BlueskyOAuthGrantOwner} from './IBlueskyOAuthService'; const STATE_LOCATOR_PREFIX = 'bsky:oauth:state_locator:'; diff --git a/fluxer_api/src/api/bluesky/DisabledBlueskyOAuthService.ts b/fluxer_api/src/api/bluesky/DisabledBlueskyOAuthService.ts index 7ff62df8f..1a8836f78 100644 --- a/fluxer_api/src/api/bluesky/DisabledBlueskyOAuthService.ts +++ b/fluxer_api/src/api/bluesky/DisabledBlueskyOAuthService.ts @@ -1,8 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import {BlueskyOAuthNotEnabledError} from '../connection/errors/BlueskyOAuthNotEnabledError'; -import type {BlueskyAuthorizeResult, BlueskyCallbackResult, IBlueskyOAuthService} from './IBlueskyOAuthService'; +import type {UserID} from '@app/api/BrandedTypes'; +import type { + BlueskyAuthorizeResult, + BlueskyCallbackResult, + IBlueskyOAuthService, +} from '@app/api/bluesky/IBlueskyOAuthService'; +import {BlueskyOAuthNotEnabledError} from '@app/api/connection/errors/BlueskyOAuthNotEnabledError'; export class DisabledBlueskyOAuthService implements IBlueskyOAuthService { readonly clientMetadata: Record = {}; diff --git a/fluxer_api/src/api/bluesky/IBlueskyOAuthService.ts b/fluxer_api/src/api/bluesky/IBlueskyOAuthService.ts index e05042fcc..e2f12f025 100644 --- a/fluxer_api/src/api/bluesky/IBlueskyOAuthService.ts +++ b/fluxer_api/src/api/bluesky/IBlueskyOAuthService.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; +import type {UserID} from '@app/api/BrandedTypes'; export interface BlueskyAuthorizeResult { authorizeUrl: string; diff --git a/fluxer_api/src/api/bot/tests/BotTestUtils.ts b/fluxer_api/src/api/bot/tests/BotTestUtils.ts index 0309f398e..f8f63f950 100644 --- a/fluxer_api/src/api/bot/tests/BotTestUtils.ts +++ b/fluxer_api/src/api/bot/tests/BotTestUtils.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {ApplicationResponse} from '@fluxer/schema/src/domains/oauth/OAuthSchemas'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface TestBotAccount { appId: string; diff --git a/fluxer_api/src/api/channel/ChannelController.ts b/fluxer_api/src/api/channel/ChannelController.ts index 7f6aa8bc0..b190662d4 100644 --- a/fluxer_api/src/api/channel/ChannelController.ts +++ b/fluxer_api/src/api/channel/ChannelController.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {HonoApp} from '../types/HonoEnv'; -import {registerChannelControllers} from './controllers/index'; +import {registerChannelControllers} from '@app/api/channel/controllers/index'; +import type {HonoApp} from '@app/api/types/HonoEnv'; export function ChannelController(app: HonoApp) { registerChannelControllers(app); diff --git a/fluxer_api/src/api/channel/ChannelMappers.ts b/fluxer_api/src/api/channel/ChannelMappers.ts index 99de7a524..fee8dbd00 100644 --- a/fluxer_api/src/api/channel/ChannelMappers.ts +++ b/fluxer_api/src/api/channel/ChannelMappers.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import {getCachedUserPartialResponses} from '@app/api/user/UserCacheHelpers'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import type { ChannelOverwriteResponse, ChannelPartialResponse, ChannelResponse, } from '@fluxer/schema/src/domains/channel/ChannelSchemas'; -import type {UserID} from '../BrandedTypes'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Channel} from '../models/Channel'; -import {getCachedUserPartialResponses} from '../user/UserCacheHelpers'; interface MapChannelToResponseParams { channel: Channel; diff --git a/fluxer_api/src/api/channel/ChannelRepository.ts b/fluxer_api/src/api/channel/ChannelRepository.ts index 694de31d9..1986ed7fd 100644 --- a/fluxer_api/src/api/channel/ChannelRepository.ts +++ b/fluxer_api/src/api/channel/ChannelRepository.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID, ChannelID, EmojiID, GuildID, MessageID, UserID} from '../BrandedTypes'; -import type {ChannelRow} from '../database/types/ChannelTypes'; -import type {MessageRow} from '../database/types/MessageTypes'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Channel} from '../models/Channel'; -import type {Message} from '../models/Message'; -import type {MessageReaction} from '../models/MessageReaction'; -import {IChannelRepository} from './IChannelRepository'; -import {ChannelRepository as NewChannelRepository} from './repositories/ChannelRepository'; +import type {AttachmentID, ChannelID, EmojiID, GuildID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {ChannelRepository as NewChannelRepository} from '@app/api/channel/repositories/ChannelRepository'; +import type {ChannelRow} from '@app/api/database/types/ChannelTypes'; +import type {MessageRow} from '@app/api/database/types/MessageTypes'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {MessageReaction} from '@app/api/models/MessageReaction'; export class ChannelRepository extends IChannelRepository { private repository: NewChannelRepository; diff --git a/fluxer_api/src/api/channel/IChannelRepository.ts b/fluxer_api/src/api/channel/IChannelRepository.ts index 15257f694..73b50566b 100644 --- a/fluxer_api/src/api/channel/IChannelRepository.ts +++ b/fluxer_api/src/api/channel/IChannelRepository.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID, ChannelID, EmojiID, GuildID, MessageID, UserID} from '../BrandedTypes'; -import type {ChannelRow} from '../database/types/ChannelTypes'; -import type {MessageRow} from '../database/types/MessageTypes'; -import type {Channel} from '../models/Channel'; -import type {Message} from '../models/Message'; -import type {MessageReaction} from '../models/MessageReaction'; -import {IChannelRepositoryAggregate} from './repositories/IChannelRepositoryAggregate'; +import type {AttachmentID, ChannelID, EmojiID, GuildID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {ChannelRow} from '@app/api/database/types/ChannelTypes'; +import type {MessageRow} from '@app/api/database/types/MessageTypes'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {MessageReaction} from '@app/api/models/MessageReaction'; export abstract class IChannelRepository extends IChannelRepositoryAggregate { abstract findUnique(channelId: ChannelID): Promise; diff --git a/fluxer_api/src/api/channel/MessageTypes.ts b/fluxer_api/src/api/channel/MessageTypes.ts index 1e4ce546d..e91e3b093 100644 --- a/fluxer_api/src/api/channel/MessageTypes.ts +++ b/fluxer_api/src/api/channel/MessageTypes.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AttachmentRequestData} from '@app/api/channel/AttachmentDTOs'; import type { MessageRequestSchemaType, MessageUpdateRequestSchemaType, } from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; -import type {AttachmentRequestData} from './AttachmentDTOs'; interface BaseMessageRequestType extends Omit {} diff --git a/fluxer_api/src/api/channel/PrivateChannelSnapshot.test.ts b/fluxer_api/src/api/channel/PrivateChannelSnapshot.test.ts index f06a042d6..c5088af52 100644 --- a/fluxer_api/src/api/channel/PrivateChannelSnapshot.test.ts +++ b/fluxer_api/src/api/channel/PrivateChannelSnapshot.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import {describe, expect, test} from 'vitest'; -import {createChannelID, createMessageID, createUserID} from '../BrandedTypes'; -import type {ChannelRow, PrivateChannelRow} from '../database/types/ChannelTypes'; +import {createChannelID, createMessageID, createUserID} from '@app/api/BrandedTypes'; import { channelRowFromPrivateChannelSnapshot, isPrivateChannelType, @@ -11,7 +8,10 @@ import { privateChannelHydrationPatch, privateChannelLastMessageIdPatch, privateChannelMetadataPatch, -} from './PrivateChannelSnapshot'; +} from '@app/api/channel/PrivateChannelSnapshot'; +import type {ChannelRow, PrivateChannelRow} from '@app/api/database/types/ChannelTypes'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; +import {describe, expect, test} from 'vitest'; const OWNER = createUserID(1n); const MEMBER_A = createUserID(2n); diff --git a/fluxer_api/src/api/channel/PrivateChannelSnapshot.ts b/fluxer_api/src/api/channel/PrivateChannelSnapshot.ts index db64a051c..90472201f 100644 --- a/fluxer_api/src/api/channel/PrivateChannelSnapshot.ts +++ b/fluxer_api/src/api/channel/PrivateChannelSnapshot.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {Db, type DbOp} from '@app/api/database/CassandraTypes'; +import type {ChannelRow, PrivateChannelRow} from '@app/api/database/types/ChannelTypes'; import {type ChannelType, ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import type {UserID} from '../BrandedTypes'; -import {Db, type DbOp} from '../database/CassandraTypes'; -import type {ChannelRow, PrivateChannelRow} from '../database/types/ChannelTypes'; type SnapshotPatch = Partial<{ is_gdm: DbOp; diff --git a/fluxer_api/src/api/channel/controllers/CallController.ts b/fluxer_api/src/api/channel/controllers/CallController.ts index f947c0c83..aff458d3f 100644 --- a/fluxer_api/src/api/channel/controllers/CallController.ts +++ b/fluxer_api/src/api/channel/controllers/CallController.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createUserID} from '@app/api/BrandedTypes'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {CallRingBodySchema, CallUpdateBodySchema} from '@fluxer/schema/src/domains/channel/ChannelRequestSchemas'; import {CallEligibilityResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import {ChannelIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createChannelID, createUserID} from '../../BrandedTypes'; -import {DefaultUserOnly, LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function CallController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/channel/controllers/ChannelController.ts b/fluxer_api/src/api/channel/controllers/ChannelController.ts index 176c8e1ab..246bba9c6 100644 --- a/fluxer_api/src/api/channel/controllers/ChannelController.ts +++ b/fluxer_api/src/api/channel/controllers/ChannelController.ts @@ -1,5 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireSudoMode} from '@app/api/auth/services/SudoVerificationService'; +import {createChannelID, createUserID} from '@app/api/BrandedTypes'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {GroupDmRecipientAddProtectionMiddleware} from '@app/api/middleware/GroupDmProtectionMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {SudoModeMiddleware} from '@app/api/middleware/SudoModeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp, HonoEnv} from '@app/api/types/HonoEnv'; +import {CLIENT_FEATURES_HEADER, parseClientFeaturesHeader} from '@app/api/utils/featureUtils'; +import {Validator} from '@app/api/Validator'; import {UnknownChannelError} from '@fluxer/errors/src/domains/channel/UnknownChannelError'; import {SudoVerificationSchema} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import { @@ -20,18 +31,6 @@ import { } from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import type {Context} from 'hono'; -import {requireSudoMode} from '../../auth/services/SudoVerificationService'; -import {createChannelID, createUserID} from '../../BrandedTypes'; -import {DefaultUserOnly, LoginRequired} from '../../middleware/AuthMiddleware'; -import {GroupDmRecipientAddProtectionMiddleware} from '../../middleware/GroupDmProtectionMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {SudoModeMiddleware} from '../../middleware/SudoModeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp, HonoEnv} from '../../types/HonoEnv'; -import {CLIENT_FEATURES_HEADER, parseClientFeaturesHeader} from '../../utils/featureUtils'; -import {Validator} from '../../Validator'; - function isPlainObject(value: unknown): value is Record { return typeof value === 'object' && value !== null && !Array.isArray(value); } diff --git a/fluxer_api/src/api/channel/controllers/MessageController.ts b/fluxer_api/src/api/channel/controllers/MessageController.ts index 870e3f892..187a63b17 100644 --- a/fluxer_api/src/api/channel/controllers/MessageController.ts +++ b/fluxer_api/src/api/channel/controllers/MessageController.ts @@ -1,5 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireSudoMode} from '@app/api/auth/services/SudoVerificationService'; +import {createAttachmentID, createChannelID, createMessageID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {MessageRequest, MessageUpdateRequest} from '@app/api/channel/MessageTypes'; +import {normalizeMessageRequestPayload} from '@app/api/channel/services/message/MessageRequestCompatibility'; +import {parseMultipartMessageData} from '@app/api/channel/services/message/MessageRequestParser'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {SudoModeMiddleware} from '@app/api/middleware/SudoModeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {parseJsonPreservingLargeIntegers} from '@app/api/utils/LosslessJsonParser'; +import {Validator} from '@app/api/Validator'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {requireClientIp} from '@fluxer/ip_utils/src/ClientIp'; @@ -30,21 +44,6 @@ import { MessageResponseSchema, } from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {requireSudoMode} from '../../auth/services/SudoVerificationService'; -import {createAttachmentID, createChannelID, createMessageID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {DefaultUserOnly, LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {SudoModeMiddleware} from '../../middleware/SudoModeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {parseJsonPreservingLargeIntegers} from '../../utils/LosslessJsonParser'; -import {Validator} from '../../Validator'; -import type {MessageRequest, MessageUpdateRequest} from '../MessageTypes'; -import {normalizeMessageRequestPayload} from '../services/message/MessageRequestCompatibility'; -import {parseMultipartMessageData} from '../services/message/MessageRequestParser'; - export function MessageController(app: HonoApp) { app.get( '/channels/:channel_id/messages', diff --git a/fluxer_api/src/api/channel/controllers/MessageInteractionController.ts b/fluxer_api/src/api/channel/controllers/MessageInteractionController.ts index 0bfe2d268..0150f7778 100644 --- a/fluxer_api/src/api/channel/controllers/MessageInteractionController.ts +++ b/fluxer_api/src/api/channel/controllers/MessageInteractionController.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import {isPersonalNotesChannel} from '@app/api/channel/services/message/MessageHelpers'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {UnclaimedAccountCannotAddReactionsError} from '@fluxer/errors/src/domains/channel/UnclaimedAccountCannotAddReactionsError'; @@ -20,15 +29,6 @@ import { ReactionUsersListResponse, ReactionUsersPageResponse, } from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {createChannelID, createMessageID, createUserID} from '../../BrandedTypes'; -import {SYSTEM_USER_ID} from '../../constants/Core'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; -import {isPersonalNotesChannel} from '../services/message/MessageHelpers'; export function MessageInteractionController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/channel/controllers/StreamController.ts b/fluxer_api/src/api/channel/controllers/StreamController.ts index 298be4910..954d30609 100644 --- a/fluxer_api/src/api/channel/controllers/StreamController.ts +++ b/fluxer_api/src/api/channel/controllers/StreamController.ts @@ -1,5 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {requireClientIp} from '@fluxer/ip_utils/src/ClientIp'; import { StreamPreviewResponse, @@ -9,14 +17,6 @@ import { StreamUpdateBodySchema, } from '@fluxer/schema/src/domains/channel/ChannelRequestSchemas'; import {StreamKeyParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createChannelID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {DefaultUserOnly, LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function StreamController(app: HonoApp) { app.patch( diff --git a/fluxer_api/src/api/channel/controllers/index.ts b/fluxer_api/src/api/channel/controllers/index.ts index ee48d4df6..a3da8b989 100644 --- a/fluxer_api/src/api/channel/controllers/index.ts +++ b/fluxer_api/src/api/channel/controllers/index.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {HonoApp} from '../../types/HonoEnv'; -import {CallController} from './CallController'; -import {ChannelController} from './ChannelController'; -import {MessageController} from './MessageController'; -import {MessageInteractionController} from './MessageInteractionController'; -import {StreamController} from './StreamController'; +import {CallController} from '@app/api/channel/controllers/CallController'; +import {ChannelController} from '@app/api/channel/controllers/ChannelController'; +import {MessageController} from '@app/api/channel/controllers/MessageController'; +import {MessageInteractionController} from '@app/api/channel/controllers/MessageInteractionController'; +import {StreamController} from '@app/api/channel/controllers/StreamController'; +import type {HonoApp} from '@app/api/types/HonoEnv'; export function registerChannelControllers(app: HonoApp) { ChannelController(app); diff --git a/fluxer_api/src/api/channel/repositories/ChannelDataRepository.test.ts b/fluxer_api/src/api/channel/repositories/ChannelDataRepository.test.ts index 2c7a7b812..9b6cb2b18 100644 --- a/fluxer_api/src/api/channel/repositories/ChannelDataRepository.test.ts +++ b/fluxer_api/src/api/channel/repositories/ChannelDataRepository.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createChannelID, createGuildID, createMessageID} from '@app/api/BrandedTypes'; +import {ChannelDataRepository} from '@app/api/channel/repositories/ChannelDataRepository'; +import {setCassandraQueryExecutorForTesting, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {CassandraParams, KvQueryMeta, PreparedQuery} from '@app/api/database/CassandraTypes'; +import type {ChannelRow} from '@app/api/database/types/ChannelTypes'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {Channel} from '@app/api/models/Channel'; +import {Channels} from '@app/api/Tables'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {type ChannelID, createChannelID, createGuildID, createMessageID} from '../../BrandedTypes'; -import {setCassandraQueryExecutorForTesting, upsertOne} from '../../database/CassandraQueryExecution'; -import type {CassandraParams, KvQueryMeta, PreparedQuery} from '../../database/CassandraTypes'; -import type {ChannelRow} from '../../database/types/ChannelTypes'; -import {createRequestCache} from '../../middleware/RequestCacheMiddleware'; -import {Channel} from '../../models/Channel'; -import {Channels} from '../../Tables'; -import {InMemoryCassandraQueryExecutor} from '../../test/InMemoryCassandraQueryExecutor'; -import {ChannelDataRepository} from './ChannelDataRepository'; class RecordingCassandraQueryExecutor { readonly statements: Array = []; diff --git a/fluxer_api/src/api/channel/repositories/ChannelDataRepository.ts b/fluxer_api/src/api/channel/repositories/ChannelDataRepository.ts index 9f3c85c99..094e23d63 100644 --- a/fluxer_api/src/api/channel/repositories/ChannelDataRepository.ts +++ b/fluxer_api/src/api/channel/repositories/ChannelDataRepository.ts @@ -1,21 +1,27 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, MessageID, UserID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchManyInChunks, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import {Db} from '../../database/CassandraTypes'; -import {buildPatchFromData, executeVersionedUpdate} from '../../database/CassandraVersionedUpdate'; -import type {ChannelRow} from '../../database/types/ChannelTypes'; -import {CHANNEL_COLUMNS} from '../../database/types/ChannelTypes'; -import {Logger} from '../../Logger'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import {Channel} from '../../models/Channel'; -import {Channels, ChannelsByGuild, PrivateChannels} from '../../Tables'; +import type {ChannelID, GuildID, MessageID, UserID} from '@app/api/BrandedTypes'; import { privateChannelFanOutTargets, privateChannelLastMessageIdPatch, privateChannelMetadataPatch, -} from '../PrivateChannelSnapshot'; -import {IChannelDataRepository} from './IChannelDataRepository'; +} from '@app/api/channel/PrivateChannelSnapshot'; +import {IChannelDataRepository} from '@app/api/channel/repositories/IChannelDataRepository'; +import { + BatchBuilder, + fetchMany, + fetchManyInChunks, + fetchOne, + upsertOne, +} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import {buildPatchFromData, executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import type {ChannelRow} from '@app/api/database/types/ChannelTypes'; +import {CHANNEL_COLUMNS} from '@app/api/database/types/ChannelTypes'; +import {Logger} from '@app/api/Logger'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {Channel} from '@app/api/models/Channel'; +import {Channels, ChannelsByGuild, PrivateChannels} from '@app/api/Tables'; const FETCH_CHANNEL_BY_ID = Channels.select({ where: [Channels.where.eq('channel_id'), Channels.where.eq('soft_deleted')], diff --git a/fluxer_api/src/api/channel/repositories/ChannelRepository.ts b/fluxer_api/src/api/channel/repositories/ChannelRepository.ts index 78a00be62..4ec4dc490 100644 --- a/fluxer_api/src/api/channel/repositories/ChannelRepository.ts +++ b/fluxer_api/src/api/channel/repositories/ChannelRepository.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import {ChannelDataRepository} from './ChannelDataRepository'; -import {IChannelRepositoryAggregate} from './IChannelRepositoryAggregate'; -import {MessageInteractionRepository} from './MessageInteractionRepository'; -import {MessageRepository} from './MessageRepository'; +import {ChannelDataRepository} from '@app/api/channel/repositories/ChannelDataRepository'; +import {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import {MessageInteractionRepository} from '@app/api/channel/repositories/MessageInteractionRepository'; +import {MessageRepository} from '@app/api/channel/repositories/MessageRepository'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; export class ChannelRepository extends IChannelRepositoryAggregate { readonly channelData: ChannelDataRepository; diff --git a/fluxer_api/src/api/channel/repositories/IChannelDataRepository.ts b/fluxer_api/src/api/channel/repositories/IChannelDataRepository.ts index 93f08b33a..a40827603 100644 --- a/fluxer_api/src/api/channel/repositories/IChannelDataRepository.ts +++ b/fluxer_api/src/api/channel/repositories/IChannelDataRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, MessageID} from '../../BrandedTypes'; -import type {ChannelRow} from '../../database/types/ChannelTypes'; -import type {Channel} from '../../models/Channel'; +import type {ChannelID, GuildID, MessageID} from '@app/api/BrandedTypes'; +import type {ChannelRow} from '@app/api/database/types/ChannelTypes'; +import type {Channel} from '@app/api/models/Channel'; export abstract class IChannelDataRepository { abstract findUnique(channelId: ChannelID): Promise; diff --git a/fluxer_api/src/api/channel/repositories/IChannelRepositoryAggregate.ts b/fluxer_api/src/api/channel/repositories/IChannelRepositoryAggregate.ts index 74353cc87..d69a4517c 100644 --- a/fluxer_api/src/api/channel/repositories/IChannelRepositoryAggregate.ts +++ b/fluxer_api/src/api/channel/repositories/IChannelRepositoryAggregate.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IChannelDataRepository} from './IChannelDataRepository'; -import type {IMessageInteractionRepository} from './IMessageInteractionRepository'; -import type {IMessageRepository} from './IMessageRepository'; +import type {IChannelDataRepository} from '@app/api/channel/repositories/IChannelDataRepository'; +import type {IMessageInteractionRepository} from '@app/api/channel/repositories/IMessageInteractionRepository'; +import type {IMessageRepository} from '@app/api/channel/repositories/IMessageRepository'; export abstract class IChannelRepositoryAggregate { abstract readonly channelData: IChannelDataRepository; diff --git a/fluxer_api/src/api/channel/repositories/IMessageInteractionRepository.ts b/fluxer_api/src/api/channel/repositories/IMessageInteractionRepository.ts index 43cecd99c..20b7ce93b 100644 --- a/fluxer_api/src/api/channel/repositories/IMessageInteractionRepository.ts +++ b/fluxer_api/src/api/channel/repositories/IMessageInteractionRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, EmojiID, MessageID, UserID} from '../../BrandedTypes'; -import type {Message} from '../../models/Message'; -import type {MessageReaction} from '../../models/MessageReaction'; +import type {ChannelID, EmojiID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {Message} from '@app/api/models/Message'; +import type {MessageReaction} from '@app/api/models/MessageReaction'; export abstract class IMessageInteractionRepository { abstract listChannelPins(channelId: ChannelID, beforePinnedTimestamp: Date, limit?: number): Promise>; diff --git a/fluxer_api/src/api/channel/repositories/IMessageRepository.ts b/fluxer_api/src/api/channel/repositories/IMessageRepository.ts index d6ac900bc..7fafcbb66 100644 --- a/fluxer_api/src/api/channel/repositories/IMessageRepository.ts +++ b/fluxer_api/src/api/channel/repositories/IMessageRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID, ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import type {MessageRow} from '../../database/types/MessageTypes'; -import type {Message} from '../../models/Message'; +import type {AttachmentID, ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {MessageRow} from '@app/api/database/types/MessageTypes'; +import type {Message} from '@app/api/models/Message'; export interface ListMessagesOptions { restrictToBeforeBucket?: boolean; diff --git a/fluxer_api/src/api/channel/repositories/MessageInteractionRepository.test.ts b/fluxer_api/src/api/channel/repositories/MessageInteractionRepository.test.ts index 3fc7d1646..206c64e8e 100644 --- a/fluxer_api/src/api/channel/repositories/MessageInteractionRepository.test.ts +++ b/fluxer_api/src/api/channel/repositories/MessageInteractionRepository.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createChannelID, createMessageID, createUserID, type MessageID} from '@app/api/BrandedTypes'; +import {ChannelDataRepository} from '@app/api/channel/repositories/ChannelDataRepository'; +import {MessageInteractionRepository} from '@app/api/channel/repositories/MessageInteractionRepository'; +import {MessageRepository} from '@app/api/channel/repositories/MessageRepository'; +import {fetchOne, setCassandraQueryExecutorForTesting} from '@app/api/database/CassandraQueryExecution'; +import type {PreparedQuery} from '@app/api/database/CassandraTypes'; +import type {MessageRow} from '@app/api/database/types/MessageTypes'; +import {Messages} from '@app/api/Tables'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {type ChannelID, createChannelID, createMessageID, createUserID, type MessageID} from '../../BrandedTypes'; -import {fetchOne, setCassandraQueryExecutorForTesting} from '../../database/CassandraQueryExecution'; -import type {PreparedQuery} from '../../database/CassandraTypes'; -import type {MessageRow} from '../../database/types/MessageTypes'; -import {Messages} from '../../Tables'; -import {InMemoryCassandraQueryExecutor} from '../../test/InMemoryCassandraQueryExecutor'; -import {ChannelDataRepository} from './ChannelDataRepository'; -import {MessageInteractionRepository} from './MessageInteractionRepository'; -import {MessageRepository} from './MessageRepository'; const FETCH_MESSAGE_HAS_REACTION = Messages.selectCql({ columns: ['has_reaction'], diff --git a/fluxer_api/src/api/channel/repositories/MessageInteractionRepository.ts b/fluxer_api/src/api/channel/repositories/MessageInteractionRepository.ts index aee1348ad..053d85968 100644 --- a/fluxer_api/src/api/channel/repositories/MessageInteractionRepository.ts +++ b/fluxer_api/src/api/channel/repositories/MessageInteractionRepository.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, EmojiID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {createEmojiID} from '@app/api/BrandedTypes'; +import {IMessageInteractionRepository} from '@app/api/channel/repositories/IMessageInteractionRepository'; +import type {MessageRepository} from '@app/api/channel/repositories/MessageRepository'; +import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {ChannelPinRow, MessageReactionRow} from '@app/api/database/types/MessageTypes'; +import type {Message} from '@app/api/models/Message'; +import {MessageReaction} from '@app/api/models/MessageReaction'; +import {ChannelPins, MessageReactions, Messages} from '@app/api/Tables'; import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; -import type {ChannelID, EmojiID, MessageID, UserID} from '../../BrandedTypes'; -import {createEmojiID} from '../../BrandedTypes'; -import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import {Db} from '../../database/CassandraTypes'; -import type {ChannelPinRow, MessageReactionRow} from '../../database/types/MessageTypes'; -import type {Message} from '../../models/Message'; -import {MessageReaction} from '../../models/MessageReaction'; -import {ChannelPins, MessageReactions, Messages} from '../../Tables'; -import {IMessageInteractionRepository} from './IMessageInteractionRepository'; -import type {MessageRepository} from './MessageRepository'; const createFetchChannelPinsQuery = (limit: number) => ChannelPins.select({ diff --git a/fluxer_api/src/api/channel/repositories/MessageRepository.ts b/fluxer_api/src/api/channel/repositories/MessageRepository.ts index 8b92daf27..558a76dca 100644 --- a/fluxer_api/src/api/channel/repositories/MessageRepository.ts +++ b/fluxer_api/src/api/channel/repositories/MessageRepository.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID, ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import type {MessageRow} from '../../database/types/MessageTypes'; -import type {Message} from '../../models/Message'; -import type {ChannelDataRepository} from './ChannelDataRepository'; -import {IMessageRepository, type ListMessagesOptions} from './IMessageRepository'; -import {MessageAttachmentRepository} from './message/MessageAttachmentRepository'; -import {MessageAuthorRepository} from './message/MessageAuthorRepository'; -import {MessageDataRepository} from './message/MessageDataRepository'; -import {MessageDeletionRepository} from './message/MessageDeletionRepository'; +import type {AttachmentID, ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {ChannelDataRepository} from '@app/api/channel/repositories/ChannelDataRepository'; +import {IMessageRepository, type ListMessagesOptions} from '@app/api/channel/repositories/IMessageRepository'; +import {MessageAttachmentRepository} from '@app/api/channel/repositories/message/MessageAttachmentRepository'; +import {MessageAuthorRepository} from '@app/api/channel/repositories/message/MessageAuthorRepository'; +import {MessageDataRepository} from '@app/api/channel/repositories/message/MessageDataRepository'; +import {MessageDeletionRepository} from '@app/api/channel/repositories/message/MessageDeletionRepository'; +import type {MessageRow} from '@app/api/database/types/MessageTypes'; +import type {Message} from '@app/api/models/Message'; export class MessageRepository extends IMessageRepository { private dataRepo: MessageDataRepository; diff --git a/fluxer_api/src/api/channel/repositories/message/AttachmentUploadTraceRepository.ts b/fluxer_api/src/api/channel/repositories/message/AttachmentUploadTraceRepository.ts index c28232ed5..6ed594e60 100644 --- a/fluxer_api/src/api/channel/repositories/message/AttachmentUploadTraceRepository.ts +++ b/fluxer_api/src/api/channel/repositories/message/AttachmentUploadTraceRepository.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID, ChannelID, UserID} from '../../../BrandedTypes'; -import {fetchOne, upsertOne} from '../../../database/CassandraQueryExecution'; +import type {AttachmentID, ChannelID, UserID} from '@app/api/BrandedTypes'; +import {fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; import type { AttachmentUploadTraceByAttachmentRow, AttachmentUploadTraceByKeyRow, -} from '../../../database/types/AttachmentUploadTypes'; -import {AttachmentUploadTracesByAttachment, AttachmentUploadTracesByKey} from '../../../Tables'; +} from '@app/api/database/types/AttachmentUploadTypes'; +import {AttachmentUploadTracesByAttachment, AttachmentUploadTracesByKey} from '@app/api/Tables'; const GET_UPLOAD_TRACE_BY_KEY_QUERY = AttachmentUploadTracesByKey.select({ where: AttachmentUploadTracesByKey.where.eq('upload_key'), diff --git a/fluxer_api/src/api/channel/repositories/message/MessageAttachmentRepository.ts b/fluxer_api/src/api/channel/repositories/message/MessageAttachmentRepository.ts index 2ef912dff..86ba92ffc 100644 --- a/fluxer_api/src/api/channel/repositories/message/MessageAttachmentRepository.ts +++ b/fluxer_api/src/api/channel/repositories/message/MessageAttachmentRepository.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID, ChannelID, MessageID} from '../../../BrandedTypes'; -import {fetchOne} from '../../../database/CassandraQueryExecution'; -import type {AttachmentLookupRow} from '../../../database/types/MessageTypes'; -import {AttachmentLookup} from '../../../Tables'; +import type {AttachmentID, ChannelID, MessageID} from '@app/api/BrandedTypes'; +import {fetchOne} from '@app/api/database/CassandraQueryExecution'; +import type {AttachmentLookupRow} from '@app/api/database/types/MessageTypes'; +import {AttachmentLookup} from '@app/api/Tables'; const LOOKUP_ATTACHMENT_BY_CHANNEL_AND_FILENAME_QUERY = AttachmentLookup.selectCql({ where: [ diff --git a/fluxer_api/src/api/channel/repositories/message/MessageAuthorRepository.ts b/fluxer_api/src/api/channel/repositories/message/MessageAuthorRepository.ts index 5bdf0d518..a6b37cff1 100644 --- a/fluxer_api/src/api/channel/repositories/message/MessageAuthorRepository.ts +++ b/fluxer_api/src/api/channel/repositories/message/MessageAuthorRepository.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createMessageID} from '@app/api/BrandedTypes'; +import type {MessageDataRepository} from '@app/api/channel/repositories/message/MessageDataRepository'; +import type {MessageDeletionRepository} from '@app/api/channel/repositories/message/MessageDeletionRepository'; +import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import {Messages, MessagesByAuthorV2} from '@app/api/Tables'; import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; -import type {ChannelID, MessageID, UserID} from '../../../BrandedTypes'; -import {createChannelID, createMessageID} from '../../../BrandedTypes'; -import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../../../database/CassandraQueryExecution'; -import {Db} from '../../../database/CassandraTypes'; -import {Messages, MessagesByAuthorV2} from '../../../Tables'; -import type {MessageDataRepository} from './MessageDataRepository'; -import type {MessageDeletionRepository} from './MessageDeletionRepository'; const SELECT_MESSAGE_BY_AUTHOR = MessagesByAuthorV2.select({ where: [MessagesByAuthorV2.where.eq('author_id'), MessagesByAuthorV2.where.eq('message_id')], diff --git a/fluxer_api/src/api/channel/repositories/message/MessageDataRepository.test.ts b/fluxer_api/src/api/channel/repositories/message/MessageDataRepository.test.ts index 014db2b5f..7dee54d11 100644 --- a/fluxer_api/src/api/channel/repositories/message/MessageDataRepository.test.ts +++ b/fluxer_api/src/api/channel/repositories/message/MessageDataRepository.test.ts @@ -1,25 +1,25 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {generateSnowflake} from '@fluxer/snowflake/src/Snowflake'; -import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; -import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {type ChannelID, createChannelID, createMessageID, createUserID, type MessageID} from '../../../BrandedTypes'; +import {type ChannelID, createChannelID, createMessageID, createUserID, type MessageID} from '@app/api/BrandedTypes'; +import {MessageDataRepository} from '@app/api/channel/repositories/message/MessageDataRepository'; import { deleteOneOrMany, fetchMany, fetchOne, setCassandraQueryExecutorForTesting, -} from '../../../database/CassandraQueryExecution'; -import type {CassandraParams, KvQueryMeta, PreparedQuery} from '../../../database/CassandraTypes'; +} from '@app/api/database/CassandraQueryExecution'; +import type {CassandraParams, KvQueryMeta, PreparedQuery} from '@app/api/database/CassandraTypes'; import type { ChannelEmptyBucketRow, ChannelMessageBucketRow, ChannelStateRow, MessageRow, -} from '../../../database/types/MessageTypes'; -import {ChannelEmptyBuckets, ChannelMessageBuckets, ChannelState, Messages} from '../../../Tables'; -import {InMemoryCassandraQueryExecutor} from '../../../test/InMemoryCassandraQueryExecutor'; -import {MessageDataRepository} from './MessageDataRepository'; +} from '@app/api/database/types/MessageTypes'; +import {ChannelEmptyBuckets, ChannelMessageBuckets, ChannelState, Messages} from '@app/api/Tables'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; +import {generateSnowflake} from '@fluxer/snowflake/src/Snowflake'; +import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; +import {afterEach, beforeEach, describe, expect, it} from 'vitest'; const FETCH_CHANNEL_STATE = ChannelState.select({where: ChannelState.where.eq('channel_id'), limit: 1}); const FETCH_MESSAGE_BUCKETS = ChannelMessageBuckets.select({ diff --git a/fluxer_api/src/api/channel/repositories/message/MessageDataRepository.ts b/fluxer_api/src/api/channel/repositories/message/MessageDataRepository.ts index 4d316104b..3979b4f93 100644 --- a/fluxer_api/src/api/channel/repositories/message/MessageDataRepository.ts +++ b/fluxer_api/src/api/channel/repositories/message/MessageDataRepository.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {generateSnowflake} from '@fluxer/snowflake/src/Snowflake'; -import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; -import type {ChannelID, MessageID} from '../../../BrandedTypes'; -import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../../../database/CassandraQueryExecution'; -import {Db, type QueryTemplate} from '../../../database/CassandraTypes'; -import {buildPatchFromData, executeVersionedUpdate} from '../../../database/CassandraVersionedUpdate'; -import type {ChannelMessageBucketRow, ChannelStateRow, MessageRow} from '../../../database/types/MessageTypes'; -import {MESSAGE_COLUMNS} from '../../../database/types/MessageTypes'; -import {Logger} from '../../../Logger'; -import {Message} from '../../../models/Message'; +import type {ChannelID, MessageID} from '@app/api/BrandedTypes'; +import type {ListMessagesOptions} from '@app/api/channel/repositories/IMessageRepository'; +import {BucketScanDirection, scanBucketsWithIndex} from '@app/api/channel/repositories/message/BucketScanEngine'; +import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db, type QueryTemplate} from '@app/api/database/CassandraTypes'; +import {buildPatchFromData, executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import type {ChannelMessageBucketRow, ChannelStateRow, MessageRow} from '@app/api/database/types/MessageTypes'; +import {MESSAGE_COLUMNS} from '@app/api/database/types/MessageTypes'; +import {Logger} from '@app/api/Logger'; +import {Message} from '@app/api/models/Message'; import { AttachmentLookup, ChannelEmptyBuckets, @@ -18,9 +18,9 @@ import { ChannelState, Messages, MessagesByAuthorV2, -} from '../../../Tables'; -import type {ListMessagesOptions} from '../IMessageRepository'; -import {BucketScanDirection, scanBucketsWithIndex} from './BucketScanEngine'; +} from '@app/api/Tables'; +import {generateSnowflake} from '@fluxer/snowflake/src/Snowflake'; +import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; function getLogger() { return Logger.child({module: 'MessageDataRepository'}); diff --git a/fluxer_api/src/api/channel/repositories/message/MessageDeletionRepository.test.ts b/fluxer_api/src/api/channel/repositories/message/MessageDeletionRepository.test.ts index 6fb8cd589..6cc8673fe 100644 --- a/fluxer_api/src/api/channel/repositories/message/MessageDeletionRepository.test.ts +++ b/fluxer_api/src/api/channel/repositories/message/MessageDeletionRepository.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createMessageID, createUserID, type MessageID} from '@app/api/BrandedTypes'; +import {MessageDataRepository} from '@app/api/channel/repositories/message/MessageDataRepository'; +import {MessageDeletionRepository} from '@app/api/channel/repositories/message/MessageDeletionRepository'; +import {setCassandraQueryExecutorForTesting, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {KvQueryMeta} from '@app/api/database/CassandraTypes'; +import type {MessageRow} from '@app/api/database/types/MessageTypes'; +import {Messages} from '@app/api/Tables'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createChannelID, createMessageID, createUserID, type MessageID} from '../../../BrandedTypes'; -import {setCassandraQueryExecutorForTesting, upsertOne} from '../../../database/CassandraQueryExecution'; -import type {KvQueryMeta} from '../../../database/CassandraTypes'; -import type {MessageRow} from '../../../database/types/MessageTypes'; -import {Messages} from '../../../Tables'; -import {InMemoryCassandraQueryExecutor} from '../../../test/InMemoryCassandraQueryExecutor'; -import {MessageDataRepository} from './MessageDataRepository'; -import {MessageDeletionRepository} from './MessageDeletionRepository'; class BatchRecordingCassandraQueryExecutor extends InMemoryCassandraQueryExecutor { readonly batchedQueries: Array = []; diff --git a/fluxer_api/src/api/channel/repositories/message/MessageDeletionRepository.ts b/fluxer_api/src/api/channel/repositories/message/MessageDeletionRepository.ts index cb5142388..f3e2919a7 100644 --- a/fluxer_api/src/api/channel/repositories/message/MessageDeletionRepository.ts +++ b/fluxer_api/src/api/channel/repositories/message/MessageDeletionRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; -import type {ChannelID, MessageID, UserID} from '../../../BrandedTypes'; -import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../../../database/CassandraQueryExecution'; -import {Db} from '../../../database/CassandraTypes'; -import type {ChannelMessageBucketRow, ChannelStateRow} from '../../../database/types/MessageTypes'; -import type {Message} from '../../../models/Message'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {MessageDataRepository} from '@app/api/channel/repositories/message/MessageDataRepository'; +import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {ChannelMessageBucketRow, ChannelStateRow} from '@app/api/database/types/MessageTypes'; +import type {Message} from '@app/api/models/Message'; import { AttachmentLookup, ChannelEmptyBuckets, @@ -15,8 +15,8 @@ import { MessageReactions, Messages, MessagesByAuthorV2, -} from '../../../Tables'; -import type {MessageDataRepository} from './MessageDataRepository'; +} from '@app/api/Tables'; +import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; const BULK_DELETE_BATCH_SIZE = 100; const BULK_DELETE_BATCH_QUERY_LIMIT = 30; diff --git a/fluxer_api/src/api/channel/services/AttachmentUploadService.ts b/fluxer_api/src/api/channel/services/AttachmentUploadService.ts index 8f58cff3d..fcbc9d6e3 100644 --- a/fluxer_api/src/api/channel/services/AttachmentUploadService.ts +++ b/fluxer_api/src/api/channel/services/AttachmentUploadService.ts @@ -1,5 +1,39 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AttachmentID, ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {UploadedAttachment} from '@app/api/channel/AttachmentDTOs'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type { + AttachmentUploadMode, + AttachmentUploadTraceRepository, +} from '@app/api/channel/repositories/message/AttachmentUploadTraceRepository'; +import type {MessageInteractionService} from '@app/api/channel/services/MessageInteractionService'; +import type {MessageService} from '@app/api/channel/services/MessageService'; +import { + assertAttachmentFileSizesWithinLimit, + getContentType, + isMessageEmpty, + isOperationDisabled, + makeAttachmentCdnKey, + makeAttachmentCdnUrl, + purgeMessageAttachments as purgeMessageAttachmentsHelper, +} from '@app/api/channel/services/message/MessageHelpers'; +import {applyUploadRelayDecision, resolveUploadRelayDecision} from '@app/api/channel/services/UploadRelay'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Attachment} from '@app/api/models/Attachment'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; +import {assertGuildMemberCanCommunicate} from '@app/api/utils/GuildCommunicationUtils'; import {Permissions, TEXT_BASED_CHANNEL_TYPES} from '@fluxer/constants/src/ChannelConstants'; import {GuildOperations} from '@fluxer/constants/src/GuildConstants'; import { @@ -26,40 +60,6 @@ import type { PresignedAttachmentUploadRequestItem, PresignedAttachmentUploadResponseItem, } from '@fluxer/schema/src/domains/message/AttachmentUploadSchemas'; -import type {AttachmentID, ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {SYSTEM_USER_ID} from '../../constants/Core'; -import type {IPurgeQueue} from '../../infrastructure/BunnyPurgeQueue'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Attachment} from '../../models/Attachment'; -import type {Channel} from '../../models/Channel'; -import type {Message} from '../../models/Message'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {mapWithConcurrency} from '../../utils/ConcurrencyUtils'; -import {assertGuildMemberCanCommunicate} from '../../utils/GuildCommunicationUtils'; -import type {UploadedAttachment} from '../AttachmentDTOs'; -import type {IChannelRepositoryAggregate} from '../repositories/IChannelRepositoryAggregate'; -import type { - AttachmentUploadMode, - AttachmentUploadTraceRepository, -} from '../repositories/message/AttachmentUploadTraceRepository'; -import type {MessageInteractionService} from './MessageInteractionService'; -import type {MessageService} from './MessageService'; -import { - assertAttachmentFileSizesWithinLimit, - getContentType, - isMessageEmpty, - isOperationDisabled, - makeAttachmentCdnKey, - makeAttachmentCdnUrl, - purgeMessageAttachments as purgeMessageAttachmentsHelper, -} from './message/MessageHelpers'; -import {applyUploadRelayDecision, resolveUploadRelayDecision} from './UploadRelay'; interface DeleteAttachmentParams { userId: UserID; diff --git a/fluxer_api/src/api/channel/services/AuthenticatedChannel.ts b/fluxer_api/src/api/channel/services/AuthenticatedChannel.ts index 92692fce7..6e570a584 100644 --- a/fluxer_api/src/api/channel/services/AuthenticatedChannel.ts +++ b/fluxer_api/src/api/channel/services/AuthenticatedChannel.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {Channel} from '@app/api/models/Channel'; import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {Channel} from '../../models/Channel'; export interface AuthenticatedChannel { channel: Channel; diff --git a/fluxer_api/src/api/channel/services/BaseChannelAuthService.ts b/fluxer_api/src/api/channel/services/BaseChannelAuthService.ts index 77e686dc7..b004566cd 100644 --- a/fluxer_api/src/api/channel/services/BaseChannelAuthService.ts +++ b/fluxer_api/src/api/channel/services/BaseChannelAuthService.ts @@ -1,5 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {AuthenticatedChannel} from '@app/api/channel/services/AuthenticatedChannel'; +import {DMPermissionValidator} from '@app/api/channel/services/DMPermissionValidator'; +import { + ensurePersonalNotesChannelExists, + isPersonalNotesChannelId, +} from '@app/api/channel/services/PersonalNotesChannelRepair'; +import { + type ContentWarningChannelLike, + channelResponseToContentWarningView, + channelToContentWarningView, + computeEffectiveChannelNsfw, + guildResponseToContentWarningView, +} from '@app/api/channel/utils/EffectiveContentWarning'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {createGuildMfaEnforcer} from '@app/api/guild/services/GuildMfaEnforcement'; +import type {GuildChannelAuthContext, IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {Channel} from '@app/api/models/Channel'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {User} from '@app/api/models/User'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {canUserAccessNsfwContent} from '@app/api/utils/AgeUtils'; import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {CannotSendMessagesToUserError} from '@fluxer/errors/src/domains/channel/CannotSendMessagesToUserError'; import {UnknownChannelError} from '@fluxer/errors/src/domains/channel/UnknownChannelError'; @@ -9,27 +33,6 @@ import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildEr import {NsfwContentRequiresAgeVerificationError} from '@fluxer/errors/src/domains/moderation/NsfwContentRequiresAgeVerificationError'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; -import type {ChannelID, GuildID, UserID} from '../../BrandedTypes'; -import {SYSTEM_USER_ID} from '../../constants/Core'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import {createGuildMfaEnforcer} from '../../guild/services/GuildMfaEnforcement'; -import type {GuildChannelAuthContext, IGatewayService} from '../../infrastructure/IGatewayService'; -import type {Channel} from '../../models/Channel'; -import type {GuildMember} from '../../models/GuildMember'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {canUserAccessNsfwContent} from '../../utils/AgeUtils'; -import type {IChannelRepositoryAggregate} from '../repositories/IChannelRepositoryAggregate'; -import { - type ContentWarningChannelLike, - channelResponseToContentWarningView, - channelToContentWarningView, - computeEffectiveChannelNsfw, - guildResponseToContentWarningView, -} from '../utils/EffectiveContentWarning'; -import type {AuthenticatedChannel} from './AuthenticatedChannel'; -import {DMPermissionValidator} from './DMPermissionValidator'; -import {ensurePersonalNotesChannelExists, isPersonalNotesChannelId} from './PersonalNotesChannelRepair'; export interface ChannelAuthOptions { errorOnMissingGuild: 'unknown_channel' | 'missing_permissions'; diff --git a/fluxer_api/src/api/channel/services/CallService.ts b/fluxer_api/src/api/channel/services/CallService.ts index daa538259..fa4fc4b3e 100644 --- a/fluxer_api/src/api/channel/services/CallService.ts +++ b/fluxer_api/src/api/channel/services/CallService.ts @@ -1,5 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createMessageID, type MessageID, type UserID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {DMPermissionValidator} from '@app/api/channel/services/DMPermissionValidator'; +import {buildBroadcastMessageData} from '@app/api/channel/services/message/MessageGatewayDispatch'; +import {incrementDmMentionCounts} from '@app/api/channel/services/message/ReadStateHelpers'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {CallData, IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IVoiceRoomStore} from '@app/api/infrastructure/IVoiceRoomStore'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {VoiceAccessContext, VoiceAvailabilityService} from '@app/api/voice/VoiceAvailabilityService'; import {AUTOMATIC_VOICE_REGION_ID, ChannelTypes, MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import {IncomingCallFlags, RelationshipTypes} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; @@ -9,21 +24,6 @@ import {NoActiveCallError} from '@fluxer/errors/src/domains/channel/NoActiveCall import {UnknownChannelError} from '@fluxer/errors/src/domains/channel/UnknownChannelError'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; -import {type ChannelID, createMessageID, type MessageID, type UserID} from '../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {CallData, IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {IVoiceRoomStore} from '../../infrastructure/IVoiceRoomStore'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {ReadStateService} from '../../read_state/ReadStateService'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {VoiceAccessContext, VoiceAvailabilityService} from '../../voice/VoiceAvailabilityService'; -import {mapChannelToResponse} from '../ChannelMappers'; -import type {IChannelRepository} from '../IChannelRepository'; -import {DMPermissionValidator} from './DMPermissionValidator'; -import {buildBroadcastMessageData} from './message/MessageGatewayDispatch'; -import {incrementDmMentionCounts} from './message/ReadStateHelpers'; export class CallService { private dmPermissionValidator: DMPermissionValidator; diff --git a/fluxer_api/src/api/channel/services/ChannelDataService.ts b/fluxer_api/src/api/channel/services/ChannelDataService.ts index 2961508c9..18005746b 100644 --- a/fluxer_api/src/api/channel/services/ChannelDataService.ts +++ b/fluxer_api/src/api/channel/services/ChannelDataService.ts @@ -1,34 +1,34 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, UserID} from '@app/api/BrandedTypes'; +import {createUserID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import {ChannelAuthService} from '@app/api/channel/services/channel_data/ChannelAuthService'; +import type {ChannelUpdateData} from '@app/api/channel/services/channel_data/ChannelOperationsService'; +import {ChannelOperationsService} from '@app/api/channel/services/channel_data/ChannelOperationsService'; +import {ChannelUtilsService} from '@app/api/channel/services/channel_data/ChannelUtilsService'; +import {GroupDmUpdateService} from '@app/api/channel/services/channel_data/GroupDmUpdateService'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ILiveKitService} from '@app/api/infrastructure/ILiveKitService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {IVoiceRoomStore} from '@app/api/infrastructure/IVoiceRoomStore'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {IInviteRepository} from '@app/api/invite/IInviteRepository'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {VoiceAvailabilityService} from '@app/api/voice/VoiceAvailabilityService'; +import type {IWebhookRepository} from '@app/api/webhook/IWebhookRepository'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import type {ChannelUpdateRequest} from '@fluxer/schema/src/domains/channel/ChannelRequestSchemas'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; -import type {ChannelID, UserID} from '../../BrandedTypes'; -import {createUserID} from '../../BrandedTypes'; -import type {GuildAuditLogService} from '../../guild/GuildAuditLogService'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {AvatarService} from '../../infrastructure/AvatarService'; -import type {IPurgeQueue} from '../../infrastructure/BunnyPurgeQueue'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ILiveKitService} from '../../infrastructure/ILiveKitService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import type {IVoiceRoomStore} from '../../infrastructure/IVoiceRoomStore'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {IInviteRepository} from '../../invite/IInviteRepository'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../models/Channel'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {VoiceAvailabilityService} from '../../voice/VoiceAvailabilityService'; -import type {IWebhookRepository} from '../../webhook/IWebhookRepository'; -import type {IChannelRepositoryAggregate} from '../repositories/IChannelRepositoryAggregate'; -import {ChannelAuthService} from './channel_data/ChannelAuthService'; -import type {ChannelUpdateData} from './channel_data/ChannelOperationsService'; -import {ChannelOperationsService} from './channel_data/ChannelOperationsService'; -import {ChannelUtilsService} from './channel_data/ChannelUtilsService'; -import {GroupDmUpdateService} from './channel_data/GroupDmUpdateService'; -import type {MessagePersistenceService} from './message/MessagePersistenceService'; type GuildChannelUpdateRequest = Exclude< ChannelUpdateRequest, diff --git a/fluxer_api/src/api/channel/services/ChannelRequestService.ts b/fluxer_api/src/api/channel/services/ChannelRequestService.ts index b7375d408..45c908163 100644 --- a/fluxer_api/src/api/channel/services/ChannelRequestService.ts +++ b/fluxer_api/src/api/channel/services/ChannelRequestService.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, UserID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import type {ChannelUpdateRequest} from '@fluxer/schema/src/domains/channel/ChannelRequestSchemas'; import type {ChannelResponse, ChannelSlowmodeStateResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; -import type {ChannelID, UserID} from '../../BrandedTypes'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {User} from '../../models/User'; -import {mapChannelToResponse} from '../ChannelMappers'; -import type {ChannelService} from './ChannelService'; export class ChannelRequestService { constructor( diff --git a/fluxer_api/src/api/channel/services/ChannelService.ts b/fluxer_api/src/api/channel/services/ChannelService.ts index 3e694ad10..c5b559d8d 100644 --- a/fluxer_api/src/api/channel/services/ChannelService.ts +++ b/fluxer_api/src/api/channel/services/ChannelService.ts @@ -1,38 +1,38 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {ChannelID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {AttachmentUploadTraceRepository} from '@app/api/channel/repositories/message/AttachmentUploadTraceRepository'; +import {AttachmentUploadService} from '@app/api/channel/services/AttachmentUploadService'; +import {CallService} from '@app/api/channel/services/CallService'; +import {ChannelDataService} from '@app/api/channel/services/ChannelDataService'; +import {GroupDmOperationsService} from '@app/api/channel/services/group_dm/GroupDmOperationsService'; +import {MessageInteractionService} from '@app/api/channel/services/MessageInteractionService'; +import {MessageService} from '@app/api/channel/services/MessageService'; +import {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import {UserMessageDeletionService} from '@app/api/channel/services/message/UserMessageDeletionService'; +import type {IFavoriteMemeRepository} from '@app/api/favorite_meme/IFavoriteMemeRepository'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {EmbedService} from '@app/api/infrastructure/EmbedService'; +import type {ILiveKitService} from '@app/api/infrastructure/ILiveKitService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {IVoiceRoomStore} from '@app/api/infrastructure/IVoiceRoomStore'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {IInviteRepository} from '@app/api/invite/IInviteRepository'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {User} from '@app/api/models/User'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {createDirectMessageSpamMitigationService} from '@app/api/user/services/DirectMessageSpamMitigationService'; +import type {VoiceAvailabilityService} from '@app/api/voice/VoiceAvailabilityService'; +import type {IWebhookRepository} from '@app/api/webhook/IWebhookRepository'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; import type {IVirusScanService} from '@pkgs/virus_scan/src/IVirusScanService'; -import type {ApiContext} from '../../ApiContext'; -import type {ChannelID} from '../../BrandedTypes'; -import type {IFavoriteMemeRepository} from '../../favorite_meme/IFavoriteMemeRepository'; -import type {GuildAuditLogService} from '../../guild/GuildAuditLogService'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {AvatarService} from '../../infrastructure/AvatarService'; -import type {IPurgeQueue} from '../../infrastructure/BunnyPurgeQueue'; -import type {EmbedService} from '../../infrastructure/EmbedService'; -import type {ILiveKitService} from '../../infrastructure/ILiveKitService'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import type {IVoiceRoomStore} from '../../infrastructure/IVoiceRoomStore'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {IInviteRepository} from '../../invite/IInviteRepository'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {User} from '../../models/User'; -import type {ReadStateService} from '../../read_state/ReadStateService'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {createDirectMessageSpamMitigationService} from '../../user/services/DirectMessageSpamMitigationService'; -import type {VoiceAvailabilityService} from '../../voice/VoiceAvailabilityService'; -import type {IWebhookRepository} from '../../webhook/IWebhookRepository'; -import type {IChannelRepository} from '../IChannelRepository'; -import type {AttachmentUploadTraceRepository} from '../repositories/message/AttachmentUploadTraceRepository'; -import {AttachmentUploadService} from './AttachmentUploadService'; -import {CallService} from './CallService'; -import {ChannelDataService} from './ChannelDataService'; -import {GroupDmOperationsService} from './group_dm/GroupDmOperationsService'; -import {MessageInteractionService} from './MessageInteractionService'; -import {MessageService} from './MessageService'; -import {MessagePersistenceService} from './message/MessagePersistenceService'; -import {UserMessageDeletionService} from './message/UserMessageDeletionService'; interface SlowmodeState { rateLimitPerUser: number; diff --git a/fluxer_api/src/api/channel/services/DMPermissionValidator.ts b/fluxer_api/src/api/channel/services/DMPermissionValidator.ts index 8c0db7c5b..f125da40a 100644 --- a/fluxer_api/src/api/channel/services/DMPermissionValidator.ts +++ b/fluxer_api/src/api/channel/services/DMPermissionValidator.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {Guild} from '@app/api/models/Guild'; +import type {User} from '@app/api/models/User'; +import type {UserSettings} from '@app/api/models/UserSettings'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {isBugHunterBotUser} from '@app/api/user/UserHelpers'; +import {checkGuildVerificationWithGuildModel} from '@app/api/utils/GuildVerificationUtils'; +import {getMutualGuildsForDmAccess} from '@app/api/utils/MutualGuildDmAccess'; import {RelationshipTypes, UserFlags} from '@fluxer/constants/src/UserConstants'; import {CannotSendMessagesToUserError} from '@fluxer/errors/src/domains/channel/CannotSendMessagesToUserError'; import {UnclaimedAccountCannotSendDirectMessagesError} from '@fluxer/errors/src/domains/channel/UnclaimedAccountCannotSendDirectMessagesError'; -import type {UserID} from '../../BrandedTypes'; -import {SYSTEM_USER_ID} from '../../constants/Core'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {Guild} from '../../models/Guild'; -import type {User} from '../../models/User'; -import type {UserSettings} from '../../models/UserSettings'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {isBugHunterBotUser} from '../../user/UserHelpers'; -import {checkGuildVerificationWithGuildModel} from '../../utils/GuildVerificationUtils'; -import {getMutualGuildsForDmAccess} from '../../utils/MutualGuildDmAccess'; interface DMPermissionValidatorDeps { userRepository: IUserRepository; diff --git a/fluxer_api/src/api/channel/services/MessageInteractionService.ts b/fluxer_api/src/api/channel/services/MessageInteractionService.ts index bf8f6cb3b..f362b0c3f 100644 --- a/fluxer_api/src/api/channel/services/MessageInteractionService.ts +++ b/fluxer_api/src/api/channel/services/MessageInteractionService.ts @@ -1,28 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {MessageInteractionAuthService} from '@app/api/channel/services/interaction/MessageInteractionAuthService'; +import {MessagePinAuthService} from '@app/api/channel/services/interaction/MessagePinAuthService'; +import {MessagePinService} from '@app/api/channel/services/interaction/MessagePinService'; +import {MessageReactionService} from '@app/api/channel/services/interaction/MessageReactionService'; +import {MessageReadStateService} from '@app/api/channel/services/interaction/MessageReadStateService'; +import {dispatchMessageUpdateBroadcast} from '@app/api/channel/services/message/MessageGatewayDispatch'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {MessageReaction} from '@app/api/models/MessageReaction'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {assertGuildMemberCanCommunicate} from '@app/api/utils/GuildCommunicationUtils'; import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import type {ChannelPinResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import type {ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import type {GuildAuditLogService} from '../../guild/GuildAuditLogService'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../models/Channel'; -import type {Message} from '../../models/Message'; -import type {MessageReaction} from '../../models/MessageReaction'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {assertGuildMemberCanCommunicate} from '../../utils/GuildCommunicationUtils'; -import type {IChannelRepository} from '../IChannelRepository'; -import {MessageInteractionAuthService} from './interaction/MessageInteractionAuthService'; -import {MessagePinAuthService} from './interaction/MessagePinAuthService'; -import {MessagePinService} from './interaction/MessagePinService'; -import {MessageReactionService} from './interaction/MessageReactionService'; -import {MessageReadStateService} from './interaction/MessageReadStateService'; -import {dispatchMessageUpdateBroadcast} from './message/MessageGatewayDispatch'; -import type {MessagePersistenceService} from './message/MessagePersistenceService'; export class MessageInteractionService { readonly authService: MessageInteractionAuthService; diff --git a/fluxer_api/src/api/channel/services/MessageService.ts b/fluxer_api/src/api/channel/services/MessageService.ts index 92c845f02..110d149d6 100644 --- a/fluxer_api/src/api/channel/services/MessageService.ts +++ b/fluxer_api/src/api/channel/services/MessageService.ts @@ -1,39 +1,39 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {AttachmentUploadTraceRepository} from '@app/api/channel/repositories/message/AttachmentUploadTraceRepository'; +import {MessageAnonymizationService} from '@app/api/channel/services/message/MessageAnonymizationService'; +import {MessageChannelAuthService} from '@app/api/channel/services/message/MessageChannelAuthService'; +import {MessageDeleteService} from '@app/api/channel/services/message/MessageDeleteService'; +import {MessageDispatchService} from '@app/api/channel/services/message/MessageDispatchService'; +import {MessageEditService} from '@app/api/channel/services/message/MessageEditService'; +import {MessageMentionService} from '@app/api/channel/services/message/MessageMentionService'; +import {MessageOperationsHelpers} from '@app/api/channel/services/message/MessageOperationsHelpers'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import {MessageProcessingService} from '@app/api/channel/services/message/MessageProcessingService'; +import {createMessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; +import {MessageRetrievalService} from '@app/api/channel/services/message/MessageRetrievalService'; +import {MessageSearchService} from '@app/api/channel/services/message/MessageSearchService'; +import {MessageSendService} from '@app/api/channel/services/message/MessageSendService'; +import {MessageSystemService} from '@app/api/channel/services/message/MessageSystemService'; +import {MessageValidationService} from '@app/api/channel/services/message/MessageValidationService'; +import type {IFavoriteMemeRepository} from '@app/api/favorite_meme/IFavoriteMemeRepository'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {DirectMessageSpamMitigationService} from '@app/api/user/services/DirectMessageSpamMitigationService'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import type {IFavoriteMemeRepository} from '../../favorite_meme/IFavoriteMemeRepository'; -import type {GuildAuditLogService} from '../../guild/GuildAuditLogService'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {IPurgeQueue} from '../../infrastructure/BunnyPurgeQueue'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {IMediaService} from '../../infrastructure/IMediaService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {ReadStateService} from '../../read_state/ReadStateService'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {DirectMessageSpamMitigationService} from '../../user/services/DirectMessageSpamMitigationService'; -import type {WorkerTaskName} from '../../worker/WorkerLaneConfig'; -import type {IChannelRepositoryAggregate} from '../repositories/IChannelRepositoryAggregate'; -import type {AttachmentUploadTraceRepository} from '../repositories/message/AttachmentUploadTraceRepository'; -import {MessageAnonymizationService} from './message/MessageAnonymizationService'; -import {MessageChannelAuthService} from './message/MessageChannelAuthService'; -import {MessageDeleteService} from './message/MessageDeleteService'; -import {MessageDispatchService} from './message/MessageDispatchService'; -import {MessageEditService} from './message/MessageEditService'; -import {MessageMentionService} from './message/MessageMentionService'; -import {MessageOperationsHelpers} from './message/MessageOperationsHelpers'; -import type {MessagePersistenceService} from './message/MessagePersistenceService'; -import {MessageProcessingService} from './message/MessageProcessingService'; -import {createMessageResponseDataService} from './message/MessageResponseDataService'; -import {MessageRetrievalService} from './message/MessageRetrievalService'; -import {MessageSearchService} from './message/MessageSearchService'; -import {MessageSendService} from './message/MessageSendService'; -import {MessageSystemService} from './message/MessageSystemService'; -import {MessageValidationService} from './message/MessageValidationService'; export class MessageService { public readonly validation: MessageValidationService; diff --git a/fluxer_api/src/api/channel/services/PersonalNotesChannelRepair.ts b/fluxer_api/src/api/channel/services/PersonalNotesChannelRepair.ts index f8922f3f8..6a10c9c65 100644 --- a/fluxer_api/src/api/channel/services/PersonalNotesChannelRepair.ts +++ b/fluxer_api/src/api/channel/services/PersonalNotesChannelRepair.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, UserID} from '@app/api/BrandedTypes'; +import {userIdToChannelId} from '@app/api/BrandedTypes'; +import type {ChannelRow} from '@app/api/database/types/ChannelTypes'; +import type {Channel} from '@app/api/models/Channel'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import type {ChannelID, UserID} from '../../BrandedTypes'; -import {userIdToChannelId} from '../../BrandedTypes'; -import type {ChannelRow} from '../../database/types/ChannelTypes'; -import type {Channel} from '../../models/Channel'; interface PersonalNotesChannelRepository { findUnique(channelId: ChannelID): Promise; diff --git a/fluxer_api/src/api/channel/services/StreamPreviewService.ts b/fluxer_api/src/api/channel/services/StreamPreviewService.ts index bee322906..0ff028e81 100644 --- a/fluxer_api/src/api/channel/services/StreamPreviewService.ts +++ b/fluxer_api/src/api/channel/services/StreamPreviewService.ts @@ -1,6 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import type {ChannelID, UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {applyUploadRelayDecision, resolveUploadRelayDecision} from '@app/api/channel/services/UploadRelay'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; import {S3ServiceException} from '@aws-sdk/client-s3'; import {STREAM_PREVIEW_CONTENT_TYPE_JPEG, STREAM_PREVIEW_MAX_BYTES} from '@fluxer/constants/src/StreamConstants'; import {FileSizeTooLargeError} from '@fluxer/errors/src/domains/core/FileSizeTooLargeError'; @@ -8,11 +13,6 @@ import {PreviewMustBeJpegError} from '@fluxer/errors/src/domains/core/PreviewMus import type {StreamPreviewUploadUrlResponseSchema} from '@fluxer/schema/src/domains/channel/ChannelRequestSchemas'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {ms, seconds} from 'itty-time'; -import type {ChannelID, UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {Logger} from '../../Logger'; -import {applyUploadRelayDecision, resolveUploadRelayDecision} from './UploadRelay'; const PREVIEW_TTL_SECONDS = seconds('1 day'); const PREVIEW_UPLOAD_URL_TTL_SECONDS = seconds('1 day'); diff --git a/fluxer_api/src/api/channel/services/StreamService.test.ts b/fluxer_api/src/api/channel/services/StreamService.test.ts index d0b8c1d07..b59a74537 100644 --- a/fluxer_api/src/api/channel/services/StreamService.test.ts +++ b/fluxer_api/src/api/channel/services/StreamService.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createUserID} from '@app/api/BrandedTypes'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {StreamPreviewService} from '@app/api/channel/services/StreamPreviewService'; +import {StreamService} from '@app/api/channel/services/StreamService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {InvalidStreamThumbnailPayloadError} from '@fluxer/errors/src/domains/channel/InvalidStreamThumbnailPayloadError'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {beforeEach, describe, expect, it} from 'vitest'; -import {createChannelID, createUserID} from '../../BrandedTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ChannelService} from './ChannelService'; -import type {StreamPreviewService} from './StreamPreviewService'; -import {StreamService} from './StreamService'; const USER_ID = createUserID(7n); const CHANNEL_ID = createChannelID(12n); diff --git a/fluxer_api/src/api/channel/services/StreamService.ts b/fluxer_api/src/api/channel/services/StreamService.ts index 61bd4360a..c865ecb98 100644 --- a/fluxer_api/src/api/channel/services/StreamService.ts +++ b/fluxer_api/src/api/channel/services/StreamService.ts @@ -1,5 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createChannelID, createGuildID, type GuildID, type UserID} from '@app/api/BrandedTypes'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {StreamPreviewService} from '@app/api/channel/services/StreamPreviewService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {InvalidChannelTypeError} from '@fluxer/errors/src/domains/channel/InvalidChannelTypeError'; import {InvalidStreamKeyFormatError} from '@fluxer/errors/src/domains/channel/InvalidStreamKeyFormatError'; @@ -12,10 +16,6 @@ import type {StreamPreviewUploadUrlResponseSchema} from '@fluxer/schema/src/doma import {isValidBase64} from '@fluxer/schema/src/primitives/FileValidators'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {seconds} from 'itty-time'; -import {type ChannelID, createChannelID, createGuildID, type GuildID, type UserID} from '../../BrandedTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ChannelService} from './ChannelService'; -import type {StreamPreviewService} from './StreamPreviewService'; type ParsedStreamKey = { scope: 'guild' | 'dm'; diff --git a/fluxer_api/src/api/channel/services/UploadRelay.ts b/fluxer_api/src/api/channel/services/UploadRelay.ts index c1a592469..38ae9cbea 100644 --- a/fluxer_api/src/api/channel/services/UploadRelay.ts +++ b/fluxer_api/src/api/channel/services/UploadRelay.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHmac} from 'node:crypto'; +import {Config} from '@app/api/Config'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; import {Logger} from '@fluxer/logger/src/Logger'; -import {Config} from '../../Config'; -import {lookupGeoip} from '../../utils/IpUtils'; const logger = new Logger('UploadRelay'); const RELAY_PATH_PREFIX = '/v1/relay'; diff --git a/fluxer_api/src/api/channel/services/channel_data/ChannelAuthService.ts b/fluxer_api/src/api/channel/services/channel_data/ChannelAuthService.ts index 4cb7bfe55..76b1292f2 100644 --- a/fluxer_api/src/api/channel/services/channel_data/ChannelAuthService.ts +++ b/fluxer_api/src/api/channel/services/channel_data/ChannelAuthService.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {BaseChannelAuthService, type ChannelAuthOptions} from '../BaseChannelAuthService'; +import {BaseChannelAuthService, type ChannelAuthOptions} from '@app/api/channel/services/BaseChannelAuthService'; export class ChannelAuthService extends BaseChannelAuthService { protected readonly options: ChannelAuthOptions = { diff --git a/fluxer_api/src/api/channel/services/channel_data/ChannelOperationsService.ts b/fluxer_api/src/api/channel/services/channel_data/ChannelOperationsService.ts index da6b1a00d..1a1313b26 100644 --- a/fluxer_api/src/api/channel/services/channel_data/ChannelOperationsService.ts +++ b/fluxer_api/src/api/channel/services/channel_data/ChannelOperationsService.ts @@ -1,5 +1,32 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, RoleID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createGuildID, createRoleID, createUserID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {ChannelAuthService} from '@app/api/channel/services/channel_data/ChannelAuthService'; +import type {ChannelUtilsService} from '@app/api/channel/services/channel_data/ChannelUtilsService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import {mapGuildToGuildResponse} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {ChannelHelpers} from '@app/api/guild/services/channel/ChannelHelpers'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ILiveKitService} from '@app/api/infrastructure/ILiveKitService'; +import type {IVoiceRoomStore} from '@app/api/infrastructure/IVoiceRoomStore'; +import type {IInviteRepository} from '@app/api/invite/IInviteRepository'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import {ChannelPermissionOverwrite} from '@app/api/models/ChannelPermissionOverwrite'; +import {deleteChannelMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {serializeChannelForAudit} from '@app/api/utils/AuditSerializationUtils'; +import {applyProtectedOverwriteBits} from '@app/api/utils/featureUtils'; +import type {VoiceAvailabilityService} from '@app/api/voice/VoiceAvailabilityService'; +import type {VoiceRegionAvailability} from '@app/api/voice/VoiceModel'; +import type {IWebhookRepository} from '@app/api/webhook/IWebhookRepository'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import { ALL_PERMISSIONS, @@ -19,33 +46,6 @@ import {MissingPermissionsError} from '@fluxer/errors/src/domains/core/MissingPe import {resolveLimit} from '@fluxer/limits/src/LimitResolver'; import {ChannelNameType} from '@fluxer/schema/src/primitives/ChannelValidators'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; -import type {ChannelID, GuildID, RoleID, UserID} from '../../../BrandedTypes'; -import {createChannelID, createGuildID, createRoleID, createUserID} from '../../../BrandedTypes'; -import type {GuildAuditLogService} from '../../../guild/GuildAuditLogService'; -import {mapGuildToGuildResponse} from '../../../guild/GuildModel'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import {ChannelHelpers} from '../../../guild/services/channel/ChannelHelpers'; -import {contentModerationService} from '../../../infrastructure/ContentModerationService'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {ILiveKitService} from '../../../infrastructure/ILiveKitService'; -import type {IVoiceRoomStore} from '../../../infrastructure/IVoiceRoomStore'; -import type {IInviteRepository} from '../../../invite/IInviteRepository'; -import {Logger} from '../../../Logger'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import {ChannelPermissionOverwrite} from '../../../models/ChannelPermissionOverwrite'; -import {deleteChannelMessageSearchDocuments} from '../../../search/MessageSearchIndexCleanup'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {serializeChannelForAudit} from '../../../utils/AuditSerializationUtils'; -import {applyProtectedOverwriteBits} from '../../../utils/featureUtils'; -import type {VoiceAvailabilityService} from '../../../voice/VoiceAvailabilityService'; -import type {VoiceRegionAvailability} from '../../../voice/VoiceModel'; -import type {IWebhookRepository} from '../../../webhook/IWebhookRepository'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {ChannelAuthService} from './ChannelAuthService'; -import type {ChannelUtilsService} from './ChannelUtilsService'; export interface ChannelUpdateData { name?: string; diff --git a/fluxer_api/src/api/channel/services/channel_data/ChannelUtilsService.ts b/fluxer_api/src/api/channel/services/channel_data/ChannelUtilsService.ts index 84d29b7ab..1600a9b84 100644 --- a/fluxer_api/src/api/channel/services/channel_data/ChannelUtilsService.ts +++ b/fluxer_api/src/api/channel/services/channel_data/ChannelUtilsService.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {MessageID, UserID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; import {dispatchChannelEvent} from '@app/api/channel/services/ChannelGatewayDispatch'; -import type {MessageID, UserID} from '../../../BrandedTypes'; -import type {IPurgeQueue} from '../../../infrastructure/BunnyPurgeQueue'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {IStorageService} from '../../../infrastructure/IStorageService'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import {mapChannelToResponse} from '../../ChannelMappers'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import {dispatchMessageCreateBroadcast} from '../message/MessageGatewayDispatch'; -import {purgeMessageAttachments} from '../message/MessageHelpers'; +import {dispatchMessageCreateBroadcast} from '@app/api/channel/services/message/MessageGatewayDispatch'; +import {purgeMessageAttachments} from '@app/api/channel/services/message/MessageHelpers'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; export class ChannelUtilsService { constructor( diff --git a/fluxer_api/src/api/channel/services/channel_data/GroupDmUpdateService.ts b/fluxer_api/src/api/channel/services/channel_data/GroupDmUpdateService.ts index 79971ae77..a79ad55d9 100644 --- a/fluxer_api/src/api/channel/services/channel_data/GroupDmUpdateService.ts +++ b/fluxer_api/src/api/channel/services/channel_data/GroupDmUpdateService.ts @@ -1,5 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, UserID} from '@app/api/BrandedTypes'; +import {createMessageID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {ChannelUtilsService} from '@app/api/channel/services/channel_data/ChannelUtilsService'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import type {ChannelRow} from '@app/api/database/types/ChannelTypes'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {ChannelTypes, MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import {InvalidChannelTypeError} from '@fluxer/errors/src/domains/channel/InvalidChannelTypeError'; import {UnknownChannelError} from '@fluxer/errors/src/domains/channel/UnknownChannelError'; @@ -7,18 +19,6 @@ import {MissingAccessError} from '@fluxer/errors/src/domains/core/MissingAccessE import {MissingPermissionsError} from '@fluxer/errors/src/domains/core/MissingPermissionsError'; import {CannotTransferOwnershipToBotError} from '@fluxer/errors/src/domains/guild/CannotTransferOwnershipToBotError'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; -import type {ChannelID, UserID} from '../../../BrandedTypes'; -import {createMessageID} from '../../../BrandedTypes'; -import type {ChannelRow} from '../../../database/types/ChannelTypes'; -import type {AvatarService} from '../../../infrastructure/AvatarService'; -import {contentModerationService} from '../../../infrastructure/ContentModerationService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {MessagePersistenceService} from '../message/MessagePersistenceService'; -import type {ChannelUtilsService} from './ChannelUtilsService'; export class GroupDmUpdateService { constructor( diff --git a/fluxer_api/src/api/channel/services/group_dm/GroupDmHelpers.ts b/fluxer_api/src/api/channel/services/group_dm/GroupDmHelpers.ts index 8d3e6883b..b4a3167d0 100644 --- a/fluxer_api/src/api/channel/services/group_dm/GroupDmHelpers.ts +++ b/fluxer_api/src/api/channel/services/group_dm/GroupDmHelpers.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; import {dispatchChannelEvent} from '@app/api/channel/services/ChannelGatewayDispatch'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import {mapChannelToResponse} from '../../ChannelMappers'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; export async function dispatchChannelDelete({ channel, diff --git a/fluxer_api/src/api/channel/services/group_dm/GroupDmOperationsService.ts b/fluxer_api/src/api/channel/services/group_dm/GroupDmOperationsService.ts index ba7b9f25e..24f2ca84c 100644 --- a/fluxer_api/src/api/channel/services/group_dm/GroupDmOperationsService.ts +++ b/fluxer_api/src/api/channel/services/group_dm/GroupDmOperationsService.ts @@ -1,6 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomInt} from 'node:crypto'; +import type {ChannelID, UserID} from '@app/api/BrandedTypes'; +import {createMessageID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import {dispatchChannelDelete} from '@app/api/channel/services/group_dm/GroupDmHelpers'; +import {dispatchMessageCreateBroadcast} from '@app/api/channel/services/message/MessageGatewayDispatch'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {User} from '@app/api/models/User'; +import {deleteChannelMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {UserPermissionUtils} from '@app/api/utils/UserPermissionUtils'; import {ChannelTypes, MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; import {MAX_GROUP_DM_RECIPIENTS} from '@fluxer/constants/src/LimitConstants'; @@ -13,26 +33,6 @@ import {CannotRemoveOtherRecipientsError} from '@fluxer/errors/src/domains/core/ import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {MissingAccessError} from '@fluxer/errors/src/domains/core/MissingAccessError'; import {NotFriendsWithUserError} from '@fluxer/errors/src/domains/user/NotFriendsWithUserError'; -import type {ChannelID, UserID} from '../../../BrandedTypes'; -import {createMessageID} from '../../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import type {User} from '../../../models/User'; -import {deleteChannelMessageSearchDocuments} from '../../../search/MessageSearchIndexCleanup'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {UserPermissionUtils} from '../../../utils/UserPermissionUtils'; -import {mapChannelToResponse} from '../../ChannelMappers'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import {dispatchMessageCreateBroadcast} from '../message/MessageGatewayDispatch'; -import type {MessagePersistenceService} from '../message/MessagePersistenceService'; -import {dispatchChannelDelete} from './GroupDmHelpers'; export class GroupDmOperationsService { private readonly userPermissionUtils: UserPermissionUtils; diff --git a/fluxer_api/src/api/channel/services/interaction/MessageInteractionAuthService.ts b/fluxer_api/src/api/channel/services/interaction/MessageInteractionAuthService.ts index 4d05a8510..e4932da08 100644 --- a/fluxer_api/src/api/channel/services/interaction/MessageInteractionAuthService.ts +++ b/fluxer_api/src/api/channel/services/interaction/MessageInteractionAuthService.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {BaseChannelAuthService, type ChannelAuthOptions} from '../BaseChannelAuthService'; +import {BaseChannelAuthService, type ChannelAuthOptions} from '@app/api/channel/services/BaseChannelAuthService'; export class MessageInteractionAuthService extends BaseChannelAuthService { protected readonly options: ChannelAuthOptions = { diff --git a/fluxer_api/src/api/channel/services/interaction/MessageInteractionBase.ts b/fluxer_api/src/api/channel/services/interaction/MessageInteractionBase.ts index 444c6979f..d9c92e455 100644 --- a/fluxer_api/src/api/channel/services/interaction/MessageInteractionBase.ts +++ b/fluxer_api/src/api/channel/services/interaction/MessageInteractionBase.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {Channel} from '@app/api/models/Channel'; import {TEXT_BASED_CHANNEL_TYPES} from '@fluxer/constants/src/ChannelConstants'; import {CannotSendMessageToNonTextChannelError} from '@fluxer/errors/src/domains/channel/CannotSendMessageToNonTextChannelError'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {Channel} from '../../../models/Channel'; export interface ParsedEmoji { id?: string; diff --git a/fluxer_api/src/api/channel/services/interaction/MessagePinAuthService.ts b/fluxer_api/src/api/channel/services/interaction/MessagePinAuthService.ts index 4f3078bc1..856664684 100644 --- a/fluxer_api/src/api/channel/services/interaction/MessagePinAuthService.ts +++ b/fluxer_api/src/api/channel/services/interaction/MessagePinAuthService.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {BaseChannelAuthService, type ChannelAuthOptions} from '../BaseChannelAuthService'; +import {BaseChannelAuthService, type ChannelAuthOptions} from '@app/api/channel/services/BaseChannelAuthService'; export class MessagePinAuthService extends BaseChannelAuthService { protected readonly options: ChannelAuthOptions = { diff --git a/fluxer_api/src/api/channel/services/interaction/MessagePinService.test.ts b/fluxer_api/src/api/channel/services/interaction/MessagePinService.test.ts index 80eca921d..64f8cf2a9 100644 --- a/fluxer_api/src/api/channel/services/interaction/MessagePinService.test.ts +++ b/fluxer_api/src/api/channel/services/interaction/MessagePinService.test.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID} from '@app/api/BrandedTypes'; +import {createChannelID, createGuildID, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {AuthenticatedChannel} from '@app/api/channel/services/AuthenticatedChannel'; +import {MessagePinService} from '@app/api/channel/services/interaction/MessagePinService'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {Message} from '@app/api/models/Message'; import {ChannelTypes, MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import {createSnowflakeFromTimestamp} from '@fluxer/snowflake/src/Snowflake'; import {describe, expect, it} from 'vitest'; -import type {ChannelID, MessageID} from '../../../BrandedTypes'; -import {createChannelID, createGuildID, createMessageID, createUserID} from '../../../BrandedTypes'; -import type {GuildAuditLogService} from '../../../guild/GuildAuditLogService'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import {Message} from '../../../models/Message'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {AuthenticatedChannel} from '../AuthenticatedChannel'; -import type {MessagePersistenceService} from '../message/MessagePersistenceService'; -import {MessagePinService} from './MessagePinService'; const CHANNEL_ID = createChannelID(10n); const GUILD_ID = createGuildID(20n); diff --git a/fluxer_api/src/api/channel/services/interaction/MessagePinService.ts b/fluxer_api/src/api/channel/services/interaction/MessagePinService.ts index 6940a05e9..4cd7a96d0 100644 --- a/fluxer_api/src/api/channel/services/interaction/MessagePinService.ts +++ b/fluxer_api/src/api/channel/services/interaction/MessagePinService.ts @@ -1,6 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {MessageID, UserID} from '@app/api/BrandedTypes'; +import {createMessageID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {AuthenticatedChannel} from '@app/api/channel/services/AuthenticatedChannel'; import {dispatchChannelEvent} from '@app/api/channel/services/ChannelGatewayDispatch'; +import {MessageInteractionBase} from '@app/api/channel/services/interaction/MessageInteractionBase'; +import { + dispatchMessageCreateBroadcast, + dispatchMessageUpdateBroadcast, +} from '@app/api/channel/services/message/MessageGatewayDispatch'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import {createMessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {MessageTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {GuildOperations} from '@fluxer/constants/src/GuildConstants'; @@ -9,20 +26,6 @@ import {UnknownMessageError} from '@fluxer/errors/src/domains/channel/UnknownMes import {FeatureTemporarilyDisabledError} from '@fluxer/errors/src/domains/core/FeatureTemporarilyDisabledError'; import type {ChannelPinResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import type {MessageID, UserID} from '../../../BrandedTypes'; -import {createMessageID} from '../../../BrandedTypes'; -import type {GuildAuditLogService} from '../../../guild/GuildAuditLogService'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {AuthenticatedChannel} from '../AuthenticatedChannel'; -import {dispatchMessageCreateBroadcast, dispatchMessageUpdateBroadcast} from '../message/MessageGatewayDispatch'; -import type {MessagePersistenceService} from '../message/MessagePersistenceService'; -import {createMessageResponseDataService} from '../message/MessageResponseDataService'; -import {MessageInteractionBase} from './MessageInteractionBase'; const PIN_LIST_UNBOUNDED_TIMESTAMP = new Date('9999-12-31T23:59:59.999Z'); diff --git a/fluxer_api/src/api/channel/services/interaction/MessageReactionService.ts b/fluxer_api/src/api/channel/services/interaction/MessageReactionService.ts index 7632688d2..69a27879e 100644 --- a/fluxer_api/src/api/channel/services/interaction/MessageReactionService.ts +++ b/fluxer_api/src/api/channel/services/interaction/MessageReactionService.ts @@ -1,6 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireEmailVerified} from '@app/api/auth/EmailVerificationUtils'; +import {createEmojiID, type MessageID, type UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {AuthenticatedChannel} from '@app/api/channel/services/AuthenticatedChannel'; import {dispatchChannelEvent} from '@app/api/channel/services/ChannelGatewayDispatch'; +import {MessageInteractionBase, type ParsedEmoji} from '@app/api/channel/services/interaction/MessageInteractionBase'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {MessageReaction} from '@app/api/models/MessageReaction'; +import type {User} from '@app/api/models/User'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapUserToPartialResponse} from '@app/api/user/UserMappers'; +import {assertGuildMemberCanCommunicate} from '@app/api/utils/GuildCommunicationUtils'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {GuildOperations} from '@fluxer/constants/src/GuildConstants'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; @@ -16,23 +33,6 @@ import {resolveLimit} from '@fluxer/limits/src/LimitResolver'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {isValidSingleUnicodeEmoji} from '@fluxer/schema/src/primitives/EmojiValidators'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import {requireEmailVerified} from '../../../auth/EmailVerificationUtils'; -import {createEmojiID, type MessageID, type UserID} from '../../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import type {MessageReaction} from '../../../models/MessageReaction'; -import type {User} from '../../../models/User'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {mapUserToPartialResponse} from '../../../user/UserMappers'; -import {assertGuildMemberCanCommunicate} from '../../../utils/GuildCommunicationUtils'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {AuthenticatedChannel} from '../AuthenticatedChannel'; -import {MessageInteractionBase, type ParsedEmoji} from './MessageInteractionBase'; const REACTION_CUSTOM_EMOJI_REGEX = /^(.+):(\d+)$/; diff --git a/fluxer_api/src/api/channel/services/interaction/MessageReadStateService.ts b/fluxer_api/src/api/channel/services/interaction/MessageReadStateService.ts index 1fb6a0647..cd8b060af 100644 --- a/fluxer_api/src/api/channel/services/interaction/MessageReadStateService.ts +++ b/fluxer_api/src/api/channel/services/interaction/MessageReadStateService.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {AuthenticatedChannel} from '@app/api/channel/services/AuthenticatedChannel'; import {dispatchChannelEvent} from '@app/api/channel/services/ChannelGatewayDispatch'; +import {MessageInteractionBase} from '@app/api/channel/services/interaction/MessageInteractionBase'; +import type {Channel} from '@app/api/models/Channel'; import {GuildOperations} from '@fluxer/constants/src/GuildConstants'; -import type {UserID} from '../../../BrandedTypes'; -import type {Channel} from '../../../models/Channel'; -import type {AuthenticatedChannel} from '../AuthenticatedChannel'; -import {MessageInteractionBase} from './MessageInteractionBase'; export class MessageReadStateService extends MessageInteractionBase { async startTyping({authChannel, userId}: {authChannel: AuthenticatedChannel; userId: UserID}): Promise { diff --git a/fluxer_api/src/api/channel/services/message/AttachmentProcessingService.ts b/fluxer_api/src/api/channel/services/message/AttachmentProcessingService.ts index c72f70cea..420664544 100644 --- a/fluxer_api/src/api/channel/services/message/AttachmentProcessingService.ts +++ b/fluxer_api/src/api/channel/services/message/AttachmentProcessingService.ts @@ -1,6 +1,30 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import fs from 'node:fs'; +import {createAttachmentID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {AttachmentToProcess} from '@app/api/channel/AttachmentDTOs'; +import type {AttachmentUploadTraceRepository} from '@app/api/channel/repositories/message/AttachmentUploadTraceRepository'; +import { + getContentType, + isMediaFile, + makeAttachmentCdnKey, + validateAttachmentIds, +} from '@app/api/channel/services/message/MessageHelpers'; +import type {MessageAttachment} from '@app/api/database/types/MessageTypes'; +import {contentModerationService, type ModerationContext} from '@app/api/infrastructure/ContentModerationService'; +import type { + IMediaService, + MediaProxyMetadataResponse, + MediaProxyNsfwMode, +} from '@app/api/infrastructure/IMediaService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService, ProcessedStorageObjectMetadata} from '@app/api/infrastructure/IStorageService'; +import {hashFileSha256} from '@app/api/infrastructure/StorageObjectHelpers'; +import {Logger} from '@app/api/Logger'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; import {MessageAttachmentFlags} from '@fluxer/constants/src/ChannelConstants'; import {MAX_MEDIA_DURATION_SECONDS} from '@fluxer/constants/src/LimitConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; @@ -12,25 +36,6 @@ import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponse import {isSupportedMediaContentType} from '@pkgs/mime_utils/src/ContentTypeUtils'; import type {IVirusScanService} from '@pkgs/virus_scan/src/IVirusScanService'; import {temporaryFile} from 'tempy'; -import {createAttachmentID, type UserID} from '../../../BrandedTypes'; -import {Config} from '../../../Config'; -import type {MessageAttachment} from '../../../database/types/MessageTypes'; -import {contentModerationService, type ModerationContext} from '../../../infrastructure/ContentModerationService'; -import type { - IMediaService, - MediaProxyMetadataResponse, - MediaProxyNsfwMode, -} from '../../../infrastructure/IMediaService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {IStorageService, ProcessedStorageObjectMetadata} from '../../../infrastructure/IStorageService'; -import {hashFileSha256} from '../../../infrastructure/StorageObjectHelpers'; -import {Logger} from '../../../Logger'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import {mapWithConcurrency} from '../../../utils/ConcurrencyUtils'; -import type {AttachmentToProcess} from '../../AttachmentDTOs'; -import type {AttachmentUploadTraceRepository} from '../../repositories/message/AttachmentUploadTraceRepository'; -import {getContentType, isMediaFile, makeAttachmentCdnKey, validateAttachmentIds} from './MessageHelpers'; const ATTACHMENT_PROCESSING_CONCURRENCY = 2; const METADATA_PROBE_DEGRADED_CONTEXT = 'message_attachment'; diff --git a/fluxer_api/src/api/channel/services/message/DmScopeUtils.ts b/fluxer_api/src/api/channel/services/message/DmScopeUtils.ts index 46d79ea50..132414891 100644 --- a/fluxer_api/src/api/channel/services/message/DmScopeUtils.ts +++ b/fluxer_api/src/api/channel/services/message/DmScopeUtils.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {Channel} from '@app/api/models/Channel'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import type {UserID} from '../../../BrandedTypes'; -import type {Channel} from '../../../models/Channel'; -import type {IUserRepository} from '../../../user/IUserRepository'; export type DmSearchScope = 'all_dms' | 'open_dms'; diff --git a/fluxer_api/src/api/channel/services/message/MessageAnonymizationService.ts b/fluxer_api/src/api/channel/services/message/MessageAnonymizationService.ts index 6449d5bf6..9b037249b 100644 --- a/fluxer_api/src/api/channel/services/message/MessageAnonymizationService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageAnonymizationService.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageID, UserID} from '../../../BrandedTypes'; -import {Logger} from '../../../Logger'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; +import type {MessageID, UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import {Logger} from '@app/api/Logger'; export class MessageAnonymizationService { constructor(private channelRepository: IChannelRepositoryAggregate) {} diff --git a/fluxer_api/src/api/channel/services/message/MessageChannelAuthService.ts b/fluxer_api/src/api/channel/services/message/MessageChannelAuthService.ts index a23b02575..2189351ad 100644 --- a/fluxer_api/src/api/channel/services/message/MessageChannelAuthService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageChannelAuthService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {BaseChannelAuthService, type ChannelAuthOptions} from '@app/api/channel/services/BaseChannelAuthService'; +import type {User} from '@app/api/models/User'; +import {checkGuildVerificationWithResponse} from '@app/api/utils/GuildVerificationUtils'; import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {User} from '../../../models/User'; -import {checkGuildVerificationWithResponse} from '../../../utils/GuildVerificationUtils'; -import {BaseChannelAuthService, type ChannelAuthOptions} from '../BaseChannelAuthService'; export class MessageChannelAuthService extends BaseChannelAuthService { protected readonly options: ChannelAuthOptions = { diff --git a/fluxer_api/src/api/channel/services/message/MessageContentService.ts b/fluxer_api/src/api/channel/services/message/MessageContentService.ts index d4c31ddb4..5562adba5 100644 --- a/fluxer_api/src/api/channel/services/message/MessageContentService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageContentService.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID, WebhookID} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {Channel} from '@app/api/models/Channel'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import * as EmojiUtils from '@app/api/utils/EmojiUtils'; import {ChannelTypes, GUILD_TEXT_BASED_CHANNEL_TYPES} from '@fluxer/constants/src/ChannelConstants'; import {GuildExplicitContentFilterTypes, GuildFeatures, GuildNSFWLevel} from '@fluxer/constants/src/GuildConstants'; import {SensitiveMediaFilterLevel} from '@fluxer/constants/src/UserConstants'; import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {GuildID, UserID, WebhookID} from '../../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import type {Channel} from '../../../models/Channel'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import * as EmojiUtils from '../../../utils/EmojiUtils'; export interface DmNsfwContext { senderFilterLevel: number; diff --git a/fluxer_api/src/api/channel/services/message/MessageDeleteService.ts b/fluxer_api/src/api/channel/services/message/MessageDeleteService.ts index 69628a606..313e2f007 100644 --- a/fluxer_api/src/api/channel/services/message/MessageDeleteService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageDeleteService.ts @@ -1,5 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {createMessageID, createUserID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {MessageChannelAuthService} from '@app/api/channel/services/message/MessageChannelAuthService'; +import type {MessageDispatchService} from '@app/api/channel/services/message/MessageDispatchService'; +import {isOperationDisabled, purgeMessageAttachments} from '@app/api/channel/services/message/MessageHelpers'; +import type {MessageSearchService} from '@app/api/channel/services/message/MessageSearchService'; +import type {MessageValidationService} from '@app/api/channel/services/message/MessageValidationService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {Webhook} from '@app/api/models/Webhook'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {GuildOperations} from '@fluxer/constants/src/GuildConstants'; @@ -12,22 +28,6 @@ import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidat import {MissingPermissionsError} from '@fluxer/errors/src/domains/core/MissingPermissionsError'; import {createSnowflakeFromTimestamp} from '@fluxer/snowflake/src/Snowflake'; import {ms} from 'itty-time'; -import type {ChannelID, GuildID, MessageID, UserID} from '../../../BrandedTypes'; -import {createMessageID, createUserID} from '../../../BrandedTypes'; -import type {GuildAuditLogService} from '../../../guild/GuildAuditLogService'; -import type {IPurgeQueue} from '../../../infrastructure/BunnyPurgeQueue'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {IStorageService} from '../../../infrastructure/IStorageService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import type {Webhook} from '../../../models/Webhook'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {MessageChannelAuthService} from './MessageChannelAuthService'; -import type {MessageDispatchService} from './MessageDispatchService'; -import {isOperationDisabled, purgeMessageAttachments} from './MessageHelpers'; -import type {MessageSearchService} from './MessageSearchService'; -import type {MessageValidationService} from './MessageValidationService'; interface MessageDeleteServiceDeps { channelRepository: IChannelRepositoryAggregate; diff --git a/fluxer_api/src/api/channel/services/message/MessageDispatchService.ts b/fluxer_api/src/api/channel/services/message/MessageDispatchService.ts index 13bc27ead..3e705d524 100644 --- a/fluxer_api/src/api/channel/services/message/MessageDispatchService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageDispatchService.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {MessageID, UserID} from '@app/api/BrandedTypes'; import {dispatchChannelEvent} from '@app/api/channel/services/ChannelGatewayDispatch'; -import type {MessageID, UserID} from '../../../BrandedTypes'; -import type {GatewayDispatchEvent} from '../../../constants/Gateway'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; import { dispatchMessageCreateBroadcast, dispatchMessageCreateToUser, dispatchMessageUpdateBroadcast, -} from './MessageGatewayDispatch'; +} from '@app/api/channel/services/message/MessageGatewayDispatch'; +import type {GatewayDispatchEvent} from '@app/api/constants/Gateway'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; export class MessageDispatchService { constructor(private gatewayService: IGatewayService) {} diff --git a/fluxer_api/src/api/channel/services/message/MessageEditService.ts b/fluxer_api/src/api/channel/services/message/MessageEditService.ts index 79836d028..0087f37cb 100644 --- a/fluxer_api/src/api/channel/services/message/MessageEditService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageEditService.ts @@ -1,5 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {MessageUpdateRequest} from '@app/api/channel/MessageTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {AuthenticatedChannel} from '@app/api/channel/services/AuthenticatedChannel'; +import type {MessageChannelAuthService} from '@app/api/channel/services/message/MessageChannelAuthService'; +import type {MessageDispatchService} from '@app/api/channel/services/message/MessageDispatchService'; +import type {MessageEmbedAttachmentResolver} from '@app/api/channel/services/message/MessageEmbedAttachmentResolver'; +import {isOperationDisabled} from '@app/api/channel/services/message/MessageHelpers'; +import type {MessageMentionService} from '@app/api/channel/services/message/MessageMentionService'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import type {MessageProcessingService} from '@app/api/channel/services/message/MessageProcessingService'; +import type {MessageSearchService} from '@app/api/channel/services/message/MessageSearchService'; +import type {MessageValidationService} from '@app/api/channel/services/message/MessageValidationService'; +import {Logger} from '@app/api/Logger'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Message} from '@app/api/models/Message'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {assertGuildMemberCanCommunicate} from '@app/api/utils/GuildCommunicationUtils'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {GuildOperations} from '@fluxer/constants/src/GuildConstants'; @@ -10,24 +28,6 @@ import {MissingPermissionsError} from '@fluxer/errors/src/domains/core/MissingPe import {ThrottledError} from '@fluxer/errors/src/domains/core/ThrottledError'; import type {AllowedMentionsRequest} from '@fluxer/schema/src/domains/message/SharedMessageSchemas'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import type {ChannelID, MessageID, UserID} from '../../../BrandedTypes'; -import {Logger} from '../../../Logger'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Message} from '../../../models/Message'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {assertGuildMemberCanCommunicate} from '../../../utils/GuildCommunicationUtils'; -import type {MessageUpdateRequest} from '../../MessageTypes'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {AuthenticatedChannel} from '../AuthenticatedChannel'; -import type {MessageChannelAuthService} from './MessageChannelAuthService'; -import type {MessageDispatchService} from './MessageDispatchService'; -import type {MessageEmbedAttachmentResolver} from './MessageEmbedAttachmentResolver'; -import {isOperationDisabled} from './MessageHelpers'; -import type {MessageMentionService} from './MessageMentionService'; -import type {MessagePersistenceService} from './MessagePersistenceService'; -import type {MessageProcessingService} from './MessageProcessingService'; -import type {MessageSearchService} from './MessageSearchService'; -import type {MessageValidationService} from './MessageValidationService'; const MESSAGE_LOCK_TTL_SECONDS = 5; const MESSAGE_LOCK_ACQUIRE_ATTEMPTS = 6; diff --git a/fluxer_api/src/api/channel/services/message/MessageEmbedAttachmentResolver.ts b/fluxer_api/src/api/channel/services/message/MessageEmbedAttachmentResolver.ts index b3a0e2037..628113cec 100644 --- a/fluxer_api/src/api/channel/services/message/MessageEmbedAttachmentResolver.ts +++ b/fluxer_api/src/api/channel/services/message/MessageEmbedAttachmentResolver.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AttachmentID, ChannelID} from '@app/api/BrandedTypes'; +import type {AttachmentRequestData} from '@app/api/channel/AttachmentDTOs'; +import type {RichEmbedMediaWithMetadata} from '@app/api/channel/EmbedTypes'; +import {makeAttachmentCdnUrl} from '@app/api/channel/services/message/MessageHelpers'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {RichEmbedRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; -import type {AttachmentID, ChannelID} from '../../../BrandedTypes'; -import type {AttachmentRequestData} from '../../AttachmentDTOs'; -import type {RichEmbedMediaWithMetadata} from '../../EmbedTypes'; -import {makeAttachmentCdnUrl} from './MessageHelpers'; interface ProcessedAttachment { attachment_id: AttachmentID; diff --git a/fluxer_api/src/api/channel/services/message/MessageGatewayDispatch.ts b/fluxer_api/src/api/channel/services/message/MessageGatewayDispatch.ts index bbf19aa96..b985926d6 100644 --- a/fluxer_api/src/api/channel/services/message/MessageGatewayDispatch.ts +++ b/fluxer_api/src/api/channel/services/message/MessageGatewayDispatch.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {dispatchChannelEvent} from '@app/api/channel/services/ChannelGatewayDispatch'; +import {createMessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import type {GuildID, UserID} from '../../../BrandedTypes'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import {dispatchChannelEvent} from '../ChannelGatewayDispatch'; -import {createMessageResponseDataService} from './MessageResponseDataService'; interface BuildBroadcastMessageDataParams { channel: Channel; diff --git a/fluxer_api/src/api/channel/services/message/MessageHelpers.ts b/fluxer_api/src/api/channel/services/message/MessageHelpers.ts index bdbcbcf81..bf1b6ef62 100644 --- a/fluxer_api/src/api/channel/services/message/MessageHelpers.ts +++ b/fluxer_api/src/api/channel/services/message/MessageHelpers.ts @@ -1,5 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AttachmentID, ChannelID, UserID} from '@app/api/BrandedTypes'; +import {createAttachmentID, userIdToChannelId} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type { + MessageSnapshot as CassandraMessageSnapshot, + MessageAttachment, +} from '@app/api/database/types/MessageTypes'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import {Attachment} from '@app/api/models/Attachment'; +import type {Embed} from '@app/api/models/Embed'; +import type {Message} from '@app/api/models/Message'; +import {MessageSnapshot as MessageSnapshotModel} from '@app/api/models/MessageSnapshot'; +import type {User} from '@app/api/models/User'; import {S3ServiceException} from '@aws-sdk/client-s3'; import {MessageFlags} from '@fluxer/constants/src/ChannelConstants'; import {ATTACHMENT_MAX_SIZE_NON_PREMIUM} from '@fluxer/constants/src/LimitConstants'; @@ -10,25 +29,6 @@ import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponse import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import {getContentTypeFromFilename, isSupportedMediaContentType} from '@pkgs/mime_utils/src/ContentTypeUtils'; import {seconds} from 'itty-time'; -import type {AttachmentID, ChannelID, UserID} from '../../../BrandedTypes'; -import {createAttachmentID, userIdToChannelId} from '../../../BrandedTypes'; -import {Config} from '../../../Config'; -import type { - MessageSnapshot as CassandraMessageSnapshot, - MessageAttachment, -} from '../../../database/types/MessageTypes'; -import type {IPurgeQueue} from '../../../infrastructure/BunnyPurgeQueue'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../../../infrastructure/IStorageService'; -import {Logger} from '../../../Logger'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import {Attachment} from '../../../models/Attachment'; -import type {Embed} from '../../../models/Embed'; -import type {Message} from '../../../models/Message'; -import {MessageSnapshot as MessageSnapshotModel} from '../../../models/MessageSnapshot'; -import type {User} from '../../../models/User'; export const MESSAGE_NONCE_TTL = seconds('5 minutes'); diff --git a/fluxer_api/src/api/channel/services/message/MessageMentionService.ts b/fluxer_api/src/api/channel/services/message/MessageMentionService.ts index ad93fac7e..4e79f52e9 100644 --- a/fluxer_api/src/api/channel/services/message/MessageMentionService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageMentionService.ts @@ -1,5 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + type ChannelID, + createChannelID, + createRoleID, + createUserID, + type GuildID, + type RoleID, + type UserID, +} from '@app/api/BrandedTypes'; +import {isOperationDisabled, isPersonalNotesChannel} from '@app/api/channel/services/message/MessageHelpers'; +import type {MessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GatewayChannelMention, IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; +import {WorkerQueueOverflowError} from '@app/api/worker/WorkerQueueOverflowError'; import {ChannelTypes, MessageTypes, SENDABLE_MESSAGE_FLAGS} from '@fluxer/constants/src/ChannelConstants'; import {GuildOperations} from '@fluxer/constants/src/GuildConstants'; import {RelationshipTypes, UserFlags} from '@fluxer/constants/src/UserConstants'; @@ -11,25 +30,6 @@ import { type AllowedMentionsRequest, } from '@fluxer/schema/src/domains/message/SharedMessageSchemas'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import { - type ChannelID, - createChannelID, - createRoleID, - createUserID, - type GuildID, - type RoleID, - type UserID, -} from '../../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {GatewayChannelMention, IGatewayService} from '../../../infrastructure/IGatewayService'; -import {Logger} from '../../../Logger'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import type {WorkerTaskName} from '../../../worker/WorkerLaneConfig'; -import {WorkerQueueOverflowError} from '../../../worker/WorkerQueueOverflowError'; -import {isOperationDisabled, isPersonalNotesChannel} from './MessageHelpers'; -import type {MessageResponseDataService} from './MessageResponseDataService'; interface MentionData { userMentions: Set; diff --git a/fluxer_api/src/api/channel/services/message/MessageOperationsHelpers.ts b/fluxer_api/src/api/channel/services/message/MessageOperationsHelpers.ts index 08c08565a..c40bc97c2 100644 --- a/fluxer_api/src/api/channel/services/message/MessageOperationsHelpers.ts +++ b/fluxer_api/src/api/channel/services/message/MessageOperationsHelpers.ts @@ -1,25 +1,25 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, UserID} from '@app/api/BrandedTypes'; +import {createAttachmentID, createChannelID, createMemeID, createMessageID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import {makeAttachmentCdnKey} from '@app/api/channel/services/message/MessageHelpers'; +import type {MessageAttachment} from '@app/api/database/types/MessageTypes'; +import type {IFavoriteMemeRepository} from '@app/api/favorite_meme/IFavoriteMemeRepository'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import type {FavoriteMeme} from '@app/api/models/FavoriteMeme'; +import type {Message} from '@app/api/models/Message'; +import type {User} from '@app/api/models/User'; import {S3ServiceException} from '@aws-sdk/client-s3'; import {MessageAttachmentFlags} from '@fluxer/constants/src/ChannelConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {UnknownMessageError} from '@fluxer/errors/src/domains/channel/UnknownMessageError'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import type {ChannelID, UserID} from '../../../BrandedTypes'; -import {createAttachmentID, createChannelID, createMemeID, createMessageID} from '../../../BrandedTypes'; -import {Config} from '../../../Config'; -import type {MessageAttachment} from '../../../database/types/MessageTypes'; -import type {IFavoriteMemeRepository} from '../../../favorite_meme/IFavoriteMemeRepository'; -import type {IMediaService} from '../../../infrastructure/IMediaService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../../../infrastructure/IStorageService'; -import {Logger} from '../../../Logger'; -import type {FavoriteMeme} from '../../../models/FavoriteMeme'; -import type {Message} from '../../../models/Message'; -import type {User} from '../../../models/User'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import {makeAttachmentCdnKey} from './MessageHelpers'; interface MessageOperationsHelpersDeps { channelRepository: IChannelRepositoryAggregate; diff --git a/fluxer_api/src/api/channel/services/message/MessagePersistenceService.ts b/fluxer_api/src/api/channel/services/message/MessagePersistenceService.ts index 143b3dfd2..00fa40470 100644 --- a/fluxer_api/src/api/channel/services/message/MessagePersistenceService.ts +++ b/fluxer_api/src/api/channel/services/message/MessagePersistenceService.ts @@ -1,6 +1,44 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; +import {AttachmentDecayService} from '@app/api/attachment/AttachmentDecayService'; +import type {ChannelID, GuildID, MessageID, RoleID, StickerID, UserID, WebhookID} from '@app/api/BrandedTypes'; +import {createAttachmentID, createGuildID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {AttachmentToProcess} from '@app/api/channel/AttachmentDTOs'; +import type {MessageUpdateRequest} from '@app/api/channel/MessageTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {AttachmentUploadTraceRepository} from '@app/api/channel/repositories/message/AttachmentUploadTraceRepository'; +import {AttachmentProcessingService} from '@app/api/channel/services/message/AttachmentProcessingService'; +import {type DmNsfwContext, MessageContentService} from '@app/api/channel/services/message/MessageContentService'; +import {MessageEmbedAttachmentResolver} from '@app/api/channel/services/message/MessageEmbedAttachmentResolver'; +import { + assertAttachmentFileSizesWithinLimit, + collectMessageAttachments, +} from '@app/api/channel/services/message/MessageHelpers'; +import {MessageStickerService} from '@app/api/channel/services/message/MessageStickerService'; +import {getContentMessage} from '@app/api/content_i18n/ContentI18n'; +import type { + MessageAttachment, + MessageEmbed, + MessageReference, + MessageStickerItem, +} from '@app/api/database/types/MessageTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {EmbedService} from '@app/api/infrastructure/EmbedService'; +import type {IMediaService, MediaProxyNsfwMode} from '@app/api/infrastructure/IMediaService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {MessageSnapshot} from '@app/api/models/MessageSnapshot'; +import type {User} from '@app/api/models/User'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {hasVisibleContent} from '@app/api/utils/StringUtils'; import {MessageFlags, Permissions, SENDABLE_MESSAGE_FLAGS} from '@fluxer/constants/src/ChannelConstants'; import {ATTACHMENT_MAX_SIZE_NON_PREMIUM} from '@fluxer/constants/src/LimitConstants'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; @@ -13,41 +51,6 @@ import type {AllowedMentionsRequest} from '@fluxer/schema/src/domains/message/Sh import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; import type {IVirusScanService} from '@pkgs/virus_scan/src/IVirusScanService'; -import {AttachmentDecayService} from '../../../attachment/AttachmentDecayService'; -import type {ChannelID, GuildID, MessageID, RoleID, StickerID, UserID, WebhookID} from '../../../BrandedTypes'; -import {createAttachmentID, createGuildID} from '../../../BrandedTypes'; -import {Config} from '../../../Config'; -import {getContentMessage} from '../../../content_i18n/ContentI18n'; -import type { - MessageAttachment, - MessageEmbed, - MessageReference, - MessageStickerItem, -} from '../../../database/types/MessageTypes'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {EmbedService} from '../../../infrastructure/EmbedService'; -import type {IMediaService, MediaProxyNsfwMode} from '../../../infrastructure/IMediaService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../../../infrastructure/IStorageService'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import type {MessageSnapshot} from '../../../models/MessageSnapshot'; -import type {User} from '../../../models/User'; -import type {ReadStateService} from '../../../read_state/ReadStateService'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {hasVisibleContent} from '../../../utils/StringUtils'; -import type {AttachmentToProcess} from '../../AttachmentDTOs'; -import type {MessageUpdateRequest} from '../../MessageTypes'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {AttachmentUploadTraceRepository} from '../../repositories/message/AttachmentUploadTraceRepository'; -import {AttachmentProcessingService} from './AttachmentProcessingService'; -import {type DmNsfwContext, MessageContentService} from './MessageContentService'; -import {MessageEmbedAttachmentResolver} from './MessageEmbedAttachmentResolver'; -import {assertAttachmentFileSizesWithinLimit, collectMessageAttachments} from './MessageHelpers'; -import {MessageStickerService} from './MessageStickerService'; function mapAttachmentForEmbedResolution(att: MessageAttachment) { return { diff --git a/fluxer_api/src/api/channel/services/message/MessageProcessingService.test.ts b/fluxer_api/src/api/channel/services/message/MessageProcessingService.test.ts index c8bc50c59..8c8e145b6 100644 --- a/fluxer_api/src/api/channel/services/message/MessageProcessingService.test.ts +++ b/fluxer_api/src/api/channel/services/message/MessageProcessingService.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import {describe, expect, it} from 'vitest'; import { type ChannelID, createChannelID, @@ -9,14 +7,16 @@ import { createUserID, type MessageID, type UserID, -} from '../../../BrandedTypes'; -import type {ChannelRow} from '../../../database/types/ChannelTypes'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import {Channel} from '../../../models/Channel'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {MessageProcessingService} from './MessageProcessingService'; +} from '@app/api/BrandedTypes'; +import {MessageProcessingService} from '@app/api/channel/services/message/MessageProcessingService'; +import type {ChannelRow} from '@app/api/database/types/ChannelTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {Channel} from '@app/api/models/Channel'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; +import {describe, expect, it} from 'vitest'; const CHANNEL_ID = createChannelID(1532860318772891648n); const AUTHOR_ID = createUserID(1471426754353995881n); diff --git a/fluxer_api/src/api/channel/services/message/MessageProcessingService.ts b/fluxer_api/src/api/channel/services/message/MessageProcessingService.ts index 1e8e97e21..7d8beb131 100644 --- a/fluxer_api/src/api/channel/services/message/MessageProcessingService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageProcessingService.ts @@ -1,27 +1,27 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createChannelID, createGuildID, type MessageID, type UserID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {MessageRequest, MessageUpdateRequest} from '@app/api/channel/MessageTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {MessageDispatchService} from '@app/api/channel/services/message/MessageDispatchService'; +import {isPersonalNotesChannel} from '@app/api/channel/services/message/MessageHelpers'; +import type {MessageMentionService} from '@app/api/channel/services/message/MessageMentionService'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import {incrementDmMentionCounts} from '@app/api/channel/services/message/ReadStateHelpers'; +import type {GatewayChannelMention, IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {User} from '@app/api/models/User'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {CannotEditOtherUserMessageError} from '@fluxer/errors/src/domains/channel/CannotEditOtherUserMessageError'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import type {AllowedMentionsRequest} from '@fluxer/schema/src/domains/message/SharedMessageSchemas'; -import {type ChannelID, createChannelID, createGuildID, type MessageID, type UserID} from '../../../BrandedTypes'; -import type {GatewayChannelMention, IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import {Logger} from '../../../Logger'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import type {User} from '../../../models/User'; -import type {ReadStateService} from '../../../read_state/ReadStateService'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {mapChannelToResponse} from '../../ChannelMappers'; -import type {MessageRequest, MessageUpdateRequest} from '../../MessageTypes'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {MessageDispatchService} from './MessageDispatchService'; -import {isPersonalNotesChannel} from './MessageHelpers'; -import type {MessageMentionService} from './MessageMentionService'; -import type {MessagePersistenceService} from './MessagePersistenceService'; -import {incrementDmMentionCounts} from './ReadStateHelpers'; interface RecipientOpenState { recipientId: UserID; diff --git a/fluxer_api/src/api/channel/services/message/MessageRequestParser.ts b/fluxer_api/src/api/channel/services/message/MessageRequestParser.ts index b0dc4f3d3..9b3036db6 100644 --- a/fluxer_api/src/api/channel/services/message/MessageRequestParser.ts +++ b/fluxer_api/src/api/channel/services/message/MessageRequestParser.ts @@ -1,5 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import { + type AttachmentRequestData, + mergeUploadWithClientData, + type UploadedAttachment, +} from '@app/api/channel/AttachmentDTOs'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {MessageRequest, MessageUpdateRequest} from '@app/api/channel/MessageTypes'; +import {normalizeMessageRequestPayload} from '@app/api/channel/services/message/MessageRequestCompatibility'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {User} from '@app/api/models/User'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {parseJsonPreservingLargeIntegers} from '@app/api/utils/LosslessJsonParser'; +import {inputValidationErrorFromZodIssues} from '@app/api/Validator'; import {MAX_ATTACHMENTS_PER_MESSAGE} from '@fluxer/constants/src/LimitConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; @@ -11,20 +29,6 @@ import type { } from '@fluxer/schema/src/domains/message/AttachmentSchemas'; import type {Context} from 'hono'; import type {z} from 'zod'; -import type {ChannelID} from '../../../BrandedTypes'; -import {Config} from '../../../Config'; -import type {GuildService} from '../../../guild/services/GuildService'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {User} from '../../../models/User'; -import type {HonoEnv} from '../../../types/HonoEnv'; -import {parseJsonPreservingLargeIntegers} from '../../../utils/LosslessJsonParser'; -import {inputValidationErrorFromZodIssues} from '../../../Validator'; -import {type AttachmentRequestData, mergeUploadWithClientData, type UploadedAttachment} from '../../AttachmentDTOs'; -import type {IChannelRepository} from '../../IChannelRepository'; -import type {MessageRequest, MessageUpdateRequest} from '../../MessageTypes'; -import {normalizeMessageRequestPayload} from './MessageRequestCompatibility'; const FIELD_NAME_PATTERN = /^files\[(\d+)\]$/; const LEGACY_FILE_FIELD_NAME_PATTERN = /^file(\d+)?$/; diff --git a/fluxer_api/src/api/channel/services/message/MessageRequestService.ts b/fluxer_api/src/api/channel/services/message/MessageRequestService.ts index cecee6d04..759b94f5b 100644 --- a/fluxer_api/src/api/channel/services/message/MessageRequestService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageRequestService.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {MessageRequest, MessageUpdateRequest} from '@app/api/channel/MessageTypes'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import {isPersonalNotesChannel} from '@app/api/channel/services/message/MessageHelpers'; +import type {MessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; import {UnclaimedAccountCannotSendMessagesError} from '@fluxer/errors/src/domains/channel/UnclaimedAccountCannotSendMessagesError'; import {UnknownMessageError} from '@fluxer/errors/src/domains/channel/UnknownMessageError'; import type { BulkMessageFetchResponse, MessageResponse, } from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import type {ChannelID, MessageID, UserID} from '../../../BrandedTypes'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {User} from '../../../models/User'; -import {mapWithConcurrency} from '../../../utils/ConcurrencyUtils'; -import type {MessageRequest, MessageUpdateRequest} from '../../MessageTypes'; -import type {ChannelService} from '../ChannelService'; -import {isPersonalNotesChannel} from './MessageHelpers'; -import type {MessageResponseDataService} from './MessageResponseDataService'; export class MessageRequestService { constructor( diff --git a/fluxer_api/src/api/channel/services/message/MessageResponseDataService.test.ts b/fluxer_api/src/api/channel/services/message/MessageResponseDataService.test.ts index a784b4d39..a29a0eeb7 100644 --- a/fluxer_api/src/api/channel/services/message/MessageResponseDataService.test.ts +++ b/fluxer_api/src/api/channel/services/message/MessageResponseDataService.test.ts @@ -1,12 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createGuildID, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import { + MESSAGE_BUILD_BATCH_MAX_BYTES, + MessageResponseDataService, +} from '@app/api/channel/services/message/MessageResponseDataService'; +import {Message} from '@app/api/models/Message'; import {MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import type {NatsConnection} from 'nats'; import {describe, expect, it} from 'vitest'; -import {createChannelID, createGuildID, createMessageID, createUserID} from '../../../BrandedTypes'; -import {Message} from '../../../models/Message'; -import {MESSAGE_BUILD_BATCH_MAX_BYTES, MessageResponseDataService} from './MessageResponseDataService'; const encoder = new TextEncoder(); const decoder = new TextDecoder(); diff --git a/fluxer_api/src/api/channel/services/message/MessageResponseDataService.ts b/fluxer_api/src/api/channel/services/message/MessageResponseDataService.ts index 195bce6d9..cee36898c 100644 --- a/fluxer_api/src/api/channel/services/message/MessageResponseDataService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageResponseDataService.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {throwForSvcErrorReply} from '@app/api/infrastructure/SvcErrorReply'; +import {Logger} from '@app/api/Logger'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import {isJsonRecord, parseJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import {NatsConnectionManager} from '@pkgs/nats/src/NatsConnectionManager'; import {StringCodec} from 'nats'; -import type {ChannelID, GuildID, MessageID, UserID} from '../../../BrandedTypes'; -import {createUserID} from '../../../BrandedTypes'; -import {Config} from '../../../Config'; -import {throwForSvcErrorReply} from '../../../infrastructure/SvcErrorReply'; -import {Logger} from '../../../Logger'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import {isJsonRecord, parseJsonRecord, parseJsonWithGuard} from '../../../utils/JsonBoundaryUtils'; const MESSAGE_RESPONSE_SERVICE_SUBJECT = 'svc.messages'; const MESSAGE_RESPONSE_SERVICE_TIMEOUT_MS = 6000; diff --git a/fluxer_api/src/api/channel/services/message/MessageRetrievalService.test.ts b/fluxer_api/src/api/channel/services/message/MessageRetrievalService.test.ts index 4ee6e01a8..7ced23f74 100644 --- a/fluxer_api/src/api/channel/services/message/MessageRetrievalService.test.ts +++ b/fluxer_api/src/api/channel/services/message/MessageRetrievalService.test.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AttachmentDecayService} from '@app/api/attachment/AttachmentDecayService'; +import type {ChannelID, MessageID} from '@app/api/BrandedTypes'; +import {createChannelID, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {AuthenticatedChannel} from '@app/api/channel/services/AuthenticatedChannel'; +import type {MessageChannelAuthService} from '@app/api/channel/services/message/MessageChannelAuthService'; +import type {MessageProcessingService} from '@app/api/channel/services/message/MessageProcessingService'; +import {MessageRetrievalService} from '@app/api/channel/services/message/MessageRetrievalService'; +import type {MessageSearchService} from '@app/api/channel/services/message/MessageSearchService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Message} from '@app/api/models/Message'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import {createSnowflakeFromTimestamp} from '@fluxer/snowflake/src/Snowflake'; import {describe, expect, it} from 'vitest'; -import type {AttachmentDecayService} from '../../../attachment/AttachmentDecayService'; -import type {ChannelID, MessageID} from '../../../BrandedTypes'; -import {createChannelID, createMessageID, createUserID} from '../../../BrandedTypes'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import {Message} from '../../../models/Message'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {AuthenticatedChannel} from '../AuthenticatedChannel'; -import type {MessageChannelAuthService} from './MessageChannelAuthService'; -import type {MessageProcessingService} from './MessageProcessingService'; -import {MessageRetrievalService} from './MessageRetrievalService'; -import type {MessageSearchService} from './MessageSearchService'; const CHANNEL_ID = createChannelID(10n); const VIEWER_ID = createUserID(7n); diff --git a/fluxer_api/src/api/channel/services/message/MessageRetrievalService.ts b/fluxer_api/src/api/channel/services/message/MessageRetrievalService.ts index 131fa2101..16b685107 100644 --- a/fluxer_api/src/api/channel/services/message/MessageRetrievalService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageRetrievalService.ts @@ -1,31 +1,34 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AttachmentDecayService} from '@app/api/attachment/AttachmentDecayService'; +import type {AttachmentID, ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {AuthenticatedChannel} from '@app/api/channel/services/AuthenticatedChannel'; +import {getDmChannelIdsForScope} from '@app/api/channel/services/message/DmScopeUtils'; +import type {MessageChannelAuthService} from '@app/api/channel/services/message/MessageChannelAuthService'; +import {collectMessageAttachments} from '@app/api/channel/services/message/MessageHelpers'; +import type {MessageProcessingService} from '@app/api/channel/services/message/MessageProcessingService'; +import { + createMessageResponseDataService, + type MessageResponseAccessContext, +} from '@app/api/channel/services/message/MessageResponseDataService'; +import type {MessageSearchService} from '@app/api/channel/services/message/MessageSearchService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import {getMessageSearchService} from '@app/api/SearchFactory'; +import {buildMessageSearchFilters} from '@app/api/search/BuildMessageSearchFilters'; +import {channelNeedsReindexing} from '@app/api/search/ChannelIndexingUtils'; +import {searchExistingMessages} from '@app/api/search/MessageSearchResultReconciler'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {UnknownMessageError} from '@fluxer/errors/src/domains/channel/UnknownMessageError'; import {FeatureTemporarilyDisabledError} from '@fluxer/errors/src/domains/core/FeatureTemporarilyDisabledError'; import type {MessageSearchRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {MessageSearchResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import {AttachmentDecayService} from '../../../attachment/AttachmentDecayService'; -import type {AttachmentID, ChannelID, MessageID, UserID} from '../../../BrandedTypes'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import {getMessageSearchService} from '../../../SearchFactory'; -import {buildMessageSearchFilters} from '../../../search/BuildMessageSearchFilters'; -import {channelNeedsReindexing} from '../../../search/ChannelIndexingUtils'; -import {searchExistingMessages} from '../../../search/MessageSearchResultReconciler'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {mapChannelToResponse} from '../../ChannelMappers'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {AuthenticatedChannel} from '../AuthenticatedChannel'; -import {getDmChannelIdsForScope} from './DmScopeUtils'; -import type {MessageChannelAuthService} from './MessageChannelAuthService'; -import {collectMessageAttachments} from './MessageHelpers'; -import type {MessageProcessingService} from './MessageProcessingService'; -import {createMessageResponseDataService, type MessageResponseAccessContext} from './MessageResponseDataService'; -import type {MessageSearchService} from './MessageSearchService'; export class MessageRetrievalService { constructor( diff --git a/fluxer_api/src/api/channel/services/message/MessageSearchService.ts b/fluxer_api/src/api/channel/services/message/MessageSearchService.ts index 2ae2f8bb0..b13e88e75 100644 --- a/fluxer_api/src/api/channel/services/message/MessageSearchService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageSearchService.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import type {Message} from '@app/api/models/Message'; +import {getMessageSearchService} from '@app/api/SearchFactory'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import {deleteMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import type {MessageSearchFilters} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import type {MessageSearchRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import type {ChannelID, MessageID} from '../../../BrandedTypes'; -import {Logger} from '../../../Logger'; -import type {Message} from '../../../models/Message'; -import {getMessageSearchService} from '../../../SearchFactory'; -import type {IMessageSearchService} from '../../../search/IMessageSearchService'; -import {deleteMessageSearchDocuments} from '../../../search/MessageSearchIndexCleanup'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import type {WorkerTaskName} from '../../../worker/WorkerLaneConfig'; interface MessageSearchIndexOptions { includeDefault?: boolean; diff --git a/fluxer_api/src/api/channel/services/message/MessageSendService.ts b/fluxer_api/src/api/channel/services/message/MessageSendService.ts index a0669bd1c..3b05d5a6b 100644 --- a/fluxer_api/src/api/channel/services/message/MessageSendService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageSendService.ts @@ -1,5 +1,53 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AttachmentID, ChannelID, GuildID, MessageID, RoleID, UserID} from '@app/api/BrandedTypes'; +import { + createAttachmentID, + createChannelID, + createGuildID, + createMessageID, + createStickerID, + createUserID, +} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {AttachmentRequestData, AttachmentToProcess} from '@app/api/channel/AttachmentDTOs'; +import type {MessageRequest, MessageUpdateRequest} from '@app/api/channel/MessageTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {AttachmentUploadTraceRepository} from '@app/api/channel/repositories/message/AttachmentUploadTraceRepository'; +import type {AuthenticatedChannel} from '@app/api/channel/services/AuthenticatedChannel'; +import type {MessageChannelAuthService} from '@app/api/channel/services/message/MessageChannelAuthService'; +import type {DmNsfwContext} from '@app/api/channel/services/message/MessageContentService'; +import type {MessageDispatchService} from '@app/api/channel/services/message/MessageDispatchService'; +import type {MessageEmbedAttachmentResolver} from '@app/api/channel/services/message/MessageEmbedAttachmentResolver'; +import { + createMessageSnapshotsForForward, + type ForwardMediaSelection, + isOperationDisabled, + isPersonalNotesChannel, +} from '@app/api/channel/services/message/MessageHelpers'; +import type {MessageMentionService} from '@app/api/channel/services/message/MessageMentionService'; +import type {MessageOperationsHelpers} from '@app/api/channel/services/message/MessageOperationsHelpers'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import type {MessageProcessingService} from '@app/api/channel/services/message/MessageProcessingService'; +import type {MessageSearchService} from '@app/api/channel/services/message/MessageSearchService'; +import type {MessageValidationService} from '@app/api/channel/services/message/MessageValidationService'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import type {MessageAttachment, MessageReference} from '@app/api/database/types/MessageTypes'; +import type {IFavoriteMemeRepository} from '@app/api/favorite_meme/IFavoriteMemeRepository'; +import type {GatewayChannelMention, IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {MessageSnapshot} from '@app/api/models/MessageSnapshot'; +import type {User} from '@app/api/models/User'; +import type {Webhook} from '@app/api/models/Webhook'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {DirectMessageSpamMitigationService} from '@app/api/user/services/DirectMessageSpamMitigationService'; +import {assertGuildMemberCanCommunicate} from '@app/api/utils/GuildCommunicationUtils'; import { ChannelTypes, MessageFlags, @@ -28,54 +76,6 @@ import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMe import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; -import type {AttachmentID, ChannelID, GuildID, MessageID, RoleID, UserID} from '../../../BrandedTypes'; -import { - createAttachmentID, - createChannelID, - createGuildID, - createMessageID, - createStickerID, - createUserID, -} from '../../../BrandedTypes'; -import {Config} from '../../../Config'; -import {SYSTEM_USER_ID} from '../../../constants/Core'; -import type {MessageAttachment, MessageReference} from '../../../database/types/MessageTypes'; -import type {IFavoriteMemeRepository} from '../../../favorite_meme/IFavoriteMemeRepository'; -import type {GatewayChannelMention, IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../../../infrastructure/IStorageService'; -import {Logger} from '../../../Logger'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import type {MessageSnapshot} from '../../../models/MessageSnapshot'; -import type {User} from '../../../models/User'; -import type {Webhook} from '../../../models/Webhook'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import type {DirectMessageSpamMitigationService} from '../../../user/services/DirectMessageSpamMitigationService'; -import {assertGuildMemberCanCommunicate} from '../../../utils/GuildCommunicationUtils'; -import type {AttachmentRequestData, AttachmentToProcess} from '../../AttachmentDTOs'; -import type {MessageRequest, MessageUpdateRequest} from '../../MessageTypes'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {AttachmentUploadTraceRepository} from '../../repositories/message/AttachmentUploadTraceRepository'; -import type {AuthenticatedChannel} from '../AuthenticatedChannel'; -import type {MessageChannelAuthService} from './MessageChannelAuthService'; -import type {DmNsfwContext} from './MessageContentService'; -import type {MessageDispatchService} from './MessageDispatchService'; -import type {MessageEmbedAttachmentResolver} from './MessageEmbedAttachmentResolver'; -import { - createMessageSnapshotsForForward, - type ForwardMediaSelection, - isOperationDisabled, - isPersonalNotesChannel, -} from './MessageHelpers'; -import type {MessageMentionService} from './MessageMentionService'; -import type {MessageOperationsHelpers} from './MessageOperationsHelpers'; -import type {MessagePersistenceService} from './MessagePersistenceService'; -import type {MessageProcessingService} from './MessageProcessingService'; -import type {MessageSearchService} from './MessageSearchService'; -import type {MessageValidationService} from './MessageValidationService'; interface MessageSendServiceDeps { channelRepository: IChannelRepositoryAggregate; diff --git a/fluxer_api/src/api/channel/services/message/MessageStickerService.ts b/fluxer_api/src/api/channel/services/message/MessageStickerService.ts index 7fd4e5a97..5194652fe 100644 --- a/fluxer_api/src/api/channel/services/message/MessageStickerService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageStickerService.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, StickerID, UserID} from '@app/api/BrandedTypes'; +import type {MessageStickerItem} from '@app/api/database/types/MessageTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {MissingPermissionsError} from '@fluxer/errors/src/domains/core/MissingPermissionsError'; -import type {GuildID, StickerID, UserID} from '../../../BrandedTypes'; -import type {MessageStickerItem} from '../../../database/types/MessageTypes'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {IUserRepository} from '../../../user/IUserRepository'; export class MessageStickerService { constructor( diff --git a/fluxer_api/src/api/channel/services/message/MessageSystemService.ts b/fluxer_api/src/api/channel/services/message/MessageSystemService.ts index fdb2d11f1..adce38800 100644 --- a/fluxer_api/src/api/channel/services/message/MessageSystemService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageSystemService.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {createMessageID} from '@app/api/BrandedTypes'; +import type {IChannelRepositoryAggregate} from '@app/api/channel/repositories/IChannelRepositoryAggregate'; +import type {MessageDispatchService} from '@app/api/channel/services/message/MessageDispatchService'; +import type {MessagePersistenceService} from '@app/api/channel/services/message/MessagePersistenceService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; import {MessageTypes} from '@fluxer/constants/src/ChannelConstants'; -import type {GuildID, UserID} from '../../../BrandedTypes'; -import {createMessageID} from '../../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../../guild/repositories/IGuildRepositoryAggregate'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {IChannelRepositoryAggregate} from '../../repositories/IChannelRepositoryAggregate'; -import type {MessageDispatchService} from './MessageDispatchService'; -import type {MessagePersistenceService} from './MessagePersistenceService'; export class MessageSystemService { constructor( diff --git a/fluxer_api/src/api/channel/services/message/MessageValidationService.test.ts b/fluxer_api/src/api/channel/services/message/MessageValidationService.test.ts index 701993325..e97b68fb9 100644 --- a/fluxer_api/src/api/channel/services/message/MessageValidationService.test.ts +++ b/fluxer_api/src/api/channel/services/message/MessageValidationService.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {MessageValidationService} from '@app/api/channel/services/message/MessageValidationService'; +import {createDefaultLimitConfig} from '@app/api/constants/LimitConfig'; +import {EMPTY_USER_ROW} from '@app/api/database/types/UserTypes'; +import {User} from '@app/api/models/User'; import {MAX_MESSAGE_LENGTH_NON_PREMIUM, MAX_MESSAGE_LENGTH_PREMIUM} from '@fluxer/constants/src/LimitConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {CannotSendEmptyMessageError} from '@fluxer/errors/src/domains/channel/CannotSendEmptyMessageError'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {describe, expect, it} from 'vitest'; -import {createUserID} from '../../../BrandedTypes'; -import {createDefaultLimitConfig} from '../../../constants/LimitConfig'; -import {EMPTY_USER_ROW} from '../../../database/types/UserTypes'; -import {User} from '../../../models/User'; -import {MessageValidationService} from './MessageValidationService'; function createValidationService(): MessageValidationService { return new MessageValidationService( diff --git a/fluxer_api/src/api/channel/services/message/MessageValidationService.ts b/fluxer_api/src/api/channel/services/message/MessageValidationService.ts index 1c999790d..eb5aa6064 100644 --- a/fluxer_api/src/api/channel/services/message/MessageValidationService.ts +++ b/fluxer_api/src/api/channel/services/message/MessageValidationService.ts @@ -1,5 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createChannelID, type MessageID, type UserID} from '@app/api/BrandedTypes'; +import type {MessageRequest, MessageUpdateRequest} from '@app/api/channel/MessageTypes'; +import { + assertAttachmentFileSizesWithinLimit, + MESSAGE_NONCE_TTL, +} from '@app/api/channel/services/message/MessageHelpers'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {User} from '@app/api/models/User'; +import {hasVisibleContent} from '@app/api/utils/StringUtils'; import { isMessageTypeDeletable, MessageFlags, @@ -24,17 +38,6 @@ import {UnknownMessageError} from '@fluxer/errors/src/domains/channel/UnknownMes import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import {type ChannelID, createChannelID, type MessageID, type UserID} from '../../../BrandedTypes'; -import {contentModerationService} from '../../../infrastructure/ContentModerationService'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {Channel} from '../../../models/Channel'; -import type {Message} from '../../../models/Message'; -import type {User} from '../../../models/User'; -import {hasVisibleContent} from '../../../utils/StringUtils'; -import type {MessageRequest, MessageUpdateRequest} from '../../MessageTypes'; -import {assertAttachmentFileSizesWithinLimit, MESSAGE_NONCE_TTL} from './MessageHelpers'; export class MessageValidationService { constructor( diff --git a/fluxer_api/src/api/channel/services/message/ReadStateHelpers.ts b/fluxer_api/src/api/channel/services/message/ReadStateHelpers.ts index de13c9446..1878b53d1 100644 --- a/fluxer_api/src/api/channel/services/message/ReadStateHelpers.ts +++ b/fluxer_api/src/api/channel/services/message/ReadStateHelpers.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID} from '@app/api/BrandedTypes'; +import type {User} from '@app/api/models/User'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; -import type {ChannelID, MessageID} from '../../../BrandedTypes'; -import type {User} from '../../../models/User'; -import type {ReadStateService} from '../../../read_state/ReadStateService'; -import type {IUserRepository} from '../../../user/IUserRepository'; interface IncrementDmMentionCountsParams { readStateService: ReadStateService; diff --git a/fluxer_api/src/api/channel/services/message/SelfMessageFilter.ts b/fluxer_api/src/api/channel/services/message/SelfMessageFilter.ts index 3e3f43910..26129f310 100644 --- a/fluxer_api/src/api/channel/services/message/SelfMessageFilter.ts +++ b/fluxer_api/src/api/channel/services/message/SelfMessageFilter.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {Channel} from '@app/api/models/Channel'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import type { BulkDeleteSelfMessagesGuildFilterMode, BulkDeleteSelfMessagesScope, } from '@fluxer/schema/src/domains/user/UserRequestSchemas'; -import type {UserID} from '../../../BrandedTypes'; -import type {Channel} from '../../../models/Channel'; export interface SelfMessageFilter { scope: BulkDeleteSelfMessagesScope; diff --git a/fluxer_api/src/api/channel/services/message/UserMessageDeletionService.ts b/fluxer_api/src/api/channel/services/message/UserMessageDeletionService.ts index 985c62b20..f887db807 100644 --- a/fluxer_api/src/api/channel/services/message/UserMessageDeletionService.ts +++ b/fluxer_api/src/api/channel/services/message/UserMessageDeletionService.ts @@ -1,25 +1,25 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import type {ChannelID, GuildID, MessageID, UserID} from '../../../BrandedTypes'; -import {createChannelID} from '../../../BrandedTypes'; -import type {IChannelRepository} from '../../../channel/IChannelRepository'; -import {assertMutableUserId} from '../../../constants/Core'; -import type {IPurgeQueue} from '../../../infrastructure/BunnyPurgeQueue'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {IStorageService} from '../../../infrastructure/IStorageService'; -import {Logger} from '../../../Logger'; -import type {Message} from '../../../models/Message'; -import {deleteMessageSearchDocuments} from '../../../search/MessageSearchIndexCleanup'; -import {chunkArray} from '../../../utils/ArrayUtils'; -import {ChannelEventDispatcher} from '../../../worker/services/ChannelEventDispatcher'; -import {purgeMessageAttachments} from './MessageHelpers'; +import type {ChannelID, GuildID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {purgeMessageAttachments} from '@app/api/channel/services/message/MessageHelpers'; import { isChannelEligible, isTimestampInWindow, type SelfMessageEligibilityContext, type SelfMessageFilter, -} from './SelfMessageFilter'; +} from '@app/api/channel/services/message/SelfMessageFilter'; +import {assertMutableUserId} from '@app/api/constants/Core'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import type {Message} from '@app/api/models/Message'; +import {deleteMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import {chunkArray} from '@app/api/utils/ArrayUtils'; +import {ChannelEventDispatcher} from '@app/api/worker/services/ChannelEventDispatcher'; +import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; interface UserMessageDeletionServiceDeps { channelRepository: IChannelRepository; diff --git a/fluxer_api/src/api/channel/tests/AttachmentDecay.test.ts b/fluxer_api/src/api/channel/tests/AttachmentDecay.test.ts index 93fe0402a..c11d3005c 100644 --- a/fluxer_api/src/api/channel/tests/AttachmentDecay.test.ts +++ b/fluxer_api/src/api/channel/tests/AttachmentDecay.test.ts @@ -1,13 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + createChannel, + createGuild, + loadFixture, + sendMessageWithAttachments, +} from '@app/api/channel/tests/AttachmentTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {getExpiryBucket} from '@app/api/utils/AttachmentDecay'; import {MessageReferenceTypes} from '@fluxer/constants/src/ChannelConstants'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {getExpiryBucket} from '../../utils/AttachmentDecay'; -import {createChannel, createGuild, loadFixture, sendMessageWithAttachments} from './AttachmentTestUtils'; interface AttachmentDecayRow { attachment_id: string; diff --git a/fluxer_api/src/api/channel/tests/AttachmentTestUtils.ts b/fluxer_api/src/api/channel/tests/AttachmentTestUtils.ts index 2aae5bde8..ac81bb0a4 100644 --- a/fluxer_api/src/api/channel/tests/AttachmentTestUtils.ts +++ b/fluxer_api/src/api/channel/tests/AttachmentTestUtils.ts @@ -3,13 +3,13 @@ import {randomUUID} from 'node:crypto'; import {readFileSync} from 'node:fs'; import {join} from 'node:path'; +import {createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {createTestAccount, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface MultipartFileInput { index: number; diff --git a/fluxer_api/src/api/channel/tests/AttachmentUploadValidation.test.ts b/fluxer_api/src/api/channel/tests/AttachmentUploadValidation.test.ts index 8edd6218f..2901a1f17 100644 --- a/fluxer_api/src/api/channel/tests/AttachmentUploadValidation.test.ts +++ b/fluxer_api/src/api/channel/tests/AttachmentUploadValidation.test.ts @@ -1,15 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + createChannel, + createGuild, + loadFixture, + sendMessageWithAttachments, +} from '@app/api/channel/tests/AttachmentTestUtils'; +import type {MediaProxyMetadataRequest} from '@app/api/infrastructure/IMediaService'; +import {setInjectedMediaService} from '@app/api/middleware/ServiceRegistry'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {TestMediaService} from '@app/api/test/TestMediaService'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {Logger} from '@fluxer/logger/src/Logger'; import {beforeAll, beforeEach, describe, expect, it, vi} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import type {MediaProxyMetadataRequest} from '../../infrastructure/IMediaService'; -import {setInjectedMediaService} from '../../middleware/ServiceRegistry'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {TestMediaService} from '../../test/TestMediaService'; -import {createChannel, createGuild, loadFixture, sendMessageWithAttachments} from './AttachmentTestUtils'; class NullUploadMetadataService extends TestMediaService { override async getMetadata(request: MediaProxyMetadataRequest) { diff --git a/fluxer_api/src/api/channel/tests/BulkDeleteMessages.test.ts b/fluxer_api/src/api/channel/tests/BulkDeleteMessages.test.ts index fb2c98799..91fed1122 100644 --- a/fluxer_api/src/api/channel/tests/BulkDeleteMessages.test.ts +++ b/fluxer_api/src/api/channel/tests/BulkDeleteMessages.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild, sendChannelMessage} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createGuild, sendChannelMessage} from './ChannelTestUtils'; describe('Bulk Delete Messages', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/BulkDeleteMyMessages.test.ts b/fluxer_api/src/api/channel/tests/BulkDeleteMyMessages.test.ts index a31be367b..baccc1ac8 100644 --- a/fluxer_api/src/api/channel/tests/BulkDeleteMyMessages.test.ts +++ b/fluxer_api/src/api/channel/tests/BulkDeleteMyMessages.test.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createChannel, createFriendship, createGroupDmChannel, sendChannelMessage, setupTestGuildWithMembers, -} from './ChannelTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; async function listMessages( harness: ApiTestHarness, diff --git a/fluxer_api/src/api/channel/tests/ChannelOperationPermissions.test.ts b/fluxer_api/src/api/channel/tests/ChannelOperationPermissions.test.ts index 29e1b45d9..6dcdddd00 100644 --- a/fluxer_api/src/api/channel/tests/ChannelOperationPermissions.test.ts +++ b/fluxer_api/src/api/channel/tests/ChannelOperationPermissions.test.ts @@ -1,10 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannel, @@ -13,7 +9,11 @@ import { deleteChannel, getChannel, updateChannel, -} from './ChannelTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Channel Operation Permissions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/ChannelOperationValidation.test.ts b/fluxer_api/src/api/channel/tests/ChannelOperationValidation.test.ts index 59b25f5a5..af308540a 100644 --- a/fluxer_api/src/api/channel/tests/ChannelOperationValidation.test.ts +++ b/fluxer_api/src/api/channel/tests/ChannelOperationValidation.test.ts @@ -1,11 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + createChannel, + createGuild, + deleteChannel, + getChannel, + updateChannel, +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createChannel, createGuild, deleteChannel, getChannel, updateChannel} from './ChannelTestUtils'; describe('Channel Operation Validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/ChannelPermissionOverwrites.test.ts b/fluxer_api/src/api/channel/tests/ChannelPermissionOverwrites.test.ts index 94c9b28ed..672b95b57 100644 --- a/fluxer_api/src/api/channel/tests/ChannelPermissionOverwrites.test.ts +++ b/fluxer_api/src/api/channel/tests/ChannelPermissionOverwrites.test.ts @@ -1,12 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; -import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { addMemberRole, createChannel, @@ -15,7 +9,13 @@ import { createRole, getChannel, setupTestGuildWithMembers, -} from './ChannelTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; +import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('Channel Permission Overwrites', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/ChannelPinsResponseShape.test.ts b/fluxer_api/src/api/channel/tests/ChannelPinsResponseShape.test.ts index 836de933f..ba7066853 100644 --- a/fluxer_api/src/api/channel/tests/ChannelPinsResponseShape.test.ts +++ b/fluxer_api/src/api/channel/tests/ChannelPinsResponseShape.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {pinMessage, sendMessage} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {pinMessage, sendMessage} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('Channel Pins Response Shape', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/ChannelTestUtils.ts b/fluxer_api/src/api/channel/tests/ChannelTestUtils.ts index 67c94e69a..232b4ab17 100644 --- a/fluxer_api/src/api/channel/tests/ChannelTestUtils.ts +++ b/fluxer_api/src/api/channel/tests/ChannelTestUtils.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {ChannelOverwriteResponse, ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import type {GuildRoleResponse} from '@fluxer/schema/src/domains/guild/GuildRoleSchemas'; import type {GuildInviteMetadataResponse} from '@fluxer/schema/src/domains/invite/InviteSchemas'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {createTestAccount, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; export async function createGuild(harness: ApiTestHarness, token: string, name: string): Promise { return createBuilder(harness, token).post('/guilds').body({name}).execute(); diff --git a/fluxer_api/src/api/channel/tests/DMBlockingBehaviors.test.ts b/fluxer_api/src/api/channel/tests/DMBlockingBehaviors.test.ts index ce5f44ee4..5e0006509 100644 --- a/fluxer_api/src/api/channel/tests/DMBlockingBehaviors.test.ts +++ b/fluxer_api/src/api/channel/tests/DMBlockingBehaviors.test.ts @@ -1,11 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, blockUser, @@ -17,7 +12,12 @@ import { initiateCall, pinMessage, sendChannelMessage, -} from './ChannelTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('DM Blocking Behaviors', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/DMChannelManagement.test.ts b/fluxer_api/src/api/channel/tests/DMChannelManagement.test.ts index ac14cec01..2ff01f72f 100644 --- a/fluxer_api/src/api/channel/tests/DMChannelManagement.test.ts +++ b/fluxer_api/src/api/channel/tests/DMChannelManagement.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createDmChannel, createFriendship, deleteChannel} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createDmChannel, createFriendship, deleteChannel} from './ChannelTestUtils'; describe('DM channel management', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/DMCreationAllowedWithFriendship.test.ts b/fluxer_api/src/api/channel/tests/DMCreationAllowedWithFriendship.test.ts index cec8cbde4..0a34fb8f0 100644 --- a/fluxer_api/src/api/channel/tests/DMCreationAllowedWithFriendship.test.ts +++ b/fluxer_api/src/api/channel/tests/DMCreationAllowedWithFriendship.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createDmChannel, createFriendship} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createDmChannel, createFriendship} from './ChannelTestUtils'; describe('DM creation allowed with friendship', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/DMCreationAllowedWithMutualGuild.test.ts b/fluxer_api/src/api/channel/tests/DMCreationAllowedWithMutualGuild.test.ts index 65c1ad679..2a3319d3e 100644 --- a/fluxer_api/src/api/channel/tests/DMCreationAllowedWithMutualGuild.test.ts +++ b/fluxer_api/src/api/channel/tests/DMCreationAllowedWithMutualGuild.test.ts @@ -1,11 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + acceptInvite, + createChannelInvite, + createDmChannel, + createGuild, + getChannel, +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {acceptInvite, createChannelInvite, createDmChannel, createGuild, getChannel} from './ChannelTestUtils'; describe('DM creation allowed with mutual guild', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/DMCreationAllowedWithStrangers.test.ts b/fluxer_api/src/api/channel/tests/DMCreationAllowedWithStrangers.test.ts index 4c2fee481..0182abe1f 100644 --- a/fluxer_api/src/api/channel/tests/DMCreationAllowedWithStrangers.test.ts +++ b/fluxer_api/src/api/channel/tests/DMCreationAllowedWithStrangers.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createDmChannel} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createDmChannel} from './ChannelTestUtils'; describe('DM creation allowed with strangers', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/DMPrivacyBidirectional.test.ts b/fluxer_api/src/api/channel/tests/DMPrivacyBidirectional.test.ts index 2ffcd6db0..49ae2e44e 100644 --- a/fluxer_api/src/api/channel/tests/DMPrivacyBidirectional.test.ts +++ b/fluxer_api/src/api/channel/tests/DMPrivacyBidirectional.test.ts @@ -1,14 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; -import {UserFlags} from '@fluxer/constants/src/UserConstants'; -import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {removeRelationship} from '../../user/tests/RelationshipTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannelInvite, @@ -19,7 +11,15 @@ import { leaveGuild, sendChannelMessage, updateUserSettings, -} from './ChannelTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {removeRelationship} from '@app/api/user/tests/RelationshipTestUtils'; +import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; +import {UserFlags} from '@fluxer/constants/src/UserConstants'; +import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; async function setUserFlags(harness: ApiTestHarness, userId: string, flags: bigint): Promise { await createBuilder(harness, '') diff --git a/fluxer_api/src/api/channel/tests/EmbedAttachmentUrlResolution.test.ts b/fluxer_api/src/api/channel/tests/EmbedAttachmentUrlResolution.test.ts index 8a9be9359..d3dd92acd 100644 --- a/fluxer_api/src/api/channel/tests/EmbedAttachmentUrlResolution.test.ts +++ b/fluxer_api/src/api/channel/tests/EmbedAttachmentUrlResolution.test.ts @@ -1,11 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + createChannel, + createGuild, + loadFixture, + sendMessageWithAttachments, +} from '@app/api/channel/tests/AttachmentTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {MessageAttachmentFlags} from '@fluxer/constants/src/ChannelConstants'; import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createChannel, createGuild, loadFixture, sendMessageWithAttachments} from './AttachmentTestUtils'; describe('Embed Attachment URL Resolution', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/GroupDMNameUpdate.test.ts b/fluxer_api/src/api/channel/tests/GroupDMNameUpdate.test.ts index 630544e25..0cd0c96cf 100644 --- a/fluxer_api/src/api/channel/tests/GroupDMNameUpdate.test.ts +++ b/fluxer_api/src/api/channel/tests/GroupDMNameUpdate.test.ts @@ -1,12 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + createFriendship, + createGroupDmChannel, + type GroupDmChannelResponse, +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createFriendship, createGroupDmChannel, type GroupDmChannelResponse} from './ChannelTestUtils'; describe('Group DM name update', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/GroupDMNicknameUpdate.test.ts b/fluxer_api/src/api/channel/tests/GroupDMNicknameUpdate.test.ts index 2bb9b141c..0b7ee5652 100644 --- a/fluxer_api/src/api/channel/tests/GroupDMNicknameUpdate.test.ts +++ b/fluxer_api/src/api/channel/tests/GroupDMNicknameUpdate.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createFriendship, createGroupDmChannel, getChannel} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {profileSubstringBlocklistCache} from '../../middleware/ProfileSubstringBlocklistCache'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createFriendship, createGroupDmChannel, getChannel} from './ChannelTestUtils'; describe('Group DM nickname update', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/GroupDMSecurityBoundaries.test.ts b/fluxer_api/src/api/channel/tests/GroupDMSecurityBoundaries.test.ts index 9a68ed83a..ec1646073 100644 --- a/fluxer_api/src/api/channel/tests/GroupDMSecurityBoundaries.test.ts +++ b/fluxer_api/src/api/channel/tests/GroupDMSecurityBoundaries.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createFriendship, createGroupDmChannel} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createFriendship, createGroupDmChannel} from './ChannelTestUtils'; describe('Group DM Security Boundaries', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/GroupDmAddRecipientPermissions.test.ts b/fluxer_api/src/api/channel/tests/GroupDmAddRecipientPermissions.test.ts index ce80462ee..eadccd094 100644 --- a/fluxer_api/src/api/channel/tests/GroupDmAddRecipientPermissions.test.ts +++ b/fluxer_api/src/api/channel/tests/GroupDmAddRecipientPermissions.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createFriendship, createGroupDmChannel} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createFriendship, createGroupDmChannel} from './ChannelTestUtils'; describe('Group DM Add Recipient Permissions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/GroupDmCaptchaRateLimit.test.ts b/fluxer_api/src/api/channel/tests/GroupDmCaptchaRateLimit.test.ts index 79cda15d2..f12c6e1af 100644 --- a/fluxer_api/src/api/channel/tests/GroupDmCaptchaRateLimit.test.ts +++ b/fluxer_api/src/api/channel/tests/GroupDmCaptchaRateLimit.test.ts @@ -1,14 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import { + createFriendship, + createGroupDmChannel, + type GroupDmChannelResponse, +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createFriendship, createGroupDmChannel, type GroupDmChannelResponse} from './ChannelTestUtils'; const HTTP_TOO_MANY_REQUESTS = 429; const TEST_CAPTCHA_TOKEN = 'test-captcha-token'; diff --git a/fluxer_api/src/api/channel/tests/GroupDmLimit.test.ts b/fluxer_api/src/api/channel/tests/GroupDmLimit.test.ts index b5d706932..533732607 100644 --- a/fluxer_api/src/api/channel/tests/GroupDmLimit.test.ts +++ b/fluxer_api/src/api/channel/tests/GroupDmLimit.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createFriendship, seedPrivateChannels} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createFriendship, seedPrivateChannels} from './ChannelTestUtils'; const MAX_GROUP_DM_LIMIT = 150; const MAX_GROUP_DMS_ERROR_CODE = 'MAX_GROUP_DMS'; diff --git a/fluxer_api/src/api/channel/tests/GroupDmRecipientLimit.test.ts b/fluxer_api/src/api/channel/tests/GroupDmRecipientLimit.test.ts index a94e0b268..09a7cc8d7 100644 --- a/fluxer_api/src/api/channel/tests/GroupDmRecipientLimit.test.ts +++ b/fluxer_api/src/api/channel/tests/GroupDmRecipientLimit.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createFriendship, seedPrivateChannels} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createFriendship, seedPrivateChannels} from './ChannelTestUtils'; const MAX_GROUP_DM_LIMIT = 150; const MAX_GROUP_DM_ERROR_CODE = 'MAX_GROUP_DMS'; diff --git a/fluxer_api/src/api/channel/tests/MessageCustomEmojiSanitization.test.ts b/fluxer_api/src/api/channel/tests/MessageCustomEmojiSanitization.test.ts index 5b6a399d6..936f0aea8 100644 --- a/fluxer_api/src/api/channel/tests/MessageCustomEmojiSanitization.test.ts +++ b/fluxer_api/src/api/channel/tests/MessageCustomEmojiSanitization.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild, getChannel, sendChannelMessage} from '@app/api/channel/tests/ChannelTestUtils'; +import {createEmoji, getGifDataUrl, getPngDataUrl} from '@app/api/emoji/tests/EmojiTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createEmoji, getGifDataUrl, getPngDataUrl} from '../../emoji/tests/EmojiTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createGuild, getChannel, sendChannelMessage} from './ChannelTestUtils'; describe('Message custom emoji sanitization', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/MessageEditEmbeds.test.ts b/fluxer_api/src/api/channel/tests/MessageEditEmbeds.test.ts index 178926321..a4666ac8f 100644 --- a/fluxer_api/src/api/channel/tests/MessageEditEmbeds.test.ts +++ b/fluxer_api/src/api/channel/tests/MessageEditEmbeds.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createGuild} from './ChannelTestUtils'; describe('Message embed edits', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/MessageForwardPermissions.test.ts b/fluxer_api/src/api/channel/tests/MessageForwardPermissions.test.ts index ac5c4aff7..27da3a880 100644 --- a/fluxer_api/src/api/channel/tests/MessageForwardPermissions.test.ts +++ b/fluxer_api/src/api/channel/tests/MessageForwardPermissions.test.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {MessageReferenceTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; -import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {extractTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; import { createChannel, createPermissionOverwrite, sendChannelMessage, setupTestGuildWithMembers, updateGuild, -} from './ChannelTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {MessageReferenceTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; +import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; +import {extractTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Message forward permissions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/MessagePinsList.test.ts b/fluxer_api/src/api/channel/tests/MessagePinsList.test.ts index 79a9f0994..65ee5b4dc 100644 --- a/fluxer_api/src/api/channel/tests/MessagePinsList.test.ts +++ b/fluxer_api/src/api/channel/tests/MessagePinsList.test.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import type {ChannelPinsResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {extractTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; -import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createMessageResponseDataService} from '../services/message/MessageResponseDataService'; +import {createMessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; import { createPermissionOverwrite, pinMessage, sendChannelMessage, setupTestGuildWithMembers, updateGuild, -} from './ChannelTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import type {ChannelPinsResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; +import {extractTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi} from 'vitest'; describe('Channel pins listing', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/MessageSendPermissions.test.ts b/fluxer_api/src/api/channel/tests/MessageSendPermissions.test.ts index 173c3815d..e3ea6b847 100644 --- a/fluxer_api/src/api/channel/tests/MessageSendPermissions.test.ts +++ b/fluxer_api/src/api/channel/tests/MessageSendPermissions.test.ts @@ -1,24 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {MAX_MESSAGE_LENGTH_PREMIUM} from '@fluxer/constants/src/LimitConstants'; -import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; -import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {afterAll, beforeAll, beforeEach, describe, expect, it, vi} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {authorizeBot, createTestBotAccount} from '../../bot/tests/BotTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {getGatewayService} from '../../middleware/ServiceRegistry'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_TIMEOUTS, wait} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {ChannelDataRepository} from '../repositories/ChannelDataRepository'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {authorizeBot, createTestBotAccount} from '@app/api/bot/tests/BotTestUtils'; +import {ChannelDataRepository} from '@app/api/channel/repositories/ChannelDataRepository'; import { createDmChannel, createFriendship, createPermissionOverwrite, setupTestGuildWithMembers, -} from './ChannelTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {getGatewayService} from '@app/api/middleware/ServiceRegistry'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_TIMEOUTS, wait} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {MAX_MESSAGE_LENGTH_PREMIUM} from '@fluxer/constants/src/LimitConstants'; +import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; +import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; +import {afterAll, beforeAll, beforeEach, describe, expect, it, vi} from 'vitest'; describe('Message send permissions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/ReactionUsersPagination.test.ts b/fluxer_api/src/api/channel/tests/ReactionUsersPagination.test.ts index 1698a829a..9415cf5a0 100644 --- a/fluxer_api/src/api/channel/tests/ReactionUsersPagination.test.ts +++ b/fluxer_api/src/api/channel/tests/ReactionUsersPagination.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {sendChannelMessage, setupTestGuildWithMembers} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {sendChannelMessage, setupTestGuildWithMembers} from './ChannelTestUtils'; const EMOJI = encodeURIComponent('👍'); diff --git a/fluxer_api/src/api/channel/tests/SlowmodeEnforcement.test.ts b/fluxer_api/src/api/channel/tests/SlowmodeEnforcement.test.ts index 94caed7bf..bee50d947 100644 --- a/fluxer_api/src/api/channel/tests/SlowmodeEnforcement.test.ts +++ b/fluxer_api/src/api/channel/tests/SlowmodeEnforcement.test.ts @@ -1,11 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createChannel, + sendChannelMessage, + setupTestGuildWithMembers, + updateChannel, +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted, getMessages} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {ensureSessionStarted, getMessages} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createChannel, sendChannelMessage, setupTestGuildWithMembers, updateChannel} from './ChannelTestUtils'; describe('Slowmode Enforcement', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/channel/tests/StreamChannelType.test.ts b/fluxer_api/src/api/channel/tests/StreamChannelType.test.ts index be77809c8..6d219a7ca 100644 --- a/fluxer_api/src/api/channel/tests/StreamChannelType.test.ts +++ b/fluxer_api/src/api/channel/tests/StreamChannelType.test.ts @@ -1,13 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + createChannel, + createDmChannel, + createFriendship, + createGuild, + getChannel, +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createChannel, createDmChannel, createFriendship, createGuild, getChannel} from './ChannelTestUtils'; const CONNECTION_ID = 'conn-channel-type'; diff --git a/fluxer_api/src/api/channel/tests/StreamPreviewOversized.test.ts b/fluxer_api/src/api/channel/tests/StreamPreviewOversized.test.ts index 4f38a9a0e..603c5019c 100644 --- a/fluxer_api/src/api/channel/tests/StreamPreviewOversized.test.ts +++ b/fluxer_api/src/api/channel/tests/StreamPreviewOversized.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {createDmChannel, createFriendship} from '@app/api/channel/tests/ChannelTestUtils'; +import {getCacheService} from '@app/api/middleware/ServiceSingletons'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import {STREAM_PREVIEW_CONTENT_TYPE_JPEG, STREAM_PREVIEW_MAX_BYTES} from '@fluxer/constants/src/StreamConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {getCacheService} from '../../middleware/ServiceSingletons'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createDmChannel, createFriendship} from './ChannelTestUtils'; const CONNECTION_ID = 'conn-oversized'; diff --git a/fluxer_api/src/api/channel/tests/TypingIndicators.test.ts b/fluxer_api/src/api/channel/tests/TypingIndicators.test.ts index f4272338d..f0f5a0f17 100644 --- a/fluxer_api/src/api/channel/tests/TypingIndicators.test.ts +++ b/fluxer_api/src/api/channel/tests/TypingIndicators.test.ts @@ -1,11 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {afterEach, beforeEach, describe, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createChannel, createFriendship, @@ -13,7 +8,12 @@ import { createPermissionOverwrite, createRole, setupTestGuildWithMembers, -} from './ChannelTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {afterEach, beforeEach, describe, test} from 'vitest'; async function sendTypingIndicator(harness: ApiTestHarness, token: string, channelId: string): Promise { await createBuilder(harness, token).post(`/channels/${channelId}/typing`).body({}).expect(204).execute(); diff --git a/fluxer_api/src/api/config/APIConfig.ts b/fluxer_api/src/api/config/APIConfig.ts index ef7b1c5f4..b77971ea7 100644 --- a/fluxer_api/src/api/config/APIConfig.ts +++ b/fluxer_api/src/api/config/APIConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import type {ResolvedDownloadsProvider} from '@fluxer/config/src/S3DownloadsProvider'; -import type {WorkerTaskName} from '../worker/WorkerLaneConfig'; export type APIWorkerMode = 'all_lanes' | 'single_lane' | 'single_task'; export type APIWorkerLaneName = 'realtime' | 'unfurl' | 'lifecycle' | 'batch'; diff --git a/fluxer_api/src/api/connection/ConnectionController.ts b/fluxer_api/src/api/connection/ConnectionController.ts index 2deba931d..b3a352a04 100644 --- a/fluxer_api/src/api/connection/ConnectionController.ts +++ b/fluxer_api/src/api/connection/ConnectionController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {requireOAuth2ScopeForBearer} from '@app/api/middleware/OAuth2ScopeMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {ConnectionRateLimitConfigs} from '@app/api/rate_limit_configs/ConnectionRateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import { ConnectionListResponse, ConnectionResponse, @@ -10,13 +17,6 @@ import { UpdateConnectionRequest, VerifyAndCreateConnectionRequest, } from '@fluxer/schema/src/domains/connection/ConnectionSchemas'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {requireOAuth2ScopeForBearer} from '../middleware/OAuth2ScopeMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {ConnectionRateLimitConfigs} from '../rate_limit_configs/ConnectionRateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; export function ConnectionController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/connection/ConnectionCredentialRepository.ts b/fluxer_api/src/api/connection/ConnectionCredentialRepository.ts index 4aaa0adc9..aa647cf02 100644 --- a/fluxer_api/src/api/connection/ConnectionCredentialRepository.ts +++ b/fluxer_api/src/api/connection/ConnectionCredentialRepository.ts @@ -1,12 +1,6 @@ import {randomUUID} from 'node:crypto'; -import {isAtprotoDid} from '@bluesky-social/oauth-client-node'; -import {z} from 'zod'; -import type {UserID} from '../BrandedTypes'; -import type {BlueskyOAuthGrantOwner} from '../bluesky/IBlueskyOAuthService'; -import {executeConditional, fetchMany} from '../database/CassandraQueryExecution'; -import {type ConditionalWriteEntry, Db, validateTtlSeconds} from '../database/CassandraTypes'; -import {USER_CONNECTION_CREDENTIAL_TYPE, type UserConnectionStorageRow} from '../database/types/ConnectionTypes'; -import {UserConnections} from '../Tables'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {BlueskyOAuthGrantOwner} from '@app/api/bluesky/IBlueskyOAuthService'; import { CONNECTION_WRITE_ATTEMPTS, ConnectionOwnerClosedError, @@ -14,7 +8,13 @@ import { connectionMembershipPatch, createPrivateConnectionRow, loadConnectionMembership, -} from './ConnectionMembership'; +} from '@app/api/connection/ConnectionMembership'; +import {executeConditional, fetchMany} from '@app/api/database/CassandraQueryExecution'; +import {type ConditionalWriteEntry, Db, validateTtlSeconds} from '@app/api/database/CassandraTypes'; +import {USER_CONNECTION_CREDENTIAL_TYPE, type UserConnectionStorageRow} from '@app/api/database/types/ConnectionTypes'; +import {UserConnections} from '@app/api/Tables'; +import {isAtprotoDid} from '@bluesky-social/oauth-client-node'; +import {z} from 'zod'; type CredentialWrite = ConditionalWriteEntry; diff --git a/fluxer_api/src/api/connection/ConnectionInitiationToken.ts b/fluxer_api/src/api/connection/ConnectionInitiationToken.ts index 7668cdf5b..9aeac5ac2 100644 --- a/fluxer_api/src/api/connection/ConnectionInitiationToken.ts +++ b/fluxer_api/src/api/connection/ConnectionInitiationToken.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHmac, timingSafeEqual} from 'node:crypto'; +import {isJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; import {type ConnectionType, ConnectionTypes} from '@fluxer/constants/src/ConnectionConstants'; -import {isJsonRecord, parseJsonWithGuard} from '../utils/JsonBoundaryUtils'; interface ConnectionInitiationTokenPayload { userId: string; diff --git a/fluxer_api/src/api/connection/ConnectionMappers.ts b/fluxer_api/src/api/connection/ConnectionMappers.ts index 44348aef6..a6d98d468 100644 --- a/fluxer_api/src/api/connection/ConnectionMappers.ts +++ b/fluxer_api/src/api/connection/ConnectionMappers.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserConnectionRow} from '@app/api/database/types/ConnectionTypes'; import type {ConnectionResponse} from '@fluxer/schema/src/domains/connection/ConnectionSchemas'; -import type {UserConnectionRow} from '../database/types/ConnectionTypes'; export function mapConnectionToResponse(row: UserConnectionRow): ConnectionResponse { return { diff --git a/fluxer_api/src/api/connection/ConnectionMembership.ts b/fluxer_api/src/api/connection/ConnectionMembership.ts index 3b42b1f2d..8988e0bc2 100644 --- a/fluxer_api/src/api/connection/ConnectionMembership.ts +++ b/fluxer_api/src/api/connection/ConnectionMembership.ts @@ -1,15 +1,15 @@ import {randomUUID} from 'node:crypto'; +import type {UserID} from '@app/api/BrandedTypes'; +import {executeConditional, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {type ConditionalWriteEntry, Db} from '@app/api/database/CassandraTypes'; +import {USER_CONNECTION_CREDENTIAL_TYPE, type UserConnectionStorageRow} from '@app/api/database/types/ConnectionTypes'; +import {UserConnections} from '@app/api/Tables'; import { type ConnectionType, ConnectionTypes, MAX_CONNECTIONS_PER_USER, } from '@fluxer/constants/src/ConnectionConstants'; import {z} from 'zod'; -import type {UserID} from '../BrandedTypes'; -import {executeConditional, fetchMany, fetchOne} from '../database/CassandraQueryExecution'; -import {type ConditionalWriteEntry, Db} from '../database/CassandraTypes'; -import {USER_CONNECTION_CREDENTIAL_TYPE, type UserConnectionStorageRow} from '../database/types/ConnectionTypes'; -import {UserConnections} from '../Tables'; const MEMBERSHIP_TYPE = '_membership'; const MEMBERSHIP_ID = '_membership'; diff --git a/fluxer_api/src/api/connection/ConnectionRepository.ts b/fluxer_api/src/api/connection/ConnectionRepository.ts index ccf5ecde0..3e0241263 100644 --- a/fluxer_api/src/api/connection/ConnectionRepository.ts +++ b/fluxer_api/src/api/connection/ConnectionRepository.ts @@ -1,22 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; -import { - type ConnectionType, - ConnectionTypes, - MAX_CONNECTIONS_PER_USER, -} from '@fluxer/constants/src/ConnectionConstants'; -import type {UserID} from '../BrandedTypes'; -import {BatchBuilder, executeConditional, fetchMany, fetchOne} from '../database/CassandraQueryExecution'; -import {type ConditionalWriteEntry, Db, type DbOp} from '../database/CassandraTypes'; -import { - type RevisionedUserConnectionRow, - USER_CONNECTION_COLUMNS, - type UserConnectionRow, - type UserConnectionStorageRow, -} from '../database/types/ConnectionTypes'; -import {UserConnections} from '../Tables'; -import {connectionCredentialKey, readConnectionCredential} from './ConnectionCredentialRepository'; +import type {UserID} from '@app/api/BrandedTypes'; +import {connectionCredentialKey, readConnectionCredential} from '@app/api/connection/ConnectionCredentialRepository'; import { CONNECTION_WRITE_ATTEMPTS, ConnectionOwnerClosedError, @@ -24,14 +10,28 @@ import { isConnectionMembershipRow, loadConnectionMembership, sealConnectionMembership, -} from './ConnectionMembership'; +} from '@app/api/connection/ConnectionMembership'; import { type ConnectionCreationResult, type ConnectionSortOrderUpdate, type CreateConnectionParams, IConnectionRepository, type UpdateConnectionParams, -} from './IConnectionRepository'; +} from '@app/api/connection/IConnectionRepository'; +import {BatchBuilder, executeConditional, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {type ConditionalWriteEntry, Db, type DbOp} from '@app/api/database/CassandraTypes'; +import { + type RevisionedUserConnectionRow, + USER_CONNECTION_COLUMNS, + type UserConnectionRow, + type UserConnectionStorageRow, +} from '@app/api/database/types/ConnectionTypes'; +import {UserConnections} from '@app/api/Tables'; +import { + type ConnectionType, + ConnectionTypes, + MAX_CONNECTIONS_PER_USER, +} from '@fluxer/constants/src/ConnectionConstants'; const FETCH_CONNECTIONS_BY_USER_CQL = UserConnections.selectCql({ columns: USER_CONNECTION_COLUMNS, diff --git a/fluxer_api/src/api/connection/ConnectionRequestService.ts b/fluxer_api/src/api/connection/ConnectionRequestService.ts index a92530244..62ff6fb51 100644 --- a/fluxer_api/src/api/connection/ConnectionRequestService.ts +++ b/fluxer_api/src/api/connection/ConnectionRequestService.ts @@ -1,6 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHmac} from 'node:crypto'; +import type {UserID} from '@app/api/BrandedTypes'; +import {signInitiationToken, verifyInitiationToken} from '@app/api/connection/ConnectionInitiationToken'; +import {mapConnectionToResponse} from '@app/api/connection/ConnectionMappers'; +import {ConnectionInitiationTokenInvalidError} from '@app/api/connection/errors/ConnectionInitiationTokenInvalidError'; +import type {IConnectionService} from '@app/api/connection/IConnectionService'; import { CONNECTION_INITIATION_TOKEN_EXPIRY_MS, CONNECTION_VERIFICATION_TOKEN_LENGTH, @@ -14,11 +19,6 @@ import type { UpdateConnectionRequest, VerifyAndCreateConnectionRequest, } from '@fluxer/schema/src/domains/connection/ConnectionSchemas'; -import type {UserID} from '../BrandedTypes'; -import {signInitiationToken, verifyInitiationToken} from './ConnectionInitiationToken'; -import {mapConnectionToResponse} from './ConnectionMappers'; -import {ConnectionInitiationTokenInvalidError} from './errors/ConnectionInitiationTokenInvalidError'; -import type {IConnectionService} from './IConnectionService'; export class ConnectionRequestService { constructor( diff --git a/fluxer_api/src/api/connection/ConnectionService.ts b/fluxer_api/src/api/connection/ConnectionService.ts index 870f66c9a..e7d2a7208 100644 --- a/fluxer_api/src/api/connection/ConnectionService.ts +++ b/fluxer_api/src/api/connection/ConnectionService.ts @@ -1,6 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {BlueskyCallbackResult} from '@app/api/bluesky/IBlueskyOAuthService'; +import {mapConnectionToResponse} from '@app/api/connection/ConnectionMappers'; +import {createDomainConnectionId} from '@app/api/connection/DomainConnectionId'; +import {BlueskyOAuthNotEnabledError} from '@app/api/connection/errors/BlueskyOAuthNotEnabledError'; +import {ConnectionAlreadyExistsError} from '@app/api/connection/errors/ConnectionAlreadyExistsError'; +import {ConnectionInvalidTypeError} from '@app/api/connection/errors/ConnectionInvalidTypeError'; +import {ConnectionLimitReachedError} from '@app/api/connection/errors/ConnectionLimitReachedError'; +import {ConnectionNotFoundError} from '@app/api/connection/errors/ConnectionNotFoundError'; +import {ConnectionVerificationFailedError} from '@app/api/connection/errors/ConnectionVerificationFailedError'; +import type { + ConnectionSortOrderUpdate, + CreateConnectionParams, + IConnectionRepository, + UpdateConnectionParams, +} from '@app/api/connection/IConnectionRepository'; +import {IConnectionService, type InitiateConnectionResult} from '@app/api/connection/IConnectionService'; +import {DomainConnectionVerifier} from '@app/api/connection/verification/DomainConnectionVerifier'; +import type {RevisionedUserConnectionRow, UserConnectionRow} from '@app/api/database/types/ConnectionTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import { type ConnectionType, @@ -9,26 +29,6 @@ import { MAX_CONNECTIONS_PER_USER, } from '@fluxer/constants/src/ConnectionConstants'; import {ConflictError} from '@fluxer/errors/src/domains/core/ConflictError'; -import type {UserID} from '../BrandedTypes'; -import type {BlueskyCallbackResult} from '../bluesky/IBlueskyOAuthService'; -import type {RevisionedUserConnectionRow, UserConnectionRow} from '../database/types/ConnectionTypes'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import {mapConnectionToResponse} from './ConnectionMappers'; -import {createDomainConnectionId} from './DomainConnectionId'; -import {BlueskyOAuthNotEnabledError} from './errors/BlueskyOAuthNotEnabledError'; -import {ConnectionAlreadyExistsError} from './errors/ConnectionAlreadyExistsError'; -import {ConnectionInvalidTypeError} from './errors/ConnectionInvalidTypeError'; -import {ConnectionLimitReachedError} from './errors/ConnectionLimitReachedError'; -import {ConnectionNotFoundError} from './errors/ConnectionNotFoundError'; -import {ConnectionVerificationFailedError} from './errors/ConnectionVerificationFailedError'; -import type { - ConnectionSortOrderUpdate, - CreateConnectionParams, - IConnectionRepository, - UpdateConnectionParams, -} from './IConnectionRepository'; -import {IConnectionService, type InitiateConnectionResult} from './IConnectionService'; -import {DomainConnectionVerifier} from './verification/DomainConnectionVerifier'; export class ConnectionService extends IConnectionService { constructor( diff --git a/fluxer_api/src/api/connection/DomainConnectionId.ts b/fluxer_api/src/api/connection/DomainConnectionId.ts index 20f595c8b..c8d9d9afe 100644 --- a/fluxer_api/src/api/connection/DomainConnectionId.ts +++ b/fluxer_api/src/api/connection/DomainConnectionId.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; -import type {UserID} from '../BrandedTypes'; +import type {UserID} from '@app/api/BrandedTypes'; export function createDomainConnectionId(userId: UserID, identifier: string): string { return createHash('sha256') diff --git a/fluxer_api/src/api/connection/IConnectionRepository.ts b/fluxer_api/src/api/connection/IConnectionRepository.ts index 2d871662e..1198f2be9 100644 --- a/fluxer_api/src/api/connection/IConnectionRepository.ts +++ b/fluxer_api/src/api/connection/IConnectionRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {RevisionedUserConnectionRow, UserConnectionRow} from '@app/api/database/types/ConnectionTypes'; import type {ConnectionType} from '@fluxer/constants/src/ConnectionConstants'; -import type {UserID} from '../BrandedTypes'; -import type {RevisionedUserConnectionRow, UserConnectionRow} from '../database/types/ConnectionTypes'; export interface CreateConnectionParams { user_id: UserID; diff --git a/fluxer_api/src/api/connection/IConnectionService.ts b/fluxer_api/src/api/connection/IConnectionService.ts index fd2b43d0b..a05ab4053 100644 --- a/fluxer_api/src/api/connection/IConnectionService.ts +++ b/fluxer_api/src/api/connection/IConnectionService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {BlueskyCallbackResult} from '@app/api/bluesky/IBlueskyOAuthService'; +import type {UpdateConnectionParams} from '@app/api/connection/IConnectionRepository'; +import type {UserConnectionRow} from '@app/api/database/types/ConnectionTypes'; import type {ConnectionType} from '@fluxer/constants/src/ConnectionConstants'; -import type {UserID} from '../BrandedTypes'; -import type {BlueskyCallbackResult} from '../bluesky/IBlueskyOAuthService'; -import type {UserConnectionRow} from '../database/types/ConnectionTypes'; -import type {UpdateConnectionParams} from './IConnectionRepository'; export type InitiateConnectionResult = Record; diff --git a/fluxer_api/src/api/connection/tests/ConnectionLimit.test.ts b/fluxer_api/src/api/connection/tests/ConnectionLimit.test.ts index 3d5b4d3b6..91c7fbb6d 100644 --- a/fluxer_api/src/api/connection/tests/ConnectionLimit.test.ts +++ b/fluxer_api/src/api/connection/tests/ConnectionLimit.test.ts @@ -1,5 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {ConnectionRepository} from '@app/api/connection/ConnectionRepository'; +import {ConnectionService} from '@app/api/connection/ConnectionService'; +import {ConnectionLimitReachedError} from '@app/api/connection/errors/ConnectionLimitReachedError'; +import {setCassandraQueryExecutorForTesting} from '@app/api/database/CassandraQueryExecution'; +import type {UserConnectionRow} from '@app/api/database/types/ConnectionTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import { ConnectionTypes, @@ -7,14 +15,6 @@ import { MAX_CONNECTIONS_PER_USER, } from '@fluxer/constants/src/ConnectionConstants'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {setCassandraQueryExecutorForTesting} from '../../database/CassandraQueryExecution'; -import type {UserConnectionRow} from '../../database/types/ConnectionTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {InMemoryCassandraQueryExecutor} from '../../test/InMemoryCassandraQueryExecutor'; -import {ConnectionRepository} from '../ConnectionRepository'; -import {ConnectionService} from '../ConnectionService'; -import {ConnectionLimitReachedError} from '../errors/ConnectionLimitReachedError'; function connectionRow(userId: UserID, connectionId: string, sortOrder: number): UserConnectionRow { return { diff --git a/fluxer_api/src/api/connection/tests/ConnectionReorder.test.ts b/fluxer_api/src/api/connection/tests/ConnectionReorder.test.ts index 9f95a82e4..6a6bb4d58 100644 --- a/fluxer_api/src/api/connection/tests/ConnectionReorder.test.ts +++ b/fluxer_api/src/api/connection/tests/ConnectionReorder.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ConnectionTypes, ConnectionVisibilityFlags} from '@fluxer/constants/src/ConnectionConstants'; -import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; -import {createUserID, type UserID} from '../../BrandedTypes'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {ConnectionRepository} from '@app/api/connection/ConnectionRepository'; +import {ConnectionService} from '@app/api/connection/ConnectionService'; import { type CassandraQueryExecutorForTesting, setCassandraQueryExecutorForTesting, -} from '../../database/CassandraQueryExecution'; -import type {CassandraParams, KvQueryMeta, PreparedQuery} from '../../database/CassandraTypes'; -import type {UserConnectionRow} from '../../database/types/ConnectionTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {InMemoryCassandraQueryExecutor} from '../../test/InMemoryCassandraQueryExecutor'; -import {ConnectionRepository} from '../ConnectionRepository'; -import {ConnectionService} from '../ConnectionService'; +} from '@app/api/database/CassandraQueryExecution'; +import type {CassandraParams, KvQueryMeta, PreparedQuery} from '@app/api/database/CassandraTypes'; +import type {UserConnectionRow} from '@app/api/database/types/ConnectionTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; +import {ConnectionTypes, ConnectionVisibilityFlags} from '@fluxer/constants/src/ConnectionConstants'; +import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; class ConditionalBatchFaultExecutor implements CassandraQueryExecutorForTesting { failNextBatch = false; diff --git a/fluxer_api/src/api/connection/verification/DomainConnectionVerifier.ts b/fluxer_api/src/api/connection/verification/DomainConnectionVerifier.ts index 68af3af21..e6bc2ee97 100644 --- a/fluxer_api/src/api/connection/verification/DomainConnectionVerifier.ts +++ b/fluxer_api/src/api/connection/verification/DomainConnectionVerifier.ts @@ -1,11 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {Resolver} from 'node:dns/promises'; +import type { + ConnectionVerificationParams, + IConnectionVerifier, +} from '@app/api/connection/verification/IConnectionVerifier'; +import {Logger} from '@app/api/Logger'; +import {EXTERNAL_RESPONSE_LIMITS} from '@app/api/utils/ExternalResponseLimits'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; import {isFqdnHostname} from '@fluxer/schema/src/primitives/UrlValidators'; -import {Logger} from '../../Logger'; -import {EXTERNAL_RESPONSE_LIMITS} from '../../utils/ExternalResponseLimits'; -import * as FetchUtils from '../../utils/FetchUtils'; -import type {ConnectionVerificationParams, IConnectionVerifier} from './IConnectionVerifier'; const VERIFICATION_TIMEOUT_MS = 5000; const DNS_VERIFICATION_TIMEOUT_MS = 2000; diff --git a/fluxer_api/src/api/constants/Core.ts b/fluxer_api/src/api/constants/Core.ts index 5a620a648..069681e5d 100644 --- a/fluxer_api/src/api/constants/Core.ts +++ b/fluxer_api/src/api/constants/Core.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; import {DELETED_USER_ID} from '@fluxer/constants/src/UserConstants'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; -import {createUserID, type UserID} from '../BrandedTypes'; export const SYSTEM_USER_ID = createUserID(0n); diff --git a/fluxer_api/src/api/content_i18n/ContentI18n.ts b/fluxer_api/src/api/content_i18n/ContentI18n.ts index 73e7b9971..af7774af4 100644 --- a/fluxer_api/src/api/content_i18n/ContentI18n.ts +++ b/fluxer_api/src/api/content_i18n/ContentI18n.ts @@ -1,11 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {CONTENT_I18N_LOCALE_MESSAGES} from '@app/api/content_i18n/ContentI18nLocales'; +import { + CONTENT_I18N_MESSAGES, + type ContentI18nCatalog, + type ContentI18nKey, +} from '@app/api/content_i18n/ContentI18nMessages'; import {identityLocale} from '@fluxer/i18n/src/normalization/IdentityLocale'; import {createStaticI18n} from '@fluxer/i18n/src/runtime/CreateStaticI18n'; import type {MessageArgsForTemplate} from '@fluxer/i18n/src/runtime/MessageCatalogTypes'; import {validateMessageTemplateVariables} from '@fluxer/i18n/src/runtime/MessageCatalogTypes'; -import {CONTENT_I18N_LOCALE_MESSAGES} from './ContentI18nLocales'; -import {CONTENT_I18N_MESSAGES, type ContentI18nCatalog, type ContentI18nKey} from './ContentI18nMessages'; const DEFAULT_LOCALE = 'en-US'; diff --git a/fluxer_api/src/api/content_i18n/ContentI18nLocales.ts b/fluxer_api/src/api/content_i18n/ContentI18nLocales.ts index ab2ad092c..b6ea95438 100644 --- a/fluxer_api/src/api/content_i18n/ContentI18nLocales.ts +++ b/fluxer_api/src/api/content_i18n/ContentI18nLocales.ts @@ -1,39 +1,39 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ContentI18nKey} from './ContentI18nMessages'; -import CONTENT_I18N_AR_MESSAGES from './locales/ar'; -import CONTENT_I18N_BG_MESSAGES from './locales/bg'; -import CONTENT_I18N_CS_MESSAGES from './locales/cs'; -import CONTENT_I18N_DA_MESSAGES from './locales/da'; -import CONTENT_I18N_DE_MESSAGES from './locales/de'; -import CONTENT_I18N_EL_MESSAGES from './locales/el'; -import CONTENT_I18N_EN_GB_MESSAGES from './locales/en-GB'; -import CONTENT_I18N_ES_419_MESSAGES from './locales/es-419'; -import CONTENT_I18N_ES_ES_MESSAGES from './locales/es-ES'; -import CONTENT_I18N_FI_MESSAGES from './locales/fi'; -import CONTENT_I18N_FR_MESSAGES from './locales/fr'; -import CONTENT_I18N_HE_MESSAGES from './locales/he'; -import CONTENT_I18N_HI_MESSAGES from './locales/hi'; -import CONTENT_I18N_HR_MESSAGES from './locales/hr'; -import CONTENT_I18N_HU_MESSAGES from './locales/hu'; -import CONTENT_I18N_ID_MESSAGES from './locales/id'; -import CONTENT_I18N_IT_MESSAGES from './locales/it'; -import CONTENT_I18N_JA_MESSAGES from './locales/ja'; -import CONTENT_I18N_KO_MESSAGES from './locales/ko'; -import CONTENT_I18N_LT_MESSAGES from './locales/lt'; -import CONTENT_I18N_NL_MESSAGES from './locales/nl'; -import CONTENT_I18N_NO_MESSAGES from './locales/no'; -import CONTENT_I18N_PL_MESSAGES from './locales/pl'; -import CONTENT_I18N_PT_BR_MESSAGES from './locales/pt-BR'; -import CONTENT_I18N_RO_MESSAGES from './locales/ro'; -import CONTENT_I18N_RU_MESSAGES from './locales/ru'; -import CONTENT_I18N_SV_SE_MESSAGES from './locales/sv-SE'; -import CONTENT_I18N_TH_MESSAGES from './locales/th'; -import CONTENT_I18N_TR_MESSAGES from './locales/tr'; -import CONTENT_I18N_UK_MESSAGES from './locales/uk'; -import CONTENT_I18N_VI_MESSAGES from './locales/vi'; -import CONTENT_I18N_ZH_CN_MESSAGES from './locales/zh-CN'; -import CONTENT_I18N_ZH_TW_MESSAGES from './locales/zh-TW'; +import type {ContentI18nKey} from '@app/api/content_i18n/ContentI18nMessages'; +import CONTENT_I18N_AR_MESSAGES from '@app/api/content_i18n/locales/ar'; +import CONTENT_I18N_BG_MESSAGES from '@app/api/content_i18n/locales/bg'; +import CONTENT_I18N_CS_MESSAGES from '@app/api/content_i18n/locales/cs'; +import CONTENT_I18N_DA_MESSAGES from '@app/api/content_i18n/locales/da'; +import CONTENT_I18N_DE_MESSAGES from '@app/api/content_i18n/locales/de'; +import CONTENT_I18N_EL_MESSAGES from '@app/api/content_i18n/locales/el'; +import CONTENT_I18N_EN_GB_MESSAGES from '@app/api/content_i18n/locales/en-GB'; +import CONTENT_I18N_ES_419_MESSAGES from '@app/api/content_i18n/locales/es-419'; +import CONTENT_I18N_ES_ES_MESSAGES from '@app/api/content_i18n/locales/es-ES'; +import CONTENT_I18N_FI_MESSAGES from '@app/api/content_i18n/locales/fi'; +import CONTENT_I18N_FR_MESSAGES from '@app/api/content_i18n/locales/fr'; +import CONTENT_I18N_HE_MESSAGES from '@app/api/content_i18n/locales/he'; +import CONTENT_I18N_HI_MESSAGES from '@app/api/content_i18n/locales/hi'; +import CONTENT_I18N_HR_MESSAGES from '@app/api/content_i18n/locales/hr'; +import CONTENT_I18N_HU_MESSAGES from '@app/api/content_i18n/locales/hu'; +import CONTENT_I18N_ID_MESSAGES from '@app/api/content_i18n/locales/id'; +import CONTENT_I18N_IT_MESSAGES from '@app/api/content_i18n/locales/it'; +import CONTENT_I18N_JA_MESSAGES from '@app/api/content_i18n/locales/ja'; +import CONTENT_I18N_KO_MESSAGES from '@app/api/content_i18n/locales/ko'; +import CONTENT_I18N_LT_MESSAGES from '@app/api/content_i18n/locales/lt'; +import CONTENT_I18N_NL_MESSAGES from '@app/api/content_i18n/locales/nl'; +import CONTENT_I18N_NO_MESSAGES from '@app/api/content_i18n/locales/no'; +import CONTENT_I18N_PL_MESSAGES from '@app/api/content_i18n/locales/pl'; +import CONTENT_I18N_PT_BR_MESSAGES from '@app/api/content_i18n/locales/pt-BR'; +import CONTENT_I18N_RO_MESSAGES from '@app/api/content_i18n/locales/ro'; +import CONTENT_I18N_RU_MESSAGES from '@app/api/content_i18n/locales/ru'; +import CONTENT_I18N_SV_SE_MESSAGES from '@app/api/content_i18n/locales/sv-SE'; +import CONTENT_I18N_TH_MESSAGES from '@app/api/content_i18n/locales/th'; +import CONTENT_I18N_TR_MESSAGES from '@app/api/content_i18n/locales/tr'; +import CONTENT_I18N_UK_MESSAGES from '@app/api/content_i18n/locales/uk'; +import CONTENT_I18N_VI_MESSAGES from '@app/api/content_i18n/locales/vi'; +import CONTENT_I18N_ZH_CN_MESSAGES from '@app/api/content_i18n/locales/zh-CN'; +import CONTENT_I18N_ZH_TW_MESSAGES from '@app/api/content_i18n/locales/zh-TW'; export const CONTENT_I18N_LOCALE_MESSAGES = { ar: CONTENT_I18N_AR_MESSAGES, diff --git a/fluxer_api/src/api/csam/NcmecReporter.ts b/fluxer_api/src/api/csam/NcmecReporter.ts index 9fd1bc885..6cd9159db 100644 --- a/fluxer_api/src/api/csam/NcmecReporter.ts +++ b/fluxer_api/src/api/csam/NcmecReporter.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; +import {EXTERNAL_RESPONSE_LIMITS} from '@app/api/utils/ExternalResponseLimits'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; import {ms} from 'itty-time'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import {EXTERNAL_RESPONSE_LIMITS} from '../utils/ExternalResponseLimits'; -import * as FetchUtils from '../utils/FetchUtils'; const NCMEC_REQUEST_TIMEOUT_MS = ms('2 minutes'); diff --git a/fluxer_api/src/api/csam/NcmecRepository.ts b/fluxer_api/src/api/csam/NcmecRepository.ts index 7174d8a68..eba5486cf 100644 --- a/fluxer_api/src/api/csam/NcmecRepository.ts +++ b/fluxer_api/src/api/csam/NcmecRepository.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID, UserID} from '../BrandedTypes'; -import {fetchOne, upsertOne} from '../database/CassandraQueryExecution'; -import type {NcmecAttachmentSubmissionRow, NcmecUserWorkflowRow} from '../database/types/CsamTypes'; -import {NcmecAttachmentSubmissions, NcmecUserWorkflows} from '../Tables'; +import type {AttachmentID, UserID} from '@app/api/BrandedTypes'; +import {fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {NcmecAttachmentSubmissionRow, NcmecUserWorkflowRow} from '@app/api/database/types/CsamTypes'; +import {NcmecAttachmentSubmissions, NcmecUserWorkflows} from '@app/api/Tables'; const GET_ATTACHMENT_SUBMISSION_QUERY = NcmecAttachmentSubmissions.select({ where: NcmecAttachmentSubmissions.where.eq('attachment_id'), diff --git a/fluxer_api/src/api/csam/NcmecSubmissionService.ts b/fluxer_api/src/api/csam/NcmecSubmissionService.ts index 768bc766c..f0ceced13 100644 --- a/fluxer_api/src/api/csam/NcmecSubmissionService.ts +++ b/fluxer_api/src/api/csam/NcmecSubmissionService.ts @@ -1,5 +1,50 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminArchiveService} from '@app/api/admin/services/AdminArchiveService'; +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {AdminUserUpdatePropagator} from '@app/api/admin/services/AdminUserUpdatePropagator'; +import { + type AttachmentID, + type ChannelID, + createAttachmentID, + createChannelID, + createMessageID, + createUserID, + type MessageID, + type ReportID, + type UserID, +} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {AttachmentUploadTraceRepository} from '@app/api/channel/repositories/message/AttachmentUploadTraceRepository'; +import { + collectMessageAttachments, + makeAttachmentCdnKey, + makeAttachmentCdnUrl, + purgeMessageAttachments, +} from '@app/api/channel/services/message/MessageHelpers'; +import type {NcmecApiClient} from '@app/api/csam/NcmecReporter'; +import {buildNcmecFileDetailsXml, buildNcmecReportXml} from '@app/api/csam/NcmecReporter'; +import type {NcmecRepository} from '@app/api/csam/NcmecRepository'; +import type {AttachmentUploadTraceByAttachmentRow} from '@app/api/database/types/AttachmentUploadTypes'; +import type {NcmecAttachmentSubmissionRow, NcmecUserWorkflowRow} from '@app/api/database/types/CsamTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {Embed} from '@app/api/models/Embed'; +import type {EmbedMedia} from '@app/api/models/EmbedMedia'; +import type {Message} from '@app/api/models/Message'; +import type {User} from '@app/api/models/User'; +import type {IARMessageContext, IARSubmission} from '@app/api/report/IReportRepository'; +import type {ReportRepository} from '@app/api/report/ReportRepository'; +import {deleteMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {reschedulePendingDeletion} from '@app/api/user/services/PendingDeletionCoordinator'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import {DeletionReasons} from '@fluxer/constants/src/Core'; import {CATEGORY_CHILD_SAFETY} from '@fluxer/constants/src/ReportCategories'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; @@ -13,51 +58,6 @@ import type {NcmecSubmissionStatus} from '@fluxer/schema/src/domains/admin/Admin import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import {ms} from 'itty-time'; -import type {AdminArchiveService} from '../admin/services/AdminArchiveService'; -import type {AdminAuditService} from '../admin/services/AdminAuditService'; -import {AdminUserUpdatePropagator} from '../admin/services/AdminUserUpdatePropagator'; -import { - type AttachmentID, - type ChannelID, - createAttachmentID, - createChannelID, - createMessageID, - createUserID, - type MessageID, - type ReportID, - type UserID, -} from '../BrandedTypes'; -import {Config} from '../Config'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import type {AttachmentUploadTraceRepository} from '../channel/repositories/message/AttachmentUploadTraceRepository'; -import { - collectMessageAttachments, - makeAttachmentCdnKey, - makeAttachmentCdnUrl, - purgeMessageAttachments, -} from '../channel/services/message/MessageHelpers'; -import type {AttachmentUploadTraceByAttachmentRow} from '../database/types/AttachmentUploadTypes'; -import type {NcmecAttachmentSubmissionRow, NcmecUserWorkflowRow} from '../database/types/CsamTypes'; -import type {IGuildRepositoryAggregate} from '../guild/repositories/IGuildRepositoryAggregate'; -import type {IPurgeQueue} from '../infrastructure/BunnyPurgeQueue'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {IStorageService} from '../infrastructure/IStorageService'; -import type {KVAccountDeletionQueueService} from '../infrastructure/KVAccountDeletionQueueService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import {Logger} from '../Logger'; -import type {Embed} from '../models/Embed'; -import type {EmbedMedia} from '../models/EmbedMedia'; -import type {Message} from '../models/Message'; -import type {User} from '../models/User'; -import type {IARMessageContext, IARSubmission} from '../report/IReportRepository'; -import type {ReportRepository} from '../report/ReportRepository'; -import {deleteMessageSearchDocuments} from '../search/MessageSearchIndexCleanup'; -import type {IUserRepository} from '../user/IUserRepository'; -import {reschedulePendingDeletion} from '../user/services/PendingDeletionCoordinator'; -import type {WorkerTaskName} from '../worker/WorkerLaneConfig'; -import type {NcmecApiClient} from './NcmecReporter'; -import {buildNcmecFileDetailsXml, buildNcmecReportXml} from './NcmecReporter'; -import type {NcmecRepository} from './NcmecRepository'; export interface NcmecAttachmentStatusResponse { status: NcmecSubmissionStatus; diff --git a/fluxer_api/src/api/csam/tests/NcmecReporter.test.ts b/fluxer_api/src/api/csam/tests/NcmecReporter.test.ts index 870ac8b19..13e3058a4 100644 --- a/fluxer_api/src/api/csam/tests/NcmecReporter.test.ts +++ b/fluxer_api/src/api/csam/tests/NcmecReporter.test.ts @@ -1,9 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + buildNcmecFileDetailsXml, + buildNcmecReportXml, + createNcmecApiConfig, + NcmecReporter, +} from '@app/api/csam/NcmecReporter'; +import {INVALID_REPORT_XML, MALFORMED_REPORT_XML} from '@app/api/test/fixtures/ncmec/NcmecXmlFixtures'; +import {fakeNcmecServer} from '@app/api/test/Setup'; import {describe, expect, test} from 'vitest'; -import {INVALID_REPORT_XML, MALFORMED_REPORT_XML} from '../../test/fixtures/ncmec/NcmecXmlFixtures'; -import {fakeNcmecServer} from '../../test/Setup'; -import {buildNcmecFileDetailsXml, buildNcmecReportXml, createNcmecApiConfig, NcmecReporter} from '../NcmecReporter'; function reporter(): NcmecReporter { return new NcmecReporter({config: createNcmecApiConfig(), fetch}); diff --git a/fluxer_api/src/api/database/CassandraDevLogger.ts b/fluxer_api/src/api/database/CassandraDevLogger.ts index 5c6481f88..e93e28fab 100644 --- a/fluxer_api/src/api/database/CassandraDevLogger.ts +++ b/fluxer_api/src/api/database/CassandraDevLogger.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Logger} from '../Logger'; -import {getIsDev} from './CassandraMetaRegistry'; -import {getStatementMeta} from './CassandraTypes'; +import {getIsDev} from '@app/api/database/CassandraMetaRegistry'; +import {getStatementMeta} from '@app/api/database/CassandraTypes'; +import {Logger} from '@app/api/Logger'; const colors = { reset: '\x1b[0m', diff --git a/fluxer_api/src/api/database/CassandraMetaRegistry.test.ts b/fluxer_api/src/api/database/CassandraMetaRegistry.test.ts index 9f23ab4c4..64018601a 100644 --- a/fluxer_api/src/api/database/CassandraMetaRegistry.test.ts +++ b/fluxer_api/src/api/database/CassandraMetaRegistry.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getKvMeta, registerKvMeta} from '@app/api/database/CassandraMetaRegistry'; +import type {KvQueryMeta, KvTableSpec} from '@app/api/database/CassandraTypes'; import {describe, expect, it} from 'vitest'; -import {getKvMeta, registerKvMeta} from './CassandraMetaRegistry'; -import type {KvQueryMeta, KvTableSpec} from './CassandraTypes'; const MetaRegistryTestRows: KvTableSpec = { name: 'meta_registry_test_rows', diff --git a/fluxer_api/src/api/database/CassandraMetaRegistry.ts b/fluxer_api/src/api/database/CassandraMetaRegistry.ts index ee8666451..ac4672807 100644 --- a/fluxer_api/src/api/database/CassandraMetaRegistry.ts +++ b/fluxer_api/src/api/database/CassandraMetaRegistry.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Config} from '../Config'; -import type {KvQueryMeta, KvTableSpec} from './CassandraTypes'; +import {Config} from '@app/api/Config'; +import type {KvQueryMeta, KvTableSpec} from '@app/api/database/CassandraTypes'; export function getIsDev(): boolean { return Config.nodeEnv === 'development'; diff --git a/fluxer_api/src/api/database/CassandraParamGuard.test.ts b/fluxer_api/src/api/database/CassandraParamGuard.test.ts index 1ff073616..5600ae916 100644 --- a/fluxer_api/src/api/database/CassandraParamGuard.test.ts +++ b/fluxer_api/src/api/database/CassandraParamGuard.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {assertNoUndefinedParams} from '@app/api/database/CassandraTypes'; import {describe, expect, it} from 'vitest'; -import {assertNoUndefinedParams} from './CassandraTypes'; function messageFor(path: string): string { return `Undefined value at "${path}". This project forbids undefined in Cassandra params; use null explicitly or omit the column via PATCH.`; diff --git a/fluxer_api/src/api/database/CassandraQueryExecution.test.ts b/fluxer_api/src/api/database/CassandraQueryExecution.test.ts index 2761fb32f..56dd1fadf 100644 --- a/fluxer_api/src/api/database/CassandraQueryExecution.test.ts +++ b/fluxer_api/src/api/database/CassandraQueryExecution.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapCassandraDriverError} from '@app/api/database/CassandraQueryExecution'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; import cassandra from 'cassandra-driver'; import {describe, expect, it} from 'vitest'; -import {mapCassandraDriverError} from './CassandraQueryExecution'; function busyConnectionError(): cassandra.errors.BusyConnectionError { return new cassandra.errors.BusyConnectionError('127.0.0.1:9042', 2048, 4); diff --git a/fluxer_api/src/api/database/CassandraQueryExecution.ts b/fluxer_api/src/api/database/CassandraQueryExecution.ts index fd6a3b428..6610c7424 100644 --- a/fluxer_api/src/api/database/CassandraQueryExecution.ts +++ b/fluxer_api/src/api/database/CassandraQueryExecution.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; -import {getClient} from '@pkgs/cassandra/src/Client'; -import cassandra from 'cassandra-driver'; -import {Logger} from '../Logger'; -import {chunkArray} from '../utils/ArrayUtils'; -import {logBatch, logQuery} from './CassandraDevLogger'; -import {getIsDev} from './CassandraMetaRegistry'; -import type {CassandraParams, KvQueryMeta, PreparedQuery, QueryTemplate} from './CassandraTypes'; +import {logBatch, logQuery} from '@app/api/database/CassandraDevLogger'; +import {getIsDev} from '@app/api/database/CassandraMetaRegistry'; +import type {CassandraParams, KvQueryMeta, PreparedQuery, QueryTemplate} from '@app/api/database/CassandraTypes'; import { assertNoUndefinedParams, getStatementMeta, isConditionalQuery, normalizeExecuteArgs, normalizeInParams, -} from './CassandraTypes'; +} from '@app/api/database/CassandraTypes'; +import {Logger} from '@app/api/Logger'; +import {chunkArray} from '@app/api/utils/ArrayUtils'; +import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; +import {getClient} from '@pkgs/cassandra/src/Client'; +import cassandra from 'cassandra-driver'; const DEFAULT_MAX_PARTITION_KEYS_PER_QUERY = 100; diff --git a/fluxer_api/src/api/database/CassandraTableDsl.test.ts b/fluxer_api/src/api/database/CassandraTableDsl.test.ts index bde610e19..a0c350d02 100644 --- a/fluxer_api/src/api/database/CassandraTableDsl.test.ts +++ b/fluxer_api/src/api/database/CassandraTableDsl.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {defineTable} from '@app/api/database/CassandraTableDsl'; +import {Db, type PreparedQuery} from '@app/api/database/CassandraTypes'; import {describe, expect, it} from 'vitest'; -import {defineTable} from './CassandraTableDsl'; -import {Db, type PreparedQuery} from './CassandraTypes'; interface TtlHelperTestRow { id: string; diff --git a/fluxer_api/src/api/database/CassandraTableDsl.ts b/fluxer_api/src/api/database/CassandraTableDsl.ts index 895ae02b6..8b5f72b15 100644 --- a/fluxer_api/src/api/database/CassandraTableDsl.ts +++ b/fluxer_api/src/api/database/CassandraTableDsl.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {isDeepStrictEqual} from 'node:util'; -import {registerKvMeta, registerTableSpec} from './CassandraMetaRegistry'; +import {registerKvMeta, registerTableSpec} from '@app/api/database/CassandraMetaRegistry'; import type { CassandraParam, CassandraParams, @@ -18,8 +18,8 @@ import type { RowValue, Table, WhereExpr, -} from './CassandraTypes'; -import {prepared, validateTtlSeconds} from './CassandraTypes'; +} from '@app/api/database/CassandraTypes'; +import {prepared, validateTtlSeconds} from '@app/api/database/CassandraTypes'; const DEFAULT_TTL_PARAM_NAME = 'ttl_seconds_bind'; const DEFAULT_LIMIT_PARAM_NAME = 'limit_bind'; diff --git a/fluxer_api/src/api/database/CassandraTypes.test.ts b/fluxer_api/src/api/database/CassandraTypes.test.ts index e0b7fb3a5..7ac1ebd04 100644 --- a/fluxer_api/src/api/database/CassandraTypes.test.ts +++ b/fluxer_api/src/api/database/CassandraTypes.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {BatchBuilder, executeQuery, fetchPage} from '@app/api/database/CassandraQueryExecution'; +import {getStatementMeta, normalizeInParams} from '@app/api/database/CassandraTypes'; import {describe, expect, it} from 'vitest'; -import {BatchBuilder, executeQuery, fetchPage} from './CassandraQueryExecution'; -import {getStatementMeta, normalizeInParams} from './CassandraTypes'; describe('getStatementMeta', () => { it('flags SELECT * statements as unsafe', () => { diff --git a/fluxer_api/src/api/database/CassandraVersionedUpdate.ts b/fluxer_api/src/api/database/CassandraVersionedUpdate.ts index a14320577..241e1ab3a 100644 --- a/fluxer_api/src/api/database/CassandraVersionedUpdate.ts +++ b/fluxer_api/src/api/database/CassandraVersionedUpdate.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {upsertOne} from './CassandraQueryExecution'; -import type {ColumnName, DbOp, PatchObject, RowValue, Table} from './CassandraTypes'; -import {Db, nextVersion} from './CassandraTypes'; +import {upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {ColumnName, DbOp, PatchObject, RowValue, Table} from '@app/api/database/CassandraTypes'; +import {Db, nextVersion} from '@app/api/database/CassandraTypes'; export async function executeVersionedUpdate< Row extends { diff --git a/fluxer_api/src/api/database/PostgresKvExactnessFuzz.test.ts b/fluxer_api/src/api/database/PostgresKvExactnessFuzz.test.ts index 95feb64c0..4faa35eaf 100644 --- a/fluxer_api/src/api/database/PostgresKvExactnessFuzz.test.ts +++ b/fluxer_api/src/api/database/PostgresKvExactnessFuzz.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from '@app/api/database/CassandraTypes'; +import {buildCandidatePlan, keyFromColumns, matchesWhere} from '@app/api/database/PostgresKvQueryExecutor'; import cassandra from 'cassandra-driver'; import {describe, expect, it} from 'vitest'; -import type {CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from './CassandraTypes'; -import {buildCandidatePlan, keyFromColumns, matchesWhere} from './PostgresKvQueryExecutor'; type Row = Record; type AnyMeta = KvQueryMeta; diff --git a/fluxer_api/src/api/database/PostgresKvLoggerSafety.test.ts b/fluxer_api/src/api/database/PostgresKvLoggerSafety.test.ts index 6d8ce402c..a154e2df2 100644 --- a/fluxer_api/src/api/database/PostgresKvLoggerSafety.test.ts +++ b/fluxer_api/src/api/database/PostgresKvLoggerSafety.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {defineTable} from '@app/api/database/CassandraTableDsl'; +import type {KvQueryMeta} from '@app/api/database/CassandraTypes'; import {describe, expect, it, vi} from 'vitest'; -import {defineTable} from './CassandraTableDsl'; -import type {KvQueryMeta} from './CassandraTypes'; -vi.mock('../Logger', () => ({ +vi.mock('@app/api/Logger', () => ({ Logger: new Proxy( {}, { @@ -42,7 +42,7 @@ const client = { describe('PostgresKvQueryExecutor logging safety', () => { it('runs full scan queries in a process whose logger was never initialized', async () => { - const {PostgresKvQueryExecutor} = await import('./PostgresKvQueryExecutor'); + const {PostgresKvQueryExecutor} = await import('@app/api/database/PostgresKvQueryExecutor'); const executor = new PostgresKvQueryExecutor(client); for (const action of ['select', 'count', 'delete'] as const) { const meta = {action, table: Probe, where: [], columns: ['k', 'v']} as unknown as KvQueryMeta; diff --git a/fluxer_api/src/api/database/PostgresKvNonSelectDrift.test.ts b/fluxer_api/src/api/database/PostgresKvNonSelectDrift.test.ts index 4bba4d25a..c69c833a8 100644 --- a/fluxer_api/src/api/database/PostgresKvNonSelectDrift.test.ts +++ b/fluxer_api/src/api/database/PostgresKvNonSelectDrift.test.ts @@ -2,6 +2,10 @@ import {spawnSync} from 'node:child_process'; import {createServer} from 'node:net'; +import {LegacyPostgresKvQueryExecutor} from '@app/api/database/__testref__/LegacyPostgresKvQueryExecutor'; +import type {CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from '@app/api/database/CassandraTypes'; +import {ensurePostgresKvSchema, PostgresKvQueryExecutor} from '@app/api/database/PostgresKvQueryExecutor'; +import {startDockerContainer} from '@app/api/test/DockerTestContainer'; import { getDefaultPostgresClient, type IPostgresClient, @@ -10,10 +14,6 @@ import { shutdownPostgres, } from '@pkgs/postgres/src/Client'; import {afterAll, beforeAll, describe, expect, it} from 'vitest'; -import {startDockerContainer} from '../test/DockerTestContainer'; -import {LegacyPostgresKvQueryExecutor} from './__testref__/LegacyPostgresKvQueryExecutor'; -import type {CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from './CassandraTypes'; -import {ensurePostgresKvSchema, PostgresKvQueryExecutor} from './PostgresKvQueryExecutor'; type Row = Record; type AnyMeta = KvQueryMeta; diff --git a/fluxer_api/src/api/database/PostgresKvNonSelectMatrix.test.ts b/fluxer_api/src/api/database/PostgresKvNonSelectMatrix.test.ts index 6f8074347..cb6721436 100644 --- a/fluxer_api/src/api/database/PostgresKvNonSelectMatrix.test.ts +++ b/fluxer_api/src/api/database/PostgresKvNonSelectMatrix.test.ts @@ -2,6 +2,14 @@ import {spawnSync} from 'node:child_process'; import {createServer} from 'node:net'; +import {LegacyPostgresKvQueryExecutor} from '@app/api/database/__testref__/LegacyPostgresKvQueryExecutor'; +import type {CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from '@app/api/database/CassandraTypes'; +import { + buildCandidatePlan, + ensurePostgresKvSchema, + PostgresKvQueryExecutor, +} from '@app/api/database/PostgresKvQueryExecutor'; +import {startDockerContainer} from '@app/api/test/DockerTestContainer'; import { getDefaultPostgresClient, type IPostgresClient, @@ -11,10 +19,6 @@ import { } from '@pkgs/postgres/src/Client'; import cassandra from 'cassandra-driver'; import {afterAll, beforeAll, describe, expect, it} from 'vitest'; -import {startDockerContainer} from '../test/DockerTestContainer'; -import {LegacyPostgresKvQueryExecutor} from './__testref__/LegacyPostgresKvQueryExecutor'; -import type {CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from './CassandraTypes'; -import {buildCandidatePlan, ensurePostgresKvSchema, PostgresKvQueryExecutor} from './PostgresKvQueryExecutor'; type Row = Record; type AnyMeta = KvQueryMeta; diff --git a/fluxer_api/src/api/database/PostgresKvOrderingAttack.test.ts b/fluxer_api/src/api/database/PostgresKvOrderingAttack.test.ts index 201f5a454..1a2f7b8ff 100644 --- a/fluxer_api/src/api/database/PostgresKvOrderingAttack.test.ts +++ b/fluxer_api/src/api/database/PostgresKvOrderingAttack.test.ts @@ -2,6 +2,21 @@ import {spawnSync} from 'node:child_process'; import {createServer} from 'node:net'; +import {LegacyPostgresKvQueryExecutor} from '@app/api/database/__testref__/LegacyPostgresKvQueryExecutor'; +import {defineTable} from '@app/api/database/CassandraTableDsl'; +import type { + CassandraParam, + CassandraParams, + KvQueryMeta, + KvTableSpec, + WhereExpr, +} from '@app/api/database/CassandraTypes'; +import { + buildCandidatePlan, + ensurePostgresKvSchema, + PostgresKvQueryExecutor, +} from '@app/api/database/PostgresKvQueryExecutor'; +import {startDockerContainer} from '@app/api/test/DockerTestContainer'; import { getDefaultPostgresClient, type IPostgresClient, @@ -11,11 +26,6 @@ import { } from '@pkgs/postgres/src/Client'; import cassandra from 'cassandra-driver'; import {afterAll, beforeAll, describe, expect, it} from 'vitest'; -import {startDockerContainer} from '../test/DockerTestContainer'; -import {LegacyPostgresKvQueryExecutor} from './__testref__/LegacyPostgresKvQueryExecutor'; -import {defineTable} from './CassandraTableDsl'; -import type {CassandraParam, CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from './CassandraTypes'; -import {buildCandidatePlan, ensurePostgresKvSchema, PostgresKvQueryExecutor} from './PostgresKvQueryExecutor'; type Row = Record; type AnyMeta = KvQueryMeta; diff --git a/fluxer_api/src/api/database/PostgresKvPagingAdversarial.test.ts b/fluxer_api/src/api/database/PostgresKvPagingAdversarial.test.ts index 791215dfc..e924b8665 100644 --- a/fluxer_api/src/api/database/PostgresKvPagingAdversarial.test.ts +++ b/fluxer_api/src/api/database/PostgresKvPagingAdversarial.test.ts @@ -2,6 +2,10 @@ import {spawnSync} from 'node:child_process'; import {createServer} from 'node:net'; +import {LegacyPostgresKvQueryExecutor} from '@app/api/database/__testref__/LegacyPostgresKvQueryExecutor'; +import type {CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from '@app/api/database/CassandraTypes'; +import {ensurePostgresKvSchema, PostgresKvQueryExecutor} from '@app/api/database/PostgresKvQueryExecutor'; +import {startDockerContainer} from '@app/api/test/DockerTestContainer'; import { getDefaultPostgresClient, type IPostgresClient, @@ -10,10 +14,6 @@ import { shutdownPostgres, } from '@pkgs/postgres/src/Client'; import {afterAll, beforeAll, describe, expect, it} from 'vitest'; -import {startDockerContainer} from '../test/DockerTestContainer'; -import {LegacyPostgresKvQueryExecutor} from './__testref__/LegacyPostgresKvQueryExecutor'; -import type {CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from './CassandraTypes'; -import {ensurePostgresKvSchema, PostgresKvQueryExecutor} from './PostgresKvQueryExecutor'; type Row = Record; type AnyMeta = KvQueryMeta; diff --git a/fluxer_api/src/api/database/PostgresKvQueryDifferential.test.ts b/fluxer_api/src/api/database/PostgresKvQueryDifferential.test.ts index 60dbed0c9..542ff9abf 100644 --- a/fluxer_api/src/api/database/PostgresKvQueryDifferential.test.ts +++ b/fluxer_api/src/api/database/PostgresKvQueryDifferential.test.ts @@ -2,6 +2,22 @@ import {spawnSync} from 'node:child_process'; import {createServer} from 'node:net'; +import {LegacyPostgresKvQueryExecutor} from '@app/api/database/__testref__/LegacyPostgresKvQueryExecutor'; +import {defineTable} from '@app/api/database/CassandraTableDsl'; +import type { + CassandraParam, + CassandraParams, + KvQueryMeta, + KvTableSpec, + WhereExpr, +} from '@app/api/database/CassandraTypes'; +import { + buildCandidatePlan, + ensurePostgresKvSchema, + PostgresKvQueryExecutor, +} from '@app/api/database/PostgresKvQueryExecutor'; +import * as Tables from '@app/api/Tables'; +import {startDockerContainer} from '@app/api/test/DockerTestContainer'; import { getDefaultPostgresClient, type IPostgresClient, @@ -11,12 +27,6 @@ import { } from '@pkgs/postgres/src/Client'; import cassandra from 'cassandra-driver'; import {afterAll, beforeAll, describe, expect, it} from 'vitest'; -import * as Tables from '../Tables'; -import {startDockerContainer} from '../test/DockerTestContainer'; -import {LegacyPostgresKvQueryExecutor} from './__testref__/LegacyPostgresKvQueryExecutor'; -import {defineTable} from './CassandraTableDsl'; -import type {CassandraParam, CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from './CassandraTypes'; -import {buildCandidatePlan, ensurePostgresKvSchema, PostgresKvQueryExecutor} from './PostgresKvQueryExecutor'; type Row = Record; type AnyMeta = KvQueryMeta; diff --git a/fluxer_api/src/api/database/PostgresKvQueryExecutor.ts b/fluxer_api/src/api/database/PostgresKvQueryExecutor.ts index a6d68b38c..782eed68b 100644 --- a/fluxer_api/src/api/database/PostgresKvQueryExecutor.ts +++ b/fluxer_api/src/api/database/PostgresKvQueryExecutor.ts @@ -1,11 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getKvMeta, getTableMetadata} from '@app/api/database/CassandraMetaRegistry'; +import type { + CassandraParams, + ColumnName, + KvColumnParam, + KvQueryMeta, + PreparedQuery, + WhereExpr, +} from '@app/api/database/CassandraTypes'; +import {isConditionalQuery, validateTtlSeconds} from '@app/api/database/CassandraTypes'; +import {Logger} from '@app/api/Logger'; import {type IPostgresClient, type PostgresQueryable, quoteIdentifier} from '@pkgs/postgres/src/Client'; import cassandra from 'cassandra-driver'; -import {Logger} from '../Logger'; -import {getKvMeta, getTableMetadata} from './CassandraMetaRegistry'; -import type {CassandraParams, ColumnName, KvColumnParam, KvQueryMeta, PreparedQuery, WhereExpr} from './CassandraTypes'; -import {isConditionalQuery, validateTtlSeconds} from './CassandraTypes'; type Row = Record; type EqWhereExpr = Extract, {kind: 'eq'}>; diff --git a/fluxer_api/src/api/database/PostgresKvQueryPlan.test.ts b/fluxer_api/src/api/database/PostgresKvQueryPlan.test.ts index bcbb0b638..4baf3c4b2 100644 --- a/fluxer_api/src/api/database/PostgresKvQueryPlan.test.ts +++ b/fluxer_api/src/api/database/PostgresKvQueryPlan.test.ts @@ -2,17 +2,17 @@ import cassandra from 'cassandra-driver'; import {describe, expect, it} from 'vitest'; -import '../Tables'; -import {getTableMetadata} from './CassandraMetaRegistry'; -import {defineTable} from './CassandraTableDsl'; -import type {CassandraParams, PreparedQuery} from './CassandraTypes'; +import '@app/api/Tables'; +import {getTableMetadata} from '@app/api/database/CassandraMetaRegistry'; +import {defineTable} from '@app/api/database/CassandraTableDsl'; +import type {CassandraParams, PreparedQuery} from '@app/api/database/CassandraTypes'; import { buildCandidatePlan, type CandidatePlan, keyFromColumns, matchesWhere, POSTGRES_KV_MIGRATION_TABLE, -} from './PostgresKvQueryExecutor'; +} from '@app/api/database/PostgresKvQueryExecutor'; type Row = Record; diff --git a/fluxer_api/src/api/database/PostgresKvStatementNames.test.ts b/fluxer_api/src/api/database/PostgresKvStatementNames.test.ts index ab233836a..23f17c653 100644 --- a/fluxer_api/src/api/database/PostgresKvStatementNames.test.ts +++ b/fluxer_api/src/api/database/PostgresKvStatementNames.test.ts @@ -2,6 +2,9 @@ import {spawnSync} from 'node:child_process'; import {createServer} from 'node:net'; +import type {CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from '@app/api/database/CassandraTypes'; +import {ensurePostgresKvSchema, PostgresKvQueryExecutor} from '@app/api/database/PostgresKvQueryExecutor'; +import {startDockerContainer} from '@app/api/test/DockerTestContainer'; import { getDefaultPostgresClient, type IPostgresClient, @@ -9,9 +12,6 @@ import { shutdownPostgres, } from '@pkgs/postgres/src/Client'; import {afterAll, beforeAll, describe, expect, it} from 'vitest'; -import {startDockerContainer} from '../test/DockerTestContainer'; -import type {CassandraParams, KvQueryMeta, KvTableSpec, WhereExpr} from './CassandraTypes'; -import {ensurePostgresKvSchema, PostgresKvQueryExecutor} from './PostgresKvQueryExecutor'; type Row = Record; diff --git a/fluxer_api/src/api/database/PostgresKvUpgradeSafety.test.ts b/fluxer_api/src/api/database/PostgresKvUpgradeSafety.test.ts index d247b6e82..2bd7074b8 100644 --- a/fluxer_api/src/api/database/PostgresKvUpgradeSafety.test.ts +++ b/fluxer_api/src/api/database/PostgresKvUpgradeSafety.test.ts @@ -2,6 +2,17 @@ import {spawnSync} from 'node:child_process'; import {createServer} from 'node:net'; +import { + LegacyPostgresKvQueryExecutor, + legacyEnsurePostgresKvSchema, +} from '@app/api/database/__testref__/LegacyPostgresKvQueryExecutor'; +import { + ensurePostgresKvSchema, + POSTGRES_KV_MIGRATION_TABLE, + PostgresKvQueryExecutor, +} from '@app/api/database/PostgresKvQueryExecutor'; +import {GuildMembers, ReadStates, Users} from '@app/api/Tables'; +import {startDockerContainer} from '@app/api/test/DockerTestContainer'; import { getDefaultPostgresClient, type IPostgresClient, @@ -10,10 +21,6 @@ import { shutdownPostgres, } from '@pkgs/postgres/src/Client'; import {afterAll, beforeAll, describe, expect, it} from 'vitest'; -import {GuildMembers, ReadStates, Users} from '../Tables'; -import {startDockerContainer} from '../test/DockerTestContainer'; -import {LegacyPostgresKvQueryExecutor, legacyEnsurePostgresKvSchema} from './__testref__/LegacyPostgresKvQueryExecutor'; -import {ensurePostgresKvSchema, POSTGRES_KV_MIGRATION_TABLE, PostgresKvQueryExecutor} from './PostgresKvQueryExecutor'; type Row = Record; @@ -497,9 +504,9 @@ FROM generate_series($1::bigint, $1::bigint + 19999) u, generate_series(1, 3) s` }, 300_000); it('emits a multi-range plan that is not slower than the tier-3 scan it replaces', async () => { - const {PushSubscriptions} = await import('../Tables'); - const {buildCandidatePlan, planFragmentGroups} = await import('./PostgresKvQueryExecutor'); - const {getKvMeta} = await import('./CassandraMetaRegistry'); + const {PushSubscriptions} = await import('@app/api/Tables'); + const {buildCandidatePlan, planFragmentGroups} = await import('@app/api/database/PostgresKvQueryExecutor'); + const {getKvMeta} = await import('@app/api/database/CassandraMetaRegistry'); const db = getDefaultPostgresClient(); const explain = async (sql: string, params: Array) => { const r = await db.query>(`EXPLAIN (ANALYZE, BUFFERS) ${sql}`, params); @@ -552,9 +559,9 @@ FROM generate_series($1::bigint, $1::bigint + 19999) u, generate_series(1, 3) s` describe('candidate plan shapes reached by real queries', () => { it('classifies the push fan-out and webhook lookups', async () => { - const {PushSubscriptions, Webhooks} = await import('../Tables'); - const {buildCandidatePlan} = await import('./PostgresKvQueryExecutor'); - const {getKvMeta} = await import('./CassandraMetaRegistry'); + const {PushSubscriptions, Webhooks} = await import('@app/api/Tables'); + const {buildCandidatePlan} = await import('@app/api/database/PostgresKvQueryExecutor'); + const {getKvMeta} = await import('@app/api/database/CassandraMetaRegistry'); const cases = [ { name: 'push_subscriptions IN(user_id) x100', diff --git a/fluxer_api/src/api/database/__testref__/LegacyPostgresKvQueryExecutor.ts b/fluxer_api/src/api/database/__testref__/LegacyPostgresKvQueryExecutor.ts index 0b9c7ecff..cebc06b37 100644 --- a/fluxer_api/src/api/database/__testref__/LegacyPostgresKvQueryExecutor.ts +++ b/fluxer_api/src/api/database/__testref__/LegacyPostgresKvQueryExecutor.ts @@ -1,10 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getKvMeta, getTableMetadata} from '@app/api/database/CassandraMetaRegistry'; +import type { + CassandraParams, + ColumnName, + KvQueryMeta, + PreparedQuery, + WhereExpr, +} from '@app/api/database/CassandraTypes'; +import {matchesWhere} from '@app/api/database/PostgresKvQueryExecutor'; import {type IPostgresClient, type PostgresQueryable, quoteIdentifier} from '@pkgs/postgres/src/Client'; import cassandra from 'cassandra-driver'; -import {getKvMeta, getTableMetadata} from '../CassandraMetaRegistry'; -import type {CassandraParams, ColumnName, KvQueryMeta, PreparedQuery, WhereExpr} from '../CassandraTypes'; -import {matchesWhere} from '../PostgresKvQueryExecutor'; type Row = Record; type EqWhereExpr = Extract, {kind: 'eq'}>; diff --git a/fluxer_api/src/api/database/types/AdminAuthTypes.ts b/fluxer_api/src/api/database/types/AdminAuthTypes.ts index 157e3fbcd..752e5923d 100644 --- a/fluxer_api/src/api/database/types/AdminAuthTypes.ts +++ b/fluxer_api/src/api/database/types/AdminAuthTypes.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; +import type {UserID} from '@app/api/BrandedTypes'; type Nullish = T | null; diff --git a/fluxer_api/src/api/database/types/AuthTypes.ts b/fluxer_api/src/api/database/types/AuthTypes.ts index e43b9f99c..d8f212e7c 100644 --- a/fluxer_api/src/api/database/types/AuthTypes.ts +++ b/fluxer_api/src/api/database/types/AuthTypes.ts @@ -7,7 +7,7 @@ import type { MfaBackupCode, PasswordResetToken, UserID, -} from '../../BrandedTypes'; +} from '@app/api/BrandedTypes'; type Nullish = T | null; diff --git a/fluxer_api/src/api/database/types/ChannelTypes.ts b/fluxer_api/src/api/database/types/ChannelTypes.ts index a9ca83377..f668e72a9 100644 --- a/fluxer_api/src/api/database/types/ChannelTypes.ts +++ b/fluxer_api/src/api/database/types/ChannelTypes.ts @@ -9,7 +9,7 @@ import type { UserID, WebhookID, WebhookToken, -} from '../../BrandedTypes'; +} from '@app/api/BrandedTypes'; type Nullish = T | null; diff --git a/fluxer_api/src/api/database/types/ConnectionTypes.ts b/fluxer_api/src/api/database/types/ConnectionTypes.ts index 32b5dfd49..f7304aac3 100644 --- a/fluxer_api/src/api/database/types/ConnectionTypes.ts +++ b/fluxer_api/src/api/database/types/ConnectionTypes.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; import type {ConnectionType} from '@fluxer/constants/src/ConnectionConstants'; -import type {UserID} from '../../BrandedTypes'; export interface UserConnectionStorageRow { user_id: UserID; diff --git a/fluxer_api/src/api/database/types/GuildDiscoveryTypes.ts b/fluxer_api/src/api/database/types/GuildDiscoveryTypes.ts index ca01db825..1b8233ca7 100644 --- a/fluxer_api/src/api/database/types/GuildDiscoveryTypes.ts +++ b/fluxer_api/src/api/database/types/GuildDiscoveryTypes.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../BrandedTypes'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; type Nullish = T | null; diff --git a/fluxer_api/src/api/database/types/GuildTypes.ts b/fluxer_api/src/api/database/types/GuildTypes.ts index f92fb53d0..550cacafa 100644 --- a/fluxer_api/src/api/database/types/GuildTypes.ts +++ b/fluxer_api/src/api/database/types/GuildTypes.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; -import type {GuildSplashCardAlignmentValue} from '@fluxer/constants/src/GuildConstants'; -import type {MentionReplyPreference} from '@fluxer/constants/src/UserConstants'; import type { ChannelID, EmojiID, @@ -12,7 +9,10 @@ import type { StickerID, UserID, VanityURLCode, -} from '../../BrandedTypes'; +} from '@app/api/BrandedTypes'; +import type {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; +import type {GuildSplashCardAlignmentValue} from '@fluxer/constants/src/GuildConstants'; +import type {MentionReplyPreference} from '@fluxer/constants/src/UserConstants'; type Nullish = T | null; diff --git a/fluxer_api/src/api/database/types/MessageTypes.ts b/fluxer_api/src/api/database/types/MessageTypes.ts index 8162d43bc..f244d1abf 100644 --- a/fluxer_api/src/api/database/types/MessageTypes.ts +++ b/fluxer_api/src/api/database/types/MessageTypes.ts @@ -10,7 +10,7 @@ import type { StickerID, UserID, WebhookID, -} from '../../BrandedTypes'; +} from '@app/api/BrandedTypes'; type Nullish = T | null; diff --git a/fluxer_api/src/api/database/types/OAuth2Types.ts b/fluxer_api/src/api/database/types/OAuth2Types.ts index a01c0eb82..784c7d3db 100644 --- a/fluxer_api/src/api/database/types/OAuth2Types.ts +++ b/fluxer_api/src/api/database/types/OAuth2Types.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApplicationID, UserID} from '../../BrandedTypes'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; export interface ApplicationRow { application_id: ApplicationID; diff --git a/fluxer_api/src/api/database/types/PaymentTypes.ts b/fluxer_api/src/api/database/types/PaymentTypes.ts index 0096234ac..8fc1d820f 100644 --- a/fluxer_api/src/api/database/types/PaymentTypes.ts +++ b/fluxer_api/src/api/database/types/PaymentTypes.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; +import type {UserID} from '@app/api/BrandedTypes'; type Nullish = T | null; export type GiftCodeDurationType = 'days' | 'weeks' | 'months' | 'years'; diff --git a/fluxer_api/src/api/database/types/ReportTypes.ts b/fluxer_api/src/api/database/types/ReportTypes.ts index 6e3b941ef..b66d92657 100644 --- a/fluxer_api/src/api/database/types/ReportTypes.ts +++ b/fluxer_api/src/api/database/types/ReportTypes.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageAttachment, MessageEmbed, MessageStickerItem} from './MessageTypes'; +import type {MessageAttachment, MessageEmbed, MessageStickerItem} from '@app/api/database/types/MessageTypes'; type MentionCollection = ReadonlyArray | Set | null | undefined; diff --git a/fluxer_api/src/api/database/types/RiskTypes.ts b/fluxer_api/src/api/database/types/RiskTypes.ts index a88a40c66..22acdf809 100644 --- a/fluxer_api/src/api/database/types/RiskTypes.ts +++ b/fluxer_api/src/api/database/types/RiskTypes.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; +import type {UserID} from '@app/api/BrandedTypes'; export interface RegistrationEventByIpRow { ip: string; diff --git a/fluxer_api/src/api/database/types/UserTypes.ts b/fluxer_api/src/api/database/types/UserTypes.ts index 4cc0619bb..ef78562c7 100644 --- a/fluxer_api/src/api/database/types/UserTypes.ts +++ b/fluxer_api/src/api/database/types/UserTypes.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {LocaleCode} from '@fluxer/constants/src/Locales'; -import type {GuildFolderIcon, MentionReplyPreference} from '@fluxer/constants/src/UserConstants'; -import type {types} from 'cassandra-driver'; import type { AttachmentID, ChannelID, @@ -12,7 +9,10 @@ import type { MemeID, MessageID, UserID, -} from '../../BrandedTypes'; +} from '@app/api/BrandedTypes'; +import type {LocaleCode} from '@fluxer/constants/src/Locales'; +import type {GuildFolderIcon, MentionReplyPreference} from '@fluxer/constants/src/UserConstants'; +import type {types} from 'cassandra-driver'; type Nullish = T | null; export type PushSubscriptionPlatform = 'web_push' | 'android_fcm' | 'ios_apns' | 'android_unified_push'; diff --git a/fluxer_api/src/api/donation/DonationController.ts b/fluxer_api/src/api/donation/DonationController.ts index bfdfc40a2..fe09917d6 100644 --- a/fluxer_api/src/api/donation/DonationController.ts +++ b/fluxer_api/src/api/donation/DonationController.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {DonationRateLimitConfigs} from '@app/api/rate_limit_configs/DonationRateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import { DonationCheckoutRequest, DonationCheckoutResponse, DonationManageQuery, DonationRequestLinkRequest, } from '@fluxer/schema/src/domains/donation/DonationSchemas'; -import {Config} from '../Config'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {DonationRateLimitConfigs} from '../rate_limit_configs/DonationRateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; export function DonationController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/donation/DonationRepository.ts b/fluxer_api/src/api/donation/DonationRepository.ts index f68229429..b81b9b80b 100644 --- a/fluxer_api/src/api/donation/DonationRepository.ts +++ b/fluxer_api/src/api/donation/DonationRepository.ts @@ -1,25 +1,25 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne} from '../database/CassandraQueryExecution'; -import {Db, type PatchObject} from '../database/CassandraTypes'; -import {executeVersionedUpdate} from '../database/CassandraVersionedUpdate'; +import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {Db, type PatchObject} from '@app/api/database/CassandraTypes'; +import {executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; import type { DonorByStripeCustomerIdRow, DonorByStripeSubscriptionIdRow, DonorMagicLinkTokenByEmailRow, DonorMagicLinkTokenRow, DonorRow, -} from '../database/types/DonationTypes'; +} from '@app/api/database/types/DonationTypes'; import { DonorMagicLinkTokens, DonorMagicLinkTokensByEmail, Donors, DonorsByStripeCustomerId, DonorsByStripeSubscriptionId, -} from './DonationTables'; -import {IDonationRepository} from './IDonationRepository'; -import {Donor} from './models/Donor'; -import {DonorMagicLinkToken} from './models/DonorMagicLinkToken'; +} from '@app/api/donation/DonationTables'; +import {IDonationRepository} from '@app/api/donation/IDonationRepository'; +import {Donor} from '@app/api/donation/models/Donor'; +import {DonorMagicLinkToken} from '@app/api/donation/models/DonorMagicLinkToken'; const FETCH_DONOR_BY_EMAIL_QUERY = Donors.selectCql({ where: Donors.where.eq('email'), diff --git a/fluxer_api/src/api/donation/DonationService.ts b/fluxer_api/src/api/donation/DonationService.ts index 444232c7d..2d4312e73 100644 --- a/fluxer_api/src/api/donation/DonationService.ts +++ b/fluxer_api/src/api/donation/DonationService.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IDonationService} from '@app/api/donation/IDonationService'; +import type {DonationCheckoutService} from '@app/api/donation/services/DonationCheckoutService'; +import type {DonationMagicLinkService} from '@app/api/donation/services/DonationMagicLinkService'; import type {DonationCurrency} from '@fluxer/schema/src/domains/donation/DonationSchemas'; -import type {IDonationService} from './IDonationService'; -import type {DonationCheckoutService} from './services/DonationCheckoutService'; -import type {DonationMagicLinkService} from './services/DonationMagicLinkService'; export class DonationService implements IDonationService { constructor( diff --git a/fluxer_api/src/api/donation/DonationTables.ts b/fluxer_api/src/api/donation/DonationTables.ts index 074831481..d78bb61fa 100644 --- a/fluxer_api/src/api/donation/DonationTables.ts +++ b/fluxer_api/src/api/donation/DonationTables.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineTable} from '../database/CassandraTableDsl'; +import {defineTable} from '@app/api/database/CassandraTableDsl'; import { DONOR_BY_STRIPE_CUSTOMER_ID_COLUMNS, DONOR_BY_STRIPE_SUBSCRIPTION_ID_COLUMNS, @@ -12,7 +12,7 @@ import { type DonorMagicLinkTokenByEmailRow, type DonorMagicLinkTokenRow, type DonorRow, -} from '../database/types/DonationTypes'; +} from '@app/api/database/types/DonationTypes'; export const Donors = defineTable({ name: 'donors', diff --git a/fluxer_api/src/api/donation/IDonationRepository.ts b/fluxer_api/src/api/donation/IDonationRepository.ts index 4876f74a6..81c0b0087 100644 --- a/fluxer_api/src/api/donation/IDonationRepository.ts +++ b/fluxer_api/src/api/donation/IDonationRepository.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {Donor} from './models/Donor'; -import type {DonorMagicLinkToken} from './models/DonorMagicLinkToken'; +import type {Donor} from '@app/api/donation/models/Donor'; +import type {DonorMagicLinkToken} from '@app/api/donation/models/DonorMagicLinkToken'; export abstract class IDonationRepository { abstract findDonorByEmail(email: string): Promise; diff --git a/fluxer_api/src/api/donation/models/Donor.ts b/fluxer_api/src/api/donation/models/Donor.ts index c1e7dcd32..c1fd13368 100644 --- a/fluxer_api/src/api/donation/models/Donor.ts +++ b/fluxer_api/src/api/donation/models/Donor.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {nextVersion} from '../../database/CassandraTypes'; -import type {DonorRow} from '../../database/types/DonationTypes'; +import {nextVersion} from '@app/api/database/CassandraTypes'; +import type {DonorRow} from '@app/api/database/types/DonationTypes'; export class Donor { readonly email: string; diff --git a/fluxer_api/src/api/donation/models/DonorMagicLinkToken.ts b/fluxer_api/src/api/donation/models/DonorMagicLinkToken.ts index f32d1cdbd..5d61b51dc 100644 --- a/fluxer_api/src/api/donation/models/DonorMagicLinkToken.ts +++ b/fluxer_api/src/api/donation/models/DonorMagicLinkToken.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {DonorMagicLinkTokenRow} from '../../database/types/DonationTypes'; +import type {DonorMagicLinkTokenRow} from '@app/api/database/types/DonationTypes'; export class DonorMagicLinkToken { readonly token: string; diff --git a/fluxer_api/src/api/donation/services/DonationCheckoutService.ts b/fluxer_api/src/api/donation/services/DonationCheckoutService.ts index e323a9a1e..5c89faf84 100644 --- a/fluxer_api/src/api/donation/services/DonationCheckoutService.ts +++ b/fluxer_api/src/api/donation/services/DonationCheckoutService.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {IDonationRepository} from '@app/api/donation/IDonationRepository'; +import type {IEmailDnsValidationService} from '@app/api/infrastructure/IEmailDnsValidationService'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {DonationAmountInvalidError} from '@fluxer/errors/src/domains/donation/DonationAmountInvalidError'; @@ -8,11 +13,6 @@ import {StripePaymentNotAvailableError} from '@fluxer/errors/src/domains/payment import {isDonationAmountWithinConstraints} from '@fluxer/schema/src/domains/donation/DonationAmountUtils'; import type {DonationCurrency} from '@fluxer/schema/src/domains/donation/DonationSchemas'; import type Stripe from 'stripe'; -import {Config} from '../../Config'; -import type {IEmailDnsValidationService} from '../../infrastructure/IEmailDnsValidationService'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import type {IDonationRepository} from '../IDonationRepository'; type CheckoutSessionCreateParams = Stripe.Checkout.SessionCreateParams; type CheckoutSessionMode = CheckoutSessionCreateParams['mode']; diff --git a/fluxer_api/src/api/donation/services/DonationMagicLinkService.ts b/fluxer_api/src/api/donation/services/DonationMagicLinkService.ts index f0a52fd80..6bee6dab9 100644 --- a/fluxer_api/src/api/donation/services/DonationMagicLinkService.ts +++ b/fluxer_api/src/api/donation/services/DonationMagicLinkService.ts @@ -1,6 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomBytes} from 'node:crypto'; +import {Config} from '@app/api/Config'; +import type {IDonationRepository} from '@app/api/donation/IDonationRepository'; +import {DonorMagicLinkToken} from '@app/api/donation/models/DonorMagicLinkToken'; +import type {IEmailDnsValidationService} from '@app/api/infrastructure/IEmailDnsValidationService'; +import {Logger} from '@app/api/Logger'; import {DONATION_MAGIC_LINK_EXPIRY_MS} from '@fluxer/constants/src/DonationConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; @@ -8,11 +13,6 @@ import {DonationMagicLinkExpiredError} from '@fluxer/errors/src/domains/donation import {DonationMagicLinkInvalidError} from '@fluxer/errors/src/domains/donation/DonationMagicLinkInvalidError'; import {DonationMagicLinkUsedError} from '@fluxer/errors/src/domains/donation/DonationMagicLinkUsedError'; import type {IEmailService} from '@pkgs/email/src/IEmailService'; -import {Config} from '../../Config'; -import type {IEmailDnsValidationService} from '../../infrastructure/IEmailDnsValidationService'; -import {Logger} from '../../Logger'; -import type {IDonationRepository} from '../IDonationRepository'; -import {DonorMagicLinkToken} from '../models/DonorMagicLinkToken'; export class DonationMagicLinkService { constructor( diff --git a/fluxer_api/src/api/donation/tests/DonationCheckout.test.ts b/fluxer_api/src/api/donation/tests/DonationCheckout.test.ts index 0d3e74d33..0bb3b0be2 100644 --- a/fluxer_api/src/api/donation/tests/DonationCheckout.test.ts +++ b/fluxer_api/src/api/donation/tests/DonationCheckout.test.ts @@ -1,11 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {getDonationAmountConstraints} from '@fluxer/schema/src/domains/donation/DonationAmountUtils'; -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createStripeApiHandlers, type StripeApiHandlers} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; import { createDonationCheckoutBuilder, createValidCheckoutBody, @@ -13,7 +7,13 @@ import { DONATION_CURRENCY_VALUES, DONATION_INTERVALS, TEST_DONOR_EMAIL, -} from './DonationTestUtils'; +} from '@app/api/donation/tests/DonationTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createStripeApiHandlers, type StripeApiHandlers} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {getDonationAmountConstraints} from '@fluxer/schema/src/domains/donation/DonationAmountUtils'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; describe('POST /donations/checkout', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/donation/tests/DonationManage.test.ts b/fluxer_api/src/api/donation/tests/DonationManage.test.ts index 8ccc94011..dbb279105 100644 --- a/fluxer_api/src/api/donation/tests/DonationManage.test.ts +++ b/fluxer_api/src/api/donation/tests/DonationManage.test.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createPwnedPasswordsRangeHandler} from '../../test/msw/handlers/PwnedPasswordsHandlers'; -import {createStripeApiHandlers, type StripeApiHandlers} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {DonationRepository} from '../DonationRepository'; -import {DonorMagicLinkToken} from '../models/DonorMagicLinkToken'; +import {Config} from '@app/api/Config'; +import {DonationRepository} from '@app/api/donation/DonationRepository'; +import {DonorMagicLinkToken} from '@app/api/donation/models/DonorMagicLinkToken'; import { createDonationManageBuilder, TEST_DONOR_EMAIL, TEST_INVALID_TOKEN, TEST_MAGIC_LINK_TOKEN, -} from './DonationTestUtils'; +} from '@app/api/donation/tests/DonationTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createPwnedPasswordsRangeHandler} from '@app/api/test/msw/handlers/PwnedPasswordsHandlers'; +import {createStripeApiHandlers, type StripeApiHandlers} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; describe('GET /donations/manage', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/donation/tests/DonationRequestLink.test.ts b/fluxer_api/src/api/donation/tests/DonationRequestLink.test.ts index 89268c14e..fb04d9d47 100644 --- a/fluxer_api/src/api/donation/tests/DonationRequestLink.test.ts +++ b/fluxer_api/src/api/donation/tests/DonationRequestLink.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {DonationRepository} from '../DonationRepository'; +import {Config} from '@app/api/Config'; +import {DonationRepository} from '@app/api/donation/DonationRepository'; import { clearDonationTestEmails, createDonationRequestLinkBuilder, createUniqueEmail, listDonationTestEmails, TEST_DONOR_EMAIL, -} from './DonationTestUtils'; +} from '@app/api/donation/tests/DonationTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; describe('POST /donations/request-link', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/donation/tests/DonationTestUtils.ts b/fluxer_api/src/api/donation/tests/DonationTestUtils.ts index 77aaa8e12..3791a5cb7 100644 --- a/fluxer_api/src/api/donation/tests/DonationTestUtils.ts +++ b/fluxer_api/src/api/donation/tests/DonationTestUtils.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth, type TestRequestBuilder} from '@app/api/test/TestRequestBuilder'; import { DONATION_CURRENCIES, type DonationCurrency, getDonationAmountConstraints, } from '@fluxer/schema/src/domains/donation/DonationAmountUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth, type TestRequestBuilder} from '../../test/TestRequestBuilder'; interface DonationTestEmailRecord { to: string; diff --git a/fluxer_api/src/api/download/DesktopReleaseContract.ts b/fluxer_api/src/api/download/DesktopReleaseContract.ts index bf32f7d54..84e9b15e5 100644 --- a/fluxer_api/src/api/download/DesktopReleaseContract.ts +++ b/fluxer_api/src/api/download/DesktopReleaseContract.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; import type {DesktopArch, DesktopChannel, DesktopPlatform} from '@fluxer/schema/src/domains/download/DownloadSchemas'; -import {isJsonRecord} from '../utils/JsonBoundaryUtils'; const DESKTOP_BUCKET_PREFIX = 'desktop'; const MIN_RELEASE_ROUTE_COUNT = 28; diff --git a/fluxer_api/src/api/download/DownloadController.ts b/fluxer_api/src/api/download/DownloadController.ts index ed724d5fc..6e310ae12 100644 --- a/fluxer_api/src/api/download/DownloadController.ts +++ b/fluxer_api/src/api/download/DownloadController.ts @@ -1,6 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {Readable} from 'node:stream'; +import {Config} from '@app/api/Config'; +import {resolveArtifactRoute} from '@app/api/download/DownloadRouting'; +import type {DesktopChecksumFile, DownloadService, DownloadStreamResult} from '@app/api/download/DownloadService'; +import { + DESKTOP_REDIRECT_PREFIX, + DOWNLOAD_PREFIX, + downloadCacheControlForKey, + UnsatisfiableRangeError, +} from '@app/api/download/DownloadService'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import { DesktopChecksumRedirectParam, DesktopRedirectParam, @@ -15,18 +27,6 @@ import { VersionInfoResponse, } from '@fluxer/schema/src/domains/download/DownloadSchemas'; import type {Context, Hono} from 'hono'; -import {Config} from '../Config'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import type {HonoEnv} from '../types/HonoEnv'; -import {Validator} from '../Validator'; -import {resolveArtifactRoute} from './DownloadRouting'; -import type {DesktopChecksumFile, DownloadService, DownloadStreamResult} from './DownloadService'; -import { - DESKTOP_REDIRECT_PREFIX, - DOWNLOAD_PREFIX, - downloadCacheControlForKey, - UnsatisfiableRangeError, -} from './DownloadService'; function artifactFilename(key: string, filenameOverride?: string): string { return filenameOverride ?? key.split('/').pop() ?? 'download'; diff --git a/fluxer_api/src/api/download/DownloadRouting.ts b/fluxer_api/src/api/download/DownloadRouting.ts index e2e933c55..447e17b82 100644 --- a/fluxer_api/src/api/download/DownloadRouting.ts +++ b/fluxer_api/src/api/download/DownloadRouting.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import {lookupGeoip} from '../utils/IpUtils'; -import {parseDesktopArtifactScope} from './DesktopReleaseContract'; -import type {DownloadService, GitHubDesktopReleaseResolution} from './DownloadService'; +import {Config} from '@app/api/Config'; +import {parseDesktopArtifactScope} from '@app/api/download/DesktopReleaseContract'; +import type {DownloadService, GitHubDesktopReleaseResolution} from '@app/api/download/DownloadService'; +import {Logger} from '@app/api/Logger'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; const COUNTRY_DEPENDENT_CACHE_CONTROL = 'private, no-store'; diff --git a/fluxer_api/src/api/download/DownloadService.ts b/fluxer_api/src/api/download/DownloadService.ts index 05a285bfb..83d9f9ae0 100644 --- a/fluxer_api/src/api/download/DownloadService.ts +++ b/fluxer_api/src/api/download/DownloadService.ts @@ -3,6 +3,19 @@ import {createHash} from 'node:crypto'; import {posix} from 'node:path'; import {Readable} from 'node:stream'; +import {Config} from '@app/api/Config'; +import { + parseDesktopArtifactScope, + parseDesktopReleaseDescriptor, + parseDesktopReleaseReadiness, +} from '@app/api/download/DesktopReleaseContract'; +import { + type IStorageService, + StorageObjectListingOverflowError, + StorageObjectRangeNotSatisfiableError, +} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import {isJsonRecord, parseJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; import {S3ServiceException} from '@aws-sdk/client-s3'; import type { DesktopArch, @@ -10,19 +23,6 @@ import type { DesktopFormat, DesktopPlatform, } from '@fluxer/schema/src/domains/download/DownloadSchemas'; -import {Config} from '../Config'; -import { - type IStorageService, - StorageObjectListingOverflowError, - StorageObjectRangeNotSatisfiableError, -} from '../infrastructure/IStorageService'; -import {Logger} from '../Logger'; -import {isJsonRecord, parseJsonRecord} from '../utils/JsonBoundaryUtils'; -import { - parseDesktopArtifactScope, - parseDesktopReleaseDescriptor, - parseDesktopReleaseReadiness, -} from './DesktopReleaseContract'; export const DOWNLOAD_PREFIX = '/dl'; export const DESKTOP_REDIRECT_PREFIX = `${DOWNLOAD_PREFIX}/desktop`; diff --git a/fluxer_api/src/api/download/tests/DownloadPresign.test.ts b/fluxer_api/src/api/download/tests/DownloadPresign.test.ts index 3beea35fe..ef93e3775 100644 --- a/fluxer_api/src/api/download/tests/DownloadPresign.test.ts +++ b/fluxer_api/src/api/download/tests/DownloadPresign.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {DownloadService} from '@app/api/download/DownloadService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; import {describe, expect, it} from 'vitest'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {DownloadService} from '../DownloadService'; const OBJECT_METADATA = { contentLength: 285_567_850, diff --git a/fluxer_api/src/api/download/tests/DownloadService.manifest.test.ts b/fluxer_api/src/api/download/tests/DownloadService.manifest.test.ts index 0956c0fc2..69e8d8bee 100644 --- a/fluxer_api/src/api/download/tests/DownloadService.manifest.test.ts +++ b/fluxer_api/src/api/download/tests/DownloadService.manifest.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {Readable} from 'node:stream'; +import {DownloadService} from '@app/api/download/DownloadService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; import {describe, expect, it} from 'vitest'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {DownloadService} from '../DownloadService'; const PREFIX = 'desktop/stable/darwin/x64'; const MANIFEST_KEY = `${PREFIX}/manifest.json`; diff --git a/fluxer_api/src/api/download/tests/DownloadService.release.test.ts b/fluxer_api/src/api/download/tests/DownloadService.release.test.ts index 81fcc52ba..1cab57027 100644 --- a/fluxer_api/src/api/download/tests/DownloadService.release.test.ts +++ b/fluxer_api/src/api/download/tests/DownloadService.release.test.ts @@ -2,11 +2,11 @@ import {createHash} from 'node:crypto'; import {Readable} from 'node:stream'; +import {getConfig} from '@app/api/Config'; +import {DownloadService} from '@app/api/download/DownloadService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; import {S3ServiceException} from '@aws-sdk/client-s3'; import {describe, expect, it} from 'vitest'; -import {getConfig} from '../../Config'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {DownloadService} from '../DownloadService'; const PREFIX = 'desktop/canary/linux/x64'; const TEST_PREFIX = 'desktop-test/canary/linux/x64'; diff --git a/fluxer_api/src/api/download/tests/DownloadService.versions.test.ts b/fluxer_api/src/api/download/tests/DownloadService.versions.test.ts index 0dd43f731..5017a483f 100644 --- a/fluxer_api/src/api/download/tests/DownloadService.versions.test.ts +++ b/fluxer_api/src/api/download/tests/DownloadService.versions.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {Readable} from 'node:stream'; +import {DownloadService} from '@app/api/download/DownloadService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; import {describe, expect, it} from 'vitest'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {DownloadService} from '../DownloadService'; const PREFIX = 'desktop/canary/linux/x64'; const BASE_URL = 'https://api.example.test'; diff --git a/fluxer_api/src/api/download/tests/DownloadServiceBaseUrl.test.ts b/fluxer_api/src/api/download/tests/DownloadServiceBaseUrl.test.ts index 1a746f133..d3ff8e0e6 100644 --- a/fluxer_api/src/api/download/tests/DownloadServiceBaseUrl.test.ts +++ b/fluxer_api/src/api/download/tests/DownloadServiceBaseUrl.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {Readable} from 'node:stream'; +import {Config} from '@app/api/Config'; +import {DownloadService} from '@app/api/download/DownloadService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; import {describe, expect, it} from 'vitest'; -import {Config} from '../../Config'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {DownloadService} from '../DownloadService'; const PREFIX = 'desktop/stable/darwin/x64'; const MANIFEST_KEY = `${PREFIX}/manifest.json`; diff --git a/fluxer_api/src/api/email/EmailProviderFactory.ts b/fluxer_api/src/api/email/EmailProviderFactory.ts index af44f6398..cf648b408 100644 --- a/fluxer_api/src/api/email/EmailProviderFactory.ts +++ b/fluxer_api/src/api/email/EmailProviderFactory.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {APIConfig} from '@app/api/config/APIConfig'; import type {IEmailProvider} from '@pkgs/email/src/EmailProviderTypes'; import {SmtpEmailProvider} from '@pkgs/email/src/SmtpEmailProvider'; -import type {APIConfig} from '../config/APIConfig'; export function createEmailProvider(emailConfig: APIConfig['email']): IEmailProvider | null { if (!emailConfig.enabled) { diff --git a/fluxer_api/src/api/emoji/tests/EmojiTestUtils.ts b/fluxer_api/src/api/emoji/tests/EmojiTestUtils.ts index c90bb541a..5390bfd4d 100644 --- a/fluxer_api/src/api/emoji/tests/EmojiTestUtils.ts +++ b/fluxer_api/src/api/emoji/tests/EmojiTestUtils.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {GuildEmojiWithUserResponse} from '@fluxer/schema/src/domains/guild/GuildEmojiSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; export const VALID_PNG_BASE64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='; export const VALID_GIF_BASE64 = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; diff --git a/fluxer_api/src/api/experiment/ExperimentController.ts b/fluxer_api/src/api/experiment/ExperimentController.ts index 1dfa77573..5b91668cb 100644 --- a/fluxer_api/src/api/experiment/ExperimentController.ts +++ b/fluxer_api/src/api/experiment/ExperimentController.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {entityTagMatches} from '@app/api/utils/EntityTag'; import {Headers as HttpHeaders} from '@fluxer/constants/src/Headers'; import {resolveVoiceNoiseSuppressionAssignment} from '@fluxer/schema/src/domains/admin/VoiceNoiseSuppressionSchemas'; import {ExperimentAssignmentsResponse} from '@fluxer/schema/src/domains/experiment/ExperimentSchemas'; -import {LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {entityTagMatches} from '../utils/EntityTag'; export function ExperimentController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/experiment/tests/ExperimentController.test.ts b/fluxer_api/src/api/experiment/tests/ExperimentController.test.ts index 24cbd9b20..b8b5d8a48 100644 --- a/fluxer_api/src/api/experiment/tests/ExperimentController.test.ts +++ b/fluxer_api/src/api/experiment/tests/ExperimentController.test.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import { DEFAULT_VOICE_NOISE_SUPPRESSION_CONFIG, @@ -13,11 +18,6 @@ import { readVoiceNoiseSuppressionAssignment, } from '@fluxer/schema/src/domains/experiment/ExperimentSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {getInstanceConfigRepository} from '../../middleware/ServiceSingletons'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; const NOT_MODIFIED = 304; const ENDPOINT = '/experiments'; diff --git a/fluxer_api/src/api/favorite_gif/FavoriteGifController.ts b/fluxer_api/src/api/favorite_gif/FavoriteGifController.ts index 2ae2cdfc7..c4e54a5a5 100644 --- a/fluxer_api/src/api/favorite_gif/FavoriteGifController.ts +++ b/fluxer_api/src/api/favorite_gif/FavoriteGifController.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {resolveFavoriteGifEntry} from '@app/api/favorite_gif/FavoriteGifResolver'; +import {resolveGifRequestCountry} from '@app/api/gif/GifRequestCountry'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {getUnfurlerService} from '@app/api/middleware/ServiceSingletons'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp, HonoEnv} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {ResolveGifUrlsBodySchema, ResolveGifUrlsResponse} from '@fluxer/schema/src/domains/gif/FavoriteGifSchemas'; import type {Context} from 'hono'; -import {resolveGifRequestCountry} from '../gif/GifRequestCountry'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {getUnfurlerService} from '../middleware/ServiceSingletons'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp, HonoEnv} from '../types/HonoEnv'; -import {Validator} from '../Validator'; -import {resolveFavoriteGifEntry} from './FavoriteGifResolver'; async function getCountry(ctx: Context): Promise { return resolveGifRequestCountry(ctx.req.raw); diff --git a/fluxer_api/src/api/favorite_gif/FavoriteGifResolver.test.ts b/fluxer_api/src/api/favorite_gif/FavoriteGifResolver.test.ts index 1b2a92f6e..ad2fe4102 100644 --- a/fluxer_api/src/api/favorite_gif/FavoriteGifResolver.test.ts +++ b/fluxer_api/src/api/favorite_gif/FavoriteGifResolver.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {resolveFavoriteGifEntry} from '@app/api/favorite_gif/FavoriteGifResolver'; +import {GifService} from '@app/api/gif/GifService'; +import type {IGifProvider} from '@app/api/gif/IGifProvider'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {IUnfurlerService} from '@app/api/infrastructure/IUnfurlerService'; import {BadGatewayError} from '@fluxer/errors/src/domains/core/BadGatewayError'; import type {GifResponse} from '@fluxer/schema/src/domains/gif/GifSchemas'; import {describe, expect, it, vi} from 'vitest'; -import {GifService} from '../gif/GifService'; -import type {IGifProvider} from '../gif/IGifProvider'; -import type {IMediaService} from '../infrastructure/IMediaService'; -import type {IUnfurlerService} from '../infrastructure/IUnfurlerService'; -import {resolveFavoriteGifEntry} from './FavoriteGifResolver'; function createProvider(gif: GifResponse, slug: string | null = gif.slug): IGifProvider { return { diff --git a/fluxer_api/src/api/favorite_gif/FavoriteGifResolver.ts b/fluxer_api/src/api/favorite_gif/FavoriteGifResolver.ts index 6f4027731..e74c06611 100644 --- a/fluxer_api/src/api/favorite_gif/FavoriteGifResolver.ts +++ b/fluxer_api/src/api/favorite_gif/FavoriteGifResolver.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {tryExtractGifProviderSlug} from '@app/api/gif/GifProviderUtils'; +import type {GifService} from '@app/api/gif/GifService'; +import type {IGifProvider} from '@app/api/gif/IGifProvider'; +import type {IMediaService, MediaProxyMetadataResponse} from '@app/api/infrastructure/IMediaService'; +import type {IUnfurlerService} from '@app/api/infrastructure/IUnfurlerService'; import {Logger} from '@fluxer/logger/src/Logger'; import type {ResolvedGifEntrySchema} from '@fluxer/schema/src/domains/gif/FavoriteGifSchemas'; import {inferFormatContentType, PREVIEW_FORMAT_PRIORITY} from '@fluxer/schema/src/domains/gif/GifMediaFormatKeys'; import type {GifMediaFormat, GifResponse} from '@fluxer/schema/src/domains/gif/GifSchemas'; import type {EmbedMediaResponse, MessageEmbedResponse} from '@fluxer/schema/src/domains/message/EmbedSchemas'; -import {tryExtractGifProviderSlug} from '../gif/GifProviderUtils'; -import type {GifService} from '../gif/GifService'; -import type {IGifProvider} from '../gif/IGifProvider'; -import type {IMediaService, MediaProxyMetadataResponse} from '../infrastructure/IMediaService'; -import type {IUnfurlerService} from '../infrastructure/IUnfurlerService'; const logger = new Logger('FavoriteGifResolver'); diff --git a/fluxer_api/src/api/favorite_meme/FavoriteMemeController.ts b/fluxer_api/src/api/favorite_meme/FavoriteMemeController.ts index 272bc6649..e3ba1e6c1 100644 --- a/fluxer_api/src/api/favorite_meme/FavoriteMemeController.ts +++ b/fluxer_api/src/api/favorite_meme/FavoriteMemeController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createMemeID, createMessageID} from '@app/api/BrandedTypes'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {ChannelIdMessageIdParam, MemeIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import { CreateFavoriteMemeBodySchema, @@ -8,13 +15,6 @@ import { FavoriteMemeResponse, UpdateFavoriteMemeBodySchema, } from '@fluxer/schema/src/domains/meme/MemeSchemas'; -import {createChannelID, createMemeID, createMessageID} from '../BrandedTypes'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; export function FavoriteMemeController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/favorite_meme/FavoriteMemeModel.ts b/fluxer_api/src/api/favorite_meme/FavoriteMemeModel.ts index 3850a0918..306efdf4f 100644 --- a/fluxer_api/src/api/favorite_meme/FavoriteMemeModel.ts +++ b/fluxer_api/src/api/favorite_meme/FavoriteMemeModel.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {userIdToChannelId} from '@app/api/BrandedTypes'; +import {makeAttachmentCdnUrl} from '@app/api/channel/services/message/MessageHelpers'; +import type {FavoriteMeme} from '@app/api/models/FavoriteMeme'; +import {assertSafeByteSize} from '@app/api/utils/ByteSizeUtils'; import type {FavoriteMemeResponse} from '@fluxer/schema/src/domains/meme/MemeSchemas'; -import {userIdToChannelId} from '../BrandedTypes'; -import {makeAttachmentCdnUrl} from '../channel/services/message/MessageHelpers'; -import type {FavoriteMeme} from '../models/FavoriteMeme'; -import {assertSafeByteSize} from '../utils/ByteSizeUtils'; export function mapFavoriteMemeToResponse(meme: FavoriteMeme): FavoriteMemeResponse { const url = makeAttachmentCdnUrl(userIdToChannelId(meme.userId), meme.attachmentId, meme.filename); diff --git a/fluxer_api/src/api/favorite_meme/FavoriteMemeRepository.ts b/fluxer_api/src/api/favorite_meme/FavoriteMemeRepository.ts index ad168784c..9665fd067 100644 --- a/fluxer_api/src/api/favorite_meme/FavoriteMemeRepository.ts +++ b/fluxer_api/src/api/favorite_meme/FavoriteMemeRepository.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MemeID, UserID} from '../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '../database/CassandraQueryExecution'; -import {Db} from '../database/CassandraTypes'; -import type {FavoriteMemeRow} from '../database/types/UserTypes'; -import {FavoriteMeme} from '../models/FavoriteMeme'; -import {FavoriteMemes, FavoriteMemesByMemeId} from '../Tables'; -import {type CreateFavoriteMemeParams, IFavoriteMemeRepository} from './IFavoriteMemeRepository'; +import type {MemeID, UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {FavoriteMemeRow} from '@app/api/database/types/UserTypes'; +import {type CreateFavoriteMemeParams, IFavoriteMemeRepository} from '@app/api/favorite_meme/IFavoriteMemeRepository'; +import {FavoriteMeme} from '@app/api/models/FavoriteMeme'; +import {FavoriteMemes, FavoriteMemesByMemeId} from '@app/api/Tables'; const FETCH_FAVORITE_MEME_CQL = FavoriteMemes.selectCql({ where: [FavoriteMemes.where.eq('user_id'), FavoriteMemes.where.eq('meme_id')], diff --git a/fluxer_api/src/api/favorite_meme/FavoriteMemeRequestService.ts b/fluxer_api/src/api/favorite_meme/FavoriteMemeRequestService.ts index a66e38f69..ab4b5b652 100644 --- a/fluxer_api/src/api/favorite_meme/FavoriteMemeRequestService.ts +++ b/fluxer_api/src/api/favorite_meme/FavoriteMemeRequestService.ts @@ -1,5 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MemeID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {mapFavoriteMemeToResponse} from '@app/api/favorite_meme/FavoriteMemeModel'; +import type {FavoriteMemeService} from '@app/api/favorite_meme/FavoriteMemeService'; +import type {User} from '@app/api/models/User'; import {UnknownFavoriteMemeError} from '@fluxer/errors/src/domains/core/UnknownFavoriteMemeError'; import type { CreateFavoriteMemeBodySchema, @@ -8,10 +12,6 @@ import type { FavoriteMemeResponse, UpdateFavoriteMemeBodySchema, } from '@fluxer/schema/src/domains/meme/MemeSchemas'; -import type {ChannelID, MemeID, MessageID, UserID} from '../BrandedTypes'; -import type {User} from '../models/User'; -import {mapFavoriteMemeToResponse} from './FavoriteMemeModel'; -import type {FavoriteMemeService} from './FavoriteMemeService'; interface FavoriteMemeListParams { userId: UserID; diff --git a/fluxer_api/src/api/favorite_meme/FavoriteMemeService.ts b/fluxer_api/src/api/favorite_meme/FavoriteMemeService.ts index fb7fbd87b..ce646688a 100644 --- a/fluxer_api/src/api/favorite_meme/FavoriteMemeService.ts +++ b/fluxer_api/src/api/favorite_meme/FavoriteMemeService.ts @@ -1,5 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {ChannelID, MemeID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {createAttachmentID, createMemeID, userIdToChannelId} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import {makeAttachmentCdnKey, makeAttachmentCdnUrl} from '@app/api/channel/services/message/MessageHelpers'; +import {mapFavoriteMemeToResponse} from '@app/api/favorite_meme/FavoriteMemeModel'; +import type {IFavoriteMemeRepository} from '@app/api/favorite_meme/IFavoriteMemeRepository'; +import { + isOptionalGifProviderError, + type ResolvedGifProviderSlug, + tryExtractGifProviderSlug, +} from '@app/api/gif/GifProviderUtils'; +import type {GifService} from '@app/api/gif/GifService'; +import type {MediaProxyMetadataResponse} from '@app/api/infrastructure/IMediaService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {IUnfurlerService} from '@app/api/infrastructure/IUnfurlerService'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {FavoriteMeme} from '@app/api/models/FavoriteMeme'; +import type {Message} from '@app/api/models/Message'; +import type {User} from '@app/api/models/User'; import {EmbedMediaFlags, MessageAttachmentFlags} from '@fluxer/constants/src/ChannelConstants'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; import {MAX_FAVORITE_MEME_TAGS, MAX_FAVORITE_MEMES_NON_PREMIUM} from '@fluxer/constants/src/LimitConstants'; @@ -12,30 +36,6 @@ import {UnknownFavoriteMemeError} from '@fluxer/errors/src/domains/core/UnknownF import type {GifMediaFormat} from '@fluxer/schema/src/domains/gif/GifSchemas'; import {normalizeFilename} from '@fluxer/schema/src/primitives/FileValidators'; import mime from 'mime'; -import type {ApiContext} from '../ApiContext'; -import type {ChannelID, MemeID, MessageID, UserID} from '../BrandedTypes'; -import {createAttachmentID, createMemeID, userIdToChannelId} from '../BrandedTypes'; -import {Config} from '../Config'; -import type {ChannelService} from '../channel/services/ChannelService'; -import {makeAttachmentCdnKey, makeAttachmentCdnUrl} from '../channel/services/message/MessageHelpers'; -import { - isOptionalGifProviderError, - type ResolvedGifProviderSlug, - tryExtractGifProviderSlug, -} from '../gif/GifProviderUtils'; -import type {GifService} from '../gif/GifService'; -import type {MediaProxyMetadataResponse} from '../infrastructure/IMediaService'; -import type {IStorageService} from '../infrastructure/IStorageService'; -import type {IUnfurlerService} from '../infrastructure/IUnfurlerService'; -import {Logger} from '../Logger'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import {resolveLimitSafe} from '../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; -import type {FavoriteMeme} from '../models/FavoriteMeme'; -import type {Message} from '../models/Message'; -import type {User} from '../models/User'; -import {mapFavoriteMemeToResponse} from './FavoriteMemeModel'; -import type {IFavoriteMemeRepository} from './IFavoriteMemeRepository'; type MessageAttachmentCandidate = Message['attachments'][number]; type MessageEmbedCandidate = Message['embeds'][number]; diff --git a/fluxer_api/src/api/favorite_meme/IFavoriteMemeRepository.ts b/fluxer_api/src/api/favorite_meme/IFavoriteMemeRepository.ts index 209fe8d47..404203c2f 100644 --- a/fluxer_api/src/api/favorite_meme/IFavoriteMemeRepository.ts +++ b/fluxer_api/src/api/favorite_meme/IFavoriteMemeRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AttachmentID, MemeID, UserID} from '@app/api/BrandedTypes'; +import type {FavoriteMeme} from '@app/api/models/FavoriteMeme'; import type {GifMediaFormat} from '@fluxer/schema/src/domains/gif/GifSchemas'; -import type {AttachmentID, MemeID, UserID} from '../BrandedTypes'; -import type {FavoriteMeme} from '../models/FavoriteMeme'; export interface CreateFavoriteMemeParams { user_id: UserID; diff --git a/fluxer_api/src/api/favorite_meme/tests/FavoriteMemeExtended.test.ts b/fluxer_api/src/api/favorite_meme/tests/FavoriteMemeExtended.test.ts index 90e89f37a..96592b403 100644 --- a/fluxer_api/src/api/favorite_meme/tests/FavoriteMemeExtended.test.ts +++ b/fluxer_api/src/api/favorite_meme/tests/FavoriteMemeExtended.test.ts @@ -1,17 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {FavoriteMemeResponse} from '@fluxer/schema/src/domains/meme/MemeSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; import { createChannel, createTestAccountForAttachmentTests, loadFixture, sendMessageWithAttachments, setupTestGuildAndChannel, -} from '../../channel/tests/AttachmentTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; +} from '@app/api/channel/tests/AttachmentTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import { createFavoriteMemeFromMessage, createFavoriteMemeFromUrl, @@ -20,7 +18,9 @@ import { getFavoriteMeme, listFavoriteMemes, updateFavoriteMeme, -} from '../../user/tests/FavoriteMemeTestUtils'; +} from '@app/api/user/tests/FavoriteMemeTestUtils'; +import type {FavoriteMemeResponse} from '@fluxer/schema/src/domains/meme/MemeSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; const TEST_IMAGE_URL = 'https://picsum.photos/id/1/100'; diff --git a/fluxer_api/src/api/gateway/GatewayController.ts b/fluxer_api/src/api/gateway/GatewayController.ts index d7e274123..69a5e8d3f 100644 --- a/fluxer_api/src/api/gateway/GatewayController.ts +++ b/fluxer_api/src/api/gateway/GatewayController.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; import {GatewayBotResponse} from '@fluxer/schema/src/domains/gateway/GatewaySchemas'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; export function GatewayController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/gateway/GatewayRequestService.ts b/fluxer_api/src/api/gateway/GatewayRequestService.ts index 1fe4d3db4..2699eade7 100644 --- a/fluxer_api/src/api/gateway/GatewayRequestService.ts +++ b/fluxer_api/src/api/gateway/GatewayRequestService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {BotAuthService} from '@app/api/oauth/BotAuthService'; import {InvalidGatewayAuthTokenError} from '@fluxer/errors/src/domains/auth/InvalidGatewayAuthTokenError'; import {MissingGatewayAuthorizationError} from '@fluxer/errors/src/domains/auth/MissingGatewayAuthorizationError'; import type {GatewayBotResponse as GatewayBotResponseType} from '@fluxer/schema/src/domains/gateway/GatewaySchemas'; -import {Config} from '../Config'; -import type {BotAuthService} from '../oauth/BotAuthService'; type TokenType = 'user' | 'bot' | 'unknown'; diff --git a/fluxer_api/src/api/geolocation/GeolocationController.ts b/fluxer_api/src/api/geolocation/GeolocationController.ts index 652293e96..9532541df 100644 --- a/fluxer_api/src/api/geolocation/GeolocationController.ts +++ b/fluxer_api/src/api/geolocation/GeolocationController.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {GeolocationResponse} from '@fluxer/schema/src/domains/geolocation/GeolocationSchemas'; import {resolveClientGeoip} from '@pkgs/geoip/src/ResolveClientGeoip'; import type {Hono} from 'hono'; -import {Config} from '../Config'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoEnv} from '../types/HonoEnv'; export function GeolocationController(app: Hono): void { app.get( diff --git a/fluxer_api/src/api/gif/GifController.test.ts b/fluxer_api/src/api/gif/GifController.test.ts index 8966785f8..e0d598e32 100644 --- a/fluxer_api/src/api/gif/GifController.test.ts +++ b/fluxer_api/src/api/gif/GifController.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GifController} from '@app/api/gif/GifController'; +import {GifService} from '@app/api/gif/GifService'; +import type {IGifProvider} from '@app/api/gif/IGifProvider'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {GIF_PROVIDER_HEADER, type GifResponse} from '@fluxer/schema/src/domains/gif/GifSchemas'; import {Hono} from 'hono'; import {describe, expect, it, vi} from 'vitest'; -import type {HonoEnv} from '../types/HonoEnv'; -import {GifController} from './GifController'; -import {GifService} from './GifService'; -import type {IGifProvider} from './IGifProvider'; function createProvider(gifs: Array): IGifProvider { return { diff --git a/fluxer_api/src/api/gif/GifController.ts b/fluxer_api/src/api/gif/GifController.ts index 28a4abf31..ef4565420 100644 --- a/fluxer_api/src/api/gif/GifController.ts +++ b/fluxer_api/src/api/gif/GifController.ts @@ -1,5 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GifProviderHeaderMiddleware} from '@app/api/gif/GifProviderHeaderMiddleware'; +import {resolveGifRequestCountry} from '@app/api/gif/GifRequestCountry'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp, HonoEnv} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import { GifFeaturedResponse, GifListResponse, @@ -11,15 +19,6 @@ import { import type {Context, MiddlewareHandler} from 'hono'; import {createMiddleware} from 'hono/factory'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp, HonoEnv} from '../types/HonoEnv'; -import {Validator} from '../Validator'; -import {GifProviderHeaderMiddleware} from './GifProviderHeaderMiddleware'; -import {resolveGifRequestCountry} from './GifRequestCountry'; - const TAGS = ['GIFs']; interface PrefixConfig { diff --git a/fluxer_api/src/api/gif/GifProviderHeaderMiddleware.test.ts b/fluxer_api/src/api/gif/GifProviderHeaderMiddleware.test.ts index cb0969988..4a8af4ef2 100644 --- a/fluxer_api/src/api/gif/GifProviderHeaderMiddleware.test.ts +++ b/fluxer_api/src/api/gif/GifProviderHeaderMiddleware.test.ts @@ -1,5 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GifProviderHeaderMiddleware} from '@app/api/gif/GifProviderHeaderMiddleware'; +import {GifService} from '@app/api/gif/GifService'; +import type {IGifProvider} from '@app/api/gif/IGifProvider'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import { GIF_PROVIDER_ATTRIBUTION_HEADER, GIF_PROVIDER_DISPLAY_NAME_HEADER, @@ -7,10 +11,6 @@ import { } from '@fluxer/schema/src/domains/gif/GifSchemas'; import {Hono} from 'hono'; import {describe, expect, it} from 'vitest'; -import type {HonoEnv} from '../types/HonoEnv'; -import {GifProviderHeaderMiddleware} from './GifProviderHeaderMiddleware'; -import {GifService} from './GifService'; -import type {IGifProvider} from './IGifProvider'; function createProvider(): IGifProvider { return { diff --git a/fluxer_api/src/api/gif/GifProviderHeaderMiddleware.ts b/fluxer_api/src/api/gif/GifProviderHeaderMiddleware.ts index 45440567c..5ae0a288f 100644 --- a/fluxer_api/src/api/gif/GifProviderHeaderMiddleware.ts +++ b/fluxer_api/src/api/gif/GifProviderHeaderMiddleware.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GifService} from '@app/api/gif/GifService'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import { GIF_PROVIDER_ATTRIBUTION_HEADER, GIF_PROVIDER_DISPLAY_NAME_HEADER, GIF_PROVIDER_HEADER, } from '@fluxer/schema/src/domains/gif/GifSchemas'; import {createMiddleware} from 'hono/factory'; -import type {HonoEnv} from '../types/HonoEnv'; -import type {GifService} from './GifService'; export const GifProviderHeaderMiddleware = createMiddleware(async (ctx, next) => { await next(); diff --git a/fluxer_api/src/api/gif/GifProviderUtils.test.ts b/fluxer_api/src/api/gif/GifProviderUtils.test.ts index b8331f0cf..ed9571e45 100644 --- a/fluxer_api/src/api/gif/GifProviderUtils.test.ts +++ b/fluxer_api/src/api/gif/GifProviderUtils.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {tryExtractGifProviderSlug} from '@app/api/gif/GifProviderUtils'; +import type {IGifProvider} from '@app/api/gif/IGifProvider'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; import {describe, expect, it} from 'vitest'; -import {tryExtractGifProviderSlug} from './GifProviderUtils'; -import type {IGifProvider} from './IGifProvider'; function createProvider(overrides: Partial = {}): IGifProvider { return { diff --git a/fluxer_api/src/api/gif/GifProviderUtils.ts b/fluxer_api/src/api/gif/GifProviderUtils.ts index 9afcde9c9..5e400947d 100644 --- a/fluxer_api/src/api/gif/GifProviderUtils.ts +++ b/fluxer_api/src/api/gif/GifProviderUtils.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IGifProvider} from '@app/api/gif/IGifProvider'; import {FeatureTemporarilyDisabledError} from '@fluxer/errors/src/domains/core/FeatureTemporarilyDisabledError'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; -import type {IGifProvider} from './IGifProvider'; export type ResolvedGifProviderSlug = { provider: IGifProvider; diff --git a/fluxer_api/src/api/gif/GifRequestCountry.test.ts b/fluxer_api/src/api/gif/GifRequestCountry.test.ts index 65224e9d2..1bb4522c6 100644 --- a/fluxer_api/src/api/gif/GifRequestCountry.test.ts +++ b/fluxer_api/src/api/gif/GifRequestCountry.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {resolveGifRequestCountry} from '@app/api/gif/GifRequestCountry'; import type {GeoipResult} from '@pkgs/geoip/src/GeoipLookup'; import {beforeEach, describe, expect, it, vi} from 'vitest'; -import {resolveGifRequestCountry} from './GifRequestCountry'; const {lookupGeoipMock} = vi.hoisted(() => ({ lookupGeoipMock: vi.fn(), })); -vi.mock('../utils/IpUtils', () => ({ +vi.mock('@app/api/utils/IpUtils', () => ({ lookupGeoip: lookupGeoipMock, })); diff --git a/fluxer_api/src/api/gif/GifRequestCountry.ts b/fluxer_api/src/api/gif/GifRequestCountry.ts index 59ee7039a..dc6d056da 100644 --- a/fluxer_api/src/api/gif/GifRequestCountry.ts +++ b/fluxer_api/src/api/gif/GifRequestCountry.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {lookupGeoip} from '../utils/IpUtils'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; const KLIPY_DEFAULT_COUNTRY = 'US'; diff --git a/fluxer_api/src/api/gif/GifService.ts b/fluxer_api/src/api/gif/GifService.ts index b29f1bdd6..f8eeafc35 100644 --- a/fluxer_api/src/api/gif/GifService.ts +++ b/fluxer_api/src/api/gif/GifService.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IGifProvider} from '@app/api/gif/IGifProvider'; import {FeatureTemporarilyDisabledError} from '@fluxer/errors/src/domains/core/FeatureTemporarilyDisabledError'; -import type {IGifProvider} from './IGifProvider'; export class GifService { private readonly provider: IGifProvider; diff --git a/fluxer_api/src/api/gif/NatsGifProvider.test.ts b/fluxer_api/src/api/gif/NatsGifProvider.test.ts index 3a28ccd81..27ce85655 100644 --- a/fluxer_api/src/api/gif/NatsGifProvider.test.ts +++ b/fluxer_api/src/api/gif/NatsGifProvider.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {buildKlipyShareUrl, extractKlipySlugFromUrl} from '@app/api/gif/NatsGifProvider'; import {describe, expect, it} from 'vitest'; -import {buildKlipyShareUrl, extractKlipySlugFromUrl} from './NatsGifProvider'; describe('NatsGifProvider KLIPY URL helpers', () => { it('extracts GIF and clip slugs from KLIPY share URLs', () => { diff --git a/fluxer_api/src/api/gif/NatsGifProvider.ts b/fluxer_api/src/api/gif/NatsGifProvider.ts index 13fa18bb5..c9b43f4dc 100644 --- a/fluxer_api/src/api/gif/NatsGifProvider.ts +++ b/fluxer_api/src/api/gif/NatsGifProvider.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {GifProviderMeta, IGifProvider} from '@app/api/gif/IGifProvider'; +import {Logger} from '@app/api/Logger'; +import {readOptionalIntegerEnv, requireIntegerInRange} from '@app/api/utils/IntegerOptions'; +import {isJsonRecord, parseJsonUnknown} from '@app/api/utils/JsonBoundaryUtils'; import {FeatureTemporarilyDisabledError} from '@fluxer/errors/src/domains/core/FeatureTemporarilyDisabledError'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; import { @@ -11,11 +16,6 @@ import { import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import {NatsConnectionManager} from '@pkgs/nats/src/NatsConnectionManager'; import {StringCodec} from 'nats'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import {readOptionalIntegerEnv, requireIntegerInRange} from '../utils/IntegerOptions'; -import {isJsonRecord, parseJsonUnknown} from '../utils/JsonBoundaryUtils'; -import type {GifProviderMeta, IGifProvider} from './IGifProvider'; const GIF_SERVICE_SUBJECT = process.env.FLUXER_GIF_SERVICE_SUBJECT || 'svc.gifs'; const DEFAULT_GIF_SERVICE_TIMEOUT_MS = 12_000; diff --git a/fluxer_api/src/api/guild/GuildAuditLogService.ts b/fluxer_api/src/api/guild/GuildAuditLogService.ts index f646c62b4..3b29da2fd 100644 --- a/fluxer_api/src/api/guild/GuildAuditLogService.ts +++ b/fluxer_api/src/api/guild/GuildAuditLogService.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, RoleID, UserID} from '@app/api/BrandedTypes'; +import type {GuildAuditLogRow} from '@app/api/database/types/GuildTypes'; +import type {AuditLogChange, GuildAuditLogChange} from '@app/api/guild/GuildAuditLogTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import {Logger} from '@app/api/Logger'; +import type {ChannelPermissionOverwrite} from '@app/api/models/ChannelPermissionOverwrite'; +import type {GuildAuditLog} from '@app/api/models/GuildAuditLog'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import {ms} from 'itty-time'; -import type {ChannelID, GuildID, RoleID, UserID} from '../BrandedTypes'; -import type {GuildAuditLogRow} from '../database/types/GuildTypes'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../infrastructure/ISnowflakeService'; -import {Logger} from '../Logger'; -import type {ChannelPermissionOverwrite} from '../models/ChannelPermissionOverwrite'; -import type {GuildAuditLog} from '../models/GuildAuditLog'; -import type {WorkerTaskName} from '../worker/WorkerLaneConfig'; -import type {AuditLogChange, GuildAuditLogChange} from './GuildAuditLogTypes'; -import type {IGuildRepositoryAggregate} from './repositories/IGuildRepositoryAggregate'; interface MessageDeleteBatchGroup { logs: Array; diff --git a/fluxer_api/src/api/guild/GuildController.ts b/fluxer_api/src/api/guild/GuildController.ts index 419847cda..a932431a1 100644 --- a/fluxer_api/src/api/guild/GuildController.ts +++ b/fluxer_api/src/api/guild/GuildController.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {HonoApp} from '../types/HonoEnv'; -import {registerGuildControllers} from './controllers/index'; +import {registerGuildControllers} from '@app/api/guild/controllers/index'; +import type {HonoApp} from '@app/api/types/HonoEnv'; export function GuildController(app: HonoApp) { registerGuildControllers(app); diff --git a/fluxer_api/src/api/guild/GuildMemberLimitUtils.ts b/fluxer_api/src/api/guild/GuildMemberLimitUtils.ts index 37c9406ce..cd34796db 100644 --- a/fluxer_api/src/api/guild/GuildMemberLimitUtils.ts +++ b/fluxer_api/src/api/guild/GuildMemberLimitUtils.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import {MAX_GUILD_MEMBERS, MAX_GUILD_MEMBERS_VERY_LARGE_GUILD} from '@fluxer/constants/src/LimitConstants'; import {DEFAULT_FREE_LIMITS} from '@fluxer/limits/src/LimitDefaults'; import {resolveLimit} from '@fluxer/limits/src/LimitResolver'; import type {LimitConfigSnapshot} from '@fluxer/limits/src/LimitTypes'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; function toGuildFeatureSet(guildFeatures: Iterable | null | undefined): Set { const featureSet = new Set(); diff --git a/fluxer_api/src/api/guild/GuildModel.ts b/fluxer_api/src/api/guild/GuildModel.ts index bf902a611..d684d9fa2 100644 --- a/fluxer_api/src/api/guild/GuildModel.ts +++ b/fluxer_api/src/api/guild/GuildModel.ts @@ -1,5 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {mapGuildFeatures} from '@app/api/guild/GuildFeatureUtils'; +import { + stripGuildBannerForFeatures, + stripGuildIconForFeatures, + stripGuildSplashForFeatures, +} from '@app/api/infrastructure/AssetEntitlementUtils'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildBan} from '@app/api/models/GuildBan'; +import type {GuildEmoji} from '@app/api/models/GuildEmoji'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {GuildRole} from '@app/api/models/GuildRole'; +import type {GuildSticker} from '@app/api/models/GuildSticker'; +import {getCachedUserPartialResponse, getCachedUserPartialResponses} from '@app/api/user/UserCacheHelpers'; import type { GuildEmojiResponse, GuildEmojiWithUserResponse, @@ -10,21 +25,6 @@ import type {GuildBanResponse, GuildMemberResponse} from '@fluxer/schema/src/dom import type {GuildPartialResponse, GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import type {GuildRoleResponse} from '@fluxer/schema/src/domains/guild/GuildRoleSchemas'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import { - stripGuildBannerForFeatures, - stripGuildIconForFeatures, - stripGuildSplashForFeatures, -} from '../infrastructure/AssetEntitlementUtils'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Guild} from '../models/Guild'; -import type {GuildBan} from '../models/GuildBan'; -import type {GuildEmoji} from '../models/GuildEmoji'; -import type {GuildMember} from '../models/GuildMember'; -import type {GuildRole} from '../models/GuildRole'; -import type {GuildSticker} from '../models/GuildSticker'; -import {getCachedUserPartialResponse, getCachedUserPartialResponses} from '../user/UserCacheHelpers'; -import {mapGuildFeatures} from './GuildFeatureUtils'; export function mapGuildToPartialResponse(guild: Guild): GuildPartialResponse { const guildId = guild.id.toString(); diff --git a/fluxer_api/src/api/guild/controllers/GuildAuditLogController.ts b/fluxer_api/src/api/guild/controllers/GuildAuditLogController.ts index 7433532b2..a4fe2153f 100644 --- a/fluxer_api/src/api/guild/controllers/GuildAuditLogController.ts +++ b/fluxer_api/src/api/guild/controllers/GuildAuditLogController.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {GuildIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import {GuildAuditLogListQuery, GuildAuditLogListResponse} from '@fluxer/schema/src/domains/guild/GuildAuditLogSchemas'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function GuildAuditLogController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/guild/controllers/GuildBaseController.ts b/fluxer_api/src/api/guild/controllers/GuildBaseController.ts index aee9b198e..0487ebd7a 100644 --- a/fluxer_api/src/api/guild/controllers/GuildBaseController.ts +++ b/fluxer_api/src/api/guild/controllers/GuildBaseController.ts @@ -1,5 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireEmailVerified} from '@app/api/auth/EmailVerificationUtils'; +import {requireSudoMode} from '@app/api/auth/services/SudoVerificationService'; +import {createGuildID} from '@app/api/BrandedTypes'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {requireOAuth2ScopeForBearer} from '@app/api/middleware/OAuth2ScopeMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {SudoModeMiddleware} from '@app/api/middleware/SudoModeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {SingleCommunityCannotCreateGuildsError} from '@fluxer/errors/src/domains/guild/SingleCommunityCannotCreateGuildsError'; import {SingleCommunityCannotDeleteError} from '@fluxer/errors/src/domains/guild/SingleCommunityCannotDeleteError'; import {SingleCommunityCannotLeaveError} from '@fluxer/errors/src/domains/guild/SingleCommunityCannotLeaveError'; @@ -20,18 +31,6 @@ import { GuildVanityURLResponse, } from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import {requireEmailVerified} from '../../auth/EmailVerificationUtils'; -import {requireSudoMode} from '../../auth/services/SudoVerificationService'; -import {createGuildID} from '../../BrandedTypes'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {requireOAuth2ScopeForBearer} from '../../middleware/OAuth2ScopeMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {SudoModeMiddleware} from '../../middleware/SudoModeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; - export function GuildBaseController(app: HonoApp) { app.post( '/guilds', diff --git a/fluxer_api/src/api/guild/controllers/GuildChannelController.ts b/fluxer_api/src/api/guild/controllers/GuildChannelController.ts index 6bcfba46a..d1075c163 100644 --- a/fluxer_api/src/api/guild/controllers/GuildChannelController.ts +++ b/fluxer_api/src/api/guild/controllers/GuildChannelController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createGuildID} from '@app/api/BrandedTypes'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import { ChannelCreateRequest, ChannelPositionUpdateRequest, @@ -7,14 +14,6 @@ import { import {ChannelListResponse, ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import {GuildIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; -import {createChannelID, createGuildID} from '../../BrandedTypes'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; - export function GuildChannelController(app: HonoApp) { app.get( '/guilds/:guild_id/channels', diff --git a/fluxer_api/src/api/guild/controllers/GuildDiscoveryController.ts b/fluxer_api/src/api/guild/controllers/GuildDiscoveryController.ts index 1dfecf535..2f37aa05e 100644 --- a/fluxer_api/src/api/guild/controllers/GuildDiscoveryController.ts +++ b/fluxer_api/src/api/guild/controllers/GuildDiscoveryController.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {GuildDiscoveryRow} from '@app/api/database/types/GuildDiscoveryTypes'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {DiscoveryApplicationStatus, DiscoveryCategoryLabels} from '@fluxer/constants/src/DiscoveryConstants'; import {GuildFeatures, JoinSourceTypes} from '@fluxer/constants/src/GuildConstants'; @@ -16,15 +25,6 @@ import { DiscoverySearchQuery, DiscoveryStatusResponse, } from '@fluxer/schema/src/domains/guild/GuildDiscoverySchemas'; -import {createGuildID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {GuildDiscoveryRow} from '../../database/types/GuildDiscoveryTypes'; -import {DefaultUserOnly, LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; function ensureDiscoveryEnabled(): void { if (!Config.discovery.enabled) { diff --git a/fluxer_api/src/api/guild/controllers/GuildEmojiController.ts b/fluxer_api/src/api/guild/controllers/GuildEmojiController.ts index 12aadba6a..31bf50032 100644 --- a/fluxer_api/src/api/guild/controllers/GuildEmojiController.ts +++ b/fluxer_api/src/api/guild/controllers/GuildEmojiController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createEmojiID, createGuildID} from '@app/api/BrandedTypes'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {EmojiIdParam, GuildIdEmojiIdParam, GuildIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import {PurgeQuery} from '@fluxer/schema/src/domains/common/CommonQuerySchemas'; import { @@ -14,13 +21,6 @@ import { GuildEmojiCreateRequest, GuildEmojiUpdateRequest, } from '@fluxer/schema/src/domains/guild/GuildRequestSchemas'; -import {createEmojiID, createGuildID} from '../../BrandedTypes'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function GuildEmojiController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/guild/controllers/GuildMemberController.ts b/fluxer_api/src/api/guild/controllers/GuildMemberController.ts index 84c7871a0..4c1d26d94 100644 --- a/fluxer_api/src/api/guild/controllers/GuildMemberController.ts +++ b/fluxer_api/src/api/guild/controllers/GuildMemberController.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireSudoMode} from '@app/api/auth/services/SudoVerificationService'; +import {createGuildID, createRoleID, createUserID} from '@app/api/BrandedTypes'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {SudoModeMiddleware} from '@app/api/middleware/SudoModeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import { GuildIdParam, GuildIdUserIdParam, @@ -19,16 +28,6 @@ import { } from '@fluxer/schema/src/domains/guild/GuildRequestSchemas'; import {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import {requireSudoMode} from '../../auth/services/SudoVerificationService'; -import {createGuildID, createRoleID, createUserID} from '../../BrandedTypes'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {SudoModeMiddleware} from '../../middleware/SudoModeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; - export function GuildMemberController(app: HonoApp) { app.get( '/guilds/:guild_id/members', diff --git a/fluxer_api/src/api/guild/controllers/GuildMemberSearchController.ts b/fluxer_api/src/api/guild/controllers/GuildMemberSearchController.ts index b3875c6ce..8560754fa 100644 --- a/fluxer_api/src/api/guild/controllers/GuildMemberSearchController.ts +++ b/fluxer_api/src/api/guild/controllers/GuildMemberSearchController.ts @@ -1,5 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID} from '@app/api/BrandedTypes'; +import {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; +import {createGuildMfaEnforcer} from '@app/api/guild/services/GuildMfaEnforcement'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import {getGuildMemberSearchService} from '@app/api/SearchFactory'; +import {guildMembersNeedReindexing} from '@app/api/search/GuildMemberIndexingUtils'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {MissingPermissionsError} from '@fluxer/errors/src/domains/core/MissingPermissionsError'; import type {SearchableGuildMember} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; @@ -10,17 +21,6 @@ import { type GuildMemberSearchResponse as GuildMemberSearchResponseBody, type GuildMemberSearchResult, } from '@fluxer/schema/src/domains/guild/GuildMemberSearchSchemas'; -import {createGuildID} from '../../BrandedTypes'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import {getGuildMemberSearchService} from '../../SearchFactory'; -import {guildMembersNeedReindexing} from '../../search/GuildMemberIndexingUtils'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; -import {GuildRepository} from '../repositories/GuildRepository'; -import {createGuildMfaEnforcer} from '../services/GuildMfaEnforcement'; const MEMBERS_PAGE_PERMISSIONS = Permissions.MANAGE_GUILD | diff --git a/fluxer_api/src/api/guild/controllers/GuildRoleController.ts b/fluxer_api/src/api/guild/controllers/GuildRoleController.ts index 743d8d37e..6cde05d81 100644 --- a/fluxer_api/src/api/guild/controllers/GuildRoleController.ts +++ b/fluxer_api/src/api/guild/controllers/GuildRoleController.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID, createRoleID} from '@app/api/BrandedTypes'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {requireOAuth2ScopeForBearer} from '@app/api/middleware/OAuth2ScopeMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {CLIENT_FEATURES_HEADER, parseClientFeaturesHeader} from '@app/api/utils/featureUtils'; +import {Validator} from '@app/api/Validator'; import {GuildIdParam, GuildIdRoleIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import { GuildRoleCreateRequest, @@ -9,16 +18,6 @@ import { } from '@fluxer/schema/src/domains/guild/GuildRequestSchemas'; import {GuildRoleListResponse, GuildRoleResponse} from '@fluxer/schema/src/domains/guild/GuildRoleSchemas'; -import {createGuildID, createRoleID} from '../../BrandedTypes'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {requireOAuth2ScopeForBearer} from '../../middleware/OAuth2ScopeMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {CLIENT_FEATURES_HEADER, parseClientFeaturesHeader} from '../../utils/featureUtils'; -import {Validator} from '../../Validator'; - export function GuildRoleController(app: HonoApp) { app.get( '/guilds/:guild_id/roles', diff --git a/fluxer_api/src/api/guild/controllers/GuildStickerController.ts b/fluxer_api/src/api/guild/controllers/GuildStickerController.ts index 3586c7b0a..3c265ac7f 100644 --- a/fluxer_api/src/api/guild/controllers/GuildStickerController.ts +++ b/fluxer_api/src/api/guild/controllers/GuildStickerController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID, createStickerID} from '@app/api/BrandedTypes'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import { GuildIdParam, GuildIdStickerIdParam, @@ -18,13 +25,6 @@ import { GuildStickerCreateRequest, GuildStickerUpdateRequest, } from '@fluxer/schema/src/domains/guild/GuildRequestSchemas'; -import {createGuildID, createStickerID} from '../../BrandedTypes'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function GuildStickerController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/guild/controllers/index.ts b/fluxer_api/src/api/guild/controllers/index.ts index 53ae21aa6..f27ba00ab 100644 --- a/fluxer_api/src/api/guild/controllers/index.ts +++ b/fluxer_api/src/api/guild/controllers/index.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {HonoApp} from '../../types/HonoEnv'; -import {GuildAuditLogController} from './GuildAuditLogController'; -import {GuildBaseController} from './GuildBaseController'; -import {GuildChannelController} from './GuildChannelController'; -import {GuildDiscoveryController} from './GuildDiscoveryController'; -import {GuildEmojiController} from './GuildEmojiController'; -import {GuildMemberController} from './GuildMemberController'; -import {GuildMemberSearchController} from './GuildMemberSearchController'; -import {GuildRoleController} from './GuildRoleController'; -import {GuildStickerController} from './GuildStickerController'; +import {GuildAuditLogController} from '@app/api/guild/controllers/GuildAuditLogController'; +import {GuildBaseController} from '@app/api/guild/controllers/GuildBaseController'; +import {GuildChannelController} from '@app/api/guild/controllers/GuildChannelController'; +import {GuildDiscoveryController} from '@app/api/guild/controllers/GuildDiscoveryController'; +import {GuildEmojiController} from '@app/api/guild/controllers/GuildEmojiController'; +import {GuildMemberController} from '@app/api/guild/controllers/GuildMemberController'; +import {GuildMemberSearchController} from '@app/api/guild/controllers/GuildMemberSearchController'; +import {GuildRoleController} from '@app/api/guild/controllers/GuildRoleController'; +import {GuildStickerController} from '@app/api/guild/controllers/GuildStickerController'; +import type {HonoApp} from '@app/api/types/HonoEnv'; export function registerGuildControllers(app: HonoApp) { GuildBaseController(app); diff --git a/fluxer_api/src/api/guild/repositories/GuildContentRepository.ts b/fluxer_api/src/api/guild/repositories/GuildContentRepository.ts index 01a676094..7be9b676e 100644 --- a/fluxer_api/src/api/guild/repositories/GuildContentRepository.ts +++ b/fluxer_api/src/api/guild/repositories/GuildContentRepository.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {EmojiID, GuildID, StickerID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import {buildPatchFromData, executeVersionedUpdate} from '../../database/CassandraVersionedUpdate'; +import type {EmojiID, GuildID, StickerID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {buildPatchFromData, executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; import { GUILD_EMOJI_COLUMNS, GUILD_STICKER_COLUMNS, type GuildEmojiRow, type GuildStickerRow, -} from '../../database/types/GuildTypes'; -import {GuildEmoji} from '../../models/GuildEmoji'; -import {GuildSticker} from '../../models/GuildSticker'; -import {GuildEmojis, GuildEmojisByEmojiId, GuildStickers, GuildStickersByStickerId} from '../../Tables'; -import {IGuildContentRepository} from './IGuildContentRepository'; +} from '@app/api/database/types/GuildTypes'; +import {IGuildContentRepository} from '@app/api/guild/repositories/IGuildContentRepository'; +import {GuildEmoji} from '@app/api/models/GuildEmoji'; +import {GuildSticker} from '@app/api/models/GuildSticker'; +import {GuildEmojis, GuildEmojisByEmojiId, GuildStickers, GuildStickersByStickerId} from '@app/api/Tables'; const FETCH_GUILD_EMOJIS_BY_GUILD_ID_QUERY = GuildEmojis.selectCql({ where: GuildEmojis.where.eq('guild_id'), diff --git a/fluxer_api/src/api/guild/repositories/GuildDataRepository.ts b/fluxer_api/src/api/guild/repositories/GuildDataRepository.ts index bb2a5dc0b..8951d80ef 100644 --- a/fluxer_api/src/api/guild/repositories/GuildDataRepository.ts +++ b/fluxer_api/src/api/guild/repositories/GuildDataRepository.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne} from '../../database/CassandraQueryExecution'; -import {buildPatchFromData, executeVersionedUpdate} from '../../database/CassandraVersionedUpdate'; -import {GUILD_COLUMNS, type GuildMemberByUserIdRow, type GuildRow} from '../../database/types/GuildTypes'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import {Guild} from '../../models/Guild'; -import {GuildMembersByUserId, Guilds} from '../../Tables'; -import {IGuildDataRepository} from './IGuildDataRepository'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {buildPatchFromData, executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import {GUILD_COLUMNS, type GuildMemberByUserIdRow, type GuildRow} from '@app/api/database/types/GuildTypes'; +import {IGuildDataRepository} from '@app/api/guild/repositories/IGuildDataRepository'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {Guild} from '@app/api/models/Guild'; +import {GuildMembersByUserId, Guilds} from '@app/api/Tables'; const FETCH_GUILD_BY_ID_QUERY = Guilds.selectCql({ where: Guilds.where.eq('guild_id'), diff --git a/fluxer_api/src/api/guild/repositories/GuildDiscoveryRepository.ts b/fluxer_api/src/api/guild/repositories/GuildDiscoveryRepository.ts index 52c5a1a50..3ca2918bc 100644 --- a/fluxer_api/src/api/guild/repositories/GuildDiscoveryRepository.ts +++ b/fluxer_api/src/api/guild/repositories/GuildDiscoveryRepository.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import type {GuildDiscoveryByStatusRow, GuildDiscoveryRow} from '@app/api/database/types/GuildDiscoveryTypes'; +import {GuildDiscovery, GuildDiscoveryByStatus} from '@app/api/Tables'; import {DISCOVERY_DEFAULT_LANGUAGE, DiscoveryCategories} from '@fluxer/constants/src/DiscoveryConstants'; -import type {GuildID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne} from '../../database/CassandraQueryExecution'; -import type {GuildDiscoveryByStatusRow, GuildDiscoveryRow} from '../../database/types/GuildDiscoveryTypes'; -import {GuildDiscovery, GuildDiscoveryByStatus} from '../../Tables'; const FETCH_DISCOVERY_BY_GUILD_ID = GuildDiscovery.selectCql({ where: GuildDiscovery.where.eq('guild_id'), diff --git a/fluxer_api/src/api/guild/repositories/GuildMemberRepository.ts b/fluxer_api/src/api/guild/repositories/GuildMemberRepository.ts index 77ce09296..8d73613b1 100644 --- a/fluxer_api/src/api/guild/repositories/GuildMemberRepository.ts +++ b/fluxer_api/src/api/guild/repositories/GuildMemberRepository.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import {buildPatchFromData, executeVersionedUpdate} from '../../database/CassandraVersionedUpdate'; -import type {GuildMemberRow, GuildMembershipMetadataRow} from '../../database/types/GuildTypes'; -import {GUILD_MEMBER_COLUMNS} from '../../database/types/GuildTypes'; -import {GuildMember} from '../../models/GuildMember'; -import {GuildMembers, GuildMembersByUserId, GuildMembershipMetadata} from '../../Tables'; -import {IGuildMemberRepository} from './IGuildMemberRepository'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {buildPatchFromData, executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import type {GuildMemberRow, GuildMembershipMetadataRow} from '@app/api/database/types/GuildTypes'; +import {GUILD_MEMBER_COLUMNS} from '@app/api/database/types/GuildTypes'; +import {IGuildMemberRepository} from '@app/api/guild/repositories/IGuildMemberRepository'; +import {GuildMember} from '@app/api/models/GuildMember'; +import {GuildMembers, GuildMembersByUserId, GuildMembershipMetadata} from '@app/api/Tables'; const FETCH_GUILD_MEMBER_BY_GUILD_AND_USER_ID_QUERY = GuildMembers.selectCql({ where: [GuildMembers.where.eq('guild_id'), GuildMembers.where.eq('user_id')], diff --git a/fluxer_api/src/api/guild/repositories/GuildModerationRepository.ts b/fluxer_api/src/api/guild/repositories/GuildModerationRepository.ts index e661571f4..049eaa8bd 100644 --- a/fluxer_api/src/api/guild/repositories/GuildModerationRepository.ts +++ b/fluxer_api/src/api/guild/repositories/GuildModerationRepository.ts @@ -1,21 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; -import {seconds} from 'itty-time'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne} from '../../database/CassandraQueryExecution'; -import {Db, type DbOp, type QueryTemplate, type WhereExpr} from '../../database/CassandraTypes'; -import {executeVersionedUpdate} from '../../database/CassandraVersionedUpdate'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {Db, type DbOp, type QueryTemplate, type WhereExpr} from '@app/api/database/CassandraTypes'; +import {executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; import type { GuildAuditLogRow, GuildBanByEmailRow, GuildBanByUserIdRow, GuildBanRow, GuildRow, -} from '../../database/types/GuildTypes'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import {GuildAuditLog} from '../../models/GuildAuditLog'; -import {GuildBan} from '../../models/GuildBan'; +} from '@app/api/database/types/GuildTypes'; +import {IGuildModerationRepository} from '@app/api/guild/repositories/IGuildModerationRepository'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {GuildAuditLog} from '@app/api/models/GuildAuditLog'; +import {GuildBan} from '@app/api/models/GuildBan'; import { GuildAuditLogs, GuildAuditLogsByAction, @@ -25,8 +24,9 @@ import { GuildBansByEmail, GuildBansByUserId, Guilds, -} from '../../Tables'; -import {IGuildModerationRepository} from './IGuildModerationRepository'; +} from '@app/api/Tables'; +import type {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; +import {seconds} from 'itty-time'; const FETCH_GUILD_BAN_BY_GUILD_AND_USER_ID_QUERY = GuildBans.selectCql({ where: [GuildBans.where.eq('guild_id'), GuildBans.where.eq('user_id')], diff --git a/fluxer_api/src/api/guild/repositories/GuildRepository.ts b/fluxer_api/src/api/guild/repositories/GuildRepository.ts index 270d34993..6cf531224 100644 --- a/fluxer_api/src/api/guild/repositories/GuildRepository.ts +++ b/fluxer_api/src/api/guild/repositories/GuildRepository.ts @@ -1,7 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; -import type {EmojiID, GuildID, RoleID, StickerID, UserID} from '../../BrandedTypes'; +import type {EmojiID, GuildID, RoleID, StickerID, UserID} from '@app/api/BrandedTypes'; import type { GuildAuditLogRow, GuildBanRow, @@ -11,21 +10,22 @@ import type { GuildRoleRow, GuildRow, GuildStickerRow, -} from '../../database/types/GuildTypes'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Guild} from '../../models/Guild'; -import type {GuildAuditLog} from '../../models/GuildAuditLog'; -import type {GuildBan} from '../../models/GuildBan'; -import type {GuildEmoji} from '../../models/GuildEmoji'; -import type {GuildMember} from '../../models/GuildMember'; -import type {GuildRole} from '../../models/GuildRole'; -import type {GuildSticker} from '../../models/GuildSticker'; -import {GuildContentRepository} from './GuildContentRepository'; -import {GuildDataRepository} from './GuildDataRepository'; -import {GuildMemberRepository} from './GuildMemberRepository'; -import {GuildModerationRepository} from './GuildModerationRepository'; -import {GuildRoleRepository} from './GuildRoleRepository'; -import type {IGuildRepositoryAggregate} from './IGuildRepositoryAggregate'; +} from '@app/api/database/types/GuildTypes'; +import {GuildContentRepository} from '@app/api/guild/repositories/GuildContentRepository'; +import {GuildDataRepository} from '@app/api/guild/repositories/GuildDataRepository'; +import {GuildMemberRepository} from '@app/api/guild/repositories/GuildMemberRepository'; +import {GuildModerationRepository} from '@app/api/guild/repositories/GuildModerationRepository'; +import {GuildRoleRepository} from '@app/api/guild/repositories/GuildRoleRepository'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildAuditLog} from '@app/api/models/GuildAuditLog'; +import type {GuildBan} from '@app/api/models/GuildBan'; +import type {GuildEmoji} from '@app/api/models/GuildEmoji'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {GuildRole} from '@app/api/models/GuildRole'; +import type {GuildSticker} from '@app/api/models/GuildSticker'; +import type {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; export class GuildRepository implements IGuildRepositoryAggregate { private dataRepo: GuildDataRepository; diff --git a/fluxer_api/src/api/guild/repositories/GuildRoleRepository.ts b/fluxer_api/src/api/guild/repositories/GuildRoleRepository.ts index 1bd568a0c..366f3ff25 100644 --- a/fluxer_api/src/api/guild/repositories/GuildRoleRepository.ts +++ b/fluxer_api/src/api/guild/repositories/GuildRoleRepository.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, RoleID} from '../../BrandedTypes'; -import {deleteOneOrMany, fetchMany, fetchOne} from '../../database/CassandraQueryExecution'; -import {buildPatchFromData, executeVersionedUpdate} from '../../database/CassandraVersionedUpdate'; -import type {GuildRoleRow} from '../../database/types/GuildTypes'; -import {GUILD_ROLE_COLUMNS} from '../../database/types/GuildTypes'; -import {GuildRole} from '../../models/GuildRole'; -import {GuildRoles} from '../../Tables'; -import {IGuildRoleRepository} from './IGuildRoleRepository'; +import type {GuildID, RoleID} from '@app/api/BrandedTypes'; +import {deleteOneOrMany, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {buildPatchFromData, executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import type {GuildRoleRow} from '@app/api/database/types/GuildTypes'; +import {GUILD_ROLE_COLUMNS} from '@app/api/database/types/GuildTypes'; +import {IGuildRoleRepository} from '@app/api/guild/repositories/IGuildRoleRepository'; +import {GuildRole} from '@app/api/models/GuildRole'; +import {GuildRoles} from '@app/api/Tables'; const FETCH_GUILD_ROLE_BY_ID_QUERY = GuildRoles.selectCql({ where: [GuildRoles.where.eq('guild_id'), GuildRoles.where.eq('role_id')], diff --git a/fluxer_api/src/api/guild/repositories/IGuildContentRepository.ts b/fluxer_api/src/api/guild/repositories/IGuildContentRepository.ts index 1bcfd6aad..81414a409 100644 --- a/fluxer_api/src/api/guild/repositories/IGuildContentRepository.ts +++ b/fluxer_api/src/api/guild/repositories/IGuildContentRepository.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {EmojiID, GuildID, StickerID} from '../../BrandedTypes'; -import type {GuildEmojiRow, GuildStickerRow} from '../../database/types/GuildTypes'; -import type {GuildEmoji} from '../../models/GuildEmoji'; -import type {GuildSticker} from '../../models/GuildSticker'; +import type {EmojiID, GuildID, StickerID} from '@app/api/BrandedTypes'; +import type {GuildEmojiRow, GuildStickerRow} from '@app/api/database/types/GuildTypes'; +import type {GuildEmoji} from '@app/api/models/GuildEmoji'; +import type {GuildSticker} from '@app/api/models/GuildSticker'; export abstract class IGuildContentRepository { abstract getEmoji(emojiId: EmojiID, guildId: GuildID): Promise; diff --git a/fluxer_api/src/api/guild/repositories/IGuildDataRepository.ts b/fluxer_api/src/api/guild/repositories/IGuildDataRepository.ts index 69be32bed..9ea2d3dec 100644 --- a/fluxer_api/src/api/guild/repositories/IGuildDataRepository.ts +++ b/fluxer_api/src/api/guild/repositories/IGuildDataRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {GuildRow} from '../../database/types/GuildTypes'; -import type {Guild} from '../../models/Guild'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildRow} from '@app/api/database/types/GuildTypes'; +import type {Guild} from '@app/api/models/Guild'; export abstract class IGuildDataRepository { abstract findUnique(guildId: GuildID): Promise; diff --git a/fluxer_api/src/api/guild/repositories/IGuildMemberRepository.ts b/fluxer_api/src/api/guild/repositories/IGuildMemberRepository.ts index 03a5ab6ad..1995bd4b9 100644 --- a/fluxer_api/src/api/guild/repositories/IGuildMemberRepository.ts +++ b/fluxer_api/src/api/guild/repositories/IGuildMemberRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {GuildMemberRow, GuildMembershipMetadataRow} from '../../database/types/GuildTypes'; -import type {GuildMember} from '../../models/GuildMember'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildMemberRow, GuildMembershipMetadataRow} from '@app/api/database/types/GuildTypes'; +import type {GuildMember} from '@app/api/models/GuildMember'; export abstract class IGuildMemberRepository { abstract getMember(guildId: GuildID, userId: UserID): Promise; diff --git a/fluxer_api/src/api/guild/repositories/IGuildModerationRepository.ts b/fluxer_api/src/api/guild/repositories/IGuildModerationRepository.ts index 02c8d41c0..335f15c89 100644 --- a/fluxer_api/src/api/guild/repositories/IGuildModerationRepository.ts +++ b/fluxer_api/src/api/guild/repositories/IGuildModerationRepository.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildAuditLogRow, GuildBanRow} from '@app/api/database/types/GuildTypes'; +import type {GuildAuditLog} from '@app/api/models/GuildAuditLog'; +import type {GuildBan} from '@app/api/models/GuildBan'; import type {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {GuildAuditLogRow, GuildBanRow} from '../../database/types/GuildTypes'; -import type {GuildAuditLog} from '../../models/GuildAuditLog'; -import type {GuildBan} from '../../models/GuildBan'; export abstract class IGuildModerationRepository { abstract getBan(guildId: GuildID, userId: UserID): Promise; diff --git a/fluxer_api/src/api/guild/repositories/IGuildRepositoryAggregate.ts b/fluxer_api/src/api/guild/repositories/IGuildRepositoryAggregate.ts index 72741aeeb..08e868b23 100644 --- a/fluxer_api/src/api/guild/repositories/IGuildRepositoryAggregate.ts +++ b/fluxer_api/src/api/guild/repositories/IGuildRepositoryAggregate.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IGuildContentRepository} from './IGuildContentRepository'; -import type {IGuildDataRepository} from './IGuildDataRepository'; -import type {IGuildMemberRepository} from './IGuildMemberRepository'; -import type {IGuildModerationRepository} from './IGuildModerationRepository'; -import type {IGuildRoleRepository} from './IGuildRoleRepository'; +import type {IGuildContentRepository} from '@app/api/guild/repositories/IGuildContentRepository'; +import type {IGuildDataRepository} from '@app/api/guild/repositories/IGuildDataRepository'; +import type {IGuildMemberRepository} from '@app/api/guild/repositories/IGuildMemberRepository'; +import type {IGuildModerationRepository} from '@app/api/guild/repositories/IGuildModerationRepository'; +import type {IGuildRoleRepository} from '@app/api/guild/repositories/IGuildRoleRepository'; export interface IGuildRepositoryAggregate extends IGuildDataRepository, diff --git a/fluxer_api/src/api/guild/repositories/IGuildRoleRepository.ts b/fluxer_api/src/api/guild/repositories/IGuildRoleRepository.ts index a0b625c4a..15f6f315e 100644 --- a/fluxer_api/src/api/guild/repositories/IGuildRoleRepository.ts +++ b/fluxer_api/src/api/guild/repositories/IGuildRoleRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, RoleID} from '../../BrandedTypes'; -import type {GuildRoleRow} from '../../database/types/GuildTypes'; -import type {GuildRole} from '../../models/GuildRole'; +import type {GuildID, RoleID} from '@app/api/BrandedTypes'; +import type {GuildRoleRow} from '@app/api/database/types/GuildTypes'; +import type {GuildRole} from '@app/api/models/GuildRole'; export abstract class IGuildRoleRepository { abstract getRole(roleId: RoleID, guildId: GuildID): Promise; diff --git a/fluxer_api/src/api/guild/services/GuildChannelService.ts b/fluxer_api/src/api/guild/services/GuildChannelService.ts index c78dbea8a..6c4eafab9 100644 --- a/fluxer_api/src/api/guild/services/GuildChannelService.ts +++ b/fluxer_api/src/api/guild/services/GuildChannelService.ts @@ -1,24 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {ChannelOperationsService} from '@app/api/guild/services/channel/ChannelOperationsService'; +import {createGuildMfaEnforcer} from '@app/api/guild/services/GuildMfaEnforcement'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {MissingPermissionsError} from '@fluxer/errors/src/domains/core/MissingPermissionsError'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import type {ChannelCreateRequest} from '@fluxer/schema/src/domains/channel/ChannelRequestSchemas'; import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import type {ChannelID, GuildID, UserID} from '../../BrandedTypes'; -import {mapChannelToResponse} from '../../channel/ChannelMappers'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {GuildAuditLogService} from '../GuildAuditLogService'; -import type {IGuildRepositoryAggregate} from '../repositories/IGuildRepositoryAggregate'; -import {ChannelOperationsService} from './channel/ChannelOperationsService'; -import {createGuildMfaEnforcer} from './GuildMfaEnforcement'; export class GuildChannelService { private readonly channelOps: ChannelOperationsService; diff --git a/fluxer_api/src/api/guild/services/GuildContentService.ts b/fluxer_api/src/api/guild/services/GuildContentService.ts index 76af38ec7..4bfe1731b 100644 --- a/fluxer_api/src/api/guild/services/GuildContentService.ts +++ b/fluxer_api/src/api/guild/services/GuildContentService.ts @@ -1,5 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {EmojiID, GuildID, StickerID, UserID} from '@app/api/BrandedTypes'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {ContentHelpers} from '@app/api/guild/services/content/ContentHelpers'; +import {EmojiService} from '@app/api/guild/services/content/EmojiService'; +import {ExpressionAssetPurger} from '@app/api/guild/services/content/ExpressionAssetPurger'; +import {StickerService} from '@app/api/guild/services/content/StickerService'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import type {IAssetDeletionQueue} from '@app/api/infrastructure/IAssetDeletionQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; import type { GuildEmojiResponse, GuildEmojiWithUserResponse, @@ -7,21 +22,6 @@ import type { GuildStickerWithUserResponse, } from '@fluxer/schema/src/domains/guild/GuildEmojiSchemas'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import type {EmojiID, GuildID, StickerID, UserID} from '../../BrandedTypes'; -import type {AvatarService} from '../../infrastructure/AvatarService'; -import type {IAssetDeletionQueue} from '../../infrastructure/IAssetDeletionQueue'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {User} from '../../models/User'; -import type {GuildAuditLogService} from '../GuildAuditLogService'; -import type {IGuildRepositoryAggregate} from '../repositories/IGuildRepositoryAggregate'; -import {ContentHelpers} from './content/ContentHelpers'; -import {EmojiService} from './content/EmojiService'; -import {ExpressionAssetPurger} from './content/ExpressionAssetPurger'; -import {StickerService} from './content/StickerService'; export class GuildContentService { private readonly contentHelpers: ContentHelpers; diff --git a/fluxer_api/src/api/guild/services/GuildDataService.ts b/fluxer_api/src/api/guild/services/GuildDataService.ts index d4ad5feed..5e59caf74 100644 --- a/fluxer_api/src/api/guild/services/GuildDataService.ts +++ b/fluxer_api/src/api/guild/services/GuildDataService.ts @@ -1,5 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import {GuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {GuildDataHelpers} from '@app/api/guild/services/data/GuildDataHelpers'; +import {GuildOperationsService} from '@app/api/guild/services/data/GuildOperationsService'; +import {GuildOwnershipService} from '@app/api/guild/services/data/GuildOwnershipService'; +import {GuildVanityService} from '@app/api/guild/services/data/GuildVanityService'; +import type {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {InviteRepository} from '@app/api/invite/InviteRepository'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {User} from '@app/api/models/User'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {IWebhookRepository} from '@app/api/webhook/IWebhookRepository'; import type { GuildCreateRequest, GuildUpdateRequest, @@ -10,27 +31,6 @@ import type { GuildResponse, GuildVanityURLResponse, } from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {ChannelService} from '../../channel/services/ChannelService'; -import type {EntityAssetService} from '../../infrastructure/EntityAssetService'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {InviteRepository} from '../../invite/InviteRepository'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Guild} from '../../models/Guild'; -import type {GuildMember} from '../../models/GuildMember'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {IWebhookRepository} from '../../webhook/IWebhookRepository'; -import type {GuildAuditLogService} from '../GuildAuditLogService'; -import {GuildDiscoveryRepository} from '../repositories/GuildDiscoveryRepository'; -import type {IGuildRepositoryAggregate} from '../repositories/IGuildRepositoryAggregate'; -import {GuildDataHelpers} from './data/GuildDataHelpers'; -import {GuildOperationsService} from './data/GuildOperationsService'; -import {GuildOwnershipService} from './data/GuildOwnershipService'; -import {GuildVanityService} from './data/GuildVanityService'; export class GuildDataService { private readonly helpers: GuildDataHelpers; diff --git a/fluxer_api/src/api/guild/services/GuildDiscoveryService.ts b/fluxer_api/src/api/guild/services/GuildDiscoveryService.ts index 71e3d327a..66d245bc9 100644 --- a/fluxer_api/src/api/guild/services/GuildDiscoveryService.ts +++ b/fluxer_api/src/api/guild/services/GuildDiscoveryService.ts @@ -1,5 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {GuildDiscoveryRow} from '@app/api/database/types/GuildDiscoveryTypes'; +import {mapGuildToGuildResponse} from '@app/api/guild/GuildModel'; +import type {IGuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import type {IGuildSearchService} from '@app/api/search/IGuildSearchService'; import { DISCOVERY_DEFAULT_LANGUAGE, DISCOVERY_MAX_TAGS, @@ -18,16 +28,6 @@ import {DiscoveryInsufficientMembersError} from '@fluxer/errors/src/domains/disc import {DiscoveryNotDiscoverableError} from '@fluxer/errors/src/domains/discovery/DiscoveryNotDiscoverableError'; import type {GuildSearchFilters} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes.jsx'; import type {DiscoveryApplicationPatchRequest} from '@fluxer/schema/src/domains/guild/GuildDiscoverySchemas'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {GuildDiscoveryRow} from '../../database/types/GuildDiscoveryTypes'; -import {contentModerationService} from '../../infrastructure/ContentModerationService'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {Logger} from '../../Logger'; -import type {IGuildSearchService} from '../../search/IGuildSearchService'; -import {mapGuildToGuildResponse} from '../GuildModel'; -import type {IGuildDiscoveryRepository} from '../repositories/GuildDiscoveryRepository'; -import type {IGuildRepositoryAggregate} from '../repositories/IGuildRepositoryAggregate'; function sanitizeTags(tags: ReadonlyArray | null | undefined): Array { if (!tags || tags.length === 0) return []; diff --git a/fluxer_api/src/api/guild/services/GuildMemberService.ts b/fluxer_api/src/api/guild/services/GuildMemberService.ts index d8943617c..afc475e62 100644 --- a/fluxer_api/src/api/guild/services/GuildMemberService.ts +++ b/fluxer_api/src/api/guild/services/GuildMemberService.ts @@ -1,5 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, InviteCode, RoleID, UserID} from '@app/api/BrandedTypes'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {GuildMemberAuditService} from '@app/api/guild/services/member/GuildMemberAuditService'; +import {GuildMemberAuthService} from '@app/api/guild/services/member/GuildMemberAuthService'; +import {GuildMemberEventService} from '@app/api/guild/services/member/GuildMemberEventService'; +import {GuildMemberOperationsService} from '@app/api/guild/services/member/GuildMemberOperationsService'; +import {GuildMemberRoleService} from '@app/api/guild/services/member/GuildMemberRoleService'; +import {GuildMemberSearchIndexService} from '@app/api/guild/services/member/GuildMemberSearchIndexService'; +import {GuildMemberValidationService} from '@app/api/guild/services/member/GuildMemberValidationService'; +import type {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import type {JoinSourceType} from '@fluxer/constants/src/GuildConstants'; import {UnknownGuildMemberError} from '@fluxer/errors/src/domains/guild/UnknownGuildMemberError'; @@ -7,25 +26,6 @@ import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMe import type {GuildMemberUpdateRequest} from '@fluxer/schema/src/domains/guild/GuildRequestSchemas'; import type {IpInfoService} from '@pkgs/geoip/src/IpInfoService'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; -import type {GuildID, InviteCode, RoleID, UserID} from '../../BrandedTypes'; -import type {ChannelService} from '../../channel/services/ChannelService'; -import type {EntityAssetService} from '../../infrastructure/EntityAssetService'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Guild} from '../../models/Guild'; -import type {GuildMember} from '../../models/GuildMember'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {GuildAuditLogService} from '../GuildAuditLogService'; -import type {IGuildRepositoryAggregate} from '../repositories/IGuildRepositoryAggregate'; -import {GuildMemberAuditService} from './member/GuildMemberAuditService'; -import {GuildMemberAuthService} from './member/GuildMemberAuthService'; -import {GuildMemberEventService} from './member/GuildMemberEventService'; -import {GuildMemberOperationsService} from './member/GuildMemberOperationsService'; -import {GuildMemberRoleService} from './member/GuildMemberRoleService'; -import {GuildMemberSearchIndexService} from './member/GuildMemberSearchIndexService'; -import {GuildMemberValidationService} from './member/GuildMemberValidationService'; export class GuildMemberService { private readonly authService: GuildMemberAuthService; diff --git a/fluxer_api/src/api/guild/services/GuildMfaEnforcement.ts b/fluxer_api/src/api/guild/services/GuildMfaEnforcement.ts index 1efcd259c..4b4665b15 100644 --- a/fluxer_api/src/api/guild/services/GuildMfaEnforcement.ts +++ b/fluxer_api/src/api/guild/services/GuildMfaEnforcement.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {GuildMFALevel} from '@fluxer/constants/src/GuildConstants'; import {MfaNotEnabledError} from '@fluxer/errors/src/domains/auth/MfaNotEnabledError'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {UserID} from '../../BrandedTypes'; -import type {IUserRepository} from '../../user/IUserRepository'; const ELEVATED_MFA_PERMISSIONS = Permissions.KICK_MEMBERS | diff --git a/fluxer_api/src/api/guild/services/GuildModerationService.ts b/fluxer_api/src/api/guild/services/GuildModerationService.ts index 31ae9fbcd..5ca522793 100644 --- a/fluxer_api/src/api/guild/services/GuildModerationService.ts +++ b/fluxer_api/src/api/guild/services/GuildModerationService.ts @@ -1,5 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildAuditLogChange} from '@app/api/guild/GuildAuditLogTypes'; +import {mapGuildBansToResponse} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {createGuildMfaEnforcer} from '@app/api/guild/services/GuildMfaEnforcement'; +import {GuildMemberSearchIndexService} from '@app/api/guild/services/member/GuildMemberSearchIndexService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {GuildBan} from '@app/api/models/GuildBan'; +import {getIpBanBlastRadiusVerdict, isSingleIpBanCandidate} from '@app/api/risk/IpBanCgnatGuard'; +import {isIpBanExempt} from '@app/api/risk/IpBanExemptions'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; @@ -13,22 +29,6 @@ import {isSameIpDecisionMatch} from '@fluxer/ip_utils/src/IpAddress'; import type {GuildBanResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; import type {IpInfoService} from '@pkgs/geoip/src/IpInfoService'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {Logger} from '../../Logger'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {GuildBan} from '../../models/GuildBan'; -import {getIpBanBlastRadiusVerdict, isSingleIpBanCandidate} from '../../risk/IpBanCgnatGuard'; -import {isIpBanExempt} from '../../risk/IpBanExemptions'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {WorkerTaskName} from '../../worker/WorkerLaneConfig'; -import type {GuildAuditLogService} from '../GuildAuditLogService'; -import type {GuildAuditLogChange} from '../GuildAuditLogTypes'; -import {mapGuildBansToResponse} from '../GuildModel'; -import type {IGuildRepositoryAggregate} from '../repositories/IGuildRepositoryAggregate'; -import {createGuildMfaEnforcer} from './GuildMfaEnforcement'; -import {GuildMemberSearchIndexService} from './member/GuildMemberSearchIndexService'; const SECONDS_PER_DAY = 86_400; diff --git a/fluxer_api/src/api/guild/services/GuildRoleService.ts b/fluxer_api/src/api/guild/services/GuildRoleService.ts index 50bd0ce76..d9d128ce9 100644 --- a/fluxer_api/src/api/guild/services/GuildRoleService.ts +++ b/fluxer_api/src/api/guild/services/GuildRoleService.ts @@ -1,5 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, RoleID, UserID} from '@app/api/BrandedTypes'; +import {createRoleID, guildIdToRoleId} from '@app/api/BrandedTypes'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildAuditLogChange} from '@app/api/guild/GuildAuditLogTypes'; +import {mapGuildRoleToResponse} from '@app/api/guild/GuildModel'; +import type {IGuildMemberRepository} from '@app/api/guild/repositories/IGuildMemberRepository'; +import type {IGuildRoleRepository} from '@app/api/guild/repositories/IGuildRoleRepository'; +import {createGuildMfaEnforcer} from '@app/api/guild/services/GuildMfaEnforcement'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import {GuildRole} from '@app/api/models/GuildRole'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {applyProtectedRolePermissions} from '@app/api/utils/featureUtils'; +import {computePermissionsDiff} from '@app/api/utils/PermissionUtils'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {ALL_PERMISSIONS, DEFAULT_PERMISSIONS, Permissions} from '@fluxer/constants/src/ChannelConstants'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; @@ -17,24 +35,6 @@ import type { import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import type {GuildRoleResponse} from '@fluxer/schema/src/domains/guild/GuildRoleSchemas'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import type {GuildID, RoleID, UserID} from '../../BrandedTypes'; -import {createRoleID, guildIdToRoleId} from '../../BrandedTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import {Logger} from '../../Logger'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../limits/LimitMatchContextBuilder'; -import {GuildRole} from '../../models/GuildRole'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {applyProtectedRolePermissions} from '../../utils/featureUtils'; -import {computePermissionsDiff} from '../../utils/PermissionUtils'; -import type {GuildAuditLogService} from '../GuildAuditLogService'; -import type {GuildAuditLogChange} from '../GuildAuditLogTypes'; -import {mapGuildRoleToResponse} from '../GuildModel'; -import type {IGuildMemberRepository} from '../repositories/IGuildMemberRepository'; -import type {IGuildRoleRepository} from '../repositories/IGuildRoleRepository'; -import {createGuildMfaEnforcer} from './GuildMfaEnforcement'; interface GuildRoleRepository extends IGuildRoleRepository, IGuildMemberRepository {} diff --git a/fluxer_api/src/api/guild/services/GuildSearchService.ts b/fluxer_api/src/api/guild/services/GuildSearchService.ts index 84e7151d9..80e42d460 100644 --- a/fluxer_api/src/api/guild/services/GuildSearchService.ts +++ b/fluxer_api/src/api/guild/services/GuildSearchService.ts @@ -1,5 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import {getMessageSearchService} from '@app/api/SearchFactory'; +import {buildMessageSearchFilters} from '@app/api/search/BuildMessageSearchFilters'; +import {channelNeedsReindexing} from '@app/api/search/ChannelIndexingUtils'; +import {MessageSearchResponseMapper} from '@app/api/search/MessageSearchResponseMapper'; +import {searchExistingMessages} from '@app/api/search/MessageSearchResultReconciler'; +import {channelRequiresAgeVerification} from '@app/api/search/SearchNsfwUtils'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {canUserAccessNsfwContent} from '@app/api/utils/AgeUtils'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {GuildNSFWLevel} from '@fluxer/constants/src/GuildConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; @@ -11,22 +27,6 @@ import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError import type {MessageSearchRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {MessageSearchResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import type {ChannelID, GuildID, UserID} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../models/Channel'; -import {getMessageSearchService} from '../../SearchFactory'; -import {buildMessageSearchFilters} from '../../search/BuildMessageSearchFilters'; -import {channelNeedsReindexing} from '../../search/ChannelIndexingUtils'; -import {MessageSearchResponseMapper} from '../../search/MessageSearchResponseMapper'; -import {searchExistingMessages} from '../../search/MessageSearchResultReconciler'; -import {channelRequiresAgeVerification} from '../../search/SearchNsfwUtils'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {canUserAccessNsfwContent} from '../../utils/AgeUtils'; -import {mapWithConcurrency} from '../../utils/ConcurrencyUtils'; -import type {WorkerTaskName} from '../../worker/WorkerLaneConfig'; const GUILD_FANOUT_CONCURRENCY = 16; const PERMISSION_CHECK_CONCURRENCY = 64; diff --git a/fluxer_api/src/api/guild/services/GuildService.ts b/fluxer_api/src/api/guild/services/GuildService.ts index 8443db876..a349abffc 100644 --- a/fluxer_api/src/api/guild/services/GuildService.ts +++ b/fluxer_api/src/api/guild/services/GuildService.ts @@ -1,5 +1,34 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {EmojiID, GuildID, RoleID, StickerID, UserID} from '@app/api/BrandedTypes'; +import {createUserID, createWebhookID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildAuditLogChange} from '@app/api/guild/GuildAuditLogTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {GuildChannelService} from '@app/api/guild/services/GuildChannelService'; +import {GuildContentService} from '@app/api/guild/services/GuildContentService'; +import {GuildDataService} from '@app/api/guild/services/GuildDataService'; +import {GuildMemberService} from '@app/api/guild/services/GuildMemberService'; +import {createGuildMfaEnforcer} from '@app/api/guild/services/GuildMfaEnforcement'; +import {GuildModerationService} from '@app/api/guild/services/GuildModerationService'; +import {GuildRoleService} from '@app/api/guild/services/GuildRoleService'; +import {GuildSearchService} from '@app/api/guild/services/GuildSearchService'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import type {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import type {IAssetDeletionQueue} from '@app/api/infrastructure/IAssetDeletionQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {InviteRepository} from '@app/api/invite/InviteRepository'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {GuildAuditLog} from '@app/api/models/GuildAuditLog'; +import type {Webhook} from '@app/api/models/Webhook'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {getCachedUserPartialResponses} from '@app/api/user/UserCacheHelpers'; +import type {IWebhookRepository} from '@app/api/webhook/IWebhookRepository'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; @@ -25,35 +54,6 @@ import type {GuildUpdateRequest} from '@fluxer/schema/src/domains/guild/GuildReq import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {IpInfoService} from '@pkgs/geoip/src/IpInfoService'; -import type {ApiContext} from '../../ApiContext'; -import type {EmojiID, GuildID, RoleID, StickerID, UserID} from '../../BrandedTypes'; -import {createUserID, createWebhookID} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {ChannelService} from '../../channel/services/ChannelService'; -import type {AvatarService} from '../../infrastructure/AvatarService'; -import type {EntityAssetService} from '../../infrastructure/EntityAssetService'; -import type {IAssetDeletionQueue} from '../../infrastructure/IAssetDeletionQueue'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {InviteRepository} from '../../invite/InviteRepository'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {GuildAuditLog} from '../../models/GuildAuditLog'; -import type {Webhook} from '../../models/Webhook'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {getCachedUserPartialResponses} from '../../user/UserCacheHelpers'; -import type {IWebhookRepository} from '../../webhook/IWebhookRepository'; -import type {GuildAuditLogService} from '../GuildAuditLogService'; -import type {GuildAuditLogChange} from '../GuildAuditLogTypes'; -import type {IGuildRepositoryAggregate} from '../repositories/IGuildRepositoryAggregate'; -import {GuildChannelService} from './GuildChannelService'; -import {GuildContentService} from './GuildContentService'; -import {GuildDataService} from './GuildDataService'; -import {GuildMemberService} from './GuildMemberService'; -import {createGuildMfaEnforcer} from './GuildMfaEnforcement'; -import {GuildModerationService} from './GuildModerationService'; -import {GuildRoleService} from './GuildRoleService'; -import {GuildSearchService} from './GuildSearchService'; interface StoredGuildAuditLogEntryResponse extends Omit { changes?: GuildAuditLogChange; diff --git a/fluxer_api/src/api/guild/services/channel/ChannelHelpers.ts b/fluxer_api/src/api/guild/services/channel/ChannelHelpers.ts index e976fa1d1..8222cd497 100644 --- a/fluxer_api/src/api/guild/services/channel/ChannelHelpers.ts +++ b/fluxer_api/src/api/guild/services/channel/ChannelHelpers.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID} from '@app/api/BrandedTypes'; +import type {Channel} from '@app/api/models/Channel'; +import {serializeChannelForAudit as serializeChannelForAuditUtil} from '@app/api/utils/AuditSerializationUtils'; +import {toIdString} from '@app/api/utils/IdUtils'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; -import type {ChannelID} from '../../../BrandedTypes'; -import type {Channel} from '../../../models/Channel'; -import {serializeChannelForAudit as serializeChannelForAuditUtil} from '../../../utils/AuditSerializationUtils'; -import {toIdString} from '../../../utils/IdUtils'; export interface ChannelReorderOperation { channelId: ChannelID; diff --git a/fluxer_api/src/api/guild/services/channel/ChannelOperationsService.ts b/fluxer_api/src/api/guild/services/channel/ChannelOperationsService.ts index ee9b42598..5493d4d0d 100644 --- a/fluxer_api/src/api/guild/services/channel/ChannelOperationsService.ts +++ b/fluxer_api/src/api/guild/services/channel/ChannelOperationsService.ts @@ -1,5 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, EmojiID, GuildID, RoleID, StickerID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createRoleID, createUserID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {PermissionOverwrite} from '@app/api/database/types/ChannelTypes'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildAuditLogChange} from '@app/api/guild/GuildAuditLogTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {ChannelHelpers, type ChannelReorderOperation} from '@app/api/guild/services/channel/ChannelHelpers'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import {ChannelPermissionOverwrite} from '@app/api/models/ChannelPermissionOverwrite'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {ALL_PERMISSIONS, ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {ContentWarningLevel, GuildFeatures, resolveVoiceChannelBitrate} from '@fluxer/constants/src/GuildConstants'; @@ -24,25 +43,6 @@ import { } from '@fluxer/schema/src/domains/channel/GuildChannelOrdering'; import {ChannelNameType} from '@fluxer/schema/src/primitives/ChannelValidators'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import type {ChannelID, EmojiID, GuildID, RoleID, StickerID, UserID} from '../../../BrandedTypes'; -import {createChannelID, createRoleID, createUserID} from '../../../BrandedTypes'; -import {mapChannelToResponse} from '../../../channel/ChannelMappers'; -import type {IChannelRepository} from '../../../channel/IChannelRepository'; -import type {PermissionOverwrite} from '../../../database/types/ChannelTypes'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import {Logger} from '../../../Logger'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../../models/Channel'; -import {ChannelPermissionOverwrite} from '../../../models/ChannelPermissionOverwrite'; -import type {GuildAuditLogService} from '../../GuildAuditLogService'; -import type {GuildAuditLogChange} from '../../GuildAuditLogTypes'; -import type {IGuildRepositoryAggregate} from '../../repositories/IGuildRepositoryAggregate'; -import {ChannelHelpers, type ChannelReorderOperation} from './ChannelHelpers'; export class ChannelOperationsService { constructor( diff --git a/fluxer_api/src/api/guild/services/content/ContentHelpers.ts b/fluxer_api/src/api/guild/services/content/ContentHelpers.ts index 4f9a3c41d..5d630370e 100644 --- a/fluxer_api/src/api/guild/services/content/ContentHelpers.ts +++ b/fluxer_api/src/api/guild/services/content/ContentHelpers.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {EmojiID, GuildID, StickerID, UserID} from '@app/api/BrandedTypes'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildAuditLogChange} from '@app/api/guild/GuildAuditLogTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import type {GuildEmoji} from '@app/api/models/GuildEmoji'; +import type {GuildSticker} from '@app/api/models/GuildSticker'; +import {serializeEmojiForAudit, serializeStickerForAudit} from '@app/api/utils/AuditSerializationUtils'; +import {hasPermission, requirePermission} from '@app/api/utils/PermissionUtils'; import type {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import type {EmojiID, GuildID, StickerID, UserID} from '../../../BrandedTypes'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import {Logger} from '../../../Logger'; -import type {GuildEmoji} from '../../../models/GuildEmoji'; -import type {GuildSticker} from '../../../models/GuildSticker'; -import {serializeEmojiForAudit, serializeStickerForAudit} from '../../../utils/AuditSerializationUtils'; -import {hasPermission, requirePermission} from '../../../utils/PermissionUtils'; -import type {GuildAuditLogService} from '../../GuildAuditLogService'; -import type {GuildAuditLogChange} from '../../GuildAuditLogTypes'; export class ContentHelpers { constructor( diff --git a/fluxer_api/src/api/guild/services/content/EmojiService.ts b/fluxer_api/src/api/guild/services/content/EmojiService.ts index c1cadc028..3358a8aa9 100644 --- a/fluxer_api/src/api/guild/services/content/EmojiService.ts +++ b/fluxer_api/src/api/guild/services/content/EmojiService.ts @@ -1,5 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createEmojiID, type EmojiID, type GuildID, type UserID} from '@app/api/BrandedTypes'; +import {getContentMessage} from '@app/api/content_i18n/ContentI18n'; +import {mapGuildEmojisWithUsersToResponse, mapGuildEmojiToResponse} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {ContentHelpers} from '@app/api/guild/services/content/ContentHelpers'; +import type {ExpressionAssetPurger} from '@app/api/guild/services/content/ExpressionAssetPurger'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {GuildEmoji} from '@app/api/models/GuildEmoji'; +import type {User} from '@app/api/models/User'; +import {getCachedUserPartialResponse} from '@app/api/user/UserCacheHelpers'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; @@ -12,22 +28,6 @@ import {getErrorMessageUnsafe} from '@fluxer/errors/src/i18n/ErrorI18n'; import {resolveLimit} from '@fluxer/limits/src/LimitResolver'; import type {GuildEmojiResponse, GuildEmojiWithUserResponse} from '@fluxer/schema/src/domains/guild/GuildEmojiSchemas'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import {createEmojiID, type EmojiID, type GuildID, type UserID} from '../../../BrandedTypes'; -import {getContentMessage} from '../../../content_i18n/ContentI18n'; -import type {AvatarService} from '../../../infrastructure/AvatarService'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {GuildEmoji} from '../../../models/GuildEmoji'; -import type {User} from '../../../models/User'; -import {getCachedUserPartialResponse} from '../../../user/UserCacheHelpers'; -import {mapGuildEmojisWithUsersToResponse, mapGuildEmojiToResponse} from '../../GuildModel'; -import type {IGuildRepositoryAggregate} from '../../repositories/IGuildRepositoryAggregate'; -import type {ContentHelpers} from './ContentHelpers'; -import type {ExpressionAssetPurger} from './ExpressionAssetPurger'; export class EmojiService { constructor( diff --git a/fluxer_api/src/api/guild/services/content/ExpressionAssetPurger.ts b/fluxer_api/src/api/guild/services/content/ExpressionAssetPurger.ts index 613517467..5fbd51e1e 100644 --- a/fluxer_api/src/api/guild/services/content/ExpressionAssetPurger.ts +++ b/fluxer_api/src/api/guild/services/content/ExpressionAssetPurger.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {IAssetDeletionQueue} from '@app/api/infrastructure/IAssetDeletionQueue'; import {getExtensionWhitelist} from '@fluxer/constants/src/AssetFormatPolicy'; -import {Config} from '../../../Config'; -import type {IAssetDeletionQueue} from '../../../infrastructure/IAssetDeletionQueue'; const STICKER_EXTENSIONS = getExtensionWhitelist('sticker'); diff --git a/fluxer_api/src/api/guild/services/content/StickerService.ts b/fluxer_api/src/api/guild/services/content/StickerService.ts index 750606e21..d4e88c3b9 100644 --- a/fluxer_api/src/api/guild/services/content/StickerService.ts +++ b/fluxer_api/src/api/guild/services/content/StickerService.ts @@ -1,5 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createStickerID, type GuildID, type StickerID, type UserID} from '@app/api/BrandedTypes'; +import {getContentMessage} from '@app/api/content_i18n/ContentI18n'; +import {mapGuildStickersWithUsersToResponse, mapGuildStickerToResponse} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {ContentHelpers} from '@app/api/guild/services/content/ContentHelpers'; +import type {ExpressionAssetPurger} from '@app/api/guild/services/content/ExpressionAssetPurger'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {GuildSticker} from '@app/api/models/GuildSticker'; +import type {User} from '@app/api/models/User'; +import {getCachedUserPartialResponse} from '@app/api/user/UserCacheHelpers'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; @@ -15,23 +32,6 @@ import type { GuildStickerWithUserResponse, } from '@fluxer/schema/src/domains/guild/GuildEmojiSchemas'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import {createStickerID, type GuildID, type StickerID, type UserID} from '../../../BrandedTypes'; -import {getContentMessage} from '../../../content_i18n/ContentI18n'; -import type {AvatarService} from '../../../infrastructure/AvatarService'; -import {contentModerationService} from '../../../infrastructure/ContentModerationService'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {GuildSticker} from '../../../models/GuildSticker'; -import type {User} from '../../../models/User'; -import {getCachedUserPartialResponse} from '../../../user/UserCacheHelpers'; -import {mapGuildStickersWithUsersToResponse, mapGuildStickerToResponse} from '../../GuildModel'; -import type {IGuildRepositoryAggregate} from '../../repositories/IGuildRepositoryAggregate'; -import type {ContentHelpers} from './ContentHelpers'; -import type {ExpressionAssetPurger} from './ExpressionAssetPurger'; export class StickerService { constructor( diff --git a/fluxer_api/src/api/guild/services/data/GuildDataHelpers.ts b/fluxer_api/src/api/guild/services/data/GuildDataHelpers.ts index 399d4f6a1..e48ec9183 100644 --- a/fluxer_api/src/api/guild/services/data/GuildDataHelpers.ts +++ b/fluxer_api/src/api/guild/services/data/GuildDataHelpers.ts @@ -1,21 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, EmojiID, GuildID, RoleID, StickerID, UserID} from '@app/api/BrandedTypes'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildAuditLogChange} from '@app/api/guild/GuildAuditLogTypes'; +import {mapGuildToGuildResponse} from '@app/api/guild/GuildModel'; +import {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; +import {createGuildMfaEnforcer} from '@app/api/guild/services/GuildMfaEnforcement'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import type {Guild} from '@app/api/models/Guild'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {serializeGuildForAudit as serializeGuildForAuditUtil} from '@app/api/utils/AuditSerializationUtils'; +import {requirePermission} from '@app/api/utils/PermissionUtils'; import type {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {AccessDeniedError} from '@fluxer/errors/src/domains/core/AccessDeniedError'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {ChannelID, EmojiID, GuildID, RoleID, StickerID, UserID} from '../../../BrandedTypes'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import {Logger} from '../../../Logger'; -import type {Guild} from '../../../models/Guild'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {serializeGuildForAudit as serializeGuildForAuditUtil} from '../../../utils/AuditSerializationUtils'; -import {requirePermission} from '../../../utils/PermissionUtils'; -import type {GuildAuditLogService} from '../../GuildAuditLogService'; -import type {GuildAuditLogChange} from '../../GuildAuditLogTypes'; -import {mapGuildToGuildResponse} from '../../GuildModel'; -import {GuildRepository} from '../../repositories/GuildRepository'; -import {createGuildMfaEnforcer} from '../GuildMfaEnforcement'; interface GuildAuth { guildData: GuildResponse; diff --git a/fluxer_api/src/api/guild/services/data/GuildOperationsService.ts b/fluxer_api/src/api/guild/services/data/GuildOperationsService.ts index 173c3ca8e..54e2ddf5a 100644 --- a/fluxer_api/src/api/guild/services/data/GuildOperationsService.ts +++ b/fluxer_api/src/api/guild/services/data/GuildOperationsService.ts @@ -1,5 +1,36 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, RoleID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createGuildID, createRoleID, guildIdToRoleId} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import {BatchBuilder} from '@app/api/database/CassandraQueryExecution'; +import type {PermissionOverwrite} from '@app/api/database/types/ChannelTypes'; +import type {GuildRow} from '@app/api/database/types/GuildTypes'; +import {mapGuildToGuildResponse, mapGuildToPartialResponse} from '@app/api/guild/GuildModel'; +import type {IGuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildDataHelpers} from '@app/api/guild/services/data/GuildDataHelpers'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {EntityAssetService, PreparedAssetUpload} from '@app/api/infrastructure/EntityAssetService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {InviteRepository} from '@app/api/invite/InviteRepository'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {Guild} from '@app/api/models/Guild'; +import type {User} from '@app/api/models/User'; +import {getGuildSearchService} from '@app/api/SearchFactory'; +import type {GuildDiscoveryContext} from '@app/api/search/guild/GuildSearchSerializer'; +import {deleteChannelMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import {Channels, ChannelsByGuild, GuildMembers, GuildMembersByUserId, GuildRoles, Guilds} from '@app/api/Tables'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapUserSettingsToResponse} from '@app/api/user/UserMappers'; +import {addGuildToUncategorizedFolder, removeGuildFromUserFolders} from '@app/api/user/utils/GuildFolderUtils'; +import type {IWebhookRepository} from '@app/api/webhook/IWebhookRepository'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {ALL_PERMISSIONS, ChannelTypes, DEFAULT_PERMISSIONS, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {DiscoveryApplicationStatus} from '@fluxer/constants/src/DiscoveryConstants'; @@ -38,37 +69,6 @@ import type { TemplateSerializedGuild, } from '@fluxer/schema/src/domains/guild/GuildTemplateSchemas'; import {extractTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; -import type {ChannelID, GuildID, RoleID, UserID} from '../../../BrandedTypes'; -import {createChannelID, createGuildID, createRoleID, guildIdToRoleId} from '../../../BrandedTypes'; -import type {IChannelRepository} from '../../../channel/IChannelRepository'; -import type {ChannelService} from '../../../channel/services/ChannelService'; -import {BatchBuilder} from '../../../database/CassandraQueryExecution'; -import type {PermissionOverwrite} from '../../../database/types/ChannelTypes'; -import type {GuildRow} from '../../../database/types/GuildTypes'; -import {contentModerationService} from '../../../infrastructure/ContentModerationService'; -import type {EntityAssetService, PreparedAssetUpload} from '../../../infrastructure/EntityAssetService'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../../infrastructure/ISnowflakeService'; -import type {InviteRepository} from '../../../invite/InviteRepository'; -import {Logger} from '../../../Logger'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import {Guild} from '../../../models/Guild'; -import type {User} from '../../../models/User'; -import {getGuildSearchService} from '../../../SearchFactory'; -import type {GuildDiscoveryContext} from '../../../search/guild/GuildSearchSerializer'; -import {deleteChannelMessageSearchDocuments} from '../../../search/MessageSearchIndexCleanup'; -import {Channels, ChannelsByGuild, GuildMembers, GuildMembersByUserId, GuildRoles, Guilds} from '../../../Tables'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {mapUserSettingsToResponse} from '../../../user/UserMappers'; -import {addGuildToUncategorizedFolder, removeGuildFromUserFolders} from '../../../user/utils/GuildFolderUtils'; -import type {IWebhookRepository} from '../../../webhook/IWebhookRepository'; -import {mapGuildToGuildResponse, mapGuildToPartialResponse} from '../../GuildModel'; -import type {IGuildDiscoveryRepository} from '../../repositories/GuildDiscoveryRepository'; -import type {IGuildRepositoryAggregate} from '../../repositories/IGuildRepositoryAggregate'; -import type {GuildDataHelpers} from './GuildDataHelpers'; const DEFAULT_TEXT_CATEGORY_NAME = 'Text Channels'; const DEFAULT_VOICE_CATEGORY_NAME = 'Voice Channels'; diff --git a/fluxer_api/src/api/guild/services/data/GuildOwnershipService.ts b/fluxer_api/src/api/guild/services/data/GuildOwnershipService.ts index a3befc8ce..a25778dac 100644 --- a/fluxer_api/src/api/guild/services/data/GuildOwnershipService.ts +++ b/fluxer_api/src/api/guild/services/data/GuildOwnershipService.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {mapGuildToGuildResponse} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildDataHelpers} from '@app/api/guild/services/data/GuildDataHelpers'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {User} from '@app/api/models/User'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {checkGuildVerificationWithGuildModel} from '@app/api/utils/GuildVerificationUtils'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {MissingAccessError} from '@fluxer/errors/src/domains/core/MissingAccessError'; import {MissingPermissionsError} from '@fluxer/errors/src/domains/core/MissingPermissionsError'; @@ -7,15 +16,6 @@ import {CannotTransferOwnershipToBotError} from '@fluxer/errors/src/domains/guil import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import {UnknownGuildMemberError} from '@fluxer/errors/src/domains/guild/UnknownGuildMemberError'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {GuildID, UserID} from '../../../BrandedTypes'; -import type {Guild} from '../../../models/Guild'; -import type {GuildMember} from '../../../models/GuildMember'; -import type {User} from '../../../models/User'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {checkGuildVerificationWithGuildModel} from '../../../utils/GuildVerificationUtils'; -import {mapGuildToGuildResponse} from '../../GuildModel'; -import type {IGuildRepositoryAggregate} from '../../repositories/IGuildRepositoryAggregate'; -import type {GuildDataHelpers} from './GuildDataHelpers'; export class GuildOwnershipService { constructor( diff --git a/fluxer_api/src/api/guild/services/data/GuildVanityService.ts b/fluxer_api/src/api/guild/services/data/GuildVanityService.ts index e4bd9fcda..9350f739a 100644 --- a/fluxer_api/src/api/guild/services/data/GuildVanityService.ts +++ b/fluxer_api/src/api/guild/services/data/GuildVanityService.ts @@ -1,5 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createInviteCode, + createVanityURLCode, + type GuildID, + type UserID, + vanityCodeToInviteCode, +} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildDataHelpers} from '@app/api/guild/services/data/GuildDataHelpers'; +import type {InviteRepository} from '@app/api/invite/InviteRepository'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {InviteTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; @@ -7,17 +18,6 @@ import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import type {GuildVanityURLResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import { - createInviteCode, - createVanityURLCode, - type GuildID, - type UserID, - vanityCodeToInviteCode, -} from '../../../BrandedTypes'; -import type {InviteRepository} from '../../../invite/InviteRepository'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {IGuildRepositoryAggregate} from '../../repositories/IGuildRepositoryAggregate'; -import type {GuildDataHelpers} from './GuildDataHelpers'; export class GuildVanityService { constructor( diff --git a/fluxer_api/src/api/guild/services/member/GuildMemberAuditService.ts b/fluxer_api/src/api/guild/services/member/GuildMemberAuditService.ts index c8112fed1..bb7c7744b 100644 --- a/fluxer_api/src/api/guild/services/member/GuildMemberAuditService.ts +++ b/fluxer_api/src/api/guild/services/member/GuildMemberAuditService.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildAuditLogChange} from '@app/api/guild/GuildAuditLogTypes'; +import {Logger} from '@app/api/Logger'; +import type {GuildMember} from '@app/api/models/GuildMember'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; -import type {GuildID, UserID} from '../../../BrandedTypes'; -import {Logger} from '../../../Logger'; -import type {GuildMember} from '../../../models/GuildMember'; -import type {GuildAuditLogService} from '../../GuildAuditLogService'; -import type {GuildAuditLogChange} from '../../GuildAuditLogTypes'; export class GuildMemberAuditService { constructor(private readonly guildAuditLogService: GuildAuditLogService) {} diff --git a/fluxer_api/src/api/guild/services/member/GuildMemberAuthService.ts b/fluxer_api/src/api/guild/services/member/GuildMemberAuthService.ts index 0624dc6f8..bf13275c2 100644 --- a/fluxer_api/src/api/guild/services/member/GuildMemberAuthService.ts +++ b/fluxer_api/src/api/guild/services/member/GuildMemberAuthService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, RoleID, UserID} from '@app/api/BrandedTypes'; +import {createGuildMfaEnforcer} from '@app/api/guild/services/GuildMfaEnforcement'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {MissingAccessError} from '@fluxer/errors/src/domains/core/MissingAccessError'; import {MissingPermissionsError} from '@fluxer/errors/src/domains/core/MissingPermissionsError'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {GuildID, RoleID, UserID} from '../../../BrandedTypes'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {createGuildMfaEnforcer} from '../GuildMfaEnforcement'; interface GuildAuth { guildData: GuildResponse; diff --git a/fluxer_api/src/api/guild/services/member/GuildMemberEventService.ts b/fluxer_api/src/api/guild/services/member/GuildMemberEventService.ts index ea1e87eca..a9ef767d4 100644 --- a/fluxer_api/src/api/guild/services/member/GuildMemberEventService.ts +++ b/fluxer_api/src/api/guild/services/member/GuildMemberEventService.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../../BrandedTypes'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {GuildMember} from '../../../models/GuildMember'; -import {mapGuildMemberToResponse} from '../../GuildModel'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {mapGuildMemberToResponse} from '@app/api/guild/GuildModel'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {GuildMember} from '@app/api/models/GuildMember'; export class GuildMemberEventService { constructor( diff --git a/fluxer_api/src/api/guild/services/member/GuildMemberOperationsService.ts b/fluxer_api/src/api/guild/services/member/GuildMemberOperationsService.ts index acbd1fe43..2f21d7ccf 100644 --- a/fluxer_api/src/api/guild/services/member/GuildMemberOperationsService.ts +++ b/fluxer_api/src/api/guild/services/member/GuildMemberOperationsService.ts @@ -1,5 +1,49 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireEmailVerified} from '@app/api/auth/EmailVerificationUtils'; +import type {GuildID, InviteCode, RoleID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createRoleID} from '@app/api/BrandedTypes'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import {assertMutableUserId} from '@app/api/constants/Core'; +import type {GuildMemberRow} from '@app/api/database/types/GuildTypes'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildAuditLogChange} from '@app/api/guild/GuildAuditLogTypes'; +import {resolveMaxGuildMembersLimit} from '@app/api/guild/GuildMemberLimitUtils'; +import {mapGuildMemberToResponse} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildMemberAuthService} from '@app/api/guild/services/member/GuildMemberAuthService'; +import type {GuildMemberEventService} from '@app/api/guild/services/member/GuildMemberEventService'; +import type {GuildMemberSearchIndexService} from '@app/api/guild/services/member/GuildMemberSearchIndexService'; +import type {GuildMemberValidationService} from '@app/api/guild/services/member/GuildMemberValidationService'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {EntityAssetService, PreparedAssetUpload} from '@app/api/infrastructure/EntityAssetService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {User} from '@app/api/models/User'; +import type {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import type {UserSettings} from '@app/api/models/UserSettings'; +import { + DEFAULT_PHONE_GATE_MEMBER_THRESHOLD, + evaluateDeferredPhoneGate, + getDeferredPhoneGateConfig, + guildTriggersPhoneGate, +} from '@app/api/risk/DeferredPhoneGate'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {getEffectiveSuspiciousFlags, isProfileSubstringExempt} from '@app/api/user/UserHelpers'; +import { + mapUserGuildSettingsToResponse, + mapUserSettingsToResponse, + mapUserToPrivateResponse, +} from '@app/api/user/UserMappers'; +import {addGuildToUncategorizedFolder, removeGuildFromUserFolders} from '@app/api/user/utils/GuildFolderUtils'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import { @@ -32,50 +76,6 @@ import type {GuildMemberUpdateRequest} from '@fluxer/schema/src/domains/guild/Gu import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; import {ms} from 'itty-time'; -import {requireEmailVerified} from '../../../auth/EmailVerificationUtils'; -import type {GuildID, InviteCode, RoleID, UserID} from '../../../BrandedTypes'; -import {createChannelID, createRoleID} from '../../../BrandedTypes'; -import type {ChannelService} from '../../../channel/services/ChannelService'; -import {assertMutableUserId} from '../../../constants/Core'; -import type {GuildMemberRow} from '../../../database/types/GuildTypes'; -import {contentModerationService} from '../../../infrastructure/ContentModerationService'; -import type {EntityAssetService, PreparedAssetUpload} from '../../../infrastructure/EntityAssetService'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../../infrastructure/UserCacheService'; -import {Logger} from '../../../Logger'; -import type {LimitConfigService} from '../../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../../limits/LimitMatchContextBuilder'; -import {profileSubstringBlocklistCache} from '../../../middleware/ProfileSubstringBlocklistCache'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {Guild} from '../../../models/Guild'; -import type {GuildMember} from '../../../models/GuildMember'; -import type {User} from '../../../models/User'; -import type {UserGuildSettings} from '../../../models/UserGuildSettings'; -import type {UserSettings} from '../../../models/UserSettings'; -import { - DEFAULT_PHONE_GATE_MEMBER_THRESHOLD, - evaluateDeferredPhoneGate, - getDeferredPhoneGateConfig, - guildTriggersPhoneGate, -} from '../../../risk/DeferredPhoneGate'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import {getEffectiveSuspiciousFlags, isProfileSubstringExempt} from '../../../user/UserHelpers'; -import { - mapUserGuildSettingsToResponse, - mapUserSettingsToResponse, - mapUserToPrivateResponse, -} from '../../../user/UserMappers'; -import {addGuildToUncategorizedFolder, removeGuildFromUserFolders} from '../../../user/utils/GuildFolderUtils'; -import type {GuildAuditLogService} from '../../GuildAuditLogService'; -import type {GuildAuditLogChange} from '../../GuildAuditLogTypes'; -import {resolveMaxGuildMembersLimit} from '../../GuildMemberLimitUtils'; -import {mapGuildMemberToResponse} from '../../GuildModel'; -import type {IGuildRepositoryAggregate} from '../../repositories/IGuildRepositoryAggregate'; -import type {GuildMemberAuthService} from './GuildMemberAuthService'; -import type {GuildMemberEventService} from './GuildMemberEventService'; -import type {GuildMemberSearchIndexService} from './GuildMemberSearchIndexService'; -import type {GuildMemberValidationService} from './GuildMemberValidationService'; const MEMBERSHIP_METADATA_TTL_SECONDS = 365 * 24 * 60 * 60; diff --git a/fluxer_api/src/api/guild/services/member/GuildMemberRoleService.ts b/fluxer_api/src/api/guild/services/member/GuildMemberRoleService.ts index ab5e64d5a..0705d1fb9 100644 --- a/fluxer_api/src/api/guild/services/member/GuildMemberRoleService.ts +++ b/fluxer_api/src/api/guild/services/member/GuildMemberRoleService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, RoleID, UserID} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildMemberAuthService} from '@app/api/guild/services/member/GuildMemberAuthService'; +import type {GuildMemberValidationService} from '@app/api/guild/services/member/GuildMemberValidationService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; import {UnknownGuildMemberError} from '@fluxer/errors/src/domains/guild/UnknownGuildMemberError'; -import type {GuildID, RoleID, UserID} from '../../../BrandedTypes'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; -import type {RequestCache} from '../../../middleware/RequestCacheMiddleware'; -import type {IGuildRepositoryAggregate} from '../../repositories/IGuildRepositoryAggregate'; -import type {GuildMemberAuthService} from './GuildMemberAuthService'; -import type {GuildMemberValidationService} from './GuildMemberValidationService'; export class GuildMemberRoleService { constructor( diff --git a/fluxer_api/src/api/guild/services/member/GuildMemberSearchIndexService.ts b/fluxer_api/src/api/guild/services/member/GuildMemberSearchIndexService.ts index 0de89d84a..390131d95 100644 --- a/fluxer_api/src/api/guild/services/member/GuildMemberSearchIndexService.ts +++ b/fluxer_api/src/api/guild/services/member/GuildMemberSearchIndexService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../../BrandedTypes'; -import {Logger} from '../../../Logger'; -import type {GuildMember} from '../../../models/GuildMember'; -import type {User} from '../../../models/User'; -import {getGuildMemberSearchService} from '../../../SearchFactory'; -import type {IGuildMemberSearchService} from '../../../search/IGuildMemberSearchService'; -import type {IGuildRepositoryAggregate} from '../../repositories/IGuildRepositoryAggregate'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {Logger} from '@app/api/Logger'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {User} from '@app/api/models/User'; +import {getGuildMemberSearchService} from '@app/api/SearchFactory'; +import type {IGuildMemberSearchService} from '@app/api/search/IGuildMemberSearchService'; interface GuildMemberSearchIndexOptions { includeDefault?: boolean; diff --git a/fluxer_api/src/api/guild/services/member/GuildMemberValidationService.ts b/fluxer_api/src/api/guild/services/member/GuildMemberValidationService.ts index 8aae49ed6..2c5fdfcdc 100644 --- a/fluxer_api/src/api/guild/services/member/GuildMemberValidationService.ts +++ b/fluxer_api/src/api/guild/services/member/GuildMemberValidationService.ts @@ -1,5 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, RoleID, UserID} from '@app/api/BrandedTypes'; +import {guildIdToRoleId} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {Logger} from '@app/api/Logger'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import {getIpBanBlastRadiusVerdict, isSingleIpBanCandidate} from '@app/api/risk/IpBanCgnatGuard'; +import {isIpBanExempt} from '@app/api/risk/IpBanExemptions'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; @@ -10,14 +18,6 @@ import {UnknownGuildRoleError} from '@fluxer/errors/src/domains/guild/UnknownGui import {isSameIpDecisionMatch} from '@fluxer/ip_utils/src/IpAddress'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import type {IpInfoService} from '@pkgs/geoip/src/IpInfoService'; -import type {GuildID, RoleID, UserID} from '../../../BrandedTypes'; -import {guildIdToRoleId} from '../../../BrandedTypes'; -import {Logger} from '../../../Logger'; -import type {GuildMember} from '../../../models/GuildMember'; -import {getIpBanBlastRadiusVerdict, isSingleIpBanCandidate} from '../../../risk/IpBanCgnatGuard'; -import {isIpBanExempt} from '../../../risk/IpBanExemptions'; -import type {IUserRepository} from '../../../user/IUserRepository'; -import type {IGuildRepositoryAggregate} from '../../repositories/IGuildRepositoryAggregate'; function ensureNotEveryoneRole(roleId: RoleID, guildId: GuildID, path: string): void { if (roleId === guildIdToRoleId(guildId)) { diff --git a/fluxer_api/src/api/guild/tests/DiscoveryApplicationLifecycle.test.ts b/fluxer_api/src/api/guild/tests/DiscoveryApplicationLifecycle.test.ts index c8ec8d596..a9d742776 100644 --- a/fluxer_api/src/api/guild/tests/DiscoveryApplicationLifecycle.test.ts +++ b/fluxer_api/src/api/guild/tests/DiscoveryApplicationLifecycle.test.ts @@ -1,5 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs, type TestAccount, totpCodeNow} from '@app/api/auth/tests/AuthTestUtils'; +import { + addMemberRole, + createGuild, + createRole, + getGuild, + setupTestGuildWithMembers, +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {DiscoveryCategories, type DiscoveryCategory} from '@fluxer/constants/src/DiscoveryConstants'; @@ -9,11 +20,6 @@ import type { DiscoveryStatusResponse, } from '@fluxer/schema/src/domains/guild/GuildDiscoverySchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs, type TestAccount, totpCodeNow} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {addMemberRole, createGuild, createRole, getGuild, setupTestGuildWithMembers} from './GuildTestUtils'; const TOTP_SECRET = 'JBSWY3DPEHPK3PXP'; diff --git a/fluxer_api/src/api/guild/tests/DiscoveryApplicationValidation.test.ts b/fluxer_api/src/api/guild/tests/DiscoveryApplicationValidation.test.ts index eef90ed2d..ab69ecabb 100644 --- a/fluxer_api/src/api/guild/tests/DiscoveryApplicationValidation.test.ts +++ b/fluxer_api/src/api/guild/tests/DiscoveryApplicationValidation.test.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild, setupTestGuildWithMembers} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_IDS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {DiscoveryCategories} from '@fluxer/constants/src/DiscoveryConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; @@ -8,11 +13,6 @@ import type { DiscoveryStatusResponse, } from '@fluxer/schema/src/domains/guild/GuildDiscoverySchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_IDS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createGuild, setupTestGuildWithMembers} from './GuildTestUtils'; type FormBodyError = { code: string; diff --git a/fluxer_api/src/api/guild/tests/DiscoverySearchAndJoin.test.ts b/fluxer_api/src/api/guild/tests/DiscoverySearchAndJoin.test.ts index c321d3661..6df8b6ce1 100644 --- a/fluxer_api/src/api/guild/tests/DiscoverySearchAndJoin.test.ts +++ b/fluxer_api/src/api/guild/tests/DiscoverySearchAndJoin.test.ts @@ -1,5 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import type {GuildID} from '@app/api/BrandedTypes'; +import {createTestBotAccount} from '@app/api/bot/tests/BotTestUtils'; +import {createGuild, getUserGuilds} from '@app/api/guild/tests/GuildTestUtils'; +import {setInjectedGatewayService} from '@app/api/middleware/ServiceRegistry'; +import {getGuildRepository} from '@app/api/middleware/ServiceSingletons'; +import {banUser} from '@app/api/moderation/tests/ModerationTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import {NoopGatewayService} from '@app/api/test/NoopGatewayService'; +import {HTTP_STATUS, TEST_IDS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import syncDiscoveryIndex from '@app/api/worker/tasks/SyncDiscoveryIndex'; +import {clearWorkerDependencies, setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {DiscoveryCategories, DiscoveryCategoryLabels} from '@fluxer/constants/src/DiscoveryConstants'; import {GuildVerificationLevel} from '@fluxer/constants/src/GuildConstants'; @@ -10,20 +24,6 @@ import type { } from '@fluxer/schema/src/domains/guild/GuildDiscoverySchemas'; import type {WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import type {GuildID} from '../../BrandedTypes'; -import {createTestBotAccount} from '../../bot/tests/BotTestUtils'; -import {setInjectedGatewayService} from '../../middleware/ServiceRegistry'; -import {getGuildRepository} from '../../middleware/ServiceSingletons'; -import {banUser} from '../../moderation/tests/ModerationTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {NoopLogger} from '../../test/mocks/NoopLogger'; -import {NoopGatewayService} from '../../test/NoopGatewayService'; -import {HTTP_STATUS, TEST_IDS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import syncDiscoveryIndex from '../../worker/tasks/SyncDiscoveryIndex'; -import {clearWorkerDependencies, setWorkerDependenciesForTest} from '../../worker/WorkerContext'; -import {createGuild, getUserGuilds} from './GuildTestUtils'; async function setGuildMemberCount(harness: ApiTestHarness, guildId: string, memberCount: number): Promise { await createBuilder(harness, '') diff --git a/fluxer_api/src/api/guild/tests/GuildAssetUpload.test.ts b/fluxer_api/src/api/guild/tests/GuildAssetUpload.test.ts index ab91ad07e..274e42575 100644 --- a/fluxer_api/src/api/guild/tests/GuildAssetUpload.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildAssetUpload.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {getGifDataUrl, getPngDataUrl, getSvgDataUrl} from '@app/api/emoji/tests/EmojiTestUtils'; +import {createGuild, updateGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {getGifDataUrl, getPngDataUrl, getSvgDataUrl} from '../../emoji/tests/EmojiTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createGuild, updateGuild} from './GuildTestUtils'; const AVATAR_MAX_SIZE = 10 * 1024 * 1024; diff --git a/fluxer_api/src/api/guild/tests/GuildAuditLogs.test.ts b/fluxer_api/src/api/guild/tests/GuildAuditLogs.test.ts index 2834e8b05..585625489 100644 --- a/fluxer_api/src/api/guild/tests/GuildAuditLogs.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildAuditLogs.test.ts @@ -1,16 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {authorizeBot, createTestBotAccount} from '@app/api/bot/tests/BotTestUtils'; +import { + createChannel, + createChannelInvite, + createRole, + setupTestGuildWithMembers, + updateRole, +} from '@app/api/guild/tests/GuildTestUtils'; +import {deleteMessage, sendMessage} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {createWebhook} from '@app/api/webhook/tests/WebhookTestUtils'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {authorizeBot, createTestBotAccount} from '../../bot/tests/BotTestUtils'; -import {deleteMessage, sendMessage} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createWebhook} from '../../webhook/tests/WebhookTestUtils'; -import {createChannel, createChannelInvite, createRole, setupTestGuildWithMembers, updateRole} from './GuildTestUtils'; interface AuditLogChange { key: string; diff --git a/fluxer_api/src/api/guild/tests/GuildChannelManagement.test.ts b/fluxer_api/src/api/guild/tests/GuildChannelManagement.test.ts index 1f3ce2e0e..b1e71fb7c 100644 --- a/fluxer_api/src/api/guild/tests/GuildChannelManagement.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildChannelManagement.test.ts @@ -1,10 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; -import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { addMemberRole, createChannel, @@ -12,11 +8,15 @@ import { getChannel, setupTestGuildWithMembers, updateChannel, -} from '../../channel/tests/ChannelTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createGuild, getGuildChannels} from './GuildTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {createGuild, getGuildChannels} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; +import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('Guild Channel Management', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildChannelPositions.test.ts b/fluxer_api/src/api/guild/tests/GuildChannelPositions.test.ts index a3b2324bc..3a8a2b354 100644 --- a/fluxer_api/src/api/guild/tests/GuildChannelPositions.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildChannelPositions.test.ts @@ -1,14 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuildID} from '../../BrandedTypes'; -import {ChannelRepository} from '../../channel/ChannelRepository'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuildID} from '@app/api/BrandedTypes'; +import {ChannelRepository} from '@app/api/channel/ChannelRepository'; import { acceptInvite, addMemberRole, @@ -19,7 +13,13 @@ import { getChannel, getGuildChannels, updateChannelPositions, -} from './GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('Guild Channel Positions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildCreationEmailVerification.test.ts b/fluxer_api/src/api/guild/tests/GuildCreationEmailVerification.test.ts index f0fd3bd20..9e9ac356d 100644 --- a/fluxer_api/src/api/guild/tests/GuildCreationEmailVerification.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildCreationEmailVerification.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GuildOperationsService} from '@app/api/guild/services/data/GuildOperationsService'; +import type {User} from '@app/api/models/User'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {describe, expect, it} from 'vitest'; -import type {User} from '../../models/User'; -import {GuildOperationsService} from '../services/data/GuildOperationsService'; const REACHED_GUILD_COUNT = new Error('reached guild count lookup'); diff --git a/fluxer_api/src/api/guild/tests/GuildExpressionCloneOptIn.test.ts b/fluxer_api/src/api/guild/tests/GuildExpressionCloneOptIn.test.ts index e402a36b7..4d3e342e2 100644 --- a/fluxer_api/src/api/guild/tests/GuildExpressionCloneOptIn.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildExpressionCloneOptIn.test.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, setUserACLs, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {getPngDataUrl} from '@app/api/emoji/tests/EmojiTestUtils'; +import {createGuild, getGuild, updateGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import type { @@ -10,12 +16,6 @@ import type { } from '@fluxer/schema/src/domains/guild/GuildEmojiSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {afterAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, setUserACLs, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {getPngDataUrl} from '../../emoji/tests/EmojiTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createGuild, getGuild, updateGuild} from './GuildTestUtils'; interface CloneSource { owner: TestAccount; diff --git a/fluxer_api/src/api/guild/tests/GuildFeatures.test.ts b/fluxer_api/src/api/guild/tests/GuildFeatures.test.ts index afc5b7165..682b299ee 100644 --- a/fluxer_api/src/api/guild/tests/GuildFeatures.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildFeatures.test.ts @@ -1,13 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; -import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { addMemberRole, createGuild, @@ -16,7 +9,14 @@ import { updateGuild, updateMember, updateRolePositions, -} from './GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; +import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; interface AuditLogEntry { id: string; diff --git a/fluxer_api/src/api/guild/tests/GuildFolderOperations.test.ts b/fluxer_api/src/api/guild/tests/GuildFolderOperations.test.ts index 556b7e0f7..56e110f17 100644 --- a/fluxer_api/src/api/guild/tests/GuildFolderOperations.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildFolderOperations.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {authorizeBot, createTestBotAccount} from '@app/api/bot/tests/BotTestUtils'; +import {acceptInvite, createChannelInvite, createGuild, getChannel} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {UNCATEGORIZED_FOLDER_ID} from '@fluxer/constants/src/UserConstants'; import type {UserSettingsResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {authorizeBot, createTestBotAccount} from '../../bot/tests/BotTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {acceptInvite, createChannelInvite, createGuild, getChannel} from './GuildTestUtils'; describe('Guild Folder Operations', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildGetFullPayload.test.ts b/fluxer_api/src/api/guild/tests/GuildGetFullPayload.test.ts index a56ad1bde..f4e8ff473 100644 --- a/fluxer_api/src/api/guild/tests/GuildGetFullPayload.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildGetFullPayload.test.ts @@ -1,8 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannel, @@ -10,8 +8,10 @@ import { createGuild, createPermissionOverwrite, getGuild, -} from '../../channel/tests/ChannelTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('GET /guilds/:guild_id full payload', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildMemberManagement.test.ts b/fluxer_api/src/api/guild/tests/GuildMemberManagement.test.ts index cd09836ba..0d1f3dabb 100644 --- a/fluxer_api/src/api/guild/tests/GuildMemberManagement.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildMemberManagement.test.ts @@ -1,18 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; -import type {GuildBanResponse, GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {getPngDataUrl, getTooLargePngDataUrl} from '../../emoji/tests/EmojiTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {profileSubstringBlocklistCache} from '../../middleware/ProfileSubstringBlocklistCache'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {grantPremium} from '../../user/tests/UserTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {getPngDataUrl, getTooLargePngDataUrl} from '@app/api/emoji/tests/EmojiTestUtils'; import { addMemberRole, createRole, @@ -21,7 +10,18 @@ import { setupTestGuildWithMembers, updateMember, updateRolePositions, -} from './GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {grantPremium} from '@app/api/user/tests/UserTestUtils'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; +import type {GuildBanResponse, GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('Guild Member Management', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildMemberVoiceMove.test.ts b/fluxer_api/src/api/guild/tests/GuildMemberVoiceMove.test.ts index cf0a25ca2..4c209949a 100644 --- a/fluxer_api/src/api/guild/tests/GuildMemberVoiceMove.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildMemberVoiceMove.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannel, setupTestGuildWithMembers} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {afterEach, beforeEach, describe, test} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createChannel, setupTestGuildWithMembers} from './GuildTestUtils'; describe('Guild Member Voice Move', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildMfaLevel.test.ts b/fluxer_api/src/api/guild/tests/GuildMfaLevel.test.ts index f87d1512f..b8b261f78 100644 --- a/fluxer_api/src/api/guild/tests/GuildMfaLevel.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildMfaLevel.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, type TestAccount, totpCodeNow} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild, setupTestGuildWithMembers} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {GuildMFALevel} from '@fluxer/constants/src/GuildConstants'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount, type TestAccount, totpCodeNow} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createGuild, setupTestGuildWithMembers} from './GuildTestUtils'; const TOTP_SECRET = 'JBSWY3DPEHPK3PXP'; diff --git a/fluxer_api/src/api/guild/tests/GuildModel.test.ts b/fluxer_api/src/api/guild/tests/GuildModel.test.ts index 9d23c8ff2..e5e61aa66 100644 --- a/fluxer_api/src/api/guild/tests/GuildModel.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildModel.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import type {GuildRow} from '@app/api/database/types/GuildTypes'; +import {mapGuildToGuildResponse, mapGuildToPartialResponse} from '@app/api/guild/GuildModel'; +import {Guild} from '@app/api/models/Guild'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import {describe, expect, test} from 'vitest'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import type {GuildRow} from '../../database/types/GuildTypes'; -import {Guild} from '../../models/Guild'; -import {mapGuildToGuildResponse, mapGuildToPartialResponse} from '../GuildModel'; function createGuild(overrides: Partial = {}): Guild { return new Guild({ diff --git a/fluxer_api/src/api/guild/tests/GuildOperationPermissions.test.ts b/fluxer_api/src/api/guild/tests/GuildOperationPermissions.test.ts index 5373bdc64..e8ea4b00f 100644 --- a/fluxer_api/src/api/guild/tests/GuildOperationPermissions.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildOperationPermissions.test.ts @@ -1,14 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {GuildFeatures, GuildNSFWLevel} from '@fluxer/constants/src/GuildConstants'; -import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {authorizeBot, createTestBotAccount} from '../../bot/tests/BotTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {authorizeBot, createTestBotAccount} from '@app/api/bot/tests/BotTestUtils'; import { acceptInvite, addMemberRole, @@ -17,7 +10,14 @@ import { createRole, getChannel, leaveGuild, -} from './GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {GuildFeatures, GuildNSFWLevel} from '@fluxer/constants/src/GuildConstants'; +import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; +import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Guild Operation Permissions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildOperationValidation.test.ts b/fluxer_api/src/api/guild/tests/GuildOperationValidation.test.ts index 5844c1da5..28ec897b4 100644 --- a/fluxer_api/src/api/guild/tests/GuildOperationValidation.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildOperationValidation.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_IDS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_IDS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('Guild Operation Validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildOwnershipTransfer.test.ts b/fluxer_api/src/api/guild/tests/GuildOwnershipTransfer.test.ts index 07274b6cd..b1fb6ddfe 100644 --- a/fluxer_api/src/api/guild/tests/GuildOwnershipTransfer.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildOwnershipTransfer.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {acceptInvite, createChannelInvite, createGuild, getChannel} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_CREDENTIALS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_CREDENTIALS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {acceptInvite, createChannelInvite, createGuild, getChannel} from './GuildTestUtils'; describe('Guild Ownership Transfer', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildRoleManagement.test.ts b/fluxer_api/src/api/guild/tests/GuildRoleManagement.test.ts index 2ad6315a1..674fe250e 100644 --- a/fluxer_api/src/api/guild/tests/GuildRoleManagement.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildRoleManagement.test.ts @@ -1,11 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, addMemberRole, @@ -16,7 +11,12 @@ import { getChannel, getRoles, updateRolePositions, -} from './GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('Guild Role Management', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildRoleOperations.test.ts b/fluxer_api/src/api/guild/tests/GuildRoleOperations.test.ts index 0b6c9fb2e..05203ffc7 100644 --- a/fluxer_api/src/api/guild/tests/GuildRoleOperations.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildRoleOperations.test.ts @@ -1,13 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuildID, createRoleID} from '../../BrandedTypes'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {GuildRoleRepository} from '../repositories/GuildRoleRepository'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuildID, createRoleID} from '@app/api/BrandedTypes'; +import {GuildRoleRepository} from '@app/api/guild/repositories/GuildRoleRepository'; import { acceptInvite, addMemberRole, @@ -18,7 +13,12 @@ import { getChannel, getRoles, updateRolePositions, -} from './GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('Guild Role Operations', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildRoleReorder.test.ts b/fluxer_api/src/api/guild/tests/GuildRoleReorder.test.ts index 2d671a174..17f172097 100644 --- a/fluxer_api/src/api/guild/tests/GuildRoleReorder.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildRoleReorder.test.ts @@ -1,11 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, addMemberRole, @@ -15,7 +10,12 @@ import { getChannel, getRoles, updateRolePositions, -} from './GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('Guild Role Reorder', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildTemplateImport.test.ts b/fluxer_api/src/api/guild/tests/GuildTemplateImport.test.ts index e759c42cf..6ffb38f74 100644 --- a/fluxer_api/src/api/guild/tests/GuildTemplateImport.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildTemplateImport.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {getGuildChannels, getRoles} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {SystemChannelFlags} from '@fluxer/constants/src/GuildConstants'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {getGuildChannels, getRoles} from './GuildTestUtils'; describe('Guild Template Import', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/GuildTestUtils.ts b/fluxer_api/src/api/guild/tests/GuildTestUtils.ts index b9697f1ba..638a67be2 100644 --- a/fluxer_api/src/api/guild/tests/GuildTestUtils.ts +++ b/fluxer_api/src/api/guild/tests/GuildTestUtils.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; import type {GuildUpdateRequest} from '@fluxer/schema/src/domains/guild/GuildRequestSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import type {GuildRoleResponse} from '@fluxer/schema/src/domains/guild/GuildRoleSchemas'; import type {GuildInviteMetadataResponse} from '@fluxer/schema/src/domains/invite/InviteSchemas'; -import {createTestAccount, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; export async function createGuild(harness: ApiTestHarness, token: string, name: string): Promise { return createBuilder(harness, token).post('/guilds').body({name}).execute(); diff --git a/fluxer_api/src/api/guild/tests/GuildUnavailableFeatureAccess.test.ts b/fluxer_api/src/api/guild/tests/GuildUnavailableFeatureAccess.test.ts index c6438b197..821c1e6ee 100644 --- a/fluxer_api/src/api/guild/tests/GuildUnavailableFeatureAccess.test.ts +++ b/fluxer_api/src/api/guild/tests/GuildUnavailableFeatureAccess.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {acceptInvite, createChannelInvite, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {acceptInvite, createChannelInvite, createGuild} from './GuildTestUtils'; const STAFF_TEST_FLAGS = UserFlags.HAS_SESSION_STARTED | UserFlags.STAFF; diff --git a/fluxer_api/src/api/guild/tests/InvitePermissions.test.ts b/fluxer_api/src/api/guild/tests/InvitePermissions.test.ts index 10b77572b..3b00da777 100644 --- a/fluxer_api/src/api/guild/tests/InvitePermissions.test.ts +++ b/fluxer_api/src/api/guild/tests/InvitePermissions.test.ts @@ -1,12 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import type {GuildInviteMetadataResponse} from '@fluxer/schema/src/domains/invite/InviteSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, addMemberRole, @@ -18,7 +12,13 @@ import { getRoles, setupTestGuildWithMembers, updateRole, -} from './GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import type {GuildInviteMetadataResponse} from '@fluxer/schema/src/domains/invite/InviteSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('Invite Permissions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/InviteSecurity.test.ts b/fluxer_api/src/api/guild/tests/InviteSecurity.test.ts index 9f87c4f4b..391dd88ad 100644 --- a/fluxer_api/src/api/guild/tests/InviteSecurity.test.ts +++ b/fluxer_api/src/api/guild/tests/InviteSecurity.test.ts @@ -1,11 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { addMemberRole, createChannelInvite, @@ -14,7 +9,12 @@ import { deleteInvite, getChannel, setupTestGuildWithMembers, -} from './GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('Invite Security', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/InviteValidation.test.ts b/fluxer_api/src/api/guild/tests/InviteValidation.test.ts index eef45f669..f7e4ae407 100644 --- a/fluxer_api/src/api/guild/tests/InviteValidation.test.ts +++ b/fluxer_api/src/api/guild/tests/InviteValidation.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild, deleteInvite, getChannel} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {GuildInviteMetadataResponse} from '@fluxer/schema/src/domains/invite/InviteSchemas'; import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createGuild, deleteInvite, getChannel} from './GuildTestUtils'; describe('Invite Validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/RoleHierarchyEnforcement.test.ts b/fluxer_api/src/api/guild/tests/RoleHierarchyEnforcement.test.ts index 3f279f661..6d97d34d9 100644 --- a/fluxer_api/src/api/guild/tests/RoleHierarchyEnforcement.test.ts +++ b/fluxer_api/src/api/guild/tests/RoleHierarchyEnforcement.test.ts @@ -1,10 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannelInvite, @@ -15,7 +11,11 @@ import { updateMember, updateRole, updateRolePositions, -} from './GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Role Hierarchy Enforcement', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/guild/tests/RolePermissionAssignmentHierarchy.test.ts b/fluxer_api/src/api/guild/tests/RolePermissionAssignmentHierarchy.test.ts index 01effbc23..5fb6419a5 100644 --- a/fluxer_api/src/api/guild/tests/RolePermissionAssignmentHierarchy.test.ts +++ b/fluxer_api/src/api/guild/tests/RolePermissionAssignmentHierarchy.test.ts @@ -1,11 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + acceptInvite, + createChannelInvite, + createGuild, + createRole, + getChannel, + updateRole, +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {acceptInvite, createChannelInvite, createGuild, createRole, getChannel, updateRole} from './GuildTestUtils'; describe('Role Permission Assignment Hierarchy', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/infrastructure/AssetDeletionQueue.ts b/fluxer_api/src/api/infrastructure/AssetDeletionQueue.ts index 0532c0ff4..fb9aa5e17 100644 --- a/fluxer_api/src/api/infrastructure/AssetDeletionQueue.ts +++ b/fluxer_api/src/api/infrastructure/AssetDeletionQueue.ts @@ -1,10 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type { + IAssetDeletionQueue, + QueuedAssetDeletion, + QueuedAssetReference, +} from '@app/api/infrastructure/IAssetDeletionQueue'; +import {Logger} from '@app/api/Logger'; +import {isJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; +import {isValidTimestamp} from '@app/api/utils/TimestampUtils'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {Logger} from '../Logger'; -import {isJsonRecord, parseJsonWithGuard} from '../utils/JsonBoundaryUtils'; -import {isValidTimestamp} from '../utils/TimestampUtils'; -import type {IAssetDeletionQueue, QueuedAssetDeletion, QueuedAssetReference} from './IAssetDeletionQueue'; const QUEUE_KEY = 'asset:deletion:queue'; const MAX_RETRIES = 5; diff --git a/fluxer_api/src/api/infrastructure/AssetEntitlementUtils.ts b/fluxer_api/src/api/infrastructure/AssetEntitlementUtils.ts index 74def9bd7..31f643a9a 100644 --- a/fluxer_api/src/api/infrastructure/AssetEntitlementUtils.ts +++ b/fluxer_api/src/api/infrastructure/AssetEntitlementUtils.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getGlobalLimitConfigSnapshot} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {User} from '@app/api/models/User'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; -import {getGlobalLimitConfigSnapshot} from '../limits/LimitConfigService'; -import {resolveLimitSafe} from '../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; -import type {User} from '../models/User'; const ANIMATED_PREFIX = 'a_'; diff --git a/fluxer_api/src/api/infrastructure/AvatarService.ts b/fluxer_api/src/api/infrastructure/AvatarService.ts index 619b6699e..cd22b504e 100644 --- a/fluxer_api/src/api/infrastructure/AvatarService.ts +++ b/fluxer_api/src/api/infrastructure/AvatarService.ts @@ -1,6 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; +import {Config} from '@app/api/Config'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {IMediaService, MediaProxyMetadataResponse} from '@app/api/infrastructure/IMediaService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {stripNonJpegImageMetadata} from '@app/api/infrastructure/StorageObjectHelpers'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import {bannedAvatarHashCache} from '@app/api/middleware/BannedAvatarHashCache'; import { type AssetKind, formatAssetUploadExtensions, @@ -14,15 +23,6 @@ import {ContentBlockedError} from '@fluxer/errors/src/domains/content/ContentBlo import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {resolveLimit} from '@fluxer/limits/src/LimitResolver'; import sharp from 'sharp'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; -import {bannedAvatarHashCache} from '../middleware/BannedAvatarHashCache'; -import {contentModerationService} from './ContentModerationService'; -import type {IMediaService, MediaProxyMetadataResponse} from './IMediaService'; -import type {IStorageService} from './IStorageService'; -import {stripNonJpegImageMetadata} from './StorageObjectHelpers'; type ResourceType = 'attachment' | 'avatar' | 'emoji' | 'sticker' | 'banner' | 'other'; type LimitConfigSnapshotProvider = Pick; diff --git a/fluxer_api/src/api/infrastructure/AvatarServiceSizeLimits.test.ts b/fluxer_api/src/api/infrastructure/AvatarServiceSizeLimits.test.ts index 958c57cd4..6fab2e210 100644 --- a/fluxer_api/src/api/infrastructure/AvatarServiceSizeLimits.test.ts +++ b/fluxer_api/src/api/infrastructure/AvatarServiceSizeLimits.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AvatarService} from '@app/api/infrastructure/AvatarService'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; import {EMOJI_MAX_SIZE, STICKER_MAX_SIZE} from '@fluxer/constants/src/LimitConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {LimitConfigSnapshot, LimitRule} from '@fluxer/limits/src/LimitTypes'; import {describe, expect, it} from 'vitest'; -import {AvatarService} from './AvatarService'; -import type {IMediaService} from './IMediaService'; -import type {IStorageService} from './IStorageService'; function createSnapshot(rules: Array = []): LimitConfigSnapshot { return {traitDefinitions: [], rules}; diff --git a/fluxer_api/src/api/infrastructure/BunnyPurgeQueue.ts b/fluxer_api/src/api/infrastructure/BunnyPurgeQueue.ts index 228191ae7..cf7ad62d3 100644 --- a/fluxer_api/src/api/infrastructure/BunnyPurgeQueue.ts +++ b/fluxer_api/src/api/infrastructure/BunnyPurgeQueue.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Logger} from '@app/api/Logger'; import type {IKVProvider, KVPurgeBatchResult} from '@pkgs/kv_client/src/IKVProvider'; -import {Logger} from '../Logger'; export interface IPurgeQueue { addUrls(urls: Array): Promise; diff --git a/fluxer_api/src/api/infrastructure/ContentModerationService.ts b/fluxer_api/src/api/infrastructure/ContentModerationService.ts index b3efed0bf..c04d531e7 100644 --- a/fluxer_api/src/api/infrastructure/ContentModerationService.ts +++ b/fluxer_api/src/api/infrastructure/ContentModerationService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import {Logger} from '@app/api/Logger'; +import {fileShaCache} from '@app/api/middleware/FileShaCache'; +import {phraseBlocklistCache} from '@app/api/middleware/PhraseBlocklistCache'; +import {urlBlocklistCache} from '@app/api/middleware/UrlBlocklistCache'; +import {extractUrlCandidates} from '@app/api/utils/UrlNormalizer'; import {ContentBlockedError} from '@fluxer/errors/src/domains/content/ContentBlockedError'; -import {Logger} from '../Logger'; -import {fileShaCache} from '../middleware/FileShaCache'; -import {phraseBlocklistCache} from '../middleware/PhraseBlocklistCache'; -import {urlBlocklistCache} from '../middleware/UrlBlocklistCache'; -import {extractUrlCandidates} from '../utils/UrlNormalizer'; export interface ModerationContext { userId: bigint | null; diff --git a/fluxer_api/src/api/infrastructure/DisabledLiveKitService.ts b/fluxer_api/src/api/infrastructure/DisabledLiveKitService.ts index d3b6d8738..b7a319252 100644 --- a/fluxer_api/src/api/infrastructure/DisabledLiveKitService.ts +++ b/fluxer_api/src/api/infrastructure/DisabledLiveKitService.ts @@ -1,8 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, UserID} from '../BrandedTypes'; -import type {VoiceRegionMetadata, VoiceServerRecord} from '../voice/VoiceModel'; -import type {ILiveKitService, ListActiveRoomsResult, ListParticipantsResult} from './ILiveKitService'; +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import type { + ILiveKitService, + ListActiveRoomsResult, + ListParticipantsResult, +} from '@app/api/infrastructure/ILiveKitService'; +import type {VoiceRegionMetadata, VoiceServerRecord} from '@app/api/voice/VoiceModel'; interface CreateTokenParams { userId: UserID; diff --git a/fluxer_api/src/api/infrastructure/DiscriminatorService.ts b/fluxer_api/src/api/infrastructure/DiscriminatorService.ts index a5d501957..7ab932d23 100644 --- a/fluxer_api/src/api/infrastructure/DiscriminatorService.ts +++ b/fluxer_api/src/api/infrastructure/DiscriminatorService.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomInt} from 'node:crypto'; +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {User} from '@app/api/models/User'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {NON_SELF_HOSTED_RESERVED_DISCRIMINATORS} from '@fluxer/constants/src/DiscriminatorConstants'; import {BadRequestError} from '@fluxer/errors/src/domains/core/BadRequestError'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {ms, seconds} from 'itty-time'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import {resolveLimitSafe} from '../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; -import type {User} from '../models/User'; -import type {IUserRepository} from '../user/IUserRepository'; interface GenerateDiscriminatorParams { username: string; diff --git a/fluxer_api/src/api/infrastructure/ElasticsearchSearchProvider.ts b/fluxer_api/src/api/infrastructure/ElasticsearchSearchProvider.ts index d1a1a5f55..7c0bc12e4 100644 --- a/fluxer_api/src/api/infrastructure/ElasticsearchSearchProvider.ts +++ b/fluxer_api/src/api/infrastructure/ElasticsearchSearchProvider.ts @@ -1,24 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ILogger} from '@app/api/ILogger'; +import {ElasticsearchAuditLogSearchService} from '@app/api/search/elasticsearch/ElasticsearchAuditLogSearchService'; +import {ElasticsearchGuildMemberSearchService} from '@app/api/search/elasticsearch/ElasticsearchGuildMemberSearchService'; +import {ElasticsearchGuildSearchService} from '@app/api/search/elasticsearch/ElasticsearchGuildSearchService'; +import {ElasticsearchMessageSearchService} from '@app/api/search/elasticsearch/ElasticsearchMessageSearchService'; +import {ElasticsearchReportSearchService} from '@app/api/search/elasticsearch/ElasticsearchReportSearchService'; +import {ElasticsearchUserSearchService} from '@app/api/search/elasticsearch/ElasticsearchUserSearchService'; +import type {IAuditLogSearchService} from '@app/api/search/IAuditLogSearchService'; +import type {IGuildMemberSearchService} from '@app/api/search/IGuildMemberSearchService'; +import type {IGuildSearchService} from '@app/api/search/IGuildSearchService'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import type {IReportSearchService} from '@app/api/search/IReportSearchService'; +import type {ISearchProvider} from '@app/api/search/ISearchProvider'; +import type {IUserSearchService} from '@app/api/search/IUserSearchService'; import type {ElasticsearchDistributedLock} from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchIndexAdapter'; import { createElasticsearchClient, type ElasticsearchClientConfig, } from '@pkgs/elasticsearch_search/src/ElasticsearchClient'; -import type {ILogger} from '../ILogger'; -import {ElasticsearchAuditLogSearchService} from '../search/elasticsearch/ElasticsearchAuditLogSearchService'; -import {ElasticsearchGuildMemberSearchService} from '../search/elasticsearch/ElasticsearchGuildMemberSearchService'; -import {ElasticsearchGuildSearchService} from '../search/elasticsearch/ElasticsearchGuildSearchService'; -import {ElasticsearchMessageSearchService} from '../search/elasticsearch/ElasticsearchMessageSearchService'; -import {ElasticsearchReportSearchService} from '../search/elasticsearch/ElasticsearchReportSearchService'; -import {ElasticsearchUserSearchService} from '../search/elasticsearch/ElasticsearchUserSearchService'; -import type {IAuditLogSearchService} from '../search/IAuditLogSearchService'; -import type {IGuildMemberSearchService} from '../search/IGuildMemberSearchService'; -import type {IGuildSearchService} from '../search/IGuildSearchService'; -import type {IMessageSearchService} from '../search/IMessageSearchService'; -import type {IReportSearchService} from '../search/IReportSearchService'; -import type {ISearchProvider} from '../search/ISearchProvider'; -import type {IUserSearchService} from '../search/IUserSearchService'; interface ElasticsearchSearchProviderOptions { config: ElasticsearchClientConfig; @@ -47,7 +47,7 @@ export class ElasticsearchSearchProvider implements ISearchProvider { const client = createElasticsearchClient(this.config); const lock = this.lock; this.messageService = new ElasticsearchMessageSearchService({client, lock}); - const {GuildDiscoveryRepository} = await import('../guild/repositories/GuildDiscoveryRepository'); + const {GuildDiscoveryRepository} = await import('@app/api/guild/repositories/GuildDiscoveryRepository'); this.guildService = new ElasticsearchGuildSearchService({ client, lock, diff --git a/fluxer_api/src/api/infrastructure/EmailDnsValidationService.ts b/fluxer_api/src/api/infrastructure/EmailDnsValidationService.ts index e08c7b4ec..7d57c14dd 100644 --- a/fluxer_api/src/api/infrastructure/EmailDnsValidationService.ts +++ b/fluxer_api/src/api/infrastructure/EmailDnsValidationService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {Resolver} from 'node:dns/promises'; +import {Config} from '@app/api/Config'; +import type {IEmailDnsValidationService} from '@app/api/infrastructure/IEmailDnsValidationService'; +import {Logger} from '@app/api/Logger'; import {ms} from 'itty-time'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import type {IEmailDnsValidationService} from './IEmailDnsValidationService'; interface DomainValidationCacheEntry { valid: boolean; @@ -42,7 +42,7 @@ const DNS_LOOKUP_TRIES = 1; const MAX_CACHED_DOMAINS = 10000; async function isInstanceEmailEnabled(): Promise { - const {getInstanceConfigRepository} = await import('../middleware/ServiceSingletons'); + const {getInstanceConfigRepository} = await import('@app/api/middleware/ServiceSingletons'); return getInstanceConfigRepository().isEmailEnabled(); } diff --git a/fluxer_api/src/api/infrastructure/EmbedService.ts b/fluxer_api/src/api/infrastructure/EmbedService.ts index dd6e2c9f2..5c26c3dae 100644 --- a/fluxer_api/src/api/infrastructure/EmbedService.ts +++ b/fluxer_api/src/api/infrastructure/EmbedService.ts @@ -1,5 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID} from '@app/api/BrandedTypes'; +import type {RichEmbedMediaWithMetadata} from '@app/api/channel/EmbedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {nextVersion} from '@app/api/database/CassandraTypes'; +import type {MessageEmbed, MessageEmbedChild} from '@app/api/database/types/MessageTypes'; +import { + type IMediaService, + type MediaProxyMetadataResponse, + type MediaProxyNsfwMode, + mediaProxyMetadataPolicy, +} from '@app/api/infrastructure/IMediaService'; +import type {IUnfurlerService, UnfurlOptions} from '@app/api/infrastructure/IUnfurlerService'; +import {Logger} from '@app/api/Logger'; +import {Embed} from '@app/api/models/Embed'; +import {EmbedAuthor} from '@app/api/models/EmbedAuthor'; +import {EmbedField} from '@app/api/models/EmbedField'; +import {EmbedFooter} from '@app/api/models/EmbedFooter'; +import {EmbedMedia} from '@app/api/models/EmbedMedia'; +import * as UnfurlerUtils from '@app/api/utils/UnfurlerUtils'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; +import {WorkerQueueOverflowError} from '@app/api/worker/WorkerQueueOverflowError'; import {EmbedMediaFlags} from '@fluxer/constants/src/ChannelConstants'; import {MAX_EMBEDS_PER_MESSAGE} from '@fluxer/constants/src/LimitConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; @@ -12,27 +33,6 @@ import type { RichEmbedRequest, } from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import type {ChannelID, MessageID} from '../BrandedTypes'; -import type {RichEmbedMediaWithMetadata} from '../channel/EmbedTypes'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import {nextVersion} from '../database/CassandraTypes'; -import type {MessageEmbed, MessageEmbedChild} from '../database/types/MessageTypes'; -import {Logger} from '../Logger'; -import {Embed} from '../models/Embed'; -import {EmbedAuthor} from '../models/EmbedAuthor'; -import {EmbedField} from '../models/EmbedField'; -import {EmbedFooter} from '../models/EmbedFooter'; -import {EmbedMedia} from '../models/EmbedMedia'; -import * as UnfurlerUtils from '../utils/UnfurlerUtils'; -import type {WorkerTaskName} from '../worker/WorkerLaneConfig'; -import {WorkerQueueOverflowError} from '../worker/WorkerQueueOverflowError'; -import { - type IMediaService, - type MediaProxyMetadataResponse, - type MediaProxyNsfwMode, - mediaProxyMetadataPolicy, -} from './IMediaService'; -import type {IUnfurlerService, UnfurlOptions} from './IUnfurlerService'; interface CreateEmbedsParams { channelId: ChannelID; diff --git a/fluxer_api/src/api/infrastructure/EntityAssetService.ts b/fluxer_api/src/api/infrastructure/EntityAssetService.ts index e67f0f593..46e8ff9d7 100644 --- a/fluxer_api/src/api/infrastructure/EntityAssetService.ts +++ b/fluxer_api/src/api/infrastructure/EntityAssetService.ts @@ -2,6 +2,15 @@ import crypto from 'node:crypto'; import {setTimeout as delay} from 'node:timers/promises'; +import {Config} from '@app/api/Config'; +import type {IAssetDeletionQueue, QueuedAssetReference} from '@app/api/infrastructure/IAssetDeletionQueue'; +import type {IMediaService, MediaProxyMetadataResponse} from '@app/api/infrastructure/IMediaService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {stripNonJpegImageMetadata} from '@app/api/infrastructure/StorageObjectHelpers'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import {awaitAll} from '@app/api/utils/ConcurrencyUtils'; import { type AssetKind, formatAssetUploadExtensions, @@ -14,15 +23,6 @@ import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidat import {resolveLimit} from '@fluxer/limits/src/LimitResolver'; import {ms} from 'itty-time'; import sharp from 'sharp'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; -import {awaitAll} from '../utils/ConcurrencyUtils'; -import type {IAssetDeletionQueue, QueuedAssetReference} from './IAssetDeletionQueue'; -import type {IMediaService, MediaProxyMetadataResponse} from './IMediaService'; -import type {IStorageService} from './IStorageService'; -import {stripNonJpegImageMetadata} from './StorageObjectHelpers'; type AssetType = 'avatar' | 'banner' | 'icon' | 'splash' | 'embed_splash' | 'branding'; type EntityType = 'user' | 'guild' | 'guild_member' | 'instance'; diff --git a/fluxer_api/src/api/infrastructure/GatewayRpcClient.ts b/fluxer_api/src/api/infrastructure/GatewayRpcClient.ts index eef916969..51e386ff9 100644 --- a/fluxer_api/src/api/infrastructure/GatewayRpcClient.ts +++ b/fluxer_api/src/api/infrastructure/GatewayRpcClient.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {GatewayRpcMethodError, GatewayRpcMethodErrorCodes} from '@app/api/infrastructure/GatewayRpcError'; +import type {IGatewayRpcTransport} from '@app/api/infrastructure/IGatewayRpcTransport'; +import type {CallData} from '@app/api/infrastructure/IGatewayService'; +import {NatsGatewayRpcTransport} from '@app/api/infrastructure/NatsGatewayRpcTransport'; +import {Logger} from '@app/api/Logger'; import {NatsConnectionManager} from '@pkgs/nats/src/NatsConnectionManager'; import {ms} from 'itty-time'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import {GatewayRpcMethodError, GatewayRpcMethodErrorCodes} from './GatewayRpcError'; -import type {IGatewayRpcTransport} from './IGatewayRpcTransport'; -import type {CallData} from './IGatewayService'; -import {NatsGatewayRpcTransport} from './NatsGatewayRpcTransport'; const MAX_RETRY_ATTEMPTS = 2; diff --git a/fluxer_api/src/api/infrastructure/GatewayService.ts b/fluxer_api/src/api/infrastructure/GatewayService.ts index be2fc683c..a2bdad9e9 100644 --- a/fluxer_api/src/api/infrastructure/GatewayService.ts +++ b/fluxer_api/src/api/infrastructure/GatewayService.ts @@ -1,5 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, MessageID, RoleID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createGuildID, createRoleID, createUserID} from '@app/api/BrandedTypes'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import type {GatewayDispatchEvent} from '@app/api/constants/Gateway'; +import {GatewayRpcClient} from '@app/api/infrastructure/GatewayRpcClient'; +import {GatewayRpcMethodError, GatewayRpcMethodErrorCodes} from '@app/api/infrastructure/GatewayRpcError'; +import type { + CallData, + GatewayActiveVoiceRooms, + GatewayChannelMention, + GatewayGuildMemoryStats, + GatewayMentionSources, + GatewayMentionSourcesPage, + GatewayNodeStats, + GatewayVoiceStateCounts, + GatewayVoiceStateEntry, + GuildChannelAuthContext, +} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {CallAlreadyExistsError} from '@fluxer/errors/src/domains/channel/CallAlreadyExistsError'; import {InvalidChannelTypeForCallError} from '@fluxer/errors/src/domains/channel/InvalidChannelTypeForCallError'; @@ -16,25 +35,6 @@ import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSc import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {ms} from 'itty-time'; -import type {ChannelID, GuildID, MessageID, RoleID, UserID} from '../BrandedTypes'; -import {createChannelID, createGuildID, createRoleID, createUserID} from '../BrandedTypes'; -import {SYSTEM_USER_ID} from '../constants/Core'; -import type {GatewayDispatchEvent} from '../constants/Gateway'; -import {Logger} from '../Logger'; -import {GatewayRpcClient} from './GatewayRpcClient'; -import {GatewayRpcMethodError, GatewayRpcMethodErrorCodes} from './GatewayRpcError'; -import type { - CallData, - GatewayActiveVoiceRooms, - GatewayChannelMention, - GatewayGuildMemoryStats, - GatewayMentionSources, - GatewayMentionSourcesPage, - GatewayNodeStats, - GatewayVoiceStateCounts, - GatewayVoiceStateEntry, - GuildChannelAuthContext, -} from './IGatewayService'; const PUSH_BADGE_COUNT_BATCH_SIZE = 100; diff --git a/fluxer_api/src/api/infrastructure/IGatewayService.ts b/fluxer_api/src/api/infrastructure/IGatewayService.ts index fde218bef..402a6392f 100644 --- a/fluxer_api/src/api/infrastructure/IGatewayService.ts +++ b/fluxer_api/src/api/infrastructure/IGatewayService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, MessageID, RoleID, UserID} from '@app/api/BrandedTypes'; +import type {GatewayDispatchEvent} from '@app/api/constants/Gateway'; import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import type {ChannelID, GuildID, MessageID, RoleID, UserID} from '../BrandedTypes'; -import type {GatewayDispatchEvent} from '../constants/Gateway'; interface VoiceState { user_id: string; diff --git a/fluxer_api/src/api/infrastructure/ILiveKitService.ts b/fluxer_api/src/api/infrastructure/ILiveKitService.ts index 9353f3c07..f28eec4a9 100644 --- a/fluxer_api/src/api/infrastructure/ILiveKitService.ts +++ b/fluxer_api/src/api/infrastructure/ILiveKitService.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, UserID} from '../BrandedTypes'; -import type {VoiceRegionMetadata, VoiceServerRecord} from '../voice/VoiceModel'; +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import type {VoiceRegionMetadata, VoiceServerRecord} from '@app/api/voice/VoiceModel'; interface CreateTokenParams { userId: UserID; diff --git a/fluxer_api/src/api/infrastructure/IUnfurlerService.ts b/fluxer_api/src/api/infrastructure/IUnfurlerService.ts index c672ba001..ffc83ac3d 100644 --- a/fluxer_api/src/api/infrastructure/IUnfurlerService.ts +++ b/fluxer_api/src/api/infrastructure/IUnfurlerService.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {MediaProxyNsfwMode} from '@app/api/infrastructure/IMediaService'; import type {MessageEmbedResponse} from '@fluxer/schema/src/domains/message/EmbedSchemas'; -import type {MediaProxyNsfwMode} from './IMediaService'; export interface UnfurlResult { embeds: Array; diff --git a/fluxer_api/src/api/infrastructure/IVoiceRoomStore.ts b/fluxer_api/src/api/infrastructure/IVoiceRoomStore.ts index fd5ed56d7..500078344 100644 --- a/fluxer_api/src/api/infrastructure/IVoiceRoomStore.ts +++ b/fluxer_api/src/api/infrastructure/IVoiceRoomStore.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID} from '../BrandedTypes'; +import type {ChannelID, GuildID} from '@app/api/BrandedTypes'; export abstract class IVoiceRoomStore { abstract pinRoomServer( diff --git a/fluxer_api/src/api/infrastructure/InMemoryVoiceRoomStore.ts b/fluxer_api/src/api/infrastructure/InMemoryVoiceRoomStore.ts index d03c0eaf9..74835bb7e 100644 --- a/fluxer_api/src/api/infrastructure/InMemoryVoiceRoomStore.ts +++ b/fluxer_api/src/api/infrastructure/InMemoryVoiceRoomStore.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID} from '../BrandedTypes'; +import type {ChannelID, GuildID} from '@app/api/BrandedTypes'; export class InMemoryVoiceRoomStore { async pinRoomServer( diff --git a/fluxer_api/src/api/infrastructure/KVAccountDeletionQueueService.ts b/fluxer_api/src/api/infrastructure/KVAccountDeletionQueueService.ts index ee0af983c..42a37a867 100644 --- a/fluxer_api/src/api/infrastructure/KVAccountDeletionQueueService.ts +++ b/fluxer_api/src/api/infrastructure/KVAccountDeletionQueueService.ts @@ -1,15 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {parseDeletionQueueMember, parseDeletionQueueUserId} from '@app/api/infrastructure/DeletionQueueMember'; +import {Logger} from '@app/api/Logger'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import { + isPendingDeletionBlocked, + resolvePendingDeletionReasonCode, +} from '@app/api/user/services/PendingDeletionCoordinator'; +import {getValidTimestamp, parseStoredTimestamp} from '@app/api/utils/TimestampUtils'; import {Int32Type} from '@fluxer/schema/src/primitives/SchemaPrimitives'; import {generateLockToken} from '@pkgs/cache/src/CacheLockValidation'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {ms, seconds} from 'itty-time'; -import type {UserID} from '../BrandedTypes'; -import {Logger} from '../Logger'; -import type {UserRepository} from '../user/repositories/UserRepository'; -import {isPendingDeletionBlocked, resolvePendingDeletionReasonCode} from '../user/services/PendingDeletionCoordinator'; -import {getValidTimestamp, parseStoredTimestamp} from '../utils/TimestampUtils'; -import {parseDeletionQueueMember, parseDeletionQueueUserId} from './DeletionQueueMember'; interface QueuedDeletion { userId: bigint; diff --git a/fluxer_api/src/api/infrastructure/KVActivityTracker.ts b/fluxer_api/src/api/infrastructure/KVActivityTracker.ts index 5830f3d26..f8a291ac0 100644 --- a/fluxer_api/src/api/infrastructure/KVActivityTracker.ts +++ b/fluxer_api/src/api/infrastructure/KVActivityTracker.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {getValidTimestamp, parseStoredTimestamp} from '@app/api/utils/TimestampUtils'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {runSlotBatches, splitIntoSlotBatches} from '@pkgs/kv_client/src/KVHashSlots'; import {seconds} from 'itty-time'; -import type {UserID} from '../BrandedTypes'; -import {Logger} from '../Logger'; -import {UserRepository} from '../user/repositories/UserRepository'; -import {getValidTimestamp, parseStoredTimestamp} from '../utils/TimestampUtils'; const TTL_SECONDS = seconds('90 days'); const STATE_VERSION_KEY = 'activity_tracker:state_version'; diff --git a/fluxer_api/src/api/infrastructure/KVBulkMessageDeletionQueueService.test.ts b/fluxer_api/src/api/infrastructure/KVBulkMessageDeletionQueueService.test.ts index ae4540c35..cd6e8679b 100644 --- a/fluxer_api/src/api/infrastructure/KVBulkMessageDeletionQueueService.test.ts +++ b/fluxer_api/src/api/infrastructure/KVBulkMessageDeletionQueueService.test.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {EMPTY_USER_ROW} from '@app/api/database/types/UserTypes'; +import {KVBulkMessageDeletionQueueService} from '@app/api/infrastructure/KVBulkMessageDeletionQueueService'; +import {User} from '@app/api/models/User'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import processPendingBulkMessageDeletions from '@app/api/worker/tasks/ProcessPendingBulkMessageDeletions'; +import {clearWorkerDependencies, setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; +import type {WorkerDependencies} from '@app/api/worker/WorkerDependencies'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import type {WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; import {afterEach, describe, expect, test} from 'vitest'; -import {createUserID, type UserID} from '../BrandedTypes'; -import {EMPTY_USER_ROW} from '../database/types/UserTypes'; -import {User} from '../models/User'; -import {NoopLogger} from '../test/mocks/NoopLogger'; -import type {UserRepository} from '../user/repositories/UserRepository'; -import processPendingBulkMessageDeletions from '../worker/tasks/ProcessPendingBulkMessageDeletions'; -import {clearWorkerDependencies, setWorkerDependenciesForTest} from '../worker/WorkerContext'; -import type {WorkerDependencies} from '../worker/WorkerDependencies'; -import {KVBulkMessageDeletionQueueService} from './KVBulkMessageDeletionQueueService'; class FakeKVProvider { readonly strings = new Map(); diff --git a/fluxer_api/src/api/infrastructure/KVBulkMessageDeletionQueueService.ts b/fluxer_api/src/api/infrastructure/KVBulkMessageDeletionQueueService.ts index d2dae784b..579de2a65 100644 --- a/fluxer_api/src/api/infrastructure/KVBulkMessageDeletionQueueService.ts +++ b/fluxer_api/src/api/infrastructure/KVBulkMessageDeletionQueueService.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; +import type {UserID} from '@app/api/BrandedTypes'; +import {parseDeletionQueueMember, parseDeletionQueueUserId} from '@app/api/infrastructure/DeletionQueueMember'; +import {Logger} from '@app/api/Logger'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {getValidTimestamp, parseStoredTimestamp} from '@app/api/utils/TimestampUtils'; import {generateLockToken} from '@pkgs/cache/src/CacheLockValidation'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {ms, seconds} from 'itty-time'; -import type {UserID} from '../BrandedTypes'; -import {Logger} from '../Logger'; -import type {UserRepository} from '../user/repositories/UserRepository'; -import {getValidTimestamp, parseStoredTimestamp} from '../utils/TimestampUtils'; -import {parseDeletionQueueMember, parseDeletionQueueUserId} from './DeletionQueueMember'; interface QueuedBulkMessageDeletion { userId: bigint; diff --git a/fluxer_api/src/api/infrastructure/LiveKitService.ts b/fluxer_api/src/api/infrastructure/LiveKitService.ts index 5ca65d1c0..fc8d1f59d 100644 --- a/fluxer_api/src/api/infrastructure/LiveKitService.ts +++ b/fluxer_api/src/api/infrastructure/LiveKitService.ts @@ -1,13 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type { + ListActiveRoomsResult, + ListParticipantsResult, + LiveKitServerError, +} from '@app/api/infrastructure/ILiveKitService'; +import {ILiveKitService} from '@app/api/infrastructure/ILiveKitService'; +import {Logger} from '@app/api/Logger'; +import type {VoiceRegionMetadata, VoiceServerRecord} from '@app/api/voice/VoiceModel'; +import type {VoiceTopology} from '@app/api/voice/VoiceTopology'; import {AccessToken, RoomServiceClient, TrackSource} from 'livekit-server-sdk'; -import type {ChannelID, GuildID, UserID} from '../BrandedTypes'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import type {VoiceRegionMetadata, VoiceServerRecord} from '../voice/VoiceModel'; -import type {VoiceTopology} from '../voice/VoiceTopology'; -import type {ListActiveRoomsResult, ListParticipantsResult, LiveKitServerError} from './ILiveKitService'; -import {ILiveKitService} from './ILiveKitService'; interface CreateTokenParams { userId: UserID; diff --git a/fluxer_api/src/api/infrastructure/LiveKitWebhookService.ts b/fluxer_api/src/api/infrastructure/LiveKitWebhookService.ts index 096338968..a0b60f120 100644 --- a/fluxer_api/src/api/infrastructure/LiveKitWebhookService.ts +++ b/fluxer_api/src/api/infrastructure/LiveKitWebhookService.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ILiveKitService} from '@app/api/infrastructure/ILiveKitService'; +import type {IVoiceRoomStore} from '@app/api/infrastructure/IVoiceRoomStore'; +import {isDMRoom, parseParticipantMetadataWithRaw, parseRoomName} from '@app/api/infrastructure/VoiceRoomContext'; +import {Logger} from '@app/api/Logger'; +import type {VoiceTopology} from '@app/api/voice/VoiceTopology'; import type {WebhookEvent} from 'livekit-server-sdk'; import {WebhookReceiver} from 'livekit-server-sdk'; -import type {ChannelID, GuildID} from '../BrandedTypes'; -import {Logger} from '../Logger'; -import type {VoiceTopology} from '../voice/VoiceTopology'; -import type {IGatewayService} from './IGatewayService'; -import type {ILiveKitService} from './ILiveKitService'; -import type {IVoiceRoomStore} from './IVoiceRoomStore'; -import {isDMRoom, parseParticipantMetadataWithRaw, parseRoomName} from './VoiceRoomContext'; interface VoiceWebhookParticipantContext { readonly type: 'dm' | 'guild'; diff --git a/fluxer_api/src/api/infrastructure/MediaService.ts b/fluxer_api/src/api/infrastructure/MediaService.ts index cfd882c8d..1a779a113 100644 --- a/fluxer_api/src/api/infrastructure/MediaService.ts +++ b/fluxer_api/src/api/infrastructure/MediaService.ts @@ -1,12 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ExplicitContentCannotBeSentError} from '@fluxer/errors/src/domains/moderation/ExplicitContentCannotBeSentError'; -import * as MediaProxyUtils from '@pkgs/media_proxy_utils/src/MediaProxyUtils'; -import {ms} from 'itty-time'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import * as FetchUtils from '../utils/FetchUtils'; -import {isJsonRecord, parseJsonWithGuard} from '../utils/JsonBoundaryUtils'; +import {Config} from '@app/api/Config'; import { IMediaService, MEDIA_PROXY_METADATA_REQUEST_VERSION, @@ -15,7 +9,13 @@ import { type MediaProxyMetadataRequest, type MediaProxyMetadataResponse, type MediaProxyNsfwMode, -} from './IMediaService'; +} from '@app/api/infrastructure/IMediaService'; +import {Logger} from '@app/api/Logger'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; +import {isJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; +import {ExplicitContentCannotBeSentError} from '@fluxer/errors/src/domains/moderation/ExplicitContentCannotBeSentError'; +import * as MediaProxyUtils from '@pkgs/media_proxy_utils/src/MediaProxyUtils'; +import {ms} from 'itty-time'; type MediaProxyRequestBody = | MediaProxyMetadataRequest diff --git a/fluxer_api/src/api/infrastructure/MeilisearchSearchProvider.ts b/fluxer_api/src/api/infrastructure/MeilisearchSearchProvider.ts index 9de70ee64..5ac93f048 100644 --- a/fluxer_api/src/api/infrastructure/MeilisearchSearchProvider.ts +++ b/fluxer_api/src/api/infrastructure/MeilisearchSearchProvider.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ILogger} from '../ILogger'; -import type {IAuditLogSearchService} from '../search/IAuditLogSearchService'; -import type {IGuildMemberSearchService} from '../search/IGuildMemberSearchService'; -import type {IGuildSearchService} from '../search/IGuildSearchService'; -import type {IMessageSearchService} from '../search/IMessageSearchService'; -import type {IReportSearchService} from '../search/IReportSearchService'; -import type {ISearchProvider} from '../search/ISearchProvider'; -import type {IUserSearchService} from '../search/IUserSearchService'; -import {type MeilisearchClientConfig, MeilisearchHttpClient} from '../search/meilisearch/MeilisearchClient'; +import type {ILogger} from '@app/api/ILogger'; +import type {IAuditLogSearchService} from '@app/api/search/IAuditLogSearchService'; +import type {IGuildMemberSearchService} from '@app/api/search/IGuildMemberSearchService'; +import type {IGuildSearchService} from '@app/api/search/IGuildSearchService'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import type {IReportSearchService} from '@app/api/search/IReportSearchService'; +import type {ISearchProvider} from '@app/api/search/ISearchProvider'; +import type {IUserSearchService} from '@app/api/search/IUserSearchService'; +import {type MeilisearchClientConfig, MeilisearchHttpClient} from '@app/api/search/meilisearch/MeilisearchClient'; import { MeilisearchAuditLogSearchService, MeilisearchGuildMemberSearchService, @@ -16,7 +16,7 @@ import { MeilisearchMessageSearchService, MeilisearchReportSearchService, MeilisearchUserSearchService, -} from '../search/meilisearch/MeilisearchSearchServices'; +} from '@app/api/search/meilisearch/MeilisearchSearchServices'; interface MeilisearchSearchProviderOptions { config: MeilisearchClientConfig; @@ -41,7 +41,7 @@ export class MeilisearchSearchProvider implements ISearchProvider { async initialize(): Promise { const client = new MeilisearchHttpClient(this.config); this.messageService = new MeilisearchMessageSearchService(client); - const {GuildDiscoveryRepository} = await import('../guild/repositories/GuildDiscoveryRepository'); + const {GuildDiscoveryRepository} = await import('@app/api/guild/repositories/GuildDiscoveryRepository'); this.guildService = new MeilisearchGuildSearchService(client, new GuildDiscoveryRepository()); this.userService = new MeilisearchUserSearchService(client); this.reportService = new MeilisearchReportSearchService(client); diff --git a/fluxer_api/src/api/infrastructure/NatsGatewayRpcTransport.ts b/fluxer_api/src/api/infrastructure/NatsGatewayRpcTransport.ts index 870cfcd08..624a0cb42 100644 --- a/fluxer_api/src/api/infrastructure/NatsGatewayRpcTransport.ts +++ b/fluxer_api/src/api/infrastructure/NatsGatewayRpcTransport.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GatewayRpcMethodError, GatewayRpcMethodErrorCodes} from '@app/api/infrastructure/GatewayRpcError'; +import type {IGatewayRpcTransport} from '@app/api/infrastructure/IGatewayRpcTransport'; +import {Logger} from '@app/api/Logger'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import {type Msg, StringCodec} from 'nats'; -import {Logger} from '../Logger'; -import {GatewayRpcMethodError, GatewayRpcMethodErrorCodes} from './GatewayRpcError'; -import type {IGatewayRpcTransport} from './IGatewayRpcTransport'; const NATS_REQUEST_TIMEOUT_MS = 5000; const NATS_SUBJECT_PREFIX = 'rpc.gateway.'; diff --git a/fluxer_api/src/api/infrastructure/NatsUnfurlerService.test.ts b/fluxer_api/src/api/infrastructure/NatsUnfurlerService.test.ts index af8cbd807..a39809d03 100644 --- a/fluxer_api/src/api/infrastructure/NatsUnfurlerService.test.ts +++ b/fluxer_api/src/api/infrastructure/NatsUnfurlerService.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {NatsUnfurlerService} from '@app/api/infrastructure/NatsUnfurlerService'; import {BadGatewayError} from '@fluxer/errors/src/domains/core/BadGatewayError'; import {GatewayTimeoutError} from '@fluxer/errors/src/domains/core/GatewayTimeoutError'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import {type NatsConnection, StringCodec} from 'nats'; import {describe, expect, it} from 'vitest'; -import {NatsUnfurlerService} from './NatsUnfurlerService'; interface FakeRequest { subject: string; diff --git a/fluxer_api/src/api/infrastructure/NatsUnfurlerService.ts b/fluxer_api/src/api/infrastructure/NatsUnfurlerService.ts index b0038156d..3e953050a 100644 --- a/fluxer_api/src/api/infrastructure/NatsUnfurlerService.ts +++ b/fluxer_api/src/api/infrastructure/NatsUnfurlerService.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {MediaProxyNsfwMode} from '@app/api/infrastructure/IMediaService'; +import {IUnfurlerService, type UnfurlOptions, type UnfurlResult} from '@app/api/infrastructure/IUnfurlerService'; +import {throwForSvcErrorReply} from '@app/api/infrastructure/SvcErrorReply'; +import {Logger} from '@app/api/Logger'; +import {isJsonRecord, parseJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; import {BadGatewayError} from '@fluxer/errors/src/domains/core/BadGatewayError'; import {GatewayTimeoutError} from '@fluxer/errors/src/domains/core/GatewayTimeoutError'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; @@ -7,11 +12,6 @@ import {FluxerError} from '@fluxer/errors/src/FluxerError'; import type {MessageEmbedResponse} from '@fluxer/schema/src/domains/message/EmbedSchemas'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import {StringCodec} from 'nats'; -import {Logger} from '../Logger'; -import {isJsonRecord, parseJsonRecord, parseJsonWithGuard} from '../utils/JsonBoundaryUtils'; -import type {MediaProxyNsfwMode} from './IMediaService'; -import {IUnfurlerService, type UnfurlOptions, type UnfurlResult} from './IUnfurlerService'; -import {throwForSvcErrorReply} from './SvcErrorReply'; const NATS_UNFURL_SUBJECT = 'svc.unfurl'; const NATS_UNFURL_TIMEOUT_MS = 12000; diff --git a/fluxer_api/src/api/infrastructure/NullSearchProvider.ts b/fluxer_api/src/api/infrastructure/NullSearchProvider.ts index 3ed52d0e5..fd6bffc54 100644 --- a/fluxer_api/src/api/infrastructure/NullSearchProvider.ts +++ b/fluxer_api/src/api/infrastructure/NullSearchProvider.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IAuditLogSearchService} from '../search/IAuditLogSearchService'; -import type {IGuildMemberSearchService} from '../search/IGuildMemberSearchService'; -import type {IGuildSearchService} from '../search/IGuildSearchService'; -import type {IMessageSearchService} from '../search/IMessageSearchService'; -import type {IReportSearchService} from '../search/IReportSearchService'; -import type {ISearchProvider} from '../search/ISearchProvider'; -import type {IUserSearchService} from '../search/IUserSearchService'; +import type {IAuditLogSearchService} from '@app/api/search/IAuditLogSearchService'; +import type {IGuildMemberSearchService} from '@app/api/search/IGuildMemberSearchService'; +import type {IGuildSearchService} from '@app/api/search/IGuildSearchService'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import type {IReportSearchService} from '@app/api/search/IReportSearchService'; +import type {ISearchProvider} from '@app/api/search/ISearchProvider'; +import type {IUserSearchService} from '@app/api/search/IUserSearchService'; export class NullSearchProvider implements ISearchProvider { async initialize(): Promise {} diff --git a/fluxer_api/src/api/infrastructure/PremiumStateReconciliationQueueService.ts b/fluxer_api/src/api/infrastructure/PremiumStateReconciliationQueueService.ts index 5dfad00f4..621a68342 100644 --- a/fluxer_api/src/api/infrastructure/PremiumStateReconciliationQueueService.ts +++ b/fluxer_api/src/api/infrastructure/PremiumStateReconciliationQueueService.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {createUserID, type UserID} from '../BrandedTypes'; -import {Logger} from '../Logger'; const QUEUE_KEY = 'premium:reconcile:queue'; const SECONDARY_KEY_PREFIX = 'premium:reconcile:queue:user:'; diff --git a/fluxer_api/src/api/infrastructure/SnowflakeService.test.ts b/fluxer_api/src/api/infrastructure/SnowflakeService.test.ts index 69ea02aa8..d1211fe06 100644 --- a/fluxer_api/src/api/infrastructure/SnowflakeService.test.ts +++ b/fluxer_api/src/api/infrastructure/SnowflakeService.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {SnowflakeService} from '@app/api/infrastructure/SnowflakeService'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import {type NatsConnection, StringCodec} from 'nats'; import {afterEach, describe, expect, it} from 'vitest'; -import {SnowflakeService} from './SnowflakeService'; interface FakeRequest { subject: string; diff --git a/fluxer_api/src/api/infrastructure/SnowflakeService.ts b/fluxer_api/src/api/infrastructure/SnowflakeService.ts index 0bbdef751..d0728ce20 100644 --- a/fluxer_api/src/api/infrastructure/SnowflakeService.ts +++ b/fluxer_api/src/api/infrastructure/SnowflakeService.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import {Logger} from '@app/api/Logger'; +import {requireIntegerInRange} from '@app/api/utils/IntegerOptions'; +import {isJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import {StringCodec} from 'nats'; -import {Logger} from '../Logger'; -import {requireIntegerInRange} from '../utils/IntegerOptions'; -import {isJsonRecord, parseJsonWithGuard} from '../utils/JsonBoundaryUtils'; -import type {ISnowflakeService} from './ISnowflakeService'; const DEFAULT_REMOTE_SUBJECT = 'svc.snowflakes'; const DEFAULT_REMOTE_BATCH_SIZE = 128; diff --git a/fluxer_api/src/api/infrastructure/StorageObjectHelpers.test.ts b/fluxer_api/src/api/infrastructure/StorageObjectHelpers.test.ts index c3a68fff8..2aee484b9 100644 --- a/fluxer_api/src/api/infrastructure/StorageObjectHelpers.test.ts +++ b/fluxer_api/src/api/infrastructure/StorageObjectHelpers.test.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + buildProcessedMediaObject, + stripNonJpegImageMetadataForUpload, +} from '@app/api/infrastructure/StorageObjectHelpers'; import {describe, expect, it} from 'vitest'; -import {buildProcessedMediaObject, stripNonJpegImageMetadataForUpload} from './StorageObjectHelpers'; const PNG_SIGNATURE = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); diff --git a/fluxer_api/src/api/infrastructure/StorageObjectHelpers.ts b/fluxer_api/src/api/infrastructure/StorageObjectHelpers.ts index ecfa0412d..c4d811429 100644 --- a/fluxer_api/src/api/infrastructure/StorageObjectHelpers.ts +++ b/fluxer_api/src/api/infrastructure/StorageObjectHelpers.ts @@ -4,10 +4,10 @@ import {execFile} from 'node:child_process'; import {createHash} from 'node:crypto'; import fs from 'node:fs'; import {promisify} from 'node:util'; +import {Logger} from '@app/api/Logger'; +import {isJsonRecord, parseJsonArray} from '@app/api/utils/JsonBoundaryUtils'; import sharp from 'sharp'; import {temporaryFile} from 'tempy'; -import {Logger} from '../Logger'; -import {isJsonRecord, parseJsonArray} from '../utils/JsonBoundaryUtils'; const execFilePromise = promisify(execFile); diff --git a/fluxer_api/src/api/infrastructure/StorageService.test.ts b/fluxer_api/src/api/infrastructure/StorageService.test.ts index 4e7ac4dcb..ef29dc84d 100644 --- a/fluxer_api/src/api/infrastructure/StorageService.test.ts +++ b/fluxer_api/src/api/infrastructure/StorageService.test.ts @@ -2,10 +2,10 @@ import fs from 'node:fs'; import {PassThrough, Readable} from 'node:stream'; +import {Config} from '@app/api/Config'; +import {StorageObjectListingOverflowError} from '@app/api/infrastructure/IStorageService'; +import {StorageService} from '@app/api/infrastructure/StorageService'; import {describe, expect, it} from 'vitest'; -import {Config} from '../Config'; -import {StorageObjectListingOverflowError} from './IStorageService'; -import {StorageService} from './StorageService'; interface CopyObjectTestParams { sourceBucket: string; diff --git a/fluxer_api/src/api/infrastructure/StorageService.ts b/fluxer_api/src/api/infrastructure/StorageService.ts index 8195f1994..509325c32 100644 --- a/fluxer_api/src/api/infrastructure/StorageService.ts +++ b/fluxer_api/src/api/infrastructure/StorageService.ts @@ -6,6 +6,15 @@ import fs from 'node:fs'; import path from 'node:path'; import {PassThrough, pipeline, Readable} from 'node:stream'; import {promisify} from 'node:util'; +import {Config} from '@app/api/Config'; +import { + type IStorageService, + type ProcessedStorageObjectMetadata, + StorageObjectListingOverflowError, + StorageObjectRangeNotSatisfiableError, +} from '@app/api/infrastructure/IStorageService'; +import {processMediaFile} from '@app/api/infrastructure/StorageObjectHelpers'; +import {Logger} from '@app/api/Logger'; import { AbortMultipartUploadCommand, CompleteMultipartUploadCommand, @@ -30,15 +39,6 @@ import type {S3ProviderSettings} from '@fluxer/config/src/S3DownloadsProvider'; import {isSupportedMediaContentType} from '@pkgs/mime_utils/src/ContentTypeUtils'; import {seconds} from 'itty-time'; import {temporaryFile} from 'tempy'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import { - type IStorageService, - type ProcessedStorageObjectMetadata, - StorageObjectListingOverflowError, - StorageObjectRangeNotSatisfiableError, -} from './IStorageService'; -import {processMediaFile} from './StorageObjectHelpers'; const STREAM_UPLOAD_PART_BYTES = 8 * 1024 * 1024; const STREAM_UPLOAD_CONCURRENCY = 4; diff --git a/fluxer_api/src/api/infrastructure/StorageServiceFactory.test.ts b/fluxer_api/src/api/infrastructure/StorageServiceFactory.test.ts index d31dbfcf5..f28b36173 100644 --- a/fluxer_api/src/api/infrastructure/StorageServiceFactory.test.ts +++ b/fluxer_api/src/api/infrastructure/StorageServiceFactory.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {createDownloadsStorageService} from '@app/api/infrastructure/StorageServiceFactory'; import {describe, expect, it} from 'vitest'; -import {Config} from '../Config'; -import {createDownloadsStorageService} from './StorageServiceFactory'; describe('createDownloadsStorageService', () => { it('returns null when no downloads override is configured', () => { diff --git a/fluxer_api/src/api/infrastructure/StorageServiceFactory.ts b/fluxer_api/src/api/infrastructure/StorageServiceFactory.ts index 08cd734a2..ee9ddfdbc 100644 --- a/fluxer_api/src/api/infrastructure/StorageServiceFactory.ts +++ b/fluxer_api/src/api/infrastructure/StorageServiceFactory.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Config} from '../Config'; -import type {IStorageService} from './IStorageService'; -import {StorageService} from './StorageService'; +import {Config} from '@app/api/Config'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {StorageService} from '@app/api/infrastructure/StorageService'; export function createStorageService(): IStorageService { return new StorageService(); diff --git a/fluxer_api/src/api/infrastructure/SvcErrorReply.ts b/fluxer_api/src/api/infrastructure/SvcErrorReply.ts index c3a6fe141..446a71ef1 100644 --- a/fluxer_api/src/api/infrastructure/SvcErrorReply.ts +++ b/fluxer_api/src/api/infrastructure/SvcErrorReply.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; -import {isJsonRecord} from '../utils/JsonBoundaryUtils'; const OVERLOADED = 'overloaded'; diff --git a/fluxer_api/src/api/infrastructure/UserCacheService.test.ts b/fluxer_api/src/api/infrastructure/UserCacheService.test.ts index 23f435dab..c885f1207 100644 --- a/fluxer_api/src/api/infrastructure/UserCacheService.test.ts +++ b/fluxer_api/src/api/infrastructure/UserCacheService.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {EMPTY_USER_ROW, type UserRow} from '@app/api/database/types/UserTypes'; +import {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {IUsersServiceClient} from '@app/api/infrastructure/UsersServiceClient'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {User} from '@app/api/models/User'; import {DELETED_USER_GLOBAL_NAME, DELETED_USER_USERNAME} from '@fluxer/constants/src/UserConstants'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {describe, expect, it} from 'vitest'; -import {createUserID, type UserID} from '../BrandedTypes'; -import {EMPTY_USER_ROW, type UserRow} from '../database/types/UserTypes'; -import {createRequestCache} from '../middleware/RequestCacheMiddleware'; -import {User} from '../models/User'; -import {UserCacheService} from './UserCacheService'; -import type {IUsersServiceClient} from './UsersServiceClient'; class FakeUsersServiceClient implements IUsersServiceClient { readonly requests: Array> = []; diff --git a/fluxer_api/src/api/infrastructure/UserCacheService.ts b/fluxer_api/src/api/infrastructure/UserCacheService.ts index 68247023f..45b914ed5 100644 --- a/fluxer_api/src/api/infrastructure/UserCacheService.ts +++ b/fluxer_api/src/api/infrastructure/UserCacheService.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {IUsersServiceClient} from '@app/api/infrastructure/UsersServiceClient'; +import {Logger} from '@app/api/Logger'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; +import {mapUserToPartialResponse} from '@app/api/user/UserMappers'; import { DELETED_USER_DISCRIMINATOR, DELETED_USER_GLOBAL_NAME, DELETED_USER_USERNAME, } from '@fluxer/constants/src/UserConstants'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import type {UserID} from '../BrandedTypes'; -import {Logger} from '../Logger'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {User} from '../models/User'; -import {mapUserToPartialResponse} from '../user/UserMappers'; -import type {IUsersServiceClient} from './UsersServiceClient'; type UserPartialResponseTimingRecorder = (name: string, operation: () => Promise) => Promise; diff --git a/fluxer_api/src/api/infrastructure/UsersServiceClient.test.ts b/fluxer_api/src/api/infrastructure/UsersServiceClient.test.ts index b6518e559..5374787b0 100644 --- a/fluxer_api/src/api/infrastructure/UsersServiceClient.test.ts +++ b/fluxer_api/src/api/infrastructure/UsersServiceClient.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {NatsUsersServiceClient} from '@app/api/infrastructure/UsersServiceClient'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import {type NatsConnection, StringCodec} from 'nats'; import {describe, expect, it} from 'vitest'; -import {createUserID} from '../BrandedTypes'; -import {NatsUsersServiceClient} from './UsersServiceClient'; interface FakeRequest { subject: string; diff --git a/fluxer_api/src/api/infrastructure/UsersServiceClient.ts b/fluxer_api/src/api/infrastructure/UsersServiceClient.ts index 53ad875cf..0c1d1bab8 100644 --- a/fluxer_api/src/api/infrastructure/UsersServiceClient.ts +++ b/fluxer_api/src/api/infrastructure/UsersServiceClient.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {throwForSvcErrorReply} from '@app/api/infrastructure/SvcErrorReply'; +import {Logger} from '@app/api/Logger'; +import {awaitAll} from '@app/api/utils/ConcurrencyUtils'; +import {readOptionalIntegerEnv, requireIntegerInRange} from '@app/api/utils/IntegerOptions'; +import {isJsonRecord, parseJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import {NatsConnectionManager} from '@pkgs/nats/src/NatsConnectionManager'; import {StringCodec} from 'nats'; -import type {UserID} from '../BrandedTypes'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import {awaitAll} from '../utils/ConcurrencyUtils'; -import {readOptionalIntegerEnv, requireIntegerInRange} from '../utils/IntegerOptions'; -import {isJsonRecord, parseJsonRecord, parseJsonWithGuard} from '../utils/JsonBoundaryUtils'; -import {throwForSvcErrorReply} from './SvcErrorReply'; const USERS_SERVICE_SUBJECT = process.env.FLUXER_USERS_SERVICE_SUBJECT || 'svc.users'; const DEFAULT_USERS_SERVICE_TIMEOUT_MS = 6000; diff --git a/fluxer_api/src/api/infrastructure/VirusScanService.ts b/fluxer_api/src/api/infrastructure/VirusScanService.ts index d28d2ade2..99e82d158 100644 --- a/fluxer_api/src/api/infrastructure/VirusScanService.ts +++ b/fluxer_api/src/api/infrastructure/VirusScanService.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {VirusHashCache} from '@pkgs/virus_scan/src/cache/VirusHashCache'; import type {IVirusScanService} from '@pkgs/virus_scan/src/IVirusScanService'; import {ClamAVProvider} from '@pkgs/virus_scan/src/providers/ClamAVProvider'; import type {VirusScanResult} from '@pkgs/virus_scan/src/VirusScanResult'; import {VirusScanService as SharedVirusScanService} from '@pkgs/virus_scan/src/VirusScanService'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; export class VirusScanService implements IVirusScanService { readonly enabled = true; diff --git a/fluxer_api/src/api/infrastructure/VoiceRoomContext.ts b/fluxer_api/src/api/infrastructure/VoiceRoomContext.ts index 967adba5b..552e83d74 100644 --- a/fluxer_api/src/api/infrastructure/VoiceRoomContext.ts +++ b/fluxer_api/src/api/infrastructure/VoiceRoomContext.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createGuildID, createUserID} from '@app/api/BrandedTypes'; import {z} from 'zod'; -import type {ChannelID, GuildID, UserID} from '../BrandedTypes'; -import {createChannelID, createGuildID, createUserID} from '../BrandedTypes'; interface DMRoomContext { readonly type: 'dm'; diff --git a/fluxer_api/src/api/infrastructure/VoiceRoomStore.ts b/fluxer_api/src/api/infrastructure/VoiceRoomStore.ts index ee7a74c09..f6e416fe1 100644 --- a/fluxer_api/src/api/infrastructure/VoiceRoomStore.ts +++ b/fluxer_api/src/api/infrastructure/VoiceRoomStore.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID} from '@app/api/BrandedTypes'; +import {createChannelID, createGuildID} from '@app/api/BrandedTypes'; +import {parseJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; +import {VOICE_OCCUPANCY_REGION_KEY_PREFIX, VOICE_OCCUPANCY_SERVER_KEY_PREFIX} from '@app/api/voice/VoiceConstants'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {ChannelID, GuildID} from '../BrandedTypes'; -import {createChannelID, createGuildID} from '../BrandedTypes'; -import {parseJsonRecord} from '../utils/JsonBoundaryUtils'; -import {VOICE_OCCUPANCY_REGION_KEY_PREFIX, VOICE_OCCUPANCY_SERVER_KEY_PREFIX} from '../voice/VoiceConstants'; export interface PinnedRoomServer { regionId: string; diff --git a/fluxer_api/src/api/infrastructure/tests/AssetEntitlementUtils.test.ts b/fluxer_api/src/api/infrastructure/tests/AssetEntitlementUtils.test.ts index 815e88af7..169bdd238 100644 --- a/fluxer_api/src/api/infrastructure/tests/AssetEntitlementUtils.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/AssetEntitlementUtils.test.ts @@ -1,15 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; -import {PremiumFlags} from '@fluxer/constants/src/UserConstants'; -import {InMemoryProvider} from '@pkgs/cache/src/providers/InMemoryProvider'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {getConfig} from '../../Config'; -import {EMPTY_USER_ROW} from '../../database/types/UserTypes'; -import {InstanceConfigRepository} from '../../instance/InstanceConfigRepository'; -import {LimitConfigService} from '../../limits/LimitConfigService'; -import {User} from '../../models/User'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {getConfig} from '@app/api/Config'; +import {EMPTY_USER_ROW} from '@app/api/database/types/UserTypes'; import { stripAnimationPrefixIfNoEntitlement, stripAvatarForUser, @@ -18,7 +11,14 @@ import { stripGuildIconForFeatures, stripGuildSplashForFeatures, userHasAnimatedAvatarEntitlement, -} from '../AssetEntitlementUtils'; +} from '@app/api/infrastructure/AssetEntitlementUtils'; +import {InstanceConfigRepository} from '@app/api/instance/InstanceConfigRepository'; +import {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {User} from '@app/api/models/User'; +import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; +import {PremiumFlags} from '@fluxer/constants/src/UserConstants'; +import {InMemoryProvider} from '@pkgs/cache/src/providers/InMemoryProvider'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; let originalSelfHosted = true; diff --git a/fluxer_api/src/api/infrastructure/tests/EmailDnsValidationService.test.ts b/fluxer_api/src/api/infrastructure/tests/EmailDnsValidationService.test.ts index a23d4412c..9e7aa6831 100644 --- a/fluxer_api/src/api/infrastructure/tests/EmailDnsValidationService.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/EmailDnsValidationService.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {EmailDnsValidationService} from '@app/api/infrastructure/EmailDnsValidationService'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; import {ms} from 'itty-time'; import {describe, expect, it} from 'vitest'; -import {Config} from '../../Config'; -import {getInstanceConfigRepository} from '../../middleware/ServiceSingletons'; -import {EmailDnsValidationService} from '../EmailDnsValidationService'; interface MxRecord { exchange: string; diff --git a/fluxer_api/src/api/infrastructure/tests/GatewayServiceErrorMapping.test.ts b/fluxer_api/src/api/infrastructure/tests/GatewayServiceErrorMapping.test.ts index 64265962c..546936460 100644 --- a/fluxer_api/src/api/infrastructure/tests/GatewayServiceErrorMapping.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/GatewayServiceErrorMapping.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {GatewayRpcClient} from '@app/api/infrastructure/GatewayRpcClient'; +import {GatewayRpcMethodError, GatewayRpcMethodErrorCodes} from '@app/api/infrastructure/GatewayRpcError'; +import {GatewayService} from '@app/api/infrastructure/GatewayService'; +import type {IGatewayRpcTransport} from '@app/api/infrastructure/IGatewayRpcTransport'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {BadGatewayError} from '@fluxer/errors/src/domains/core/BadGatewayError'; import {BadRequestError} from '@fluxer/errors/src/domains/core/BadRequestError'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import {afterEach, describe, expect, it} from 'vitest'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import {GatewayRpcClient} from '../GatewayRpcClient'; -import {GatewayRpcMethodError, GatewayRpcMethodErrorCodes} from '../GatewayRpcError'; -import {GatewayService} from '../GatewayService'; -import type {IGatewayRpcTransport} from '../IGatewayRpcTransport'; function failingTransport(code: string): IGatewayRpcTransport { return { diff --git a/fluxer_api/src/api/infrastructure/tests/KVAccountDeletionQueueRebuild.test.ts b/fluxer_api/src/api/infrastructure/tests/KVAccountDeletionQueueRebuild.test.ts index 40c4b19d7..fa9393f2c 100644 --- a/fluxer_api/src/api/infrastructure/tests/KVAccountDeletionQueueRebuild.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/KVAccountDeletionQueueRebuild.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {EMPTY_USER_ROW, type UserRow} from '@app/api/database/types/UserTypes'; +import {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import {User} from '@app/api/models/User'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {describe, expect, it} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import {EMPTY_USER_ROW, type UserRow} from '../../database/types/UserTypes'; -import {User} from '../../models/User'; -import {MockKVProvider} from '../../test/mocks/MockKVProvider'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import {KVAccountDeletionQueueService} from '../KVAccountDeletionQueueService'; function createUser(id: bigint, overrides: Partial> = {}): User { return new User({ diff --git a/fluxer_api/src/api/infrastructure/tests/KVAccountDeletionQueueRebuildLock.test.ts b/fluxer_api/src/api/infrastructure/tests/KVAccountDeletionQueueRebuildLock.test.ts index 212264095..a938a9107 100644 --- a/fluxer_api/src/api/infrastructure/tests/KVAccountDeletionQueueRebuildLock.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/KVAccountDeletionQueueRebuildLock.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {EMPTY_USER_ROW} from '@app/api/database/types/UserTypes'; +import {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import {User} from '@app/api/models/User'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; import {ms} from 'itty-time'; import {afterEach, describe, expect, it, vi} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import {EMPTY_USER_ROW} from '../../database/types/UserTypes'; -import {User} from '../../models/User'; -import {MockKVProvider} from '../../test/mocks/MockKVProvider'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import {KVAccountDeletionQueueService} from '../KVAccountDeletionQueueService'; const PAGE_DURATION_MS = ms('3 minutes'); const PAGE_COUNT = 3; diff --git a/fluxer_api/src/api/infrastructure/tests/KVActivityTrackerClusterSlots.test.ts b/fluxer_api/src/api/infrastructure/tests/KVActivityTrackerClusterSlots.test.ts index 964ed168c..bce02c0cc 100644 --- a/fluxer_api/src/api/infrastructure/tests/KVActivityTrackerClusterSlots.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/KVActivityTrackerClusterSlots.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {KVActivityTracker} from '@app/api/infrastructure/KVActivityTracker'; +import type {User} from '@app/api/models/User'; +import {BatchRecordingKVProvider} from '@app/api/test/mocks/BatchRecordingKVProvider'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import {computeHashSlot} from '@pkgs/kv_client/src/KVHashSlots'; import {afterEach, describe, expect, it, vi} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import type {User} from '../../models/User'; -import {BatchRecordingKVProvider} from '../../test/mocks/BatchRecordingKVProvider'; -import {UserRepository} from '../../user/repositories/UserRepository'; -import {KVActivityTracker} from '../KVActivityTracker'; function createUser(id: bigint, lastActiveAt: Date): User { return {id: createUserID(id), lastActiveAt} as unknown as User; diff --git a/fluxer_api/src/api/infrastructure/tests/KVActivityTrackerFanout.test.ts b/fluxer_api/src/api/infrastructure/tests/KVActivityTrackerFanout.test.ts index 8fec036e1..17748d19e 100644 --- a/fluxer_api/src/api/infrastructure/tests/KVActivityTrackerFanout.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/KVActivityTrackerFanout.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {KVActivityTracker} from '@app/api/infrastructure/KVActivityTracker'; +import type {User} from '@app/api/models/User'; +import {BatchRecordingKVProvider} from '@app/api/test/mocks/BatchRecordingKVProvider'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import type {IKVPipeline} from '@pkgs/kv_client/src/IKVProvider'; import {afterEach, describe, expect, it, vi} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import type {User} from '../../models/User'; -import {BatchRecordingKVProvider} from '../../test/mocks/BatchRecordingKVProvider'; -import {UserRepository} from '../../user/repositories/UserRepository'; -import {KVActivityTracker} from '../KVActivityTracker'; const REBUILD_KV_BATCH_SIZE = 1000; const MAX_CONCURRENT_ROUND_TRIPS = 16; diff --git a/fluxer_api/src/api/infrastructure/tests/LiveKitService.test.ts b/fluxer_api/src/api/infrastructure/tests/LiveKitService.test.ts index f13bf162c..beb86f03d 100644 --- a/fluxer_api/src/api/infrastructure/tests/LiveKitService.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/LiveKitService.test.ts @@ -1,9 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createGuildID} from '@app/api/BrandedTypes'; +import { + computeLiveKitPublishSources, + LiveKitService, + VOICE_TOKEN_TTL_SECONDS, +} from '@app/api/infrastructure/LiveKitService'; import {AccessToken, TrackSource} from 'livekit-server-sdk'; import {describe, expect, it} from 'vitest'; -import {createChannelID, createGuildID} from '../../BrandedTypes'; -import {computeLiveKitPublishSources, LiveKitService, VOICE_TOKEN_TTL_SECONDS} from '../LiveKitService'; function decodeJwtPayload(token: string): Record { const [, payload] = token.split('.'); diff --git a/fluxer_api/src/api/infrastructure/tests/LiveKitWebhookService.test.ts b/fluxer_api/src/api/infrastructure/tests/LiveKitWebhookService.test.ts index 631aa7590..f1baffe74 100644 --- a/fluxer_api/src/api/infrastructure/tests/LiveKitWebhookService.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/LiveKitWebhookService.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createGuildID} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ILiveKitService} from '@app/api/infrastructure/ILiveKitService'; +import type {IVoiceRoomStore} from '@app/api/infrastructure/IVoiceRoomStore'; +import {LiveKitWebhookService} from '@app/api/infrastructure/LiveKitWebhookService'; +import type {IVoiceRepository} from '@app/api/voice/IVoiceRepository'; +import {VoiceTopology} from '@app/api/voice/VoiceTopology'; import type {WebhookEvent} from 'livekit-server-sdk'; import {describe, expect, it, vi} from 'vitest'; -import {createChannelID, createGuildID} from '../../BrandedTypes'; -import type {IVoiceRepository} from '../../voice/IVoiceRepository'; -import {VoiceTopology} from '../../voice/VoiceTopology'; -import type {IGatewayService} from '../IGatewayService'; -import type {ILiveKitService} from '../ILiveKitService'; -import type {IVoiceRoomStore} from '../IVoiceRoomStore'; -import {LiveKitWebhookService} from '../LiveKitWebhookService'; const GUILD_ID = createGuildID(1n); const CHANNEL_ID = createChannelID(2n); diff --git a/fluxer_api/src/api/infrastructure/tests/SvcErrorReply.test.ts b/fluxer_api/src/api/infrastructure/tests/SvcErrorReply.test.ts index 9b0f3cd65..b652535bc 100644 --- a/fluxer_api/src/api/infrastructure/tests/SvcErrorReply.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/SvcErrorReply.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {svcErrorReplyReason, throwForSvcErrorReply} from '@app/api/infrastructure/SvcErrorReply'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; import {describe, expect, it} from 'vitest'; -import {svcErrorReplyReason, throwForSvcErrorReply} from '../SvcErrorReply'; describe('SvcErrorReply', () => { it('recognises the shard overload reply', () => { diff --git a/fluxer_api/src/api/infrastructure/tests/VoiceRoomStoreClusterSlots.test.ts b/fluxer_api/src/api/infrastructure/tests/VoiceRoomStoreClusterSlots.test.ts index ef626c856..421a6bd0c 100644 --- a/fluxer_api/src/api/infrastructure/tests/VoiceRoomStoreClusterSlots.test.ts +++ b/fluxer_api/src/api/infrastructure/tests/VoiceRoomStoreClusterSlots.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createGuildID} from '@app/api/BrandedTypes'; +import {VoiceRoomStore} from '@app/api/infrastructure/VoiceRoomStore'; +import {BatchRecordingKVProvider} from '@app/api/test/mocks/BatchRecordingKVProvider'; +import {VOICE_OCCUPANCY_REGION_KEY_PREFIX, VOICE_OCCUPANCY_SERVER_KEY_PREFIX} from '@app/api/voice/VoiceConstants'; import {computeHashSlot} from '@pkgs/kv_client/src/KVHashSlots'; import {describe, expect, it} from 'vitest'; -import {createChannelID, createGuildID} from '../../BrandedTypes'; -import {BatchRecordingKVProvider} from '../../test/mocks/BatchRecordingKVProvider'; -import {VOICE_OCCUPANCY_REGION_KEY_PREFIX, VOICE_OCCUPANCY_SERVER_KEY_PREFIX} from '../../voice/VoiceConstants'; -import {VoiceRoomStore} from '../VoiceRoomStore'; describe('VoiceRoomStore cluster hash slots', () => { it('keeps occupancy writes off batched commands that span hash slots', async () => { diff --git a/fluxer_api/src/api/instance/DateOfBirthCollectionCache.ts b/fluxer_api/src/api/instance/DateOfBirthCollectionCache.ts index dc62e2cd9..d037f8189 100644 --- a/fluxer_api/src/api/instance/DateOfBirthCollectionCache.ts +++ b/fluxer_api/src/api/instance/DateOfBirthCollectionCache.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Config} from '../Config'; +import {Config} from '@app/api/Config'; let cachedCollectDateOfBirth: boolean | null = null; diff --git a/fluxer_api/src/api/instance/DiscoveryValidators.ts b/fluxer_api/src/api/instance/DiscoveryValidators.ts index 0d545cbc8..23190ad34 100644 --- a/fluxer_api/src/api/instance/DiscoveryValidators.ts +++ b/fluxer_api/src/api/instance/DiscoveryValidators.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; -import {entityTagMatches} from '../utils/EntityTag'; +import {entityTagMatches} from '@app/api/utils/EntityTag'; export interface DiscoveryValidators { etag: string; diff --git a/fluxer_api/src/api/instance/GatewayRolloutConfigPublisher.test.ts b/fluxer_api/src/api/instance/GatewayRolloutConfigPublisher.test.ts index a4e3eb8f5..1381a07b6 100644 --- a/fluxer_api/src/api/instance/GatewayRolloutConfigPublisher.test.ts +++ b/fluxer_api/src/api/instance/GatewayRolloutConfigPublisher.test.ts @@ -1,10 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + GATEWAY_ROLLOUT_CONFIG_NATS_SUBJECT, + GatewayRolloutConfigPublisher, +} from '@app/api/instance/GatewayRolloutConfigPublisher'; import type {GatewayRolloutConfig} from '@fluxer/schema/src/domains/admin/GatewayRolloutSchemas'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import {type NatsConnection, StringCodec} from 'nats'; import {describe, expect, it} from 'vitest'; -import {GATEWAY_ROLLOUT_CONFIG_NATS_SUBJECT, GatewayRolloutConfigPublisher} from './GatewayRolloutConfigPublisher'; interface FakePublish { subject: string; diff --git a/fluxer_api/src/api/instance/InstanceConfigCache.ts b/fluxer_api/src/api/instance/InstanceConfigCache.ts index 31a826199..8e1c991ec 100644 --- a/fluxer_api/src/api/instance/InstanceConfigCache.ts +++ b/fluxer_api/src/api/instance/InstanceConfigCache.ts @@ -1,8 +1,8 @@ import {randomUUID} from 'node:crypto'; +import {Logger} from '@app/api/Logger'; +import {parseJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; +import {RefreshSubscription, RefreshSubscriptionUnavailableError} from '@app/api/utils/RefreshSubscription'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {Logger} from '../Logger'; -import {parseJsonRecord} from '../utils/JsonBoundaryUtils'; -import {RefreshSubscription, RefreshSubscriptionUnavailableError} from '../utils/RefreshSubscription'; interface InstanceConfigCacheOptions { provider: IKVProvider | null; diff --git a/fluxer_api/src/api/instance/InstanceConfigRepository.test.ts b/fluxer_api/src/api/instance/InstanceConfigRepository.test.ts index 57334411c..4e863259f 100644 --- a/fluxer_api/src/api/instance/InstanceConfigRepository.test.ts +++ b/fluxer_api/src/api/instance/InstanceConfigRepository.test.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {setCassandraQueryExecutorForTesting} from '@app/api/database/CassandraQueryExecution'; +import type {PreparedQuery} from '@app/api/database/CassandraTypes'; +import { + INSTANCE_CONFIG_REFRESH_CHANNEL, + InstanceConfigRepository, + type InstanceRegistrationConfig, +} from '@app/api/instance/InstanceConfigRepository'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; import { DEFAULT_VOICE_NOISE_SUPPRESSION_CONFIG, type VoiceNoiseSuppressionConfig, @@ -9,15 +18,6 @@ import { type ExperimentDeliveryConfig, } from '@fluxer/schema/src/domains/experiment/ExperimentSchemas'; import {afterEach, describe, expect, it, vi} from 'vitest'; -import {setCassandraQueryExecutorForTesting} from '../database/CassandraQueryExecution'; -import type {PreparedQuery} from '../database/CassandraTypes'; -import {InMemoryCassandraQueryExecutor} from '../test/InMemoryCassandraQueryExecutor'; -import {MockKVProvider} from '../test/mocks/MockKVProvider'; -import { - INSTANCE_CONFIG_REFRESH_CHANNEL, - InstanceConfigRepository, - type InstanceRegistrationConfig, -} from './InstanceConfigRepository'; const VOICE_NOISE_SUPPRESSION_CONFIG_KEY = 'voice_noise_suppression_config'; const EXPERIMENT_DELIVERY_CONFIG_KEY = 'experiment_delivery_config'; diff --git a/fluxer_api/src/api/instance/InstanceConfigRepository.ts b/fluxer_api/src/api/instance/InstanceConfigRepository.ts index d66fba5d8..6843b603e 100644 --- a/fluxer_api/src/api/instance/InstanceConfigRepository.ts +++ b/fluxer_api/src/api/instance/InstanceConfigRepository.ts @@ -1,6 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; +import {Config} from '@app/api/Config'; +import type {APIConfig, BlueskyOAuthConfig, BlueskyOAuthKeyConfig} from '@app/api/config/APIConfig'; +import {fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {InstanceConfigurationRow} from '@app/api/database/types/InstanceConfigTypes'; +import { + getDefaultDateOfBirthCollection, + setCachedDateOfBirthCollection, +} from '@app/api/instance/DateOfBirthCollectionCache'; +import {InstanceConfigCache} from '@app/api/instance/InstanceConfigCache'; +import {normalizeSsoAllowedEmailDomains} from '@app/api/instance/SsoConfigValidation'; +import {Logger} from '@app/api/Logger'; +import {isLimitConfigSnapshot} from '@app/api/limits/LimitConfigValidation'; +import {resolveDeferredPhoneGateEnabled, setCachedDeferredPhoneGateEnabled} from '@app/api/risk/DeferredPhoneGateCache'; +import {InstanceConfiguration} from '@app/api/Tables'; +import {DEFAULT_DECAY_CONSTANTS, DEFAULT_RENEWAL_CONSTANTS} from '@app/api/utils/AttachmentDecay'; +import {isJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; import type {LimitConfigSnapshot} from '@fluxer/limits/src/LimitTypes'; import { InstanceConfigResponse, @@ -35,19 +51,6 @@ import { import {normalizeString, SnowflakeType} from '@fluxer/schema/src/primitives/SchemaPrimitives'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {z} from 'zod'; -import {Config} from '../Config'; -import type {APIConfig, BlueskyOAuthConfig, BlueskyOAuthKeyConfig} from '../config/APIConfig'; -import {fetchMany, fetchOne, upsertOne} from '../database/CassandraQueryExecution'; -import type {InstanceConfigurationRow} from '../database/types/InstanceConfigTypes'; -import {Logger} from '../Logger'; -import {isLimitConfigSnapshot} from '../limits/LimitConfigValidation'; -import {resolveDeferredPhoneGateEnabled, setCachedDeferredPhoneGateEnabled} from '../risk/DeferredPhoneGateCache'; -import {InstanceConfiguration} from '../Tables'; -import {DEFAULT_DECAY_CONSTANTS, DEFAULT_RENEWAL_CONSTANTS} from '../utils/AttachmentDecay'; -import {isJsonRecord} from '../utils/JsonBoundaryUtils'; -import {getDefaultDateOfBirthCollection, setCachedDateOfBirthCollection} from './DateOfBirthCollectionCache'; -import {InstanceConfigCache} from './InstanceConfigCache'; -import {normalizeSsoAllowedEmailDomains} from './SsoConfigValidation'; const GATEWAY_ROLLOUT_CONFIG_KEY = 'gateway_rollout_config'; const VOICE_NOISE_SUPPRESSION_CONFIG_KEY = 'voice_noise_suppression_config'; diff --git a/fluxer_api/src/api/instance/InstanceController.test.ts b/fluxer_api/src/api/instance/InstanceController.test.ts index 1d9f6d05b..d848230e7 100644 --- a/fluxer_api/src/api/instance/InstanceController.test.ts +++ b/fluxer_api/src/api/instance/InstanceController.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {SsoService} from '@app/api/auth/services/SsoService'; +import {setCassandraQueryExecutorForTesting} from '@app/api/database/CassandraQueryExecution'; +import {InstanceConfigRepository} from '@app/api/instance/InstanceConfigRepository'; +import {InstanceController} from '@app/api/instance/InstanceController'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {Hono} from 'hono'; import {afterEach, describe, expect, it} from 'vitest'; -import type {SsoService} from '../auth/services/SsoService'; -import {setCassandraQueryExecutorForTesting} from '../database/CassandraQueryExecution'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import {InMemoryCassandraQueryExecutor} from '../test/InMemoryCassandraQueryExecutor'; -import {MockKVProvider} from '../test/mocks/MockKVProvider'; -import type {HonoEnv} from '../types/HonoEnv'; -import {InstanceConfigRepository} from './InstanceConfigRepository'; -import {InstanceController} from './InstanceController'; interface DiscoveryCaptcha { provider: string; diff --git a/fluxer_api/src/api/instance/InstanceController.ts b/fluxer_api/src/api/instance/InstanceController.ts index 61529ef5b..eaba6cca4 100644 --- a/fluxer_api/src/api/instance/InstanceController.ts +++ b/fluxer_api/src/api/instance/InstanceController.ts @@ -1,19 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {GifService} from '@app/api/gif/GifService'; +import type {IGifProvider} from '@app/api/gif/IGifProvider'; +import { + type DiscoveryValidators, + isDiscoveryNotModified, + nextDiscoveryValidators, +} from '@app/api/instance/DiscoveryValidators'; +import type {InstanceCaptchaEffectiveConfig} from '@app/api/instance/InstanceConfigRepository'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {API_CODE_VERSION} from '@fluxer/constants/src/AppConstants'; import {buildDiscoveryResponse, type DiscoveryStaticInput} from '@fluxer/instance_bootstrap/src/BuildDiscovery'; import type {InstanceAppPublic} from '@fluxer/instance_bootstrap/src/Types'; import {WellKnownFluxerResponse} from '@fluxer/schema/src/domains/instance/InstanceSchemas'; import type {Hono} from 'hono'; -import {Config} from '../Config'; -import type {GifService} from '../gif/GifService'; -import type {IGifProvider} from '../gif/IGifProvider'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoEnv} from '../types/HonoEnv'; -import {type DiscoveryValidators, isDiscoveryNotModified, nextDiscoveryValidators} from './DiscoveryValidators'; -import type {InstanceCaptchaEffectiveConfig} from './InstanceConfigRepository'; let discoveryValidators: DiscoveryValidators | null = null; diff --git a/fluxer_api/src/api/instance/SingleCommunityService.ts b/fluxer_api/src/api/instance/SingleCommunityService.ts index ed1198511..db92eae51 100644 --- a/fluxer_api/src/api/instance/SingleCommunityService.ts +++ b/fluxer_api/src/api/instance/SingleCommunityService.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID, type GuildID, type UserID} from '@app/api/BrandedTypes'; +import type {GuildDataService} from '@app/api/guild/services/GuildDataService'; +import type {GuildMemberService} from '@app/api/guild/services/GuildMemberService'; +import type {InstanceConfigRepository} from '@app/api/instance/InstanceConfigRepository'; +import {Logger} from '@app/api/Logger'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; import {JoinSourceTypes} from '@fluxer/constants/src/GuildConstants'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; -import {createGuildID, type GuildID, type UserID} from '../BrandedTypes'; -import type {GuildDataService} from '../guild/services/GuildDataService'; -import type {GuildMemberService} from '../guild/services/GuildMemberService'; -import {Logger} from '../Logger'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {User} from '../models/User'; -import type {InstanceConfigRepository} from './InstanceConfigRepository'; export class SingleCommunityService { constructor( diff --git a/fluxer_api/src/api/instance/SsoConfigValidation.ts b/fluxer_api/src/api/instance/SsoConfigValidation.ts index f86e8a74b..69fc5a11e 100644 --- a/fluxer_api/src/api/instance/SsoConfigValidation.ts +++ b/fluxer_api/src/api/instance/SsoConfigValidation.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {domainToASCII} from 'node:url'; +import {Config} from '@app/api/Config'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {InstanceConfigResponse} from '@fluxer/schema/src/domains/admin/AdminSchemas'; import type {RequestUrlPolicy} from '@pkgs/http_client/src/HttpClientTypes'; import {createPublicInternetRequestUrlPolicy} from '@pkgs/http_client/src/PublicInternetRequestUrlPolicy'; -import {Config} from '../Config'; interface SsoConfigValidationInput { enabled: boolean; diff --git a/fluxer_api/src/api/instance/tests/SingleCommunityService.test.ts b/fluxer_api/src/api/instance/tests/SingleCommunityService.test.ts index 6a6d4818e..dc4a9011e 100644 --- a/fluxer_api/src/api/instance/tests/SingleCommunityService.test.ts +++ b/fluxer_api/src/api/instance/tests/SingleCommunityService.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {InstancePolicyConfig} from '@app/api/instance/InstanceConfigRepository'; +import {SingleCommunityService} from '@app/api/instance/SingleCommunityService'; +import type {User} from '@app/api/models/User'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import {describe, expect, it} from 'vitest'; -import type {User} from '../../models/User'; -import type {InstancePolicyConfig} from '../InstanceConfigRepository'; -import {SingleCommunityService} from '../SingleCommunityService'; const EXISTING_GUILD_ID = '1234567890123456789'; const OWNER = {id: 42n} as unknown as User; diff --git a/fluxer_api/src/api/invite/IInviteRepository.ts b/fluxer_api/src/api/invite/IInviteRepository.ts index 02cb4433d..234a6f1f6 100644 --- a/fluxer_api/src/api/invite/IInviteRepository.ts +++ b/fluxer_api/src/api/invite/IInviteRepository.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, InviteCode, UserID} from '../BrandedTypes'; -import type {Invite} from '../models/Invite'; +import type {ChannelID, GuildID, InviteCode, UserID} from '@app/api/BrandedTypes'; +import type {Invite} from '@app/api/models/Invite'; export abstract class IInviteRepository { abstract findUnique(code: InviteCode): Promise; diff --git a/fluxer_api/src/api/invite/InviteController.ts b/fluxer_api/src/api/invite/InviteController.ts index a10e82464..ab7a344d6 100644 --- a/fluxer_api/src/api/invite/InviteController.ts +++ b/fluxer_api/src/api/invite/InviteController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createGuildID, createInviteCode} from '@app/api/BrandedTypes'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {ChannelIdParam, GuildIdParam, InviteCodeParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import { ChannelInviteCreateRequest, @@ -8,14 +15,6 @@ import { InviteResponseSchema, } from '@fluxer/schema/src/domains/invite/InviteSchemas'; -import {createChannelID, createGuildID, createInviteCode} from '../BrandedTypes'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; - export function InviteController(app: HonoApp) { app.get( '/invites/:invite_code', diff --git a/fluxer_api/src/api/invite/InviteModel.ts b/fluxer_api/src/api/invite/InviteModel.ts index 041f83c8a..db299d636 100644 --- a/fluxer_api/src/api/invite/InviteModel.ts +++ b/fluxer_api/src/api/invite/InviteModel.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Invite} from '@app/api/models/Invite'; +import {getCachedUserPartialResponse, getCachedUserPartialResponses} from '@app/api/user/UserCacheHelpers'; import {InviteTypes} from '@fluxer/constants/src/ChannelConstants'; import {UnknownInviteError} from '@fluxer/errors/src/domains/invite/UnknownInviteError'; import type {ChannelPartialResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; @@ -10,13 +17,6 @@ import type { GuildInviteMetadataResponse, GuildInviteResponse, } from '@fluxer/schema/src/domains/invite/InviteSchemas'; -import type {ChannelID, GuildID} from '../BrandedTypes'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Channel} from '../models/Channel'; -import type {Invite} from '../models/Invite'; -import {getCachedUserPartialResponse, getCachedUserPartialResponses} from '../user/UserCacheHelpers'; interface MapInviteToGuildInviteResponseParams { invite: Invite; diff --git a/fluxer_api/src/api/invite/InviteRepository.ts b/fluxer_api/src/api/invite/InviteRepository.ts index 8b4aadf8c..c2bbae2d8 100644 --- a/fluxer_api/src/api/invite/InviteRepository.ts +++ b/fluxer_api/src/api/invite/InviteRepository.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, InviteCode, UserID} from '../BrandedTypes'; -import {createInviteCode} from '../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '../database/CassandraQueryExecution'; -import {Db} from '../database/CassandraTypes'; -import type {InviteRow} from '../database/types/ChannelTypes'; -import {Invite} from '../models/Invite'; -import {Invites, InvitesByChannel, InvitesByGuild} from '../Tables'; -import {IInviteRepository} from './IInviteRepository'; +import type {ChannelID, GuildID, InviteCode, UserID} from '@app/api/BrandedTypes'; +import {createInviteCode} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {InviteRow} from '@app/api/database/types/ChannelTypes'; +import {IInviteRepository} from '@app/api/invite/IInviteRepository'; +import {Invite} from '@app/api/models/Invite'; +import {Invites, InvitesByChannel, InvitesByGuild} from '@app/api/Tables'; const FETCH_INVITE_BY_CODE_CQL = Invites.selectCql({ where: Invites.where.eq('code'), diff --git a/fluxer_api/src/api/invite/InviteRequestService.ts b/fluxer_api/src/api/invite/InviteRequestService.ts index 6a885ce28..33a07c93f 100644 --- a/fluxer_api/src/api/invite/InviteRequestService.ts +++ b/fluxer_api/src/api/invite/InviteRequestService.ts @@ -1,5 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, InviteCode, UserID} from '@app/api/BrandedTypes'; +import {mapChannelToPartialResponse} from '@app/api/channel/ChannelMappers'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import { + mapInviteToGroupDmInviteMetadataResponse, + mapInviteToGroupDmInviteResponse, + mapInviteToGuildInviteMetadataResponse, + mapInviteToGuildInviteResponse, +} from '@app/api/invite/InviteModel'; +import type {InviteService} from '@app/api/invite/InviteService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Invite} from '@app/api/models/Invite'; import {InviteTypes} from '@fluxer/constants/src/ChannelConstants'; import type {ChannelPartialResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import type {GuildPartialResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; @@ -8,22 +24,6 @@ import type { InviteMetadataResponseSchema, InviteResponseSchema, } from '@fluxer/schema/src/domains/invite/InviteSchemas'; -import type {ChannelID, GuildID, InviteCode, UserID} from '../BrandedTypes'; -import {mapChannelToPartialResponse} from '../channel/ChannelMappers'; -import type {ChannelService} from '../channel/services/ChannelService'; -import type {GuildService} from '../guild/services/GuildService'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Channel} from '../models/Channel'; -import type {Invite} from '../models/Invite'; -import { - mapInviteToGroupDmInviteMetadataResponse, - mapInviteToGroupDmInviteResponse, - mapInviteToGuildInviteMetadataResponse, - mapInviteToGuildInviteResponse, -} from './InviteModel'; -import type {InviteService} from './InviteService'; interface MappingHelpers { userCacheService: UserCacheService; diff --git a/fluxer_api/src/api/invite/InviteService.ts b/fluxer_api/src/api/invite/InviteService.ts index 548b5526b..76b0f1bd7 100644 --- a/fluxer_api/src/api/invite/InviteService.ts +++ b/fluxer_api/src/api/invite/InviteService.ts @@ -1,5 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {ChannelID, GuildID, InviteCode, UserID} from '@app/api/BrandedTypes'; +import {createInviteCode, vanityCodeToInviteCode} from '@app/api/BrandedTypes'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {IInviteRepository} from '@app/api/invite/IInviteRepository'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import {Invite} from '@app/api/models/Invite'; +import * as RandomUtils from '@app/api/utils/RandomUtils'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {ChannelTypes, InviteTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {GuildFeatures, GuildOperations, JoinSourceTypes} from '@fluxer/constants/src/GuildConstants'; @@ -16,21 +31,6 @@ import type { GroupDmInviteMetadataResponse, GuildInviteMetadataResponse, } from '@fluxer/schema/src/domains/invite/InviteSchemas'; -import type {ApiContext} from '../ApiContext'; -import type {ChannelID, GuildID, InviteCode, UserID} from '../BrandedTypes'; -import {createInviteCode, vanityCodeToInviteCode} from '../BrandedTypes'; -import type {ChannelService} from '../channel/services/ChannelService'; -import type {GuildAuditLogService} from '../guild/GuildAuditLogService'; -import type {GuildService} from '../guild/services/GuildService'; -import {Logger} from '../Logger'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import {resolveLimitSafe} from '../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Channel} from '../models/Channel'; -import {Invite} from '../models/Invite'; -import * as RandomUtils from '../utils/RandomUtils'; -import type {IInviteRepository} from './IInviteRepository'; interface GetChannelInvitesParams { userId: UserID; diff --git a/fluxer_api/src/api/invite/tests/GroupDMInviteRecipientsSerialization.test.ts b/fluxer_api/src/api/invite/tests/GroupDMInviteRecipientsSerialization.test.ts index f87ab51db..cd0ba3d78 100644 --- a/fluxer_api/src/api/invite/tests/GroupDMInviteRecipientsSerialization.test.ts +++ b/fluxer_api/src/api/invite/tests/GroupDMInviteRecipientsSerialization.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannelInvite, createFriendship, createGroupDmChannel} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannelInvite, createFriendship, createGroupDmChannel} from '../../channel/tests/ChannelTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface GroupDmInviteChannelResponse { id: string; diff --git a/fluxer_api/src/api/invite/tests/InviteGuildMemberLimit.test.ts b/fluxer_api/src/api/invite/tests/InviteGuildMemberLimit.test.ts index ef95e6188..061c6299a 100644 --- a/fluxer_api/src/api/invite/tests/InviteGuildMemberLimit.test.ts +++ b/fluxer_api/src/api/invite/tests/InviteGuildMemberLimit.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import {MAX_GUILD_MEMBERS, MAX_GUILD_MEMBERS_VERY_LARGE_GUILD} from '@fluxer/constants/src/LimitConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../channel/tests/ChannelTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface InviteResponse { code: string; diff --git a/fluxer_api/src/api/invite/tests/InvitePermissions.test.ts b/fluxer_api/src/api/invite/tests/InvitePermissions.test.ts index 973b63852..a989d9b22 100644 --- a/fluxer_api/src/api/invite/tests/InvitePermissions.test.ts +++ b/fluxer_api/src/api/invite/tests/InvitePermissions.test.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {afterAll, beforeAll, beforeEach, describe, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannelInvite, createGuild, getChannel, updateRole, -} from '../../channel/tests/ChannelTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {deleteInvite} from './InviteTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {deleteInvite} from '@app/api/invite/tests/InviteTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {afterAll, beforeAll, beforeEach, describe, test} from 'vitest'; const BASIC_PERMISSIONS = Permissions.VIEW_CHANNEL | diff --git a/fluxer_api/src/api/invite/tests/InviteSecurityChecks.test.ts b/fluxer_api/src/api/invite/tests/InviteSecurityChecks.test.ts index f0b6c4236..dc144ab7f 100644 --- a/fluxer_api/src/api/invite/tests/InviteSecurityChecks.test.ts +++ b/fluxer_api/src/api/invite/tests/InviteSecurityChecks.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannelID, createGuildID, createInviteCode, createUserID} from '@app/api/BrandedTypes'; +import {acceptInvite, createChannelInvite, createGuild, getChannel} from '@app/api/channel/tests/ChannelTestUtils'; +import {InviteRepository} from '@app/api/invite/InviteRepository'; +import {deleteInvite} from '@app/api/invite/tests/InviteTestUtils'; +import {banUser} from '@app/api/moderation/tests/ModerationTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {InviteTypes} from '@fluxer/constants/src/ChannelConstants'; import type {GuildInviteMetadataResponse} from '@fluxer/schema/src/domains/invite/InviteSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannelID, createGuildID, createInviteCode, createUserID} from '../../BrandedTypes'; -import {acceptInvite, createChannelInvite, createGuild, getChannel} from '../../channel/tests/ChannelTestUtils'; -import {banUser} from '../../moderation/tests/ModerationTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {InviteRepository} from '../InviteRepository'; -import {deleteInvite} from './InviteTestUtils'; async function createGuildInviteWithCodeForTesting( code: string, diff --git a/fluxer_api/src/api/invite/tests/InviteTestUtils.ts b/fluxer_api/src/api/invite/tests/InviteTestUtils.ts index 31d4a23de..165778d9c 100644 --- a/fluxer_api/src/api/invite/tests/InviteTestUtils.ts +++ b/fluxer_api/src/api/invite/tests/InviteTestUtils.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; export async function deleteInvite(harness: ApiTestHarness, token: string, code: string): Promise { await createBuilder(harness, token).delete(`/invites/${code}`).expect(204).execute(); diff --git a/fluxer_api/src/api/invite/tests/InviteValidation.test.ts b/fluxer_api/src/api/invite/tests/InviteValidation.test.ts index 0855df4df..a214072ec 100644 --- a/fluxer_api/src/api/invite/tests/InviteValidation.test.ts +++ b/fluxer_api/src/api/invite/tests/InviteValidation.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../channel/tests/ChannelTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('Invite Validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/jobs/IJobLedgerRepository.ts b/fluxer_api/src/api/jobs/IJobLedgerRepository.ts index 081e5a293..6078ed108 100644 --- a/fluxer_api/src/api/jobs/IJobLedgerRepository.ts +++ b/fluxer_api/src/api/jobs/IJobLedgerRepository.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {JobByIdRow, JobStatus} from '../database/types/JobLedgerTypes'; +import type {JobByIdRow, JobStatus} from '@app/api/database/types/JobLedgerTypes'; export interface CreateJobInput { jobId: bigint; diff --git a/fluxer_api/src/api/jobs/JobAdminService.ts b/fluxer_api/src/api/jobs/JobAdminService.ts index 625870398..c357308dd 100644 --- a/fluxer_api/src/api/jobs/JobAdminService.ts +++ b/fluxer_api/src/api/jobs/JobAdminService.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {JobByIdRow} from '@app/api/database/types/JobLedgerTypes'; +import type {IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; import type {JobLedgerEntry, ListJobsRequest} from '@fluxer/schema/src/domains/admin/JobsSchemas'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import type {JobByIdRow} from '../database/types/JobLedgerTypes'; -import type {IJobLedgerRepository} from './IJobLedgerRepository'; export class JobAdminService { constructor( diff --git a/fluxer_api/src/api/jobs/JobLedgerRepository.test.ts b/fluxer_api/src/api/jobs/JobLedgerRepository.test.ts index bf83af2c1..b814f57cf 100644 --- a/fluxer_api/src/api/jobs/JobLedgerRepository.test.ts +++ b/fluxer_api/src/api/jobs/JobLedgerRepository.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {setCassandraQueryExecutorForTesting} from '@app/api/database/CassandraQueryExecution'; +import type {JobStatus} from '@app/api/database/types/JobLedgerTypes'; +import {JobLedgerRepository} from '@app/api/jobs/JobLedgerRepository'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {setCassandraQueryExecutorForTesting} from '../database/CassandraQueryExecution'; -import type {JobStatus} from '../database/types/JobLedgerTypes'; -import {InMemoryCassandraQueryExecutor} from '../test/InMemoryCassandraQueryExecutor'; -import {JobLedgerRepository} from './JobLedgerRepository'; let executor: InMemoryCassandraQueryExecutor; diff --git a/fluxer_api/src/api/jobs/JobLedgerRepository.ts b/fluxer_api/src/api/jobs/JobLedgerRepository.ts index 71edcffff..3cb2c77bd 100644 --- a/fluxer_api/src/api/jobs/JobLedgerRepository.ts +++ b/fluxer_api/src/api/jobs/JobLedgerRepository.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../database/CassandraQueryExecution'; -import {Db} from '../database/CassandraTypes'; -import type {JobActiveRow, JobByDayBucketRow, JobByIdRow, JobStatus} from '../database/types/JobLedgerTypes'; -import {JobsActive, JobsByDayBucket, JobsById} from '../Tables'; +import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {JobActiveRow, JobByDayBucketRow, JobByIdRow, JobStatus} from '@app/api/database/types/JobLedgerTypes'; import { type CreateJobInput, IJobLedgerRepository, type ListJobsCursor, type ListJobsFilters, type ListJobsResult, -} from './IJobLedgerRepository'; +} from '@app/api/jobs/IJobLedgerRepository'; +import {JobsActive, JobsByDayBucket, JobsById} from '@app/api/Tables'; const FETCH_JOB_BY_ID_QUERY = JobsById.select({ where: JobsById.where.eq('job_id'), diff --git a/fluxer_api/src/api/limits/InstancePremiumModeCache.ts b/fluxer_api/src/api/limits/InstancePremiumModeCache.ts index 7e9e6be82..d6a6b8718 100644 --- a/fluxer_api/src/api/limits/InstancePremiumModeCache.ts +++ b/fluxer_api/src/api/limits/InstancePremiumModeCache.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {InstancePremiumMode} from '../instance/InstanceConfigRepository'; +import type {InstancePremiumMode} from '@app/api/instance/InstanceConfigRepository'; let cachedPremiumMode: InstancePremiumMode = 'everyone'; diff --git a/fluxer_api/src/api/limits/LimitConfigService.ts b/fluxer_api/src/api/limits/LimitConfigService.ts index edc571638..e16f3d3cd 100644 --- a/fluxer_api/src/api/limits/LimitConfigService.ts +++ b/fluxer_api/src/api/limits/LimitConfigService.ts @@ -1,28 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; -import {computeWireFormat} from '@fluxer/limits/src/LimitDiffer'; -import type {LimitConfigSnapshot, LimitConfigWireFormat} from '@fluxer/limits/src/LimitTypes'; -import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {Config} from '../Config'; +import {Config} from '@app/api/Config'; import { createDefaultLimitConfig, getLegacyLimitConfigKvKey, LIMIT_CONFIG_REFRESH_CHANNEL, mergeWithCurrentDefaults, sanitizeLimitConfigForInstance, -} from '../constants/LimitConfig'; +} from '@app/api/constants/LimitConfig'; import { INSTANCE_CONFIG_REFRESH_CHANNEL, type InstanceConfigRepository, type InstancePolicyConfig, type InstancePremiumMode, -} from '../instance/InstanceConfigRepository'; -import {Logger} from '../Logger'; -import {awaitAll} from '../utils/ConcurrencyUtils'; -import {RefreshSubscription} from '../utils/RefreshSubscription'; -import {setCachedInstancePremiumMode} from './InstancePremiumModeCache'; +} from '@app/api/instance/InstanceConfigRepository'; +import {Logger} from '@app/api/Logger'; +import {setCachedInstancePremiumMode} from '@app/api/limits/InstancePremiumModeCache'; +import {awaitAll} from '@app/api/utils/ConcurrencyUtils'; +import {RefreshSubscription} from '@app/api/utils/RefreshSubscription'; +import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; +import {computeWireFormat} from '@fluxer/limits/src/LimitDiffer'; +import type {LimitConfigSnapshot, LimitConfigWireFormat} from '@fluxer/limits/src/LimitTypes'; +import type {ICacheService} from '@pkgs/cache/src/ICacheService'; +import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; const MAX_PENDING_OPERATIONS = 32; diff --git a/fluxer_api/src/api/limits/LimitConfigValidation.ts b/fluxer_api/src/api/limits/LimitConfigValidation.ts index e8c38eeff..b216ada18 100644 --- a/fluxer_api/src/api/limits/LimitConfigValidation.ts +++ b/fluxer_api/src/api/limits/LimitConfigValidation.ts @@ -1,5 +1,5 @@ +import {isJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; import type {LimitConfigSnapshot, LimitRule} from '@fluxer/limits/src/LimitTypes'; -import {isJsonRecord} from '../utils/JsonBoundaryUtils'; function isStringArray(value: unknown): value is Array { return Array.isArray(value) && value.every((entry) => typeof entry === 'string'); diff --git a/fluxer_api/src/api/limits/LimitMatchContextBuilder.ts b/fluxer_api/src/api/limits/LimitMatchContextBuilder.ts index 6b8652886..04b8330e6 100644 --- a/fluxer_api/src/api/limits/LimitMatchContextBuilder.ts +++ b/fluxer_api/src/api/limits/LimitMatchContextBuilder.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {User} from '@app/api/models/User'; +import {checkIsPremium} from '@app/api/user/UserHelpers'; import type {LimitMatchContext} from '@fluxer/limits/src/LimitTypes'; -import type {User} from '../models/User'; -import {checkIsPremium} from '../user/UserHelpers'; export function createLimitMatchContext({ user, diff --git a/fluxer_api/src/api/limits/tests/LimitConfigDefaults.test.ts b/fluxer_api/src/api/limits/tests/LimitConfigDefaults.test.ts index 54caa4ba5..0c4abbf16 100644 --- a/fluxer_api/src/api/limits/tests/LimitConfigDefaults.test.ts +++ b/fluxer_api/src/api/limits/tests/LimitConfigDefaults.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createDefaultLimitConfig, mergeWithCurrentDefaults} from '@app/api/constants/LimitConfig'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import {MAX_GUILD_MEMBERS_VERY_LARGE_GUILD} from '@fluxer/constants/src/LimitConstants'; import type {LimitConfigSnapshot, LimitRule} from '@fluxer/limits/src/LimitTypes'; import {describe, expect, test} from 'vitest'; -import {createDefaultLimitConfig, mergeWithCurrentDefaults} from '../../constants/LimitConfig'; interface LegacyLimitRule extends LimitRule { unlockedFeatures?: Array; diff --git a/fluxer_api/src/api/limits/tests/LimitWireFormat.test.ts b/fluxer_api/src/api/limits/tests/LimitWireFormat.test.ts index 13d578830..cf5077972 100644 --- a/fluxer_api/src/api/limits/tests/LimitWireFormat.test.ts +++ b/fluxer_api/src/api/limits/tests/LimitWireFormat.test.ts @@ -1,5 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; import {DEFAULT_FREE_LIMITS, DEFAULT_PREMIUM_LIMITS} from '@fluxer/limits/src/LimitDefaults'; import {expandWireFormat} from '@fluxer/limits/src/LimitDiffer'; @@ -7,9 +10,6 @@ import {computeDefaultsHash} from '@fluxer/limits/src/LimitHashing'; import {resolveLimits} from '@fluxer/limits/src/LimitResolver'; import type {LimitConfigWireFormat, LimitMatchContext} from '@fluxer/limits/src/LimitTypes'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; const WIRE_COMPATIBILITY_LIMIT_KEYS: ReadonlySet = new Set([ 'max_guild_emojis', diff --git a/fluxer_api/src/api/message/tests/MessageTestUtils.ts b/fluxer_api/src/api/message/tests/MessageTestUtils.ts index 9ab36ab2a..68f4489f9 100644 --- a/fluxer_api/src/api/message/tests/MessageTestUtils.ts +++ b/fluxer_api/src/api/message/tests/MessageTestUtils.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import type {TestAccount} from '../../auth/tests/AuthTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; export async function sendMessage( harness: ApiTestHarness, token: string, diff --git a/fluxer_api/src/api/middleware/AbusiveIpAutoBanner.ts b/fluxer_api/src/api/middleware/AbusiveIpAutoBanner.ts index 12f58eb9f..9c7368710 100644 --- a/fluxer_api/src/api/middleware/AbusiveIpAutoBanner.ts +++ b/fluxer_api/src/api/middleware/AbusiveIpAutoBanner.ts @@ -1,22 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash, randomUUID} from 'node:crypto'; +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import {Config} from '@app/api/Config'; +import {IP_BAN_REFRESH_CHANNEL} from '@app/api/constants/IpBan'; +import {Logger} from '@app/api/Logger'; +import {ipBanCache} from '@app/api/middleware/IpBanMiddleware'; +import {getIpInfoService} from '@app/api/middleware/ServiceMiddleware'; +import {getKVClient} from '@app/api/middleware/ServiceRegistry'; +import {getCacheService} from '@app/api/middleware/ServiceSingletons'; +import {isIpBanExempt} from '@app/api/risk/IpBanExemptions'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {parseJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; import {extractClientIp} from '@fluxer/ip_utils/src/ClientIp'; import {getSameIpDecisionKey, isPublicIpAddress, parseIpAddress} from '@fluxer/ip_utils/src/IpAddress'; import type {IpInfoLookupResult} from '@pkgs/geoip/src/IpInfoService'; import type {IKVProvider, IKVSubscription} from '@pkgs/kv_client/src/IKVProvider'; import {createMiddleware} from 'hono/factory'; -import {AdminRepository} from '../admin/AdminRepository'; -import {Config} from '../Config'; -import {IP_BAN_REFRESH_CHANNEL} from '../constants/IpBan'; -import {Logger} from '../Logger'; -import {isIpBanExempt} from '../risk/IpBanExemptions'; -import type {HonoEnv} from '../types/HonoEnv'; -import {parseJsonRecord} from '../utils/JsonBoundaryUtils'; -import {ipBanCache} from './IpBanMiddleware'; -import {getIpInfoService} from './ServiceMiddleware'; -import {getKVClient} from './ServiceRegistry'; -import {getCacheService} from './ServiceSingletons'; type IpClass = 'datacenter' | 'anonymous' | 'mobile' | 'residential' | 'unknown'; type TriggerKind = 'score' | 'token_diversity' | 'score_and_token_diversity'; diff --git a/fluxer_api/src/api/middleware/AdminMiddleware.ts b/fluxer_api/src/api/middleware/AdminMiddleware.ts index 2e4863178..cffd9755b 100644 --- a/fluxer_api/src/api/middleware/AdminMiddleware.ts +++ b/fluxer_api/src/api/middleware/AdminMiddleware.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createApplicationID, createUserID} from '@app/api/BrandedTypes'; +import {assertMutableUserId} from '@app/api/constants/Core'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {AdminACLs} from '@fluxer/constants/src/AdminACLs'; import {ADMIN_OAUTH2_APPLICATION_ID} from '@fluxer/constants/src/Core'; import {AccessDeniedError} from '@fluxer/errors/src/domains/core/AccessDeniedError'; @@ -9,11 +14,6 @@ import {UnauthorizedError} from '@fluxer/errors/src/domains/core/UnauthorizedErr import {SnowflakeType} from '@fluxer/schema/src/primitives/SchemaPrimitives'; import type {Context} from 'hono'; import {createMiddleware} from 'hono/factory'; -import {createApplicationID, createUserID} from '../BrandedTypes'; -import {assertMutableUserId} from '../constants/Core'; -import {Logger} from '../Logger'; -import type {User} from '../models/User'; -import type {HonoEnv} from '../types/HonoEnv'; const ADMIN_OAUTH2_APPLICATION_ID_BRANDED = createApplicationID(ADMIN_OAUTH2_APPLICATION_ID); type AdminAuthTokenType = 'bearer' | 'session' | 'admin_api_key'; diff --git a/fluxer_api/src/api/middleware/AuditLogMiddleware.ts b/fluxer_api/src/api/middleware/AuditLogMiddleware.ts index 2bcac8cdb..44c35f3bf 100644 --- a/fluxer_api/src/api/middleware/AuditLogMiddleware.ts +++ b/fluxer_api/src/api/middleware/AuditLogMiddleware.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {AuditLogReasonType} from '@fluxer/schema/src/primitives/ChannelValidators'; import {createMiddleware} from 'hono/factory'; -import type {HonoEnv} from '../types/HonoEnv'; export const AuditLogMiddleware = createMiddleware(async (ctx, next) => { const auditLogReasonHeader = ctx.req.header('X-Audit-Log-Reason'); diff --git a/fluxer_api/src/api/middleware/AuthMiddleware.ts b/fluxer_api/src/api/middleware/AuthMiddleware.ts index 7f5900f0b..af4bbd820 100644 --- a/fluxer_api/src/api/middleware/AuthMiddleware.ts +++ b/fluxer_api/src/api/middleware/AuthMiddleware.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {getEffectiveSuspiciousFlags} from '@app/api/user/UserHelpers'; import {AccessDeniedError} from '@fluxer/errors/src/domains/core/AccessDeniedError'; import {UnauthorizedError} from '@fluxer/errors/src/domains/core/UnauthorizedError'; import {AccountSuspiciousActivityError} from '@fluxer/errors/src/domains/user/AccountSuspiciousActivityError'; import {createMiddleware} from 'hono/factory'; -import type {HonoEnv} from '../types/HonoEnv'; -import {getEffectiveSuspiciousFlags} from '../user/UserHelpers'; function ensureOAuth2BearerRouteSupport( authTokenType: 'session' | 'bearer' | 'bot' | 'admin_api_key' | undefined, diff --git a/fluxer_api/src/api/middleware/BannedAvatarHashCache.ts b/fluxer_api/src/api/middleware/BannedAvatarHashCache.ts index 6f979e406..b7fda74cd 100644 --- a/fluxer_api/src/api/middleware/BannedAvatarHashCache.ts +++ b/fluxer_api/src/api/middleware/BannedAvatarHashCache.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import {BANNED_AVATAR_HASHES_REFRESH_CHANNEL} from '@app/api/constants/ContentModeration'; +import {Logger} from '@app/api/Logger'; +import {RefreshSubscription} from '@app/api/utils/RefreshSubscription'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {AdminRepository} from '../admin/AdminRepository'; -import {BANNED_AVATAR_HASHES_REFRESH_CHANNEL} from '../constants/ContentModeration'; -import {Logger} from '../Logger'; -import {RefreshSubscription} from '../utils/RefreshSubscription'; function stripAnimationPrefix(hash: string): string { return hash.startsWith('a_') ? hash.substring(2) : hash; diff --git a/fluxer_api/src/api/middleware/CaptchaMiddleware.ts b/fluxer_api/src/api/middleware/CaptchaMiddleware.ts index 2e0840ac4..7a6429528 100644 --- a/fluxer_api/src/api/middleware/CaptchaMiddleware.ts +++ b/fluxer_api/src/api/middleware/CaptchaMiddleware.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {InstanceCaptchaEffectiveConfig} from '@app/api/instance/InstanceConfigRepository'; +import type {User} from '@app/api/models/User'; +import {accountPolicyContactHasCapability} from '@app/api/risk/AccountPolicyService'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {Headers} from '@fluxer/constants/src/Headers'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {CaptchaRequiredError, InvalidCaptchaError} from '@fluxer/errors/src/CaptchaErrors'; @@ -9,11 +14,6 @@ import {createCaptchaProvider} from '@pkgs/captcha/src/CaptchaProviderFactory'; import type {ICaptchaProvider} from '@pkgs/captcha/src/ICaptchaProvider'; import type {Context} from 'hono'; import {createMiddleware} from 'hono/factory'; -import {Config} from '../Config'; -import type {InstanceCaptchaEffectiveConfig} from '../instance/InstanceConfigRepository'; -import type {User} from '../models/User'; -import {accountPolicyContactHasCapability} from '../risk/AccountPolicyService'; -import type {HonoEnv} from '../types/HonoEnv'; function resolveProviderSecret( config: InstanceCaptchaEffectiveConfig, diff --git a/fluxer_api/src/api/middleware/ConcurrencyLimitMiddleware.ts b/fluxer_api/src/api/middleware/ConcurrencyLimitMiddleware.ts index d8200b2fd..93fc183b7 100644 --- a/fluxer_api/src/api/middleware/ConcurrencyLimitMiddleware.ts +++ b/fluxer_api/src/api/middleware/ConcurrencyLimitMiddleware.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {normalizeRequestPath} from '@app/api/utils/RequestPathUtils'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; import {createMiddleware} from 'hono/factory'; -import type {HonoEnv} from '../types/HonoEnv'; -import {normalizeRequestPath} from '../utils/RequestPathUtils'; const PROBE_PATHS = new Set(['/_health', '/_healthz', '/_metrics']); const OVERLOAD_RETRY_AFTER_SECONDS = 1; diff --git a/fluxer_api/src/api/middleware/ContentFilterMiddleware.ts b/fluxer_api/src/api/middleware/ContentFilterMiddleware.ts index 8ced3ed3c..a6d737da5 100644 --- a/fluxer_api/src/api/middleware/ContentFilterMiddleware.ts +++ b/fluxer_api/src/api/middleware/ContentFilterMiddleware.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Logger} from '@app/api/Logger'; +import {phraseBlocklistCache} from '@app/api/middleware/PhraseBlocklistCache'; +import {urlBlocklistCache} from '@app/api/middleware/UrlBlocklistCache'; +import {readRequestJsonBody} from '@app/api/utils/RequestJsonBody'; +import {extractUrlCandidates} from '@app/api/utils/UrlNormalizer'; import {ContentBlockedError} from '@fluxer/errors/src/domains/content/ContentBlockedError'; import {createMiddleware} from 'hono/factory'; -import {Logger} from '../Logger'; -import {readRequestJsonBody} from '../utils/RequestJsonBody'; -import {extractUrlCandidates} from '../utils/UrlNormalizer'; -import {phraseBlocklistCache} from './PhraseBlocklistCache'; -import {urlBlocklistCache} from './UrlBlocklistCache'; const SKIP_FIELDS = new Set([ 'acls', diff --git a/fluxer_api/src/api/middleware/FileShaCache.ts b/fluxer_api/src/api/middleware/FileShaCache.ts index b852514fb..9bc73a58a 100644 --- a/fluxer_api/src/api/middleware/FileShaCache.ts +++ b/fluxer_api/src/api/middleware/FileShaCache.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import {BANNED_FILE_SHAS_REFRESH_CHANNEL} from '@app/api/constants/ContentModeration'; +import {Logger} from '@app/api/Logger'; +import {RefreshSubscription} from '@app/api/utils/RefreshSubscription'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {AdminRepository} from '../admin/AdminRepository'; -import {BANNED_FILE_SHAS_REFRESH_CHANNEL} from '../constants/ContentModeration'; -import {Logger} from '../Logger'; -import {RefreshSubscription} from '../utils/RefreshSubscription'; class FileShaCache { private banned: Set = new Set(); diff --git a/fluxer_api/src/api/middleware/GroupDmProtectionMiddleware.ts b/fluxer_api/src/api/middleware/GroupDmProtectionMiddleware.ts index b7cc83e59..37cdc2b73 100644 --- a/fluxer_api/src/api/middleware/GroupDmProtectionMiddleware.ts +++ b/fluxer_api/src/api/middleware/GroupDmProtectionMiddleware.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {verifyCaptchaToken} from '@app/api/middleware/CaptchaMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import type {CreatePrivateChannelRequest} from '@fluxer/schema/src/domains/user/UserRequestSchemas'; import type {Context, MiddlewareHandler, Next} from 'hono'; import {createMiddleware} from 'hono/factory'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoEnv} from '../types/HonoEnv'; -import {verifyCaptchaToken} from './CaptchaMiddleware'; -import {RateLimitMiddleware} from './RateLimitMiddleware'; const groupDmCreateRateLimit = RateLimitMiddleware(RateLimitConfigs.USER_GROUP_DM_CREATE); const groupDmRecipientAddRateLimit = RateLimitMiddleware(RateLimitConfigs.USER_GROUP_DM_RECIPIENT_ADD); diff --git a/fluxer_api/src/api/middleware/GuildAvailabilityMiddleware.ts b/fluxer_api/src/api/middleware/GuildAvailabilityMiddleware.ts index 43440cd17..cd99ef122 100644 --- a/fluxer_api/src/api/middleware/GuildAvailabilityMiddleware.ts +++ b/fluxer_api/src/api/middleware/GuildAvailabilityMiddleware.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createChannelID, createGuildID, type GuildID} from '@app/api/BrandedTypes'; +import type {Guild} from '@app/api/models/Guild'; +import type {User} from '@app/api/models/User'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {normalizeRequestPath} from '@app/api/utils/RequestPathUtils'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {MissingAccessError} from '@fluxer/errors/src/domains/core/MissingAccessError'; import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; import type {Context} from 'hono'; import {createMiddleware} from 'hono/factory'; -import {type ChannelID, createChannelID, createGuildID, type GuildID} from '../BrandedTypes'; -import type {Guild} from '../models/Guild'; -import type {User} from '../models/User'; -import type {HonoEnv} from '../types/HonoEnv'; -import {normalizeRequestPath} from '../utils/RequestPathUtils'; function parseResourceId(path: string, resourceName: 'guilds' | 'channels'): string | null { const segments = path.split('/').filter(Boolean); diff --git a/fluxer_api/src/api/middleware/GuildStackServiceFactory.ts b/fluxer_api/src/api/middleware/GuildStackServiceFactory.ts index b5d79f203..8fad152ee 100644 --- a/fluxer_api/src/api/middleware/GuildStackServiceFactory.ts +++ b/fluxer_api/src/api/middleware/GuildStackServiceFactory.ts @@ -1,31 +1,31 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {AttachmentUploadTraceRepository} from '@app/api/channel/repositories/message/AttachmentUploadTraceRepository'; +import {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {IFavoriteMemeRepository} from '@app/api/favorite_meme/IFavoriteMemeRepository'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {GuildService} from '@app/api/guild/services/GuildService'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {EmbedService} from '@app/api/infrastructure/EmbedService'; +import type {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import type {IAssetDeletionQueue} from '@app/api/infrastructure/IAssetDeletionQueue'; +import type {ILiveKitService} from '@app/api/infrastructure/ILiveKitService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {IVoiceRoomStore} from '@app/api/infrastructure/IVoiceRoomStore'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {InviteRepository} from '@app/api/invite/InviteRepository'; +import {InviteService} from '@app/api/invite/InviteService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {VoiceAvailabilityService} from '@app/api/voice/VoiceAvailabilityService'; +import type {IWebhookRepository} from '@app/api/webhook/IWebhookRepository'; import type {IpInfoService} from '@pkgs/geoip/src/IpInfoService'; import type {IVirusScanService} from '@pkgs/virus_scan/src/IVirusScanService'; -import type {ApiContext} from '../ApiContext'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import type {AttachmentUploadTraceRepository} from '../channel/repositories/message/AttachmentUploadTraceRepository'; -import {ChannelService} from '../channel/services/ChannelService'; -import type {IFavoriteMemeRepository} from '../favorite_meme/IFavoriteMemeRepository'; -import type {GuildAuditLogService} from '../guild/GuildAuditLogService'; -import type {IGuildRepositoryAggregate} from '../guild/repositories/IGuildRepositoryAggregate'; -import {GuildService} from '../guild/services/GuildService'; -import type {AvatarService} from '../infrastructure/AvatarService'; -import type {IPurgeQueue} from '../infrastructure/BunnyPurgeQueue'; -import type {EmbedService} from '../infrastructure/EmbedService'; -import type {EntityAssetService} from '../infrastructure/EntityAssetService'; -import type {IAssetDeletionQueue} from '../infrastructure/IAssetDeletionQueue'; -import type {ILiveKitService} from '../infrastructure/ILiveKitService'; -import type {IStorageService} from '../infrastructure/IStorageService'; -import type {IVoiceRoomStore} from '../infrastructure/IVoiceRoomStore'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {InviteRepository} from '../invite/InviteRepository'; -import {InviteService} from '../invite/InviteService'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import type {ReadStateService} from '../read_state/ReadStateService'; -import type {IUserRepository} from '../user/IUserRepository'; -import type {VoiceAvailabilityService} from '../voice/VoiceAvailabilityService'; -import type {IWebhookRepository} from '../webhook/IWebhookRepository'; interface GuildStackServiceFactoryDependencies { apiContext: ApiContext; diff --git a/fluxer_api/src/api/middleware/IpBanMiddleware.ts b/fluxer_api/src/api/middleware/IpBanMiddleware.ts index fe9ae614a..c213d3ffa 100644 --- a/fluxer_api/src/api/middleware/IpBanMiddleware.ts +++ b/fluxer_api/src/api/middleware/IpBanMiddleware.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import type {BannedIpEntry, BannedIpKind} from '@app/api/admin/IAdminRepository'; +import {IP_BAN_REFRESH_CHANNEL} from '@app/api/constants/IpBan'; +import {Logger} from '@app/api/Logger'; +import {isIpBanExempt} from '@app/api/risk/IpBanExemptions'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {parseIpBanEntry, tryParseSingleIp} from '@app/api/utils/IpRangeUtils'; +import {RefreshSubscription} from '@app/api/utils/RefreshSubscription'; +import {getRequestClientIp} from '@app/api/utils/RequestClientIp'; import {IpBannedError} from '@fluxer/errors/src/domains/moderation/IpBannedError'; import {getSameIpDecisionKey, type IpAddressFamily} from '@fluxer/ip_utils/src/IpAddress'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {createMiddleware} from 'hono/factory'; -import {AdminRepository} from '../admin/AdminRepository'; -import type {BannedIpEntry, BannedIpKind} from '../admin/IAdminRepository'; -import {IP_BAN_REFRESH_CHANNEL} from '../constants/IpBan'; -import {Logger} from '../Logger'; -import {isIpBanExempt} from '../risk/IpBanExemptions'; -import type {HonoEnv} from '../types/HonoEnv'; -import {parseIpBanEntry, tryParseSingleIp} from '../utils/IpRangeUtils'; -import {RefreshSubscription} from '../utils/RefreshSubscription'; -import {getRequestClientIp} from '../utils/RequestClientIp'; type FamilyMap = Record>; diff --git a/fluxer_api/src/api/middleware/LazyServiceProvider.ts b/fluxer_api/src/api/middleware/LazyServiceProvider.ts index fcf801260..0a3bdffae 100644 --- a/fluxer_api/src/api/middleware/LazyServiceProvider.ts +++ b/fluxer_api/src/api/middleware/LazyServiceProvider.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {HonoEnv} from '@app/api/types/HonoEnv'; import type {Context} from 'hono'; -import type {HonoEnv} from '../types/HonoEnv'; type RequestVariables = HonoEnv['Variables']; diff --git a/fluxer_api/src/api/middleware/LocalAuthMiddleware.ts b/fluxer_api/src/api/middleware/LocalAuthMiddleware.ts index 29fa49e44..3720f20ca 100644 --- a/fluxer_api/src/api/middleware/LocalAuthMiddleware.ts +++ b/fluxer_api/src/api/middleware/LocalAuthMiddleware.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {SsoRequiredError} from '@fluxer/errors/src/domains/auth/SsoRequiredError'; import {createMiddleware} from 'hono/factory'; -import type {HonoEnv} from '../types/HonoEnv'; export const LocalAuthMiddleware = createMiddleware(async (ctx, next) => { const ssoService = ctx.get('ssoService'); diff --git a/fluxer_api/src/api/middleware/LocaleMiddleware.ts b/fluxer_api/src/api/middleware/LocaleMiddleware.ts index 555c3930b..d48baaf8c 100644 --- a/fluxer_api/src/api/middleware/LocaleMiddleware.ts +++ b/fluxer_api/src/api/middleware/LocaleMiddleware.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {Locales} from '@fluxer/constants/src/Locales'; import {parseAcceptLanguage} from '@pkgs/locale/src/LocaleService'; import {createMiddleware} from 'hono/factory'; -import type {HonoEnv} from '../types/HonoEnv'; export const LocaleMiddleware = createMiddleware(async (ctx, next) => { const acceptLanguage = ctx.req.header('accept-language'); diff --git a/fluxer_api/src/api/middleware/OAuth2ScopeMiddleware.ts b/fluxer_api/src/api/middleware/OAuth2ScopeMiddleware.ts index f0a400935..fc0ac26a0 100644 --- a/fluxer_api/src/api/middleware/OAuth2ScopeMiddleware.ts +++ b/fluxer_api/src/api/middleware/OAuth2ScopeMiddleware.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {HonoEnv} from '@app/api/types/HonoEnv'; import type {OAuth2Scope} from '@fluxer/constants/src/OAuth2Constants'; import {UnauthorizedError} from '@fluxer/errors/src/domains/core/UnauthorizedError'; import {MissingOAuthScopeError} from '@fluxer/errors/src/domains/oauth/MissingOAuthScopeError'; import type {Context} from 'hono'; import {createMiddleware} from 'hono/factory'; -import type {HonoEnv} from '../types/HonoEnv'; type OAuth2ScopeCheckMode = 'strict' | 'bearer_only'; diff --git a/fluxer_api/src/api/middleware/PhraseBlocklistCache.ts b/fluxer_api/src/api/middleware/PhraseBlocklistCache.ts index 860337e90..6a2673889 100644 --- a/fluxer_api/src/api/middleware/PhraseBlocklistCache.ts +++ b/fluxer_api/src/api/middleware/PhraseBlocklistCache.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import {BANNED_PHRASES_REFRESH_CHANNEL} from '@app/api/constants/ContentModeration'; +import {Logger} from '@app/api/Logger'; +import {buildPhraseMatchForms, canonicalizeStoredPhrase} from '@app/api/utils/PhraseBlocklistNormalization'; +import {RefreshSubscription} from '@app/api/utils/RefreshSubscription'; +import {SubstringMatcher} from '@app/api/utils/SubstringMatcher'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {AdminRepository} from '../admin/AdminRepository'; -import {BANNED_PHRASES_REFRESH_CHANNEL} from '../constants/ContentModeration'; -import {Logger} from '../Logger'; -import {buildPhraseMatchForms, canonicalizeStoredPhrase} from '../utils/PhraseBlocklistNormalization'; -import {RefreshSubscription} from '../utils/RefreshSubscription'; -import {SubstringMatcher} from '../utils/SubstringMatcher'; export class PhraseBlocklistCache { private rawPhrases: Array = []; diff --git a/fluxer_api/src/api/middleware/ProfileSubstringBlocklistCache.ts b/fluxer_api/src/api/middleware/ProfileSubstringBlocklistCache.ts index bea0463a1..275c3fe60 100644 --- a/fluxer_api/src/api/middleware/ProfileSubstringBlocklistCache.ts +++ b/fluxer_api/src/api/middleware/ProfileSubstringBlocklistCache.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import {BANNED_PROFILE_SUBSTRINGS_REFRESH_CHANNEL} from '@app/api/constants/ContentModeration'; +import type {BannedProfileSubstringScope} from '@app/api/database/types/AdminArchiveTypes'; +import {Logger} from '@app/api/Logger'; +import {buildPhraseMatchForms, canonicalizeStoredPhrase} from '@app/api/utils/PhraseBlocklistNormalization'; +import {RefreshSubscription} from '@app/api/utils/RefreshSubscription'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {AdminRepository} from '../admin/AdminRepository'; -import {BANNED_PROFILE_SUBSTRINGS_REFRESH_CHANNEL} from '../constants/ContentModeration'; -import type {BannedProfileSubstringScope} from '../database/types/AdminArchiveTypes'; -import {Logger} from '../Logger'; -import {buildPhraseMatchForms, canonicalizeStoredPhrase} from '../utils/PhraseBlocklistNormalization'; -import {RefreshSubscription} from '../utils/RefreshSubscription'; type ProfileScope = BannedProfileSubstringScope; diff --git a/fluxer_api/src/api/middleware/RateLimitMiddleware.ts b/fluxer_api/src/api/middleware/RateLimitMiddleware.ts index 8444920f5..1a0b80ef2 100644 --- a/fluxer_api/src/api/middleware/RateLimitMiddleware.ts +++ b/fluxer_api/src/api/middleware/RateLimitMiddleware.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import {Config} from '@app/api/Config'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {getRequestClientIp} from '@app/api/utils/RequestClientIp'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {RateLimitError} from '@fluxer/errors/src/domains/core/RateLimitError'; import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress'; import type {BucketConfig, RateLimitResult, RateLimitScope} from '@pkgs/rate_limit/src/IRateLimitService'; import type {Context, MiddlewareHandler} from 'hono'; import {createMiddleware} from 'hono/factory'; -import * as AuthSession from '../auth/AuthSession'; -import {Config} from '../Config'; -import type {HonoEnv} from '../types/HonoEnv'; -import {getRequestClientIp} from '../utils/RequestClientIp'; type AccountType = 'user' | 'bot' | 'webhook'; diff --git a/fluxer_api/src/api/middleware/RequestCacheMiddleware.ts b/fluxer_api/src/api/middleware/RequestCacheMiddleware.ts index b817d2d34..7e7c01f50 100644 --- a/fluxer_api/src/api/middleware/RequestCacheMiddleware.ts +++ b/fluxer_api/src/api/middleware/RequestCacheMiddleware.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID} from '@app/api/BrandedTypes'; +import type {Channel} from '@app/api/models/Channel'; +import type {Guild} from '@app/api/models/Guild'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {createMiddleware} from 'hono/factory'; -import type {ChannelID, GuildID} from '../BrandedTypes'; -import type {Channel} from '../models/Channel'; -import type {Guild} from '../models/Guild'; -import type {HonoEnv} from '../types/HonoEnv'; export interface RequestCache { userPartials: Map; diff --git a/fluxer_api/src/api/middleware/RequireClientIpMiddleware.ts b/fluxer_api/src/api/middleware/RequireClientIpMiddleware.ts index 9408a7de5..e7a1cb160 100644 --- a/fluxer_api/src/api/middleware/RequireClientIpMiddleware.ts +++ b/fluxer_api/src/api/middleware/RequireClientIpMiddleware.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {getRequestClientIp} from '@app/api/utils/RequestClientIp'; +import {stripApiPrefix} from '@app/api/utils/RequestPathUtils'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {ForbiddenError} from '@fluxer/errors/src/domains/core/ForbiddenError'; import {createMiddleware} from 'hono/factory'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import type {HonoEnv} from '../types/HonoEnv'; -import {getRequestClientIp} from '../utils/RequestClientIp'; -import {stripApiPrefix} from '../utils/RequestPathUtils'; interface RequireClientIpOptions { exemptPaths?: Array; diff --git a/fluxer_api/src/api/middleware/ResponseTypeMiddleware.ts b/fluxer_api/src/api/middleware/ResponseTypeMiddleware.ts index 24f3c5e53..c009401b9 100644 --- a/fluxer_api/src/api/middleware/ResponseTypeMiddleware.ts +++ b/fluxer_api/src/api/middleware/ResponseTypeMiddleware.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {InternalServerError} from '@fluxer/errors/src/domains/core/InternalServerError'; import {createLogger} from '@fluxer/logger/src/Logger'; import type {Context, MiddlewareHandler} from 'hono'; import type {ZodType} from 'zod'; -import {Config} from '../Config'; -import type {HonoEnv} from '../types/HonoEnv'; const responseValidationLogger = createLogger('response_validation'); diff --git a/fluxer_api/src/api/middleware/ServiceMiddleware.ts b/fluxer_api/src/api/middleware/ServiceMiddleware.ts index 500e88b10..3abd5af44 100644 --- a/fluxer_api/src/api/middleware/ServiceMiddleware.ts +++ b/fluxer_api/src/api/middleware/ServiceMiddleware.ts @@ -1,98 +1,52 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; -import {lookupAsnByIp, lookupGeoipByIp} from '@pkgs/geoip/src/GeoipLookup'; -import {createIpInfoService, createUnavailableIpInfoService, type IpInfoService} from '@pkgs/geoip/src/IpInfoService'; -import {createMiddleware} from 'hono/factory'; -import type {ApiContext} from '../ApiContext'; -import {AdminService} from '../admin/AdminService'; -import {AuthRequestService} from '../auth/AuthRequestService'; -import {DesktopHandoffService} from '../auth/services/DesktopHandoffService'; +import type {ApiContext} from '@app/api/ApiContext'; +import {AdminService} from '@app/api/admin/AdminService'; +import {AuthRequestService} from '@app/api/auth/AuthRequestService'; +import {DesktopHandoffService} from '@app/api/auth/services/DesktopHandoffService'; import { CassandraInboundSmsChallengeRepository, InboundSmsChallengeService, -} from '../auth/services/InboundSmsChallengeService'; -import type {IRegistrationRiskEvaluator} from '../auth/services/IRegistrationRiskEvaluator'; -import {noopRegistrationRiskEvaluator, RegistrationRiskEvaluator} from '../auth/services/RegistrationRiskEvaluator'; -import {SsoService} from '../auth/services/SsoService'; -import type {IBlueskyOAuthService} from '../bluesky/IBlueskyOAuthService'; -import {Config} from '../Config'; -import {createApiContext} from '../CreateApiContext'; -import {ChannelRepository} from '../channel/ChannelRepository'; -import {ChannelRequestService} from '../channel/services/ChannelRequestService'; -import {MessageRequestService} from '../channel/services/message/MessageRequestService'; -import {createMessageResponseDataService} from '../channel/services/message/MessageResponseDataService'; -import {StreamService} from '../channel/services/StreamService'; -import {ConnectionRequestService} from '../connection/ConnectionRequestService'; -import {ConnectionService} from '../connection/ConnectionService'; -import {DonationService} from '../donation/DonationService'; -import {DonationCheckoutService} from '../donation/services/DonationCheckoutService'; -import {DonationMagicLinkService} from '../donation/services/DonationMagicLinkService'; -import {FavoriteMemeRequestService} from '../favorite_meme/FavoriteMemeRequestService'; -import {FavoriteMemeService} from '../favorite_meme/FavoriteMemeService'; -import {GuildRepository} from '../guild/repositories/GuildRepository'; -import {DisabledLiveKitService} from '../infrastructure/DisabledLiveKitService'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {ILiveKitService} from '../infrastructure/ILiveKitService'; -import type {IMediaService} from '../infrastructure/IMediaService'; -import {InMemoryVoiceRoomStore} from '../infrastructure/InMemoryVoiceRoomStore'; -import type {IVoiceRoomStore} from '../infrastructure/IVoiceRoomStore'; -import {LiveKitService} from '../infrastructure/LiveKitService'; -import {LiveKitWebhookService} from '../infrastructure/LiveKitWebhookService'; -import {VoiceRoomStore} from '../infrastructure/VoiceRoomStore'; -import {SingleCommunityService} from '../instance/SingleCommunityService'; -import {InviteRequestService} from '../invite/InviteRequestService'; -import {JobLedgerRepository} from '../jobs/JobLedgerRepository'; -import {Logger} from '../Logger'; -import {ApplicationService} from '../oauth/ApplicationService'; -import {OAuth2ApplicationsRequestService} from '../oauth/OAuth2ApplicationsRequestService'; -import {OAuth2RequestService} from '../oauth/OAuth2RequestService'; -import {OAuth2Service} from '../oauth/OAuth2Service'; -import {ReportRequestService} from '../report/ReportRequestService'; -import {ReportService} from '../report/ReportService'; -import type {IAccountPolicyEvaluator} from '../risk/AccountPolicyEvaluator'; +} from '@app/api/auth/services/InboundSmsChallengeService'; +import type {IRegistrationRiskEvaluator} from '@app/api/auth/services/IRegistrationRiskEvaluator'; import { - getAccountPolicyEvaluator, - setInjectedAccountPolicyEvaluator as setInjectedAccountPolicyEvaluatorInService, -} from '../risk/AccountPolicyService'; -import {createIpInfoChecker} from '../risk/adapters/IpInfoAdapter'; -import {createReverseDnsLookup} from '../risk/adapters/ReverseDnsAdapter'; -import {DeterministicRiskEngine} from '../risk/DeterministicRiskEngine'; -import {CassandraHistoricalOutcomeRepository} from '../risk/HistoricalOutcomeRepository'; -import {createKvIpInfoLookupBudget} from '../risk/IpInfoBudget'; -import {buildIpInfoCache, buildIpInfoRequestAuditLogger} from '../risk/IpInfoCacheFactory'; -import {CassandraRegistrationEventsRepository} from '../risk/RegistrationEventsRepository'; -import { - type IpInfoPrescreenVerdict, - ipInfoPrescreenOptionsFromEnv, - prescreenIpInfoLookup, -} from '../risk/RegistrationIpPrescreen'; -import {CassandraRiskAssessmentRepository} from '../risk/RiskAssessmentRepository'; -import {createRiskToolbox} from '../risk/RiskToolboxFactory'; -import {CassandraSuspiciousIpRepository} from '../risk/SuspiciousIpRepository'; -import {RpcService} from '../rpc/RpcService'; -import {getReportSearchService} from '../SearchFactory'; -import {SearchService} from '../search/SearchService'; -import {StripeService} from '../stripe/StripeService'; -import {AgeVerificationService} from '../stripe/services/AgeVerificationService'; -import type {HonoEnv} from '../types/HonoEnv'; -import type {UserRepository} from '../user/repositories/UserRepository'; -import {EmailChangeService} from '../user/services/EmailChangeService'; -import {MfaBackupCodesChallengeService} from '../user/services/MfaBackupCodesChallengeService'; -import {PasswordChangeService} from '../user/services/PasswordChangeService'; -import {UserAccountRequestService} from '../user/services/UserAccountRequestService'; -import {UserAuthRequestService} from '../user/services/UserAuthRequestService'; -import {UserChannelRequestService} from '../user/services/UserChannelRequestService'; -import {UserContentRequestService} from '../user/services/UserContentRequestService'; -import {UserRelationshipRequestService} from '../user/services/UserRelationshipRequestService'; -import {UserService} from '../user/services/UserService'; -import {getRequestClientIp} from '../utils/RequestClientIp'; -import {VoiceService} from '../voice/VoiceService'; -import {WebhookRequestService} from '../webhook/WebhookRequestService'; -import {WebhookService} from '../webhook/WebhookService'; -import {createGuildStackServices, type GuildStackServices} from './GuildStackServiceFactory'; -import {installLazyServices, type RequestScopedServices} from './LazyServiceProvider'; -import type {RequestCache} from './RequestCacheMiddleware'; + noopRegistrationRiskEvaluator, + RegistrationRiskEvaluator, +} from '@app/api/auth/services/RegistrationRiskEvaluator'; +import {SsoService} from '@app/api/auth/services/SsoService'; +import type {IBlueskyOAuthService} from '@app/api/bluesky/IBlueskyOAuthService'; +import {Config} from '@app/api/Config'; +import {createApiContext} from '@app/api/CreateApiContext'; +import {ChannelRepository} from '@app/api/channel/ChannelRepository'; +import {ChannelRequestService} from '@app/api/channel/services/ChannelRequestService'; +import {MessageRequestService} from '@app/api/channel/services/message/MessageRequestService'; +import {createMessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; +import {StreamService} from '@app/api/channel/services/StreamService'; +import {ConnectionRequestService} from '@app/api/connection/ConnectionRequestService'; +import {ConnectionService} from '@app/api/connection/ConnectionService'; +import {DonationService} from '@app/api/donation/DonationService'; +import {DonationCheckoutService} from '@app/api/donation/services/DonationCheckoutService'; +import {DonationMagicLinkService} from '@app/api/donation/services/DonationMagicLinkService'; +import {FavoriteMemeRequestService} from '@app/api/favorite_meme/FavoriteMemeRequestService'; +import {FavoriteMemeService} from '@app/api/favorite_meme/FavoriteMemeService'; +import {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; +import {DisabledLiveKitService} from '@app/api/infrastructure/DisabledLiveKitService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ILiveKitService} from '@app/api/infrastructure/ILiveKitService'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import {InMemoryVoiceRoomStore} from '@app/api/infrastructure/InMemoryVoiceRoomStore'; +import type {IVoiceRoomStore} from '@app/api/infrastructure/IVoiceRoomStore'; +import {LiveKitService} from '@app/api/infrastructure/LiveKitService'; +import {LiveKitWebhookService} from '@app/api/infrastructure/LiveKitWebhookService'; +import {VoiceRoomStore} from '@app/api/infrastructure/VoiceRoomStore'; +import {SingleCommunityService} from '@app/api/instance/SingleCommunityService'; +import {InviteRequestService} from '@app/api/invite/InviteRequestService'; +import {JobLedgerRepository} from '@app/api/jobs/JobLedgerRepository'; +import {Logger} from '@app/api/Logger'; +import {createGuildStackServices, type GuildStackServices} from '@app/api/middleware/GuildStackServiceFactory'; +import {installLazyServices, type RequestScopedServices} from '@app/api/middleware/LazyServiceProvider'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; import { ensureVoiceResourcesInitialized, getBillingRepository, @@ -106,7 +60,7 @@ import { getVoiceTopology, getWorkerService, resolveBlueskyOAuthService, -} from './ServiceRegistry'; +} from '@app/api/middleware/ServiceRegistry'; import { ensureVirusScanInitialized, getAdminApiKeyService, @@ -165,9 +119,58 @@ import { getVirusScanServiceInstance, getVoiceRepository, getWebhookRepository, -} from './ServiceSingletons'; +} from '@app/api/middleware/ServiceSingletons'; +import {ApplicationService} from '@app/api/oauth/ApplicationService'; +import {OAuth2ApplicationsRequestService} from '@app/api/oauth/OAuth2ApplicationsRequestService'; +import {OAuth2RequestService} from '@app/api/oauth/OAuth2RequestService'; +import {OAuth2Service} from '@app/api/oauth/OAuth2Service'; +import {ReportRequestService} from '@app/api/report/ReportRequestService'; +import {ReportService} from '@app/api/report/ReportService'; +import type {IAccountPolicyEvaluator} from '@app/api/risk/AccountPolicyEvaluator'; +import { + getAccountPolicyEvaluator, + setInjectedAccountPolicyEvaluator as setInjectedAccountPolicyEvaluatorInService, +} from '@app/api/risk/AccountPolicyService'; +import {createIpInfoChecker} from '@app/api/risk/adapters/IpInfoAdapter'; +import {createReverseDnsLookup} from '@app/api/risk/adapters/ReverseDnsAdapter'; +import {DeterministicRiskEngine} from '@app/api/risk/DeterministicRiskEngine'; +import {CassandraHistoricalOutcomeRepository} from '@app/api/risk/HistoricalOutcomeRepository'; +import {createKvIpInfoLookupBudget} from '@app/api/risk/IpInfoBudget'; +import {buildIpInfoCache, buildIpInfoRequestAuditLogger} from '@app/api/risk/IpInfoCacheFactory'; +import {CassandraRegistrationEventsRepository} from '@app/api/risk/RegistrationEventsRepository'; +import { + type IpInfoPrescreenVerdict, + ipInfoPrescreenOptionsFromEnv, + prescreenIpInfoLookup, +} from '@app/api/risk/RegistrationIpPrescreen'; +import {CassandraRiskAssessmentRepository} from '@app/api/risk/RiskAssessmentRepository'; +import {createRiskToolbox} from '@app/api/risk/RiskToolboxFactory'; +import {CassandraSuspiciousIpRepository} from '@app/api/risk/SuspiciousIpRepository'; +import {RpcService} from '@app/api/rpc/RpcService'; +import {getReportSearchService} from '@app/api/SearchFactory'; +import {SearchService} from '@app/api/search/SearchService'; +import {StripeService} from '@app/api/stripe/StripeService'; +import {AgeVerificationService} from '@app/api/stripe/services/AgeVerificationService'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {EmailChangeService} from '@app/api/user/services/EmailChangeService'; +import {MfaBackupCodesChallengeService} from '@app/api/user/services/MfaBackupCodesChallengeService'; +import {PasswordChangeService} from '@app/api/user/services/PasswordChangeService'; +import {UserAccountRequestService} from '@app/api/user/services/UserAccountRequestService'; +import {UserAuthRequestService} from '@app/api/user/services/UserAuthRequestService'; +import {UserChannelRequestService} from '@app/api/user/services/UserChannelRequestService'; +import {UserContentRequestService} from '@app/api/user/services/UserContentRequestService'; +import {UserRelationshipRequestService} from '@app/api/user/services/UserRelationshipRequestService'; +import {UserService} from '@app/api/user/services/UserService'; +import {getRequestClientIp} from '@app/api/utils/RequestClientIp'; +import {VoiceService} from '@app/api/voice/VoiceService'; +import {WebhookRequestService} from '@app/api/webhook/WebhookRequestService'; +import {WebhookService} from '@app/api/webhook/WebhookService'; +import {lookupAsnByIp, lookupGeoipByIp} from '@pkgs/geoip/src/GeoipLookup'; +import {createIpInfoService, createUnavailableIpInfoService, type IpInfoService} from '@pkgs/geoip/src/IpInfoService'; +import {createMiddleware} from 'hono/factory'; -export {initializeServiceSingletons} from './ServiceSingletons'; +export {initializeServiceSingletons} from '@app/api/middleware/ServiceSingletons'; let _reportService: ReportService | null = null; diff --git a/fluxer_api/src/api/middleware/ServiceRegistry.ts b/fluxer_api/src/api/middleware/ServiceRegistry.ts index e5a690b07..03fd1087c 100644 --- a/fluxer_api/src/api/middleware/ServiceRegistry.ts +++ b/fluxer_api/src/api/middleware/ServiceRegistry.ts @@ -1,37 +1,37 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {BillingRepository} from '@app/api/billing/repositories/BillingRepository'; +import {BlueskyOAuthService} from '@app/api/bluesky/BlueskyOAuthService'; +import {DisabledBlueskyOAuthService} from '@app/api/bluesky/DisabledBlueskyOAuthService'; +import type {IBlueskyOAuthService} from '@app/api/bluesky/IBlueskyOAuthService'; +import {Config} from '@app/api/Config'; +import type {BlueskyOAuthConfig} from '@app/api/config/APIConfig'; +import {DisabledLiveKitService} from '@app/api/infrastructure/DisabledLiveKitService'; +import {GatewayService as ProdGatewayService} from '@app/api/infrastructure/GatewayService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ILiveKitService} from '@app/api/infrastructure/ILiveKitService'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import {InMemoryVoiceRoomStore} from '@app/api/infrastructure/InMemoryVoiceRoomStore'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IVoiceRoomStore} from '@app/api/infrastructure/IVoiceRoomStore'; +import {LiveKitService} from '@app/api/infrastructure/LiveKitService'; +import {MediaService as ProdMediaService} from '@app/api/infrastructure/MediaService'; +import {SnowflakeService} from '@app/api/infrastructure/SnowflakeService'; +import {VoiceRoomStore} from '@app/api/infrastructure/VoiceRoomStore'; +import type {InstanceConfigRepository} from '@app/api/instance/InstanceConfigRepository'; +import {Logger} from '@app/api/Logger'; +import {setInjectedSearchProvider} from '@app/api/SearchFactory'; +import type {ISearchProvider} from '@app/api/search/ISearchProvider'; +import {readOptionalIntegerEnv} from '@app/api/utils/IntegerOptions'; +import {VoiceAvailabilityService} from '@app/api/voice/VoiceAvailabilityService'; +import {VoiceRepository} from '@app/api/voice/VoiceRepository'; +import {VoiceServerLoadTracker} from '@app/api/voice/VoiceServerLoad'; +import {VoiceTopology} from '@app/api/voice/VoiceTopology'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {KVClient} from '@pkgs/kv_client/src/KVClient'; import {NatsConnectionManager} from '@pkgs/nats/src/NatsConnectionManager'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import {BillingRepository} from '../billing/repositories/BillingRepository'; -import {BlueskyOAuthService} from '../bluesky/BlueskyOAuthService'; -import {DisabledBlueskyOAuthService} from '../bluesky/DisabledBlueskyOAuthService'; -import type {IBlueskyOAuthService} from '../bluesky/IBlueskyOAuthService'; -import {Config} from '../Config'; -import type {BlueskyOAuthConfig} from '../config/APIConfig'; -import {DisabledLiveKitService} from '../infrastructure/DisabledLiveKitService'; -import {GatewayService as ProdGatewayService} from '../infrastructure/GatewayService'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {ILiveKitService} from '../infrastructure/ILiveKitService'; -import type {IMediaService} from '../infrastructure/IMediaService'; -import {InMemoryVoiceRoomStore} from '../infrastructure/InMemoryVoiceRoomStore'; -import type {ISnowflakeService} from '../infrastructure/ISnowflakeService'; -import type {IVoiceRoomStore} from '../infrastructure/IVoiceRoomStore'; -import {LiveKitService} from '../infrastructure/LiveKitService'; -import {MediaService as ProdMediaService} from '../infrastructure/MediaService'; -import {SnowflakeService} from '../infrastructure/SnowflakeService'; -import {VoiceRoomStore} from '../infrastructure/VoiceRoomStore'; -import type {InstanceConfigRepository} from '../instance/InstanceConfigRepository'; -import {Logger} from '../Logger'; -import {setInjectedSearchProvider} from '../SearchFactory'; -import type {ISearchProvider} from '../search/ISearchProvider'; -import {readOptionalIntegerEnv} from '../utils/IntegerOptions'; -import {VoiceAvailabilityService} from '../voice/VoiceAvailabilityService'; -import {VoiceRepository} from '../voice/VoiceRepository'; -import {VoiceServerLoadTracker} from '../voice/VoiceServerLoad'; -import {VoiceTopology} from '../voice/VoiceTopology'; -import type {WorkerTaskName} from '../worker/WorkerLaneConfig'; export function createSnowflakeService(): SnowflakeService { const connectionManager = new NatsConnectionManager({ diff --git a/fluxer_api/src/api/middleware/ServiceSingletons.ts b/fluxer_api/src/api/middleware/ServiceSingletons.ts index 8e1a4c69f..a754f66c0 100644 --- a/fluxer_api/src/api/middleware/ServiceSingletons.ts +++ b/fluxer_api/src/api/middleware/ServiceSingletons.ts @@ -1,5 +1,96 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import {AdminApiKeyRepository} from '@app/api/admin/repositories/AdminApiKeyRepository'; +import {AdminArchiveRepository} from '@app/api/admin/repositories/AdminArchiveRepository'; +import {AdminApiKeyService} from '@app/api/admin/services/AdminApiKeyService'; +import {AdminArchiveService} from '@app/api/admin/services/AdminArchiveService'; +import {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {PhoneAttemptRiskService} from '@app/api/auth/services/PhoneAttemptRiskService'; +import {PhoneFraudGraphService} from '@app/api/auth/services/PhoneFraudGraphService'; +import type {UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {ChannelRepository} from '@app/api/channel/ChannelRepository'; +import {AttachmentUploadTraceRepository} from '@app/api/channel/repositories/message/AttachmentUploadTraceRepository'; +import {StreamPreviewService} from '@app/api/channel/services/StreamPreviewService'; +import type {APIConfig} from '@app/api/config/APIConfig'; +import {ConnectionRepository} from '@app/api/connection/ConnectionRepository'; +import {createNcmecApiConfig, NcmecReporter} from '@app/api/csam/NcmecReporter'; +import {NcmecRepository} from '@app/api/csam/NcmecRepository'; +import {NcmecSubmissionService} from '@app/api/csam/NcmecSubmissionService'; +import {DonationRepository} from '@app/api/donation/DonationRepository'; +import {DownloadService} from '@app/api/download/DownloadService'; +import {createEmailProvider} from '@app/api/email/EmailProviderFactory'; +import {FavoriteMemeRepository} from '@app/api/favorite_meme/FavoriteMemeRepository'; +import {GatewayRequestService} from '@app/api/gateway/GatewayRequestService'; +import {GifService} from '@app/api/gif/GifService'; +import {createNatsGifProvider} from '@app/api/gif/NatsGifProvider'; +import {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import {GuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; +import {GuildDiscoveryService} from '@app/api/guild/services/GuildDiscoveryService'; +import {AssetDeletionQueue} from '@app/api/infrastructure/AssetDeletionQueue'; +import {AvatarService} from '@app/api/infrastructure/AvatarService'; +import {BunnyPurgeQueue, type IPurgeQueue, NoopPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import {DisabledVirusScanService} from '@app/api/infrastructure/DisabledVirusScanService'; +import {DiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import {EmailDnsValidationService} from '@app/api/infrastructure/EmailDnsValidationService'; +import {EmbedService} from '@app/api/infrastructure/EmbedService'; +import {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import {ErrorI18nService} from '@app/api/infrastructure/ErrorI18nService'; +import type {IAssetDeletionQueue} from '@app/api/infrastructure/IAssetDeletionQueue'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {IUnfurlerService} from '@app/api/infrastructure/IUnfurlerService'; +import {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import {KVActivityTracker} from '@app/api/infrastructure/KVActivityTracker'; +import {KVBulkMessageDeletionQueueService} from '@app/api/infrastructure/KVBulkMessageDeletionQueueService'; +import {NatsUnfurlerService} from '@app/api/infrastructure/NatsUnfurlerService'; +import {PremiumStateReconciliationQueueService} from '@app/api/infrastructure/PremiumStateReconciliationQueueService'; +import {createDownloadsStorageService, createStorageService} from '@app/api/infrastructure/StorageServiceFactory'; +import {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {createUsersServiceClient} from '@app/api/infrastructure/UsersServiceClient'; +import {VirusScanService} from '@app/api/infrastructure/VirusScanService'; +import {GatewayRolloutConfigPublisher} from '@app/api/instance/GatewayRolloutConfigPublisher'; +import {InstanceConfigRepository} from '@app/api/instance/InstanceConfigRepository'; +import {InviteRepository} from '@app/api/invite/InviteRepository'; +import {Logger} from '@app/api/Logger'; +import {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import { + acquireSnowflakeService, + getGatewayService, + getKVClient, + getMediaService, + getSnowflakeService, + getWorkerService, + releaseSnowflakeService, + type SnowflakeServiceHandle, +} from '@app/api/middleware/ServiceRegistry'; +import {clearSingletonsForTesting, singleton} from '@app/api/middleware/Singleton'; +import {BotAuthService} from '@app/api/oauth/BotAuthService'; +import {BotMfaMirrorService} from '@app/api/oauth/BotMfaMirrorService'; +import {ApplicationRepository} from '@app/api/oauth/repositories/ApplicationRepository'; +import {OAuth2TokenRepository} from '@app/api/oauth/repositories/OAuth2TokenRepository'; +import {ReadStateRepository} from '@app/api/read_state/ReadStateRepository'; +import {ReadStateRequestService} from '@app/api/read_state/ReadStateRequestService'; +import {ReadStateService} from '@app/api/read_state/ReadStateService'; +import {ReportRepository} from '@app/api/report/ReportRepository'; +import {getGuildSearchService} from '@app/api/SearchFactory'; +import {ThemeService} from '@app/api/theme/ThemeService'; +import {EntranceSoundPlayService} from '@app/api/user/entrance_sound/EntranceSoundPlayService'; +import {EntranceSoundRepository} from '@app/api/user/entrance_sound/EntranceSoundRepository'; +import {EntranceSoundService} from '@app/api/user/entrance_sound/EntranceSoundService'; +import {EmailChangeRepository} from '@app/api/user/repositories/auth/EmailChangeRepository'; +import {PasswordChangeRepository} from '@app/api/user/repositories/auth/PasswordChangeRepository'; +import {UserContactChangeLogRepository} from '@app/api/user/repositories/UserContactChangeLogRepository'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {VisionarySlotRepository} from '@app/api/user/repositories/VisionarySlotRepository'; +import {UserActivityBuffer} from '@app/api/user/services/UserActivityBuffer'; +import {UserContactChangeLogService} from '@app/api/user/services/UserContactChangeLogService'; +import {awaitAll} from '@app/api/utils/ConcurrencyUtils'; +import {UserPermissionUtils} from '@app/api/utils/UserPermissionUtils'; +import {VoiceRepository} from '@app/api/voice/VoiceRepository'; +import {SweegoWebhookService} from '@app/api/webhook/SweegoWebhookService'; +import {WebhookRepository} from '@app/api/webhook/WebhookRepository'; import {createMockLogger} from '@fluxer/logger/src/mock'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {KVCacheProvider} from '@pkgs/cache/src/providers/KVCacheProvider'; @@ -15,97 +106,6 @@ import type {ISmsProvider} from '@pkgs/sms/src/providers/ISmsProvider'; import {createSmsProvider} from '@pkgs/sms/src/providers/SmsProviderFactory'; import {SmsService} from '@pkgs/sms/src/SmsService'; import type {IVirusScanService} from '@pkgs/virus_scan/src/IVirusScanService'; -import {AdminRepository} from '../admin/AdminRepository'; -import {AdminApiKeyRepository} from '../admin/repositories/AdminApiKeyRepository'; -import {AdminArchiveRepository} from '../admin/repositories/AdminArchiveRepository'; -import {AdminApiKeyService} from '../admin/services/AdminApiKeyService'; -import {AdminArchiveService} from '../admin/services/AdminArchiveService'; -import {AdminAuditService} from '../admin/services/AdminAuditService'; -import {PhoneAttemptRiskService} from '../auth/services/PhoneAttemptRiskService'; -import {PhoneFraudGraphService} from '../auth/services/PhoneFraudGraphService'; -import type {UserID} from '../BrandedTypes'; -import {Config} from '../Config'; -import {ChannelRepository} from '../channel/ChannelRepository'; -import {AttachmentUploadTraceRepository} from '../channel/repositories/message/AttachmentUploadTraceRepository'; -import {StreamPreviewService} from '../channel/services/StreamPreviewService'; -import type {APIConfig} from '../config/APIConfig'; -import {ConnectionRepository} from '../connection/ConnectionRepository'; -import {createNcmecApiConfig, NcmecReporter} from '../csam/NcmecReporter'; -import {NcmecRepository} from '../csam/NcmecRepository'; -import {NcmecSubmissionService} from '../csam/NcmecSubmissionService'; -import {DonationRepository} from '../donation/DonationRepository'; -import {DownloadService} from '../download/DownloadService'; -import {createEmailProvider} from '../email/EmailProviderFactory'; -import {FavoriteMemeRepository} from '../favorite_meme/FavoriteMemeRepository'; -import {GatewayRequestService} from '../gateway/GatewayRequestService'; -import {GifService} from '../gif/GifService'; -import {createNatsGifProvider} from '../gif/NatsGifProvider'; -import {GuildAuditLogService} from '../guild/GuildAuditLogService'; -import {GuildDiscoveryRepository} from '../guild/repositories/GuildDiscoveryRepository'; -import {GuildRepository} from '../guild/repositories/GuildRepository'; -import {GuildDiscoveryService} from '../guild/services/GuildDiscoveryService'; -import {AssetDeletionQueue} from '../infrastructure/AssetDeletionQueue'; -import {AvatarService} from '../infrastructure/AvatarService'; -import {BunnyPurgeQueue, type IPurgeQueue, NoopPurgeQueue} from '../infrastructure/BunnyPurgeQueue'; -import {DisabledVirusScanService} from '../infrastructure/DisabledVirusScanService'; -import {DiscriminatorService} from '../infrastructure/DiscriminatorService'; -import {EmailDnsValidationService} from '../infrastructure/EmailDnsValidationService'; -import {EmbedService} from '../infrastructure/EmbedService'; -import {EntityAssetService} from '../infrastructure/EntityAssetService'; -import {ErrorI18nService} from '../infrastructure/ErrorI18nService'; -import type {IAssetDeletionQueue} from '../infrastructure/IAssetDeletionQueue'; -import type {IStorageService} from '../infrastructure/IStorageService'; -import type {IUnfurlerService} from '../infrastructure/IUnfurlerService'; -import {KVAccountDeletionQueueService} from '../infrastructure/KVAccountDeletionQueueService'; -import {KVActivityTracker} from '../infrastructure/KVActivityTracker'; -import {KVBulkMessageDeletionQueueService} from '../infrastructure/KVBulkMessageDeletionQueueService'; -import {NatsUnfurlerService} from '../infrastructure/NatsUnfurlerService'; -import {PremiumStateReconciliationQueueService} from '../infrastructure/PremiumStateReconciliationQueueService'; -import {createDownloadsStorageService, createStorageService} from '../infrastructure/StorageServiceFactory'; -import {UserCacheService} from '../infrastructure/UserCacheService'; -import {createUsersServiceClient} from '../infrastructure/UsersServiceClient'; -import {VirusScanService} from '../infrastructure/VirusScanService'; -import {GatewayRolloutConfigPublisher} from '../instance/GatewayRolloutConfigPublisher'; -import {InstanceConfigRepository} from '../instance/InstanceConfigRepository'; -import {InviteRepository} from '../invite/InviteRepository'; -import {Logger} from '../Logger'; -import {LimitConfigService} from '../limits/LimitConfigService'; -import {BotAuthService} from '../oauth/BotAuthService'; -import {BotMfaMirrorService} from '../oauth/BotMfaMirrorService'; -import {ApplicationRepository} from '../oauth/repositories/ApplicationRepository'; -import {OAuth2TokenRepository} from '../oauth/repositories/OAuth2TokenRepository'; -import {ReadStateRepository} from '../read_state/ReadStateRepository'; -import {ReadStateRequestService} from '../read_state/ReadStateRequestService'; -import {ReadStateService} from '../read_state/ReadStateService'; -import {ReportRepository} from '../report/ReportRepository'; -import {getGuildSearchService} from '../SearchFactory'; -import {ThemeService} from '../theme/ThemeService'; -import {EntranceSoundPlayService} from '../user/entrance_sound/EntranceSoundPlayService'; -import {EntranceSoundRepository} from '../user/entrance_sound/EntranceSoundRepository'; -import {EntranceSoundService} from '../user/entrance_sound/EntranceSoundService'; -import {EmailChangeRepository} from '../user/repositories/auth/EmailChangeRepository'; -import {PasswordChangeRepository} from '../user/repositories/auth/PasswordChangeRepository'; -import {UserContactChangeLogRepository} from '../user/repositories/UserContactChangeLogRepository'; -import {UserRepository} from '../user/repositories/UserRepository'; -import {VisionarySlotRepository} from '../user/repositories/VisionarySlotRepository'; -import {UserActivityBuffer} from '../user/services/UserActivityBuffer'; -import {UserContactChangeLogService} from '../user/services/UserContactChangeLogService'; -import {awaitAll} from '../utils/ConcurrencyUtils'; -import {UserPermissionUtils} from '../utils/UserPermissionUtils'; -import {VoiceRepository} from '../voice/VoiceRepository'; -import {SweegoWebhookService} from '../webhook/SweegoWebhookService'; -import {WebhookRepository} from '../webhook/WebhookRepository'; -import { - acquireSnowflakeService, - getGatewayService, - getKVClient, - getMediaService, - getSnowflakeService, - getWorkerService, - releaseSnowflakeService, - type SnowflakeServiceHandle, -} from './ServiceRegistry'; -import {clearSingletonsForTesting, singleton} from './Singleton'; export const getUserRepository = singleton(() => new UserRepository(getKVClient())); export const getGuildRepository = singleton(() => new GuildRepository()); diff --git a/fluxer_api/src/api/middleware/SudoModeMiddleware.ts b/fluxer_api/src/api/middleware/SudoModeMiddleware.ts index 2c389239c..c7fb3c426 100644 --- a/fluxer_api/src/api/middleware/SudoModeMiddleware.ts +++ b/fluxer_api/src/api/middleware/SudoModeMiddleware.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getSudoModeService} from '@app/api/auth/services/SudoModeService'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {createMiddleware} from 'hono/factory'; -import {getSudoModeService} from '../auth/services/SudoModeService'; -import type {HonoEnv} from '../types/HonoEnv'; export const SUDO_MODE_HEADER = 'X-Fluxer-Sudo-Mode-JWT'; export const SudoModeMiddleware = createMiddleware(async (ctx, next) => { diff --git a/fluxer_api/src/api/middleware/TorExitListCache.ts b/fluxer_api/src/api/middleware/TorExitListCache.ts index a33141bbf..81e4f2dae 100644 --- a/fluxer_api/src/api/middleware/TorExitListCache.ts +++ b/fluxer_api/src/api/middleware/TorExitListCache.ts @@ -2,11 +2,11 @@ import {randomInt, randomUUID} from 'node:crypto'; import {setTimeout as delay} from 'node:timers/promises'; +import {Logger} from '@app/api/Logger'; +import {streamToStringWithLimit} from '@app/api/utils/FetchUtils'; import {parseIpAddress} from '@fluxer/ip_utils/src/IpAddress'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {z} from 'zod'; -import {Logger} from '../Logger'; -import {streamToStringWithLimit} from '../utils/FetchUtils'; const ONIONOO_URL = 'https://onionoo.torproject.org/details?type=relay&running=true&flag=Exit&fields=exit_addresses,or_addresses'; diff --git a/fluxer_api/src/api/middleware/TorExitMiddleware.ts b/fluxer_api/src/api/middleware/TorExitMiddleware.ts index dcce1406c..4ec6c287d 100644 --- a/fluxer_api/src/api/middleware/TorExitMiddleware.ts +++ b/fluxer_api/src/api/middleware/TorExitMiddleware.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {torExitListCache} from '@app/api/middleware/TorExitListCache'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {getRequestClientIp} from '@app/api/utils/RequestClientIp'; import {IpBannedError} from '@fluxer/errors/src/domains/moderation/IpBannedError'; import {createMiddleware} from 'hono/factory'; -import type {HonoEnv} from '../types/HonoEnv'; -import {getRequestClientIp} from '../utils/RequestClientIp'; -import {torExitListCache} from './TorExitListCache'; export const TorExitMiddleware = createMiddleware(async (ctx, next) => { const clientIp = getRequestClientIp(ctx); diff --git a/fluxer_api/src/api/middleware/TrustedClientIpHeaderMiddleware.ts b/fluxer_api/src/api/middleware/TrustedClientIpHeaderMiddleware.ts index 90b2032b2..8e650b78f 100644 --- a/fluxer_api/src/api/middleware/TrustedClientIpHeaderMiddleware.ts +++ b/fluxer_api/src/api/middleware/TrustedClientIpHeaderMiddleware.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ILogger} from '@app/api/ILogger'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {resolveClientIpWithOptions} from '@app/api/utils/RequestClientIp'; +import {stripApiPrefix} from '@app/api/utils/RequestPathUtils'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {ForbiddenError} from '@fluxer/errors/src/domains/core/ForbiddenError'; import {createMiddleware} from 'hono/factory'; -import type {ILogger} from '../ILogger'; -import type {HonoEnv} from '../types/HonoEnv'; -import {resolveClientIpWithOptions} from '../utils/RequestClientIp'; -import {stripApiPrefix} from '../utils/RequestPathUtils'; interface TrustedClientIpHeaderOptions { enabled: boolean; diff --git a/fluxer_api/src/api/middleware/UrlBlocklistCache.ts b/fluxer_api/src/api/middleware/UrlBlocklistCache.ts index 0dec7e162..e3c816e30 100644 --- a/fluxer_api/src/api/middleware/UrlBlocklistCache.ts +++ b/fluxer_api/src/api/middleware/UrlBlocklistCache.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import {BANNED_URL_DOMAINS_REFRESH_CHANNEL, BANNED_URLS_REFRESH_CHANNEL} from '@app/api/constants/ContentModeration'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import {RISK_S3_KEYS, readLinesFromS3} from '@app/api/risk/RiskBlocklistS3'; +import {RefreshSubscription} from '@app/api/utils/RefreshSubscription'; +import {canonicalizeUrl} from '@app/api/utils/UrlNormalizer'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {AdminRepository} from '../admin/AdminRepository'; -import {BANNED_URL_DOMAINS_REFRESH_CHANNEL, BANNED_URLS_REFRESH_CHANNEL} from '../constants/ContentModeration'; -import type {IStorageService} from '../infrastructure/IStorageService'; -import {Logger} from '../Logger'; -import {RISK_S3_KEYS, readLinesFromS3} from '../risk/RiskBlocklistS3'; -import {RefreshSubscription} from '../utils/RefreshSubscription'; -import {canonicalizeUrl} from '../utils/UrlNormalizer'; class UrlBlocklistCache { private exactUrls: Set = new Set(); diff --git a/fluxer_api/src/api/middleware/UserMiddleware.ts b/fluxer_api/src/api/middleware/UserMiddleware.ts index 2c70b6591..4fe6bb5a8 100644 --- a/fluxer_api/src/api/middleware/UserMiddleware.ts +++ b/fluxer_api/src/api/middleware/UserMiddleware.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import * as AuthSession from '@app/api/auth/AuthSession'; +import {Logger} from '@app/api/Logger'; +import {hashAuthToken, recordAbuseSignal} from '@app/api/middleware/AbusiveIpAutoBanner'; +import type {User} from '@app/api/models/User'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {requireRequestClientIp} from '@app/api/utils/RequestClientIp'; +import {stripApiPrefix} from '@app/api/utils/RequestPathUtils'; import type {Context} from 'hono'; import {createMiddleware} from 'hono/factory'; -import * as AuthSession from '../auth/AuthSession'; -import {Logger} from '../Logger'; -import type {User} from '../models/User'; -import type {HonoEnv} from '../types/HonoEnv'; -import {requireRequestClientIp} from '../utils/RequestClientIp'; -import {stripApiPrefix} from '../utils/RequestPathUtils'; -import {hashAuthToken, recordAbuseSignal} from './AbusiveIpAutoBanner'; type TokenType = 'session' | 'bearer' | 'bot' | 'admin_api_key'; diff --git a/fluxer_api/src/api/middleware/tests/AbusiveIpAutoBanner.test.ts b/fluxer_api/src/api/middleware/tests/AbusiveIpAutoBanner.test.ts index 10dfd18a5..1066fba3d 100644 --- a/fluxer_api/src/api/middleware/tests/AbusiveIpAutoBanner.test.ts +++ b/fluxer_api/src/api/middleware/tests/AbusiveIpAutoBanner.test.ts @@ -1,12 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress'; -import type {IpInfoLookupResult} from '@pkgs/geoip/src/IpInfoService'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {AdminRepository} from '../../admin/AdminRepository'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createApiTestHarness} from '../../test/ApiTestHarness'; -import type {MockKVProvider} from '../../test/mocks/MockKVProvider'; +import {AdminRepository} from '@app/api/admin/AdminRepository'; import { drainAbuseAutoBanTasksForTests, drainAbuseIpClassLookupsForTests, @@ -16,9 +10,15 @@ import { setAbuseIpClassTtlsForTests, startAbuseReplicationSubscriber, stopAbuseReplicationSubscriber, -} from '../AbusiveIpAutoBanner'; -import {ipBanCache} from '../IpBanMiddleware'; -import {setInjectedIpInfoService} from '../ServiceMiddleware'; +} from '@app/api/middleware/AbusiveIpAutoBanner'; +import {ipBanCache} from '@app/api/middleware/IpBanMiddleware'; +import {setInjectedIpInfoService} from '@app/api/middleware/ServiceMiddleware'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import type {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress'; +import type {IpInfoLookupResult} from '@pkgs/geoip/src/IpInfoService'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; function ipInfoResult(ip: string, overrides: Partial = {}): IpInfoLookupResult { return { diff --git a/fluxer_api/src/api/middleware/tests/AbusiveIpClassReplication.test.ts b/fluxer_api/src/api/middleware/tests/AbusiveIpClassReplication.test.ts index 7ff76c137..2a7ed433f 100644 --- a/fluxer_api/src/api/middleware/tests/AbusiveIpClassReplication.test.ts +++ b/fluxer_api/src/api/middleware/tests/AbusiveIpClassReplication.test.ts @@ -1,10 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IpInfoLookupResult} from '@pkgs/geoip/src/IpInfoService'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createApiTestHarness} from '../../test/ApiTestHarness'; -import type {MockKVProvider} from '../../test/mocks/MockKVProvider'; import { drainAbuseAutoBanTasksForTests, drainAbuseIpClassLookupsForTests, @@ -14,9 +9,14 @@ import { setAbuseIpClassTtlsForTests, startAbuseReplicationSubscriber, stopAbuseReplicationSubscriber, -} from '../AbusiveIpAutoBanner'; -import {ipBanCache} from '../IpBanMiddleware'; -import {setInjectedIpInfoService} from '../ServiceMiddleware'; +} from '@app/api/middleware/AbusiveIpAutoBanner'; +import {ipBanCache} from '@app/api/middleware/IpBanMiddleware'; +import {setInjectedIpInfoService} from '@app/api/middleware/ServiceMiddleware'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import type {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import type {IpInfoLookupResult} from '@pkgs/geoip/src/IpInfoService'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; function ipInfoResult(ip: string, overrides: Partial = {}): IpInfoLookupResult { return { diff --git a/fluxer_api/src/api/middleware/tests/CaptchaProviderHeader.test.ts b/fluxer_api/src/api/middleware/tests/CaptchaProviderHeader.test.ts index dfc9c8613..cd194df02 100644 --- a/fluxer_api/src/api/middleware/tests/CaptchaProviderHeader.test.ts +++ b/fluxer_api/src/api/middleware/tests/CaptchaProviderHeader.test.ts @@ -1,12 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type { + InstanceCaptchaEffectiveConfig, + InstanceConfigRepository, +} from '@app/api/instance/InstanceConfigRepository'; +import {CaptchaMiddleware} from '@app/api/middleware/CaptchaMiddleware'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {AppErrorHandler} from '@fluxer/errors/src/domains/core/ErrorHandlers'; import {Hono} from 'hono'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {Config} from '../../Config'; -import type {InstanceCaptchaEffectiveConfig, InstanceConfigRepository} from '../../instance/InstanceConfigRepository'; -import type {HonoEnv} from '../../types/HonoEnv'; -import {CaptchaMiddleware} from '../CaptchaMiddleware'; const HCAPTCHA_ONLY: InstanceCaptchaEffectiveConfig = { enabled: true, diff --git a/fluxer_api/src/api/middleware/tests/ClientIpResolution.test.ts b/fluxer_api/src/api/middleware/tests/ClientIpResolution.test.ts index 6c83d49e8..0ac7b2ef7 100644 --- a/fluxer_api/src/api/middleware/tests/ClientIpResolution.test.ts +++ b/fluxer_api/src/api/middleware/tests/ClientIpResolution.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {IpBanMiddleware, ipBanCache} from '@app/api/middleware/IpBanMiddleware'; +import {torExitListCache} from '@app/api/middleware/TorExitListCache'; +import {TorExitMiddleware} from '@app/api/middleware/TorExitMiddleware'; +import {TrustedClientIpHeaderMiddleware} from '@app/api/middleware/TrustedClientIpHeaderMiddleware'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import type {ClientIpResolution} from '@app/api/utils/RequestClientIp'; import {ForbiddenError} from '@fluxer/errors/src/domains/core/ForbiddenError'; import {IpBannedError} from '@fluxer/errors/src/domains/moderation/IpBannedError'; import {Hono} from 'hono'; import {beforeEach, describe, expect, it} from 'vitest'; -import {NoopLogger} from '../../test/mocks/NoopLogger'; -import type {HonoEnv} from '../../types/HonoEnv'; -import type {ClientIpResolution} from '../../utils/RequestClientIp'; -import {IpBanMiddleware, ipBanCache} from '../IpBanMiddleware'; -import {torExitListCache} from '../TorExitListCache'; -import {TorExitMiddleware} from '../TorExitMiddleware'; -import {TrustedClientIpHeaderMiddleware} from '../TrustedClientIpHeaderMiddleware'; interface Pipeline { request: (headers: Record) => Promise; diff --git a/fluxer_api/src/api/middleware/tests/ConcurrencyLimitMiddleware.test.ts b/fluxer_api/src/api/middleware/tests/ConcurrencyLimitMiddleware.test.ts index f6937c803..8c2abe069 100644 --- a/fluxer_api/src/api/middleware/tests/ConcurrencyLimitMiddleware.test.ts +++ b/fluxer_api/src/api/middleware/tests/ConcurrencyLimitMiddleware.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {ConcurrencyLimitMiddleware} from '@app/api/middleware/ConcurrencyLimitMiddleware'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {AppErrorHandler} from '@fluxer/errors/src/domains/core/ErrorHandlers'; import {ServiceUnavailableError} from '@fluxer/errors/src/domains/core/ServiceUnavailableError'; import {Logger} from '@fluxer/logger/src/Logger'; import {Hono} from 'hono'; import {describe, expect, test, vi} from 'vitest'; -import type {HonoEnv} from '../../types/HonoEnv'; -import {ConcurrencyLimitMiddleware} from '../ConcurrencyLimitMiddleware'; interface Deferred { promise: Promise; diff --git a/fluxer_api/src/api/middleware/tests/ContentFilterMiddleware.test.ts b/fluxer_api/src/api/middleware/tests/ContentFilterMiddleware.test.ts index 23025c71e..90f9fe744 100644 --- a/fluxer_api/src/api/middleware/tests/ContentFilterMiddleware.test.ts +++ b/fluxer_api/src/api/middleware/tests/ContentFilterMiddleware.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {extractStringValues, shouldSkipContentFilterPath} from '@app/api/middleware/ContentFilterMiddleware'; import {describe, expect, test} from 'vitest'; -import {extractStringValues, shouldSkipContentFilterPath} from '../ContentFilterMiddleware'; describe('extractStringValues', () => { test('returns text from user-generated content fields', () => { diff --git a/fluxer_api/src/api/middleware/tests/GlobalRateLimitRevokesSession.test.ts b/fluxer_api/src/api/middleware/tests/GlobalRateLimitRevokesSession.test.ts index 0e00360a0..05c3c951d 100644 --- a/fluxer_api/src/api/middleware/tests/GlobalRateLimitRevokesSession.test.ts +++ b/fluxer_api/src/api/middleware/tests/GlobalRateLimitRevokesSession.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createAuthHarness, createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; const HTTP_TOO_MANY_REQUESTS = 429; diff --git a/fluxer_api/src/api/middleware/tests/IpBanMiddleware.test.ts b/fluxer_api/src/api/middleware/tests/IpBanMiddleware.test.ts index d817bdb4f..2076a3590 100644 --- a/fluxer_api/src/api/middleware/tests/IpBanMiddleware.test.ts +++ b/fluxer_api/src/api/middleware/tests/IpBanMiddleware.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {ipBanCache} from '@app/api/middleware/IpBanMiddleware'; import {beforeEach, describe, expect, it} from 'vitest'; -import {ipBanCache} from '../IpBanMiddleware'; beforeEach(() => { ipBanCache.resetCaches(); diff --git a/fluxer_api/src/api/middleware/tests/LazyServiceProvider.test.ts b/fluxer_api/src/api/middleware/tests/LazyServiceProvider.test.ts index 4a27c96b0..dc7a69926 100644 --- a/fluxer_api/src/api/middleware/tests/LazyServiceProvider.test.ts +++ b/fluxer_api/src/api/middleware/tests/LazyServiceProvider.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {installLazyServices, type LazyServiceProvider} from '@app/api/middleware/LazyServiceProvider'; +import {ServiceMiddleware} from '@app/api/middleware/ServiceMiddleware'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {Hono} from 'hono'; import {afterAll, beforeAll, describe, expect, it} from 'vitest'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createApiTestHarness} from '../../test/ApiTestHarness'; -import type {HonoEnv} from '../../types/HonoEnv'; -import {installLazyServices, type LazyServiceProvider} from '../LazyServiceProvider'; -import {ServiceMiddleware} from '../ServiceMiddleware'; const NO_CONTENT = 204; diff --git a/fluxer_api/src/api/middleware/tests/PhraseBlocklistCache.test.ts b/fluxer_api/src/api/middleware/tests/PhraseBlocklistCache.test.ts index 9085083f7..aa2650229 100644 --- a/fluxer_api/src/api/middleware/tests/PhraseBlocklistCache.test.ts +++ b/fluxer_api/src/api/middleware/tests/PhraseBlocklistCache.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {PhraseBlocklistCache} from '@app/api/middleware/PhraseBlocklistCache'; import {beforeEach, describe, expect, it} from 'vitest'; -import {PhraseBlocklistCache} from '../PhraseBlocklistCache'; describe('PhraseBlocklistCache', () => { let cache: PhraseBlocklistCache; diff --git a/fluxer_api/src/api/middleware/tests/PhraseBlocklistEquivalence.test.ts b/fluxer_api/src/api/middleware/tests/PhraseBlocklistEquivalence.test.ts index a1e9bc808..d5a47016b 100644 --- a/fluxer_api/src/api/middleware/tests/PhraseBlocklistEquivalence.test.ts +++ b/fluxer_api/src/api/middleware/tests/PhraseBlocklistEquivalence.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {PhraseBlocklistCache} from '@app/api/middleware/PhraseBlocklistCache'; +import {buildPhraseMatchForms, canonicalizeStoredPhrase} from '@app/api/utils/PhraseBlocklistNormalization'; +import {SubstringMatcher} from '@app/api/utils/SubstringMatcher'; import {transliterate} from 'transliteration'; import {describe, expect, test} from 'vitest'; -import {buildPhraseMatchForms, canonicalizeStoredPhrase} from '../../utils/PhraseBlocklistNormalization'; -import {SubstringMatcher} from '../../utils/SubstringMatcher'; -import {PhraseBlocklistCache} from '../PhraseBlocklistCache'; const LEGACY_CONTROL_OR_FORMAT_REGEX = /[\p{Cc}\p{Cf}\uFFFE\uFFFF]/gu; const LEGACY_VARIATION_SELECTOR_REGEX = /(?:[\uFE00-\uFE0F]|[\u{E0100}-\u{E01EF}])/gu; diff --git a/fluxer_api/src/api/middleware/tests/ProfileSubstringBlocklistCache.test.ts b/fluxer_api/src/api/middleware/tests/ProfileSubstringBlocklistCache.test.ts index e929f1041..d0cd830f8 100644 --- a/fluxer_api/src/api/middleware/tests/ProfileSubstringBlocklistCache.test.ts +++ b/fluxer_api/src/api/middleware/tests/ProfileSubstringBlocklistCache.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {ProfileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; import {beforeEach, describe, expect, it} from 'vitest'; -import {ProfileSubstringBlocklistCache} from '../ProfileSubstringBlocklistCache'; describe('ProfileSubstringBlocklistCache', () => { let cache: ProfileSubstringBlocklistCache; diff --git a/fluxer_api/src/api/middleware/tests/PublicRouteRateLimits.test.ts b/fluxer_api/src/api/middleware/tests/PublicRouteRateLimits.test.ts index 0c937ec39..a69882d3d 100644 --- a/fluxer_api/src/api/middleware/tests/PublicRouteRateLimits.test.ts +++ b/fluxer_api/src/api/middleware/tests/PublicRouteRateLimits.test.ts @@ -1,6 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import {BlueskyOAuthController} from '@app/api/bluesky/BlueskyOAuthController'; +import type {IBlueskyOAuthService} from '@app/api/bluesky/IBlueskyOAuthService'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {ConnectionRateLimitConfigs} from '@app/api/rate_limit_configs/ConnectionRateLimitConfig'; +import type {HonoApp, HonoEnv} from '@app/api/types/HonoEnv'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import type { BucketConfig, @@ -10,11 +15,6 @@ import type { } from '@pkgs/rate_limit/src/IRateLimitService'; import {Hono} from 'hono'; import {describe, expect, test} from 'vitest'; -import {BlueskyOAuthController} from '../../bluesky/BlueskyOAuthController'; -import type {IBlueskyOAuthService} from '../../bluesky/IBlueskyOAuthService'; -import {ConnectionRateLimitConfigs} from '../../rate_limit_configs/ConnectionRateLimitConfig'; -import type {HonoApp, HonoEnv} from '../../types/HonoEnv'; -import {RateLimitMiddleware} from '../RateLimitMiddleware'; const CLIENT_IP = '203.0.113.10'; const HTTP_TOO_MANY_REQUESTS = 429; diff --git a/fluxer_api/src/api/middleware/tests/RateLimitMiddleware.test.ts b/fluxer_api/src/api/middleware/tests/RateLimitMiddleware.test.ts index 2917ec75f..791656977 100644 --- a/fluxer_api/src/api/middleware/tests/RateLimitMiddleware.test.ts +++ b/fluxer_api/src/api/middleware/tests/RateLimitMiddleware.test.ts @@ -1,6 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import {RateLimitMiddleware, type RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import type { BucketConfig, IRateLimitService, @@ -9,8 +11,6 @@ import type { } from '@pkgs/rate_limit/src/IRateLimitService'; import {type Context, Hono} from 'hono'; import {describe, expect, test} from 'vitest'; -import type {HonoEnv} from '../../types/HonoEnv'; -import {RateLimitMiddleware, type RouteRateLimitConfig} from '../RateLimitMiddleware'; const CLIENT_IP = '203.0.113.10'; const SWAPPED_CLIENT_IP = '198.51.100.7'; diff --git a/fluxer_api/src/api/middleware/tests/RequireClientIpMiddleware.test.ts b/fluxer_api/src/api/middleware/tests/RequireClientIpMiddleware.test.ts index 2c3a80904..036b5b13f 100644 --- a/fluxer_api/src/api/middleware/tests/RequireClientIpMiddleware.test.ts +++ b/fluxer_api/src/api/middleware/tests/RequireClientIpMiddleware.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {RequireClientIpMiddleware} from '@app/api/middleware/RequireClientIpMiddleware'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import type {ClientIpResolution} from '@app/api/utils/RequestClientIp'; import {AppErrorHandler} from '@fluxer/errors/src/domains/core/ErrorHandlers'; import {Hono} from 'hono'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {Config} from '../../Config'; -import type {HonoEnv} from '../../types/HonoEnv'; -import type {ClientIpResolution} from '../../utils/RequestClientIp'; -import {RequireClientIpMiddleware} from '../RequireClientIpMiddleware'; interface Harness { request: (headers: Record) => Promise; diff --git a/fluxer_api/src/api/middleware/tests/ResponseTypeMiddleware.test.ts b/fluxer_api/src/api/middleware/tests/ResponseTypeMiddleware.test.ts index facf47675..a6ab3a632 100644 --- a/fluxer_api/src/api/middleware/tests/ResponseTypeMiddleware.test.ts +++ b/fluxer_api/src/api/middleware/tests/ResponseTypeMiddleware.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {OpenAPI, ResponseType} from '@app/api/middleware/ResponseTypeMiddleware'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {Logger} from '@fluxer/logger/src/Logger'; import {SnowflakeType} from '@fluxer/schema/src/primitives/SchemaPrimitives'; import {Hono} from 'hono'; import {afterEach, beforeEach, describe, expect, test, vi} from 'vitest'; import {z} from 'zod'; -import {Config} from '../../Config'; -import type {HonoEnv} from '../../types/HonoEnv'; -import {OpenAPI, ResponseType} from '../ResponseTypeMiddleware'; const SnowflakeResponse = z.object({id: SnowflakeType}); diff --git a/fluxer_api/src/api/middleware/tests/SessionWithMissingUserRow.test.ts b/fluxer_api/src/api/middleware/tests/SessionWithMissingUserRow.test.ts index 274b945f8..040569643 100644 --- a/fluxer_api/src/api/middleware/tests/SessionWithMissingUserRow.test.ts +++ b/fluxer_api/src/api/middleware/tests/SessionWithMissingUserRow.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import {createAuthHarness} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createAuthHarness} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../../user/repositories/UserRepository'; const MISSING_USER_ID = createUserID(999999999999999998n); const SESSION_TOKEN = 'flx_Zmlzc2lvbmVkc2Vzc2lvbnRva2VuMDAwMDAx'; diff --git a/fluxer_api/src/api/middleware/tests/TrustedClientIpHeaderMiddleware.test.ts b/fluxer_api/src/api/middleware/tests/TrustedClientIpHeaderMiddleware.test.ts index 2d40f7a6f..9a9251744 100644 --- a/fluxer_api/src/api/middleware/tests/TrustedClientIpHeaderMiddleware.test.ts +++ b/fluxer_api/src/api/middleware/tests/TrustedClientIpHeaderMiddleware.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ILogger} from '@app/api/ILogger'; +import {TrustedClientIpHeaderMiddleware} from '@app/api/middleware/TrustedClientIpHeaderMiddleware'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {Hono} from 'hono'; import {describe, expect, it} from 'vitest'; -import type {ILogger} from '../../ILogger'; -import type {HonoEnv} from '../../types/HonoEnv'; -import {TrustedClientIpHeaderMiddleware} from '../TrustedClientIpHeaderMiddleware'; class MockLogger implements ILogger { trace(_msgOrObject: string | object, _msg?: string): void {} diff --git a/fluxer_api/src/api/models/AdminApiKey.ts b/fluxer_api/src/api/models/AdminApiKey.ts index 58c668bde..099e7fd3b 100644 --- a/fluxer_api/src/api/models/AdminApiKey.ts +++ b/fluxer_api/src/api/models/AdminApiKey.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import type {AdminApiKeyRow} from '../database/types/AdminAuthTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {AdminApiKeyRow} from '@app/api/database/types/AdminAuthTypes'; export class AdminApiKey { readonly keyId: bigint; diff --git a/fluxer_api/src/api/models/Application.ts b/fluxer_api/src/api/models/Application.ts index 606d6329a..9f1b721fb 100644 --- a/fluxer_api/src/api/models/Application.ts +++ b/fluxer_api/src/api/models/Application.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApplicationID, UserID} from '../BrandedTypes'; -import type {ApplicationRow} from '../database/types/OAuth2Types'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; +import type {ApplicationRow} from '@app/api/database/types/OAuth2Types'; export class Application { readonly applicationId: ApplicationID; diff --git a/fluxer_api/src/api/models/Attachment.ts b/fluxer_api/src/api/models/Attachment.ts index aaff1b505..8d40223e5 100644 --- a/fluxer_api/src/api/models/Attachment.ts +++ b/fluxer_api/src/api/models/Attachment.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID} from '../BrandedTypes'; -import type {MessageAttachment} from '../database/types/MessageTypes'; +import type {AttachmentID} from '@app/api/BrandedTypes'; +import type {MessageAttachment} from '@app/api/database/types/MessageTypes'; export class Attachment { readonly id: AttachmentID; diff --git a/fluxer_api/src/api/models/AuthSession.ts b/fluxer_api/src/api/models/AuthSession.ts index 1ccd97e7c..3a294a6f1 100644 --- a/fluxer_api/src/api/models/AuthSession.ts +++ b/fluxer_api/src/api/models/AuthSession.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import type {AuthSessionRow, AuthSessionTombstoneRow} from '../database/types/AuthTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {AuthSessionRow, AuthSessionTombstoneRow} from '@app/api/database/types/AuthTypes'; export class AuthSession { readonly userId: UserID; diff --git a/fluxer_api/src/api/models/CallInfo.ts b/fluxer_api/src/api/models/CallInfo.ts index 6b2f014a2..5d99bc1cd 100644 --- a/fluxer_api/src/api/models/CallInfo.ts +++ b/fluxer_api/src/api/models/CallInfo.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import type {MessageCall} from '../database/types/MessageTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {MessageCall} from '@app/api/database/types/MessageTypes'; export class CallInfo { readonly participantIds: Set; diff --git a/fluxer_api/src/api/models/Channel.ts b/fluxer_api/src/api/models/Channel.ts index 8903cbe0b..838f55718 100644 --- a/fluxer_api/src/api/models/Channel.ts +++ b/fluxer_api/src/api/models/Channel.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, MessageID, RoleID, UserID} from '@app/api/BrandedTypes'; +import type {ChannelRow, PermissionOverwrite} from '@app/api/database/types/ChannelTypes'; +import {ChannelPermissionOverwrite} from '@app/api/models/ChannelPermissionOverwrite'; import {type ChannelType, ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {VOICE_CHANNEL_CONNECTION_LIMIT_DEFAULT} from '@fluxer/constants/src/LimitConstants'; -import type {ChannelID, GuildID, MessageID, RoleID, UserID} from '../BrandedTypes'; -import type {ChannelRow, PermissionOverwrite} from '../database/types/ChannelTypes'; -import {ChannelPermissionOverwrite} from './ChannelPermissionOverwrite'; export class Channel { readonly id: ChannelID; diff --git a/fluxer_api/src/api/models/ChannelPermissionOverwrite.ts b/fluxer_api/src/api/models/ChannelPermissionOverwrite.ts index f7f7bf8e9..17229d7c6 100644 --- a/fluxer_api/src/api/models/ChannelPermissionOverwrite.ts +++ b/fluxer_api/src/api/models/ChannelPermissionOverwrite.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {PermissionOverwrite} from '../database/types/ChannelTypes'; +import type {PermissionOverwrite} from '@app/api/database/types/ChannelTypes'; export class ChannelPermissionOverwrite { readonly type: number; diff --git a/fluxer_api/src/api/models/EmailRevertToken.ts b/fluxer_api/src/api/models/EmailRevertToken.ts index 75056f05e..43dc6fa7e 100644 --- a/fluxer_api/src/api/models/EmailRevertToken.ts +++ b/fluxer_api/src/api/models/EmailRevertToken.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import {createEmailRevertToken} from '../BrandedTypes'; -import type {EmailRevertTokenRow} from '../database/types/AuthTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import {createEmailRevertToken} from '@app/api/BrandedTypes'; +import type {EmailRevertTokenRow} from '@app/api/database/types/AuthTypes'; export class EmailRevertToken { readonly token: string; diff --git a/fluxer_api/src/api/models/EmailVerificationToken.ts b/fluxer_api/src/api/models/EmailVerificationToken.ts index 8481a07a2..6aec6a7a8 100644 --- a/fluxer_api/src/api/models/EmailVerificationToken.ts +++ b/fluxer_api/src/api/models/EmailVerificationToken.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import {createEmailVerificationToken} from '../BrandedTypes'; -import type {EmailVerificationTokenRow} from '../database/types/AuthTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import {createEmailVerificationToken} from '@app/api/BrandedTypes'; +import type {EmailVerificationTokenRow} from '@app/api/database/types/AuthTypes'; export class EmailVerificationToken { readonly token: string; diff --git a/fluxer_api/src/api/models/Embed.ts b/fluxer_api/src/api/models/Embed.ts index 4b59d0f57..87be2218a 100644 --- a/fluxer_api/src/api/models/Embed.ts +++ b/fluxer_api/src/api/models/Embed.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageEmbed, MessageEmbedChild} from '../database/types/MessageTypes'; -import {sanitizeOptionalAbsoluteUrlOrNull} from '../utils/UrlSanitizer'; -import {EmbedAuthor} from './EmbedAuthor'; -import {EmbedField} from './EmbedField'; -import {EmbedFooter} from './EmbedFooter'; -import {EmbedMedia} from './EmbedMedia'; -import {EmbedProvider} from './EmbedProvider'; +import type {MessageEmbed, MessageEmbedChild} from '@app/api/database/types/MessageTypes'; +import {EmbedAuthor} from '@app/api/models/EmbedAuthor'; +import {EmbedField} from '@app/api/models/EmbedField'; +import {EmbedFooter} from '@app/api/models/EmbedFooter'; +import {EmbedMedia} from '@app/api/models/EmbedMedia'; +import {EmbedProvider} from '@app/api/models/EmbedProvider'; +import {sanitizeOptionalAbsoluteUrlOrNull} from '@app/api/utils/UrlSanitizer'; export class Embed { readonly type: string | null; diff --git a/fluxer_api/src/api/models/EmbedAuthor.ts b/fluxer_api/src/api/models/EmbedAuthor.ts index b04933175..53a0adf76 100644 --- a/fluxer_api/src/api/models/EmbedAuthor.ts +++ b/fluxer_api/src/api/models/EmbedAuthor.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageEmbedAuthor} from '../database/types/MessageTypes'; -import {sanitizeOptionalAbsoluteUrlOrNull} from '../utils/UrlSanitizer'; +import type {MessageEmbedAuthor} from '@app/api/database/types/MessageTypes'; +import {sanitizeOptionalAbsoluteUrlOrNull} from '@app/api/utils/UrlSanitizer'; export class EmbedAuthor { readonly name: string | null; diff --git a/fluxer_api/src/api/models/EmbedField.ts b/fluxer_api/src/api/models/EmbedField.ts index 6dbe74510..665488e76 100644 --- a/fluxer_api/src/api/models/EmbedField.ts +++ b/fluxer_api/src/api/models/EmbedField.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageEmbedField} from '../database/types/MessageTypes'; +import type {MessageEmbedField} from '@app/api/database/types/MessageTypes'; export class EmbedField { readonly name: string; diff --git a/fluxer_api/src/api/models/EmbedFooter.ts b/fluxer_api/src/api/models/EmbedFooter.ts index 2fe85a34f..04005d6b9 100644 --- a/fluxer_api/src/api/models/EmbedFooter.ts +++ b/fluxer_api/src/api/models/EmbedFooter.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageEmbedFooter} from '../database/types/MessageTypes'; -import {sanitizeOptionalAbsoluteUrlOrNull} from '../utils/UrlSanitizer'; +import type {MessageEmbedFooter} from '@app/api/database/types/MessageTypes'; +import {sanitizeOptionalAbsoluteUrlOrNull} from '@app/api/utils/UrlSanitizer'; export class EmbedFooter { readonly text: string | null; diff --git a/fluxer_api/src/api/models/EmbedMedia.ts b/fluxer_api/src/api/models/EmbedMedia.ts index bcd0217c7..858c3c130 100644 --- a/fluxer_api/src/api/models/EmbedMedia.ts +++ b/fluxer_api/src/api/models/EmbedMedia.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageEmbedMedia} from '../database/types/MessageTypes'; +import type {MessageEmbedMedia} from '@app/api/database/types/MessageTypes'; export class EmbedMedia { readonly url: string | null; diff --git a/fluxer_api/src/api/models/EmbedProvider.ts b/fluxer_api/src/api/models/EmbedProvider.ts index 9462445da..0636bf6de 100644 --- a/fluxer_api/src/api/models/EmbedProvider.ts +++ b/fluxer_api/src/api/models/EmbedProvider.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageEmbedProvider} from '../database/types/MessageTypes'; -import {sanitizeOptionalAbsoluteUrlOrNull} from '../utils/UrlSanitizer'; +import type {MessageEmbedProvider} from '@app/api/database/types/MessageTypes'; +import {sanitizeOptionalAbsoluteUrlOrNull} from '@app/api/utils/UrlSanitizer'; export class EmbedProvider { readonly name: string | null; diff --git a/fluxer_api/src/api/models/EntranceSound.ts b/fluxer_api/src/api/models/EntranceSound.ts index 6e4ab3d8b..e82274266 100644 --- a/fluxer_api/src/api/models/EntranceSound.ts +++ b/fluxer_api/src/api/models/EntranceSound.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {EntranceSoundID, UserID} from '../BrandedTypes'; -import type {UserEntranceSoundRow, UserEntranceSoundSelectionRow} from '../database/types/UserTypes'; +import type {EntranceSoundID, UserID} from '@app/api/BrandedTypes'; +import type {UserEntranceSoundRow, UserEntranceSoundSelectionRow} from '@app/api/database/types/UserTypes'; export class EntranceSound { readonly userId: UserID; diff --git a/fluxer_api/src/api/models/FavoriteMeme.ts b/fluxer_api/src/api/models/FavoriteMeme.ts index 2349ba9f1..bd47c9b18 100644 --- a/fluxer_api/src/api/models/FavoriteMeme.ts +++ b/fluxer_api/src/api/models/FavoriteMeme.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AttachmentID, MemeID, UserID} from '@app/api/BrandedTypes'; +import {userIdToChannelId} from '@app/api/BrandedTypes'; +import type {FavoriteMemeRow} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import {isJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; import type {GifMediaFormat} from '@fluxer/schema/src/domains/gif/GifSchemas'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import type {AttachmentID, MemeID, UserID} from '../BrandedTypes'; -import {userIdToChannelId} from '../BrandedTypes'; -import type {FavoriteMemeRow} from '../database/types/UserTypes'; -import {Logger} from '../Logger'; -import {isJsonRecord, parseJsonWithGuard} from '../utils/JsonBoundaryUtils'; export class FavoriteMeme { readonly id: MemeID; diff --git a/fluxer_api/src/api/models/GiftCode.ts b/fluxer_api/src/api/models/GiftCode.ts index b6389483e..c1a2d409f 100644 --- a/fluxer_api/src/api/models/GiftCode.ts +++ b/fluxer_api/src/api/models/GiftCode.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import type {GiftCodeDurationType, GiftCodeRow} from '../database/types/PaymentTypes'; -import {addMonthsClamp} from '../stripe/StripeUtils'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {GiftCodeDurationType, GiftCodeRow} from '@app/api/database/types/PaymentTypes'; +import {addMonthsClamp} from '@app/api/stripe/StripeUtils'; interface GiftCodeDuration { durationType: GiftCodeDurationType; diff --git a/fluxer_api/src/api/models/Guild.ts b/fluxer_api/src/api/models/Guild.ts index 140403b0b..15212ea2c 100644 --- a/fluxer_api/src/api/models/Guild.ts +++ b/fluxer_api/src/api/models/Guild.ts @@ -1,5 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, UserID, VanityURLCode} from '@app/api/BrandedTypes'; +import type {GuildRow} from '@app/api/database/types/GuildTypes'; import { type GuildExplicitContentFilterType, type GuildMFALevelValue, @@ -10,8 +12,6 @@ import { normalizeLegacyNsfwLevel, } from '@fluxer/constants/src/GuildConstants'; import type {GuildDefaultMessageNotifications} from '@fluxer/constants/src/NotificationConstants'; -import type {ChannelID, GuildID, UserID, VanityURLCode} from '../BrandedTypes'; -import type {GuildRow} from '../database/types/GuildTypes'; export class Guild { readonly id: GuildID; diff --git a/fluxer_api/src/api/models/GuildAuditLog.ts b/fluxer_api/src/api/models/GuildAuditLog.ts index c5f8d1f3e..738d945e3 100644 --- a/fluxer_api/src/api/models/GuildAuditLog.ts +++ b/fluxer_api/src/api/models/GuildAuditLog.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildAuditLogRow} from '@app/api/database/types/GuildTypes'; +import type {GuildAuditLogChange} from '@app/api/guild/GuildAuditLogTypes'; +import {isJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; import type {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import type {GuildID, UserID} from '../BrandedTypes'; -import type {GuildAuditLogRow} from '../database/types/GuildTypes'; -import type {GuildAuditLogChange} from '../guild/GuildAuditLogTypes'; -import {isJsonRecord, parseJsonWithGuard} from '../utils/JsonBoundaryUtils'; export class GuildAuditLog { readonly guildId: GuildID; diff --git a/fluxer_api/src/api/models/GuildBan.ts b/fluxer_api/src/api/models/GuildBan.ts index 059b5c057..655766843 100644 --- a/fluxer_api/src/api/models/GuildBan.ts +++ b/fluxer_api/src/api/models/GuildBan.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../BrandedTypes'; -import type {GuildBanRow} from '../database/types/GuildTypes'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildBanRow} from '@app/api/database/types/GuildTypes'; export class GuildBan { readonly guildId: GuildID; diff --git a/fluxer_api/src/api/models/GuildChannelOverride.ts b/fluxer_api/src/api/models/GuildChannelOverride.ts index 6e99564bd..485a185ae 100644 --- a/fluxer_api/src/api/models/GuildChannelOverride.ts +++ b/fluxer_api/src/api/models/GuildChannelOverride.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelOverride} from '@app/api/database/types/UserTypes'; +import {MuteConfiguration} from '@app/api/models/MuteConfiguration'; import type {ChannelMessageNotifications} from '@fluxer/constants/src/NotificationConstants'; -import type {ChannelOverride} from '../database/types/UserTypes'; -import {MuteConfiguration} from './MuteConfiguration'; export class GuildChannelOverride { readonly collapsed: boolean; diff --git a/fluxer_api/src/api/models/GuildEmoji.ts b/fluxer_api/src/api/models/GuildEmoji.ts index df11205b1..b41ae18c2 100644 --- a/fluxer_api/src/api/models/GuildEmoji.ts +++ b/fluxer_api/src/api/models/GuildEmoji.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {EmojiID, GuildID, UserID} from '../BrandedTypes'; -import type {GuildEmojiRow} from '../database/types/GuildTypes'; +import type {EmojiID, GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildEmojiRow} from '@app/api/database/types/GuildTypes'; export class GuildEmoji { readonly guildId: GuildID; diff --git a/fluxer_api/src/api/models/GuildMember.ts b/fluxer_api/src/api/models/GuildMember.ts index fe46019c9..8cefa27dc 100644 --- a/fluxer_api/src/api/models/GuildMember.ts +++ b/fluxer_api/src/api/models/GuildMember.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, InviteCode, RoleID, UserID} from '@app/api/BrandedTypes'; +import type {GuildMemberRow} from '@app/api/database/types/GuildTypes'; import {GuildMemberProfileFlags, type JoinSourceType} from '@fluxer/constants/src/GuildConstants'; import type {MentionReplyPreference} from '@fluxer/constants/src/UserConstants'; -import type {GuildID, InviteCode, RoleID, UserID} from '../BrandedTypes'; -import type {GuildMemberRow} from '../database/types/GuildTypes'; export class GuildMember { readonly guildId: GuildID; diff --git a/fluxer_api/src/api/models/GuildRole.ts b/fluxer_api/src/api/models/GuildRole.ts index 96ccb0ffc..1fd8c0c14 100644 --- a/fluxer_api/src/api/models/GuildRole.ts +++ b/fluxer_api/src/api/models/GuildRole.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, RoleID} from '../BrandedTypes'; -import type {GuildRoleRow} from '../database/types/GuildTypes'; +import type {GuildID, RoleID} from '@app/api/BrandedTypes'; +import type {GuildRoleRow} from '@app/api/database/types/GuildTypes'; export class GuildRole { readonly guildId: GuildID; diff --git a/fluxer_api/src/api/models/GuildSticker.ts b/fluxer_api/src/api/models/GuildSticker.ts index 04c88b361..31e55315f 100644 --- a/fluxer_api/src/api/models/GuildSticker.ts +++ b/fluxer_api/src/api/models/GuildSticker.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, StickerID, UserID} from '../BrandedTypes'; -import type {GuildStickerRow} from '../database/types/GuildTypes'; +import type {GuildID, StickerID, UserID} from '@app/api/BrandedTypes'; +import type {GuildStickerRow} from '@app/api/database/types/GuildTypes'; export class GuildSticker { readonly guildId: GuildID; diff --git a/fluxer_api/src/api/models/Invite.ts b/fluxer_api/src/api/models/Invite.ts index 7f62f18d4..53e589607 100644 --- a/fluxer_api/src/api/models/Invite.ts +++ b/fluxer_api/src/api/models/Invite.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, InviteCode, UserID} from '../BrandedTypes'; -import type {InviteRow} from '../database/types/ChannelTypes'; +import type {ChannelID, GuildID, InviteCode, UserID} from '@app/api/BrandedTypes'; +import type {InviteRow} from '@app/api/database/types/ChannelTypes'; export class Invite { readonly code: InviteCode; diff --git a/fluxer_api/src/api/models/Message.ts b/fluxer_api/src/api/models/Message.ts index b768fe5be..223b8f076 100644 --- a/fluxer_api/src/api/models/Message.ts +++ b/fluxer_api/src/api/models/Message.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID, RoleID, UserID, WebhookID} from '@app/api/BrandedTypes'; +import type {MessageRow} from '@app/api/database/types/MessageTypes'; +import {Attachment} from '@app/api/models/Attachment'; +import {CallInfo} from '@app/api/models/CallInfo'; +import {Embed} from '@app/api/models/Embed'; +import {MessageRef} from '@app/api/models/MessageRef'; +import {MessageSnapshot} from '@app/api/models/MessageSnapshot'; +import {StickerItem} from '@app/api/models/StickerItem'; import type {MessageTypeValue} from '@fluxer/constants/src/ChannelConstants'; -import type {ChannelID, MessageID, RoleID, UserID, WebhookID} from '../BrandedTypes'; -import type {MessageRow} from '../database/types/MessageTypes'; -import {Attachment} from './Attachment'; -import {CallInfo} from './CallInfo'; -import {Embed} from './Embed'; -import {MessageRef} from './MessageRef'; -import {MessageSnapshot} from './MessageSnapshot'; -import {StickerItem} from './StickerItem'; export class Message { readonly channelId: ChannelID; diff --git a/fluxer_api/src/api/models/MessageReaction.ts b/fluxer_api/src/api/models/MessageReaction.ts index 30f5a9ef6..b02e611a0 100644 --- a/fluxer_api/src/api/models/MessageReaction.ts +++ b/fluxer_api/src/api/models/MessageReaction.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, EmojiID, MessageID, UserID} from '../BrandedTypes'; -import type {MessageReactionRow} from '../database/types/MessageTypes'; +import type {ChannelID, EmojiID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {MessageReactionRow} from '@app/api/database/types/MessageTypes'; export class MessageReaction { readonly channelId: ChannelID; diff --git a/fluxer_api/src/api/models/MessageRef.ts b/fluxer_api/src/api/models/MessageRef.ts index 0d7967b65..bd3db8d67 100644 --- a/fluxer_api/src/api/models/MessageRef.ts +++ b/fluxer_api/src/api/models/MessageRef.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, MessageID} from '@app/api/BrandedTypes'; +import type {MessageReference} from '@app/api/database/types/MessageTypes'; import type {MessageReferenceTypeValue} from '@fluxer/constants/src/ChannelConstants'; -import type {ChannelID, GuildID, MessageID} from '../BrandedTypes'; -import type {MessageReference} from '../database/types/MessageTypes'; export class MessageRef { readonly channelId: ChannelID; diff --git a/fluxer_api/src/api/models/MessageSnapshot.ts b/fluxer_api/src/api/models/MessageSnapshot.ts index be3351d33..208e48b3c 100644 --- a/fluxer_api/src/api/models/MessageSnapshot.ts +++ b/fluxer_api/src/api/models/MessageSnapshot.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, RoleID, UserID} from '@app/api/BrandedTypes'; +import type {MessageSnapshot as CassandraMessageSnapshot} from '@app/api/database/types/MessageTypes'; +import {Attachment} from '@app/api/models/Attachment'; +import {Embed} from '@app/api/models/Embed'; +import {StickerItem} from '@app/api/models/StickerItem'; import type {MessageTypeValue} from '@fluxer/constants/src/ChannelConstants'; -import type {ChannelID, RoleID, UserID} from '../BrandedTypes'; -import type {MessageSnapshot as CassandraMessageSnapshot} from '../database/types/MessageTypes'; -import {Attachment} from './Attachment'; -import {Embed} from './Embed'; -import {StickerItem} from './StickerItem'; export class MessageSnapshot { readonly content: string | null; diff --git a/fluxer_api/src/api/models/MfaBackupCode.ts b/fluxer_api/src/api/models/MfaBackupCode.ts index 1ad96b30d..ea7467636 100644 --- a/fluxer_api/src/api/models/MfaBackupCode.ts +++ b/fluxer_api/src/api/models/MfaBackupCode.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import {createMfaBackupCode} from '../BrandedTypes'; -import type {MfaBackupCodeRow} from '../database/types/AuthTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import {createMfaBackupCode} from '@app/api/BrandedTypes'; +import type {MfaBackupCodeRow} from '@app/api/database/types/AuthTypes'; export class MfaBackupCode { readonly userId: UserID; diff --git a/fluxer_api/src/api/models/MuteConfiguration.ts b/fluxer_api/src/api/models/MuteConfiguration.ts index 241bd5f28..1ca459dca 100644 --- a/fluxer_api/src/api/models/MuteConfiguration.ts +++ b/fluxer_api/src/api/models/MuteConfiguration.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MuteConfig} from '../database/types/UserTypes'; +import type {MuteConfig} from '@app/api/database/types/UserTypes'; export class MuteConfiguration { readonly endTime: Date | null; diff --git a/fluxer_api/src/api/models/OAuth2AccessToken.ts b/fluxer_api/src/api/models/OAuth2AccessToken.ts index c3402db09..ff587e7c9 100644 --- a/fluxer_api/src/api/models/OAuth2AccessToken.ts +++ b/fluxer_api/src/api/models/OAuth2AccessToken.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApplicationID, UserID} from '../BrandedTypes'; -import type {OAuth2AccessTokenRow} from '../database/types/OAuth2Types'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; +import type {OAuth2AccessTokenRow} from '@app/api/database/types/OAuth2Types'; export class OAuth2AccessToken { readonly token: string; diff --git a/fluxer_api/src/api/models/OAuth2AuthorizationCode.ts b/fluxer_api/src/api/models/OAuth2AuthorizationCode.ts index 0e1104b6d..5eaa8b9c7 100644 --- a/fluxer_api/src/api/models/OAuth2AuthorizationCode.ts +++ b/fluxer_api/src/api/models/OAuth2AuthorizationCode.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApplicationID, UserID} from '../BrandedTypes'; -import type {OAuth2AuthorizationCodeRow} from '../database/types/OAuth2Types'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; +import type {OAuth2AuthorizationCodeRow} from '@app/api/database/types/OAuth2Types'; export class OAuth2AuthorizationCode { readonly code: string; diff --git a/fluxer_api/src/api/models/OAuth2RefreshToken.ts b/fluxer_api/src/api/models/OAuth2RefreshToken.ts index bde2eb260..14195bff1 100644 --- a/fluxer_api/src/api/models/OAuth2RefreshToken.ts +++ b/fluxer_api/src/api/models/OAuth2RefreshToken.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApplicationID, UserID} from '../BrandedTypes'; -import type {OAuth2RefreshTokenRow} from '../database/types/OAuth2Types'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; +import type {OAuth2RefreshTokenRow} from '@app/api/database/types/OAuth2Types'; export class OAuth2RefreshToken { readonly token: string; diff --git a/fluxer_api/src/api/models/PasswordResetToken.ts b/fluxer_api/src/api/models/PasswordResetToken.ts index a412ddb12..f615713f1 100644 --- a/fluxer_api/src/api/models/PasswordResetToken.ts +++ b/fluxer_api/src/api/models/PasswordResetToken.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import {createPasswordResetToken} from '../BrandedTypes'; -import type {PasswordResetTokenRow} from '../database/types/AuthTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import {createPasswordResetToken} from '@app/api/BrandedTypes'; +import type {PasswordResetTokenRow} from '@app/api/database/types/AuthTypes'; export class PasswordResetToken { readonly token: string; diff --git a/fluxer_api/src/api/models/Payment.ts b/fluxer_api/src/api/models/Payment.ts index 5ff8cf95c..42474fd43 100644 --- a/fluxer_api/src/api/models/Payment.ts +++ b/fluxer_api/src/api/models/Payment.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import type {PaymentRow} from '../database/types/PaymentTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {PaymentRow} from '@app/api/database/types/PaymentTypes'; export class Payment { readonly checkoutSessionId: string; diff --git a/fluxer_api/src/api/models/PushSubscription.ts b/fluxer_api/src/api/models/PushSubscription.ts index dd038023a..f283a6c5a 100644 --- a/fluxer_api/src/api/models/PushSubscription.ts +++ b/fluxer_api/src/api/models/PushSubscription.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import type {PushSubscriptionPlatform, PushSubscriptionRow} from '../database/types/UserTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {PushSubscriptionPlatform, PushSubscriptionRow} from '@app/api/database/types/UserTypes'; export class PushSubscription { readonly userId: UserID; diff --git a/fluxer_api/src/api/models/ReadState.ts b/fluxer_api/src/api/models/ReadState.ts index 82bb5577b..ba28be267 100644 --- a/fluxer_api/src/api/models/ReadState.ts +++ b/fluxer_api/src/api/models/ReadState.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, MessageID, UserID} from '../BrandedTypes'; -import type {ReadStateRow} from '../database/types/ChannelTypes'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {ReadStateRow} from '@app/api/database/types/ChannelTypes'; type ReadStateSourceRow = ReadStateRow & {version?: bigint | number | null}; diff --git a/fluxer_api/src/api/models/RecentMention.ts b/fluxer_api/src/api/models/RecentMention.ts index 8e5fc94e5..1998dbd1e 100644 --- a/fluxer_api/src/api/models/RecentMention.ts +++ b/fluxer_api/src/api/models/RecentMention.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, MessageID, UserID} from '../BrandedTypes'; -import type {RecentMentionRow} from '../database/types/UserTypes'; +import type {ChannelID, GuildID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {RecentMentionRow} from '@app/api/database/types/UserTypes'; export class RecentMention { readonly userId: UserID; diff --git a/fluxer_api/src/api/models/Relationship.ts b/fluxer_api/src/api/models/Relationship.ts index dcbac4649..142117b04 100644 --- a/fluxer_api/src/api/models/Relationship.ts +++ b/fluxer_api/src/api/models/Relationship.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {RelationshipRow} from '@app/api/database/types/UserTypes'; import type {RelationshipType} from '@fluxer/constants/src/UserConstants'; -import type {UserID} from '../BrandedTypes'; -import type {RelationshipRow} from '../database/types/UserTypes'; export class Relationship { readonly sourceUserId: UserID; diff --git a/fluxer_api/src/api/models/SavedMessage.ts b/fluxer_api/src/api/models/SavedMessage.ts index 91a366297..dd9ae8a95 100644 --- a/fluxer_api/src/api/models/SavedMessage.ts +++ b/fluxer_api/src/api/models/SavedMessage.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, MessageID, UserID} from '../BrandedTypes'; -import type {SavedMessageRow} from '../database/types/UserTypes'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {SavedMessageRow} from '@app/api/database/types/UserTypes'; export class SavedMessage { readonly userId: UserID; diff --git a/fluxer_api/src/api/models/StickerItem.ts b/fluxer_api/src/api/models/StickerItem.ts index 29c8d9b1f..9aaace8db 100644 --- a/fluxer_api/src/api/models/StickerItem.ts +++ b/fluxer_api/src/api/models/StickerItem.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {StickerID} from '../BrandedTypes'; -import type {MessageStickerItem} from '../database/types/MessageTypes'; +import type {StickerID} from '@app/api/BrandedTypes'; +import type {MessageStickerItem} from '@app/api/database/types/MessageTypes'; export class StickerItem { readonly id: StickerID; diff --git a/fluxer_api/src/api/models/User.ts b/fluxer_api/src/api/models/User.ts index 3b7550fec..972214a08 100644 --- a/fluxer_api/src/api/models/User.ts +++ b/fluxer_api/src/api/models/User.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {getGlobalLimitConfigSnapshot} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import {checkIsPremium, getEffectivePremiumUntil} from '@app/api/user/UserHelpers'; import { extractPremiumFlagsFromLegacyUserFlags, type MentionReplyPreference, @@ -8,12 +14,6 @@ import { type UserPremiumType, } from '@fluxer/constants/src/UserConstants'; import {types} from 'cassandra-driver'; -import type {UserID} from '../BrandedTypes'; -import type {UserRow} from '../database/types/UserTypes'; -import {getGlobalLimitConfigSnapshot} from '../limits/LimitConfigService'; -import {resolveLimitSafe} from '../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; -import {checkIsPremium, getEffectivePremiumUntil} from '../user/UserHelpers'; export class User { readonly id: UserID; diff --git a/fluxer_api/src/api/models/UserCustomStatus.ts b/fluxer_api/src/api/models/UserCustomStatus.ts index e4f8e8d81..6bd7738ee 100644 --- a/fluxer_api/src/api/models/UserCustomStatus.ts +++ b/fluxer_api/src/api/models/UserCustomStatus.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {EmojiID} from '../BrandedTypes'; -import type {CustomStatus} from '../database/types/UserTypes'; +import type {EmojiID} from '@app/api/BrandedTypes'; +import type {CustomStatus} from '@app/api/database/types/UserTypes'; export class UserCustomStatus { readonly text: string | null; diff --git a/fluxer_api/src/api/models/UserGuildFolder.ts b/fluxer_api/src/api/models/UserGuildFolder.ts index 7ac2d3195..544f34ae2 100644 --- a/fluxer_api/src/api/models/UserGuildFolder.ts +++ b/fluxer_api/src/api/models/UserGuildFolder.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID} from '@app/api/BrandedTypes'; +import type {GuildFolder} from '@app/api/database/types/UserTypes'; import {DEFAULT_GUILD_FOLDER_ICON, type GuildFolderIcon} from '@fluxer/constants/src/UserConstants'; -import type {GuildID} from '../BrandedTypes'; -import type {GuildFolder} from '../database/types/UserTypes'; export class UserGuildFolder { readonly folderId: number; diff --git a/fluxer_api/src/api/models/UserGuildSettings.ts b/fluxer_api/src/api/models/UserGuildSettings.ts index 914d6e53e..0c5e76561 100644 --- a/fluxer_api/src/api/models/UserGuildSettings.ts +++ b/fluxer_api/src/api/models/UserGuildSettings.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import type {ChannelOverride, UserGuildSettingsRow} from '@app/api/database/types/UserTypes'; +import {GuildChannelOverride} from '@app/api/models/GuildChannelOverride'; +import {MuteConfiguration} from '@app/api/models/MuteConfiguration'; import type {ChannelMessageNotifications} from '@fluxer/constants/src/NotificationConstants'; -import type {ChannelID, GuildID, UserID} from '../BrandedTypes'; -import type {ChannelOverride, UserGuildSettingsRow} from '../database/types/UserTypes'; -import {GuildChannelOverride} from './GuildChannelOverride'; -import {MuteConfiguration} from './MuteConfiguration'; export class UserGuildSettings { readonly userId: UserID; diff --git a/fluxer_api/src/api/models/UserNote.ts b/fluxer_api/src/api/models/UserNote.ts index 4bd19ae4f..5b1c9e9a4 100644 --- a/fluxer_api/src/api/models/UserNote.ts +++ b/fluxer_api/src/api/models/UserNote.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import type {NoteRow} from '../database/types/UserTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {NoteRow} from '@app/api/database/types/UserTypes'; export class UserNote { readonly sourceUserId: UserID; diff --git a/fluxer_api/src/api/models/UserSettings.ts b/fluxer_api/src/api/models/UserSettings.ts index 855d991ee..a657d9906 100644 --- a/fluxer_api/src/api/models/UserSettings.ts +++ b/fluxer_api/src/api/models/UserSettings.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {UserSettingsRow} from '@app/api/database/types/UserTypes'; +import {UserCustomStatus} from '@app/api/models/UserCustomStatus'; +import {UserGuildFolder} from '@app/api/models/UserGuildFolder'; import type {LocaleCode} from '@fluxer/constants/src/Locales'; import { DEFAULT_GUILD_FOLDER_ICON, @@ -21,11 +26,6 @@ import { UserExplicitContentFilterTypes, } from '@fluxer/constants/src/UserConstants'; import {decodeSyncedPreferences} from '@fluxer/schema/src/domains/user/SyncedPreferencesCodec'; -import type {GuildID, UserID} from '../BrandedTypes'; -import {Config} from '../Config'; -import type {UserSettingsRow} from '../database/types/UserTypes'; -import {UserCustomStatus} from './UserCustomStatus'; -import {UserGuildFolder} from './UserGuildFolder'; export class UserSettings { readonly userId: UserID; diff --git a/fluxer_api/src/api/models/VisionarySlot.ts b/fluxer_api/src/api/models/VisionarySlot.ts index 55d6427ee..3cf110881 100644 --- a/fluxer_api/src/api/models/VisionarySlot.ts +++ b/fluxer_api/src/api/models/VisionarySlot.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import type {VisionarySlotRow} from '../database/types/PaymentTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {VisionarySlotRow} from '@app/api/database/types/PaymentTypes'; export class VisionarySlot { readonly slotIndex: number; diff --git a/fluxer_api/src/api/models/WebAuthnCredential.ts b/fluxer_api/src/api/models/WebAuthnCredential.ts index 870c48fdd..123f34d1a 100644 --- a/fluxer_api/src/api/models/WebAuthnCredential.ts +++ b/fluxer_api/src/api/models/WebAuthnCredential.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import type {WebAuthnCredentialRow} from '../database/types/AuthTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {WebAuthnCredentialRow} from '@app/api/database/types/AuthTypes'; export class WebAuthnCredential { readonly credentialId: string; diff --git a/fluxer_api/src/api/models/Webhook.ts b/fluxer_api/src/api/models/Webhook.ts index 6bac6b75a..f8bf3b4b8 100644 --- a/fluxer_api/src/api/models/Webhook.ts +++ b/fluxer_api/src/api/models/Webhook.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, UserID, WebhookID, WebhookToken} from '../BrandedTypes'; -import type {WebhookRow} from '../database/types/ChannelTypes'; +import type {ChannelID, GuildID, UserID, WebhookID, WebhookToken} from '@app/api/BrandedTypes'; +import type {WebhookRow} from '@app/api/database/types/ChannelTypes'; export class Webhook { readonly id: WebhookID; diff --git a/fluxer_api/src/api/models/tests/EmbedFieldSerialization.test.ts b/fluxer_api/src/api/models/tests/EmbedFieldSerialization.test.ts index 2a157d6c3..8fa728482 100644 --- a/fluxer_api/src/api/models/tests/EmbedFieldSerialization.test.ts +++ b/fluxer_api/src/api/models/tests/EmbedFieldSerialization.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {EmbedField} from '@app/api/models/EmbedField'; import {describe, expect, it} from 'vitest'; -import {EmbedField} from '../EmbedField'; describe('EmbedField serialization', () => { it('normalizes null names and values to empty strings for response-safe storage', () => { diff --git a/fluxer_api/src/api/models/tests/EmbedIconUrlSanitization.test.ts b/fluxer_api/src/api/models/tests/EmbedIconUrlSanitization.test.ts index b78a1de88..9736e1cbb 100644 --- a/fluxer_api/src/api/models/tests/EmbedIconUrlSanitization.test.ts +++ b/fluxer_api/src/api/models/tests/EmbedIconUrlSanitization.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Embed} from '@app/api/models/Embed'; +import {EmbedAuthor} from '@app/api/models/EmbedAuthor'; +import {EmbedFooter} from '@app/api/models/EmbedFooter'; +import {EmbedProvider} from '@app/api/models/EmbedProvider'; import {describe, expect, it} from 'vitest'; -import {Embed} from '../Embed'; -import {EmbedAuthor} from '../EmbedAuthor'; -import {EmbedFooter} from '../EmbedFooter'; -import {EmbedProvider} from '../EmbedProvider'; describe('EmbedAuthor icon URL sanitisation', () => { it('normalises empty icon_url values to null', () => { diff --git a/fluxer_api/src/api/models/tests/GiftCode.test.ts b/fluxer_api/src/api/models/tests/GiftCode.test.ts index 71d8beb33..db814988a 100644 --- a/fluxer_api/src/api/models/tests/GiftCode.test.ts +++ b/fluxer_api/src/api/models/tests/GiftCode.test.ts @@ -1,9 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import type {GiftCodeDurationType, GiftCodeRow} from '@app/api/database/types/PaymentTypes'; +import { + addGiftCodeDuration, + GiftCode, + mapGiftCodeDurationToMonths, + mapGiftDurationMonthsToFields, +} from '@app/api/models/GiftCode'; import {describe, expect, test} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import type {GiftCodeDurationType, GiftCodeRow} from '../../database/types/PaymentTypes'; -import {addGiftCodeDuration, GiftCode, mapGiftCodeDurationToMonths, mapGiftDurationMonthsToFields} from '../GiftCode'; const TEST_USER_ID = createUserID(1n); const BASE_DATE = new Date('2026-03-01T00:00:00.000Z'); diff --git a/fluxer_api/src/api/models/tests/StickerItem.test.ts b/fluxer_api/src/api/models/tests/StickerItem.test.ts index 4c3612e53..f4a6d7e2b 100644 --- a/fluxer_api/src/api/models/tests/StickerItem.test.ts +++ b/fluxer_api/src/api/models/tests/StickerItem.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createStickerID} from '@app/api/BrandedTypes'; +import {StickerItem} from '@app/api/models/StickerItem'; import {describe, expect, it} from 'vitest'; -import {createStickerID} from '../../BrandedTypes'; -import {StickerItem} from '../StickerItem'; describe('StickerItem', () => { it('defaults animated to false when it is omitted', () => { diff --git a/fluxer_api/src/api/models/tests/UserUnclaimedAccount.test.ts b/fluxer_api/src/api/models/tests/UserUnclaimedAccount.test.ts index 4ade1749e..3b74cfacb 100644 --- a/fluxer_api/src/api/models/tests/UserUnclaimedAccount.test.ts +++ b/fluxer_api/src/api/models/tests/UserUnclaimedAccount.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {EMPTY_USER_ROW, type UserRow} from '@app/api/database/types/UserTypes'; +import {User} from '@app/api/models/User'; import {describe, expect, it} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import {EMPTY_USER_ROW, type UserRow} from '../../database/types/UserTypes'; -import {User} from '../User'; function createUserRow(overrides: Partial = {}): UserRow { return { diff --git a/fluxer_api/src/api/moderation/tests/ModerationTestUtils.ts b/fluxer_api/src/api/moderation/tests/ModerationTestUtils.ts index 7b6b1d794..45ab9327e 100644 --- a/fluxer_api/src/api/moderation/tests/ModerationTestUtils.ts +++ b/fluxer_api/src/api/moderation/tests/ModerationTestUtils.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; export async function banUser( harness: ApiTestHarness, moderatorToken: string, diff --git a/fluxer_api/src/api/oauth/ApplicationMessageAuthorAnonymization.ts b/fluxer_api/src/api/oauth/ApplicationMessageAuthorAnonymization.ts index 2bfdb7a86..0128e812b 100644 --- a/fluxer_api/src/api/oauth/ApplicationMessageAuthorAnonymization.ts +++ b/fluxer_api/src/api/oauth/ApplicationMessageAuthorAnonymization.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {MessageAnonymizationService} from '@app/api/channel/services/message/MessageAnonymizationService'; +import {EMPTY_USER_ROW} from '@app/api/database/types/UserTypes'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import {Logger} from '@app/api/Logger'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import { DELETED_USER_DISCRIMINATOR, DELETED_USER_GLOBAL_NAME, DELETED_USER_USERNAME, UserFlags, } from '@fluxer/constants/src/UserConstants'; -import {createUserID, type UserID} from '../BrandedTypes'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import {MessageAnonymizationService} from '../channel/services/message/MessageAnonymizationService'; -import {EMPTY_USER_ROW} from '../database/types/UserTypes'; -import type {ISnowflakeService} from '../infrastructure/ISnowflakeService'; -import {Logger} from '../Logger'; -import type {IUserRepository} from '../user/IUserRepository'; interface RemapAuthorMessagesToDeletedUserParams { originalAuthorId: UserID; diff --git a/fluxer_api/src/api/oauth/ApplicationService.ts b/fluxer_api/src/api/oauth/ApplicationService.ts index 3a6c9a2f4..6298fb4f5 100644 --- a/fluxer_api/src/api/oauth/ApplicationService.ts +++ b/fluxer_api/src/api/oauth/ApplicationService.ts @@ -1,5 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; +import {applicationIdToUserId} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ApplicationRow} from '@app/api/database/types/OAuth2Types'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {DiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {EntityAssetService, PreparedAssetUpload} from '@app/api/infrastructure/EntityAssetService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import type {Application} from '@app/api/models/Application'; +import type {User} from '@app/api/models/User'; +import {remapAuthorMessagesToDeletedUser} from '@app/api/oauth/ApplicationMessageAuthorAnonymization'; +import type {BotAuthService} from '@app/api/oauth/BotAuthService'; +import {generateOAuthTokenSecret} from '@app/api/oauth/OAuthTokenSecret'; +import type {IApplicationRepository} from '@app/api/oauth/repositories/IApplicationRepository'; +import {enforceFluxerTagChangeRateLimit} from '@app/api/user/FluxerTagChangeRateLimit'; +import {hasPartialUserFieldsChanged, mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import {runAllInOrder} from '@app/api/utils/ConcurrencyUtils'; +import {hashPassword} from '@app/api/utils/PasswordUtils'; +import {generateRandomUsername} from '@app/api/utils/UsernameGenerator'; +import {deriveUsernameFromDisplayName} from '@app/api/utils/UsernameSuggestionUtils'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import { DELETED_USER_GLOBAL_NAME, @@ -16,30 +40,6 @@ import {BotUserNotFoundError} from '@fluxer/errors/src/domains/oauth/BotUserNotF import {UnclaimedAccountCannotCreateApplicationsError} from '@fluxer/errors/src/domains/oauth/UnclaimedAccountCannotCreateApplicationsError'; import {UnknownApplicationError} from '@fluxer/errors/src/domains/oauth/UnknownApplicationError'; import type {BotProfileUpdateRequest} from '@fluxer/schema/src/domains/oauth/OAuthSchemas'; -import type {ApiContext} from '../ApiContext'; -import type {ApplicationID, UserID} from '../BrandedTypes'; -import {applicationIdToUserId} from '../BrandedTypes'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import type {ApplicationRow} from '../database/types/OAuth2Types'; -import type {UserRow} from '../database/types/UserTypes'; -import {contentModerationService} from '../infrastructure/ContentModerationService'; -import type {DiscriminatorService} from '../infrastructure/DiscriminatorService'; -import type {EntityAssetService, PreparedAssetUpload} from '../infrastructure/EntityAssetService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import {Logger} from '../Logger'; -import {profileSubstringBlocklistCache} from '../middleware/ProfileSubstringBlocklistCache'; -import type {Application} from '../models/Application'; -import type {User} from '../models/User'; -import {enforceFluxerTagChangeRateLimit} from '../user/FluxerTagChangeRateLimit'; -import {hasPartialUserFieldsChanged, mapUserToPrivateResponse} from '../user/UserMappers'; -import {runAllInOrder} from '../utils/ConcurrencyUtils'; -import {hashPassword} from '../utils/PasswordUtils'; -import {generateRandomUsername} from '../utils/UsernameGenerator'; -import {deriveUsernameFromDisplayName} from '../utils/UsernameSuggestionUtils'; -import {remapAuthorMessagesToDeletedUser} from './ApplicationMessageAuthorAnonymization'; -import type {BotAuthService} from './BotAuthService'; -import {generateOAuthTokenSecret} from './OAuthTokenSecret'; -import type {IApplicationRepository} from './repositories/IApplicationRepository'; interface ApplicationServiceDeps { discriminatorService: DiscriminatorService; diff --git a/fluxer_api/src/api/oauth/BotAuthService.ts b/fluxer_api/src/api/oauth/BotAuthService.ts index e985ff23e..07101a5ba 100644 --- a/fluxer_api/src/api/oauth/BotAuthService.ts +++ b/fluxer_api/src/api/oauth/BotAuthService.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApplicationID, UserID} from '../BrandedTypes'; -import {hashPassword, verifyPassword} from '../utils/PasswordUtils'; -import {generateOAuthTokenSecret} from './OAuthTokenSecret'; -import type {IApplicationRepository} from './repositories/IApplicationRepository'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; +import {generateOAuthTokenSecret} from '@app/api/oauth/OAuthTokenSecret'; +import type {IApplicationRepository} from '@app/api/oauth/repositories/IApplicationRepository'; +import {hashPassword, verifyPassword} from '@app/api/utils/PasswordUtils'; export class BotAuthService { constructor(private readonly applicationRepository: IApplicationRepository) {} diff --git a/fluxer_api/src/api/oauth/BotMfaMirrorService.ts b/fluxer_api/src/api/oauth/BotMfaMirrorService.ts index c854607f6..72958d665 100644 --- a/fluxer_api/src/api/oauth/BotMfaMirrorService.ts +++ b/fluxer_api/src/api/oauth/BotMfaMirrorService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../BrandedTypes'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {Application} from '../models/Application'; -import type {User} from '../models/User'; -import type {IUserRepository} from '../user/IUserRepository'; -import {mapUserToPrivateResponse} from '../user/UserMappers'; -import type {IApplicationRepository} from './repositories/IApplicationRepository'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {Application} from '@app/api/models/Application'; +import type {User} from '@app/api/models/User'; +import type {IApplicationRepository} from '@app/api/oauth/repositories/IApplicationRepository'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; export class BotMfaMirrorService { constructor( diff --git a/fluxer_api/src/api/oauth/OAuth2ApplicationsController.ts b/fluxer_api/src/api/oauth/OAuth2ApplicationsController.ts index da4eb964a..7ddbe2497 100644 --- a/fluxer_api/src/api/oauth/OAuth2ApplicationsController.ts +++ b/fluxer_api/src/api/oauth/OAuth2ApplicationsController.ts @@ -1,5 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {DefaultUserOnly, LoginRequiredAllowSuspicious} from '@app/api/middleware/AuthMiddleware'; +import {CaptchaMiddleware} from '@app/api/middleware/CaptchaMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {SudoModeMiddleware} from '@app/api/middleware/SudoModeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp, HonoEnv} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {SudoVerificationSchema} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {ApplicationIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import { @@ -12,14 +20,6 @@ import { OAuth2ApplicationsMeResponse, } from '@fluxer/schema/src/domains/oauth/OAuthSchemas'; import type {Context} from 'hono'; -import {DefaultUserOnly, LoginRequiredAllowSuspicious} from '../middleware/AuthMiddleware'; -import {CaptchaMiddleware} from '../middleware/CaptchaMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {SudoModeMiddleware} from '../middleware/SudoModeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp, HonoEnv} from '../types/HonoEnv'; -import {Validator} from '../Validator'; export function OAuth2ApplicationsController(app: HonoApp) { const listApplicationsHandler = async (ctx: Context) => { diff --git a/fluxer_api/src/api/oauth/OAuth2ApplicationsRequestService.ts b/fluxer_api/src/api/oauth/OAuth2ApplicationsRequestService.ts index 56cb2bc0d..a1fbf0bf8 100644 --- a/fluxer_api/src/api/oauth/OAuth2ApplicationsRequestService.ts +++ b/fluxer_api/src/api/oauth/OAuth2ApplicationsRequestService.ts @@ -1,5 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {SudoVerificationBody} from '@app/api/auth/services/SudoVerificationService'; +import {requireSudoMode} from '@app/api/auth/services/SudoVerificationService'; +import {createApplicationID, type UserID} from '@app/api/BrandedTypes'; +import {UsernameNotAvailableError} from '@app/api/infrastructure/DiscriminatorService'; +import type {Application} from '@app/api/models/Application'; +import type {User} from '@app/api/models/User'; +import type {ApplicationService} from '@app/api/oauth/ApplicationService'; +import {ApplicationNotOwnedError} from '@app/api/oauth/ApplicationService'; +import {mapApplicationToResponse, mapBotProfileToResponse} from '@app/api/oauth/OAuth2Mappers'; +import type {IApplicationRepository} from '@app/api/oauth/repositories/IApplicationRepository'; import {MAX_APPLICATIONS_PER_USER} from '@fluxer/constants/src/LimitConstants'; import {AccessDeniedError} from '@fluxer/errors/src/domains/core/AccessDeniedError'; import {BotUserNotFoundError} from '@fluxer/errors/src/domains/oauth/BotUserNotFoundError'; @@ -13,17 +24,6 @@ import type { BotProfileUpdateRequest, } from '@fluxer/schema/src/domains/oauth/OAuthSchemas'; import type {Context} from 'hono'; -import type {ApiContext} from '../ApiContext'; -import type {SudoVerificationBody} from '../auth/services/SudoVerificationService'; -import {requireSudoMode} from '../auth/services/SudoVerificationService'; -import {createApplicationID, type UserID} from '../BrandedTypes'; -import {UsernameNotAvailableError} from '../infrastructure/DiscriminatorService'; -import type {Application} from '../models/Application'; -import type {User} from '../models/User'; -import type {ApplicationService} from './ApplicationService'; -import {ApplicationNotOwnedError} from './ApplicationService'; -import {mapApplicationToResponse, mapBotProfileToResponse} from './OAuth2Mappers'; -import type {IApplicationRepository} from './repositories/IApplicationRepository'; export class OAuth2ApplicationsRequestService { constructor( diff --git a/fluxer_api/src/api/oauth/OAuth2Controller.ts b/fluxer_api/src/api/oauth/OAuth2Controller.ts index 2e42c99c6..9c68506e8 100644 --- a/fluxer_api/src/api/oauth/OAuth2Controller.ts +++ b/fluxer_api/src/api/oauth/OAuth2Controller.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {DefaultUserOnly, LoginRequiredAllowSuspicious} from '@app/api/middleware/AuthMiddleware'; +import {requireOAuth2BearerToken, requireOAuth2Scope} from '@app/api/middleware/OAuth2ScopeMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {SudoModeMiddleware} from '@app/api/middleware/SudoModeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {SudoVerificationSchema} from '@fluxer/schema/src/domains/auth/AuthSchemas'; import { ApplicationAuthorizationIdParam, @@ -23,15 +32,6 @@ import { RevokeRequestForm, TokenRequest, } from '@fluxer/schema/src/domains/oauth/OAuthSchemas'; -import {Config} from '../Config'; -import {DefaultUserOnly, LoginRequiredAllowSuspicious} from '../middleware/AuthMiddleware'; -import {requireOAuth2BearerToken, requireOAuth2Scope} from '../middleware/OAuth2ScopeMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {SudoModeMiddleware} from '../middleware/SudoModeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; export function OAuth2Controller(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/oauth/OAuth2Mappers.ts b/fluxer_api/src/api/oauth/OAuth2Mappers.ts index d7132ca5f..41410ad07 100644 --- a/fluxer_api/src/api/oauth/OAuth2Mappers.ts +++ b/fluxer_api/src/api/oauth/OAuth2Mappers.ts @@ -1,5 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {stripBannerForUser} from '@app/api/infrastructure/AssetEntitlementUtils'; +import type {Application} from '@app/api/models/Application'; +import type {User} from '@app/api/models/User'; +import {mapUserToPartialResponse} from '@app/api/user/UserMappers'; import {type UserAuthenticatorType, UserAuthenticatorTypes} from '@fluxer/constants/src/UserConstants'; import type { ApplicationBotResponse, @@ -7,10 +11,6 @@ import type { BotProfileResponse, BotTokenResetResponse, } from '@fluxer/schema/src/domains/oauth/OAuthSchemas'; -import {stripBannerForUser} from '../infrastructure/AssetEntitlementUtils'; -import type {Application} from '../models/Application'; -import type {User} from '../models/User'; -import {mapUserToPartialResponse} from '../user/UserMappers'; function getActiveAuthenticatorTypes(user: User): Array { return Array.from(user.authenticatorTypes ?? []).filter( diff --git a/fluxer_api/src/api/oauth/OAuth2RequestService.ts b/fluxer_api/src/api/oauth/OAuth2RequestService.ts index dd9231f14..c020d657f 100644 --- a/fluxer_api/src/api/oauth/OAuth2RequestService.ts +++ b/fluxer_api/src/api/oauth/OAuth2RequestService.ts @@ -1,5 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {SudoVerificationBody} from '@app/api/auth/services/SudoVerificationService'; +import {requireSudoMode} from '@app/api/auth/services/SudoVerificationService'; +import {createApplicationID, createChannelID, createGuildID, createRoleID, type UserID} from '@app/api/BrandedTypes'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import {Logger} from '@app/api/Logger'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {ApplicationService} from '@app/api/oauth/ApplicationService'; +import {ApplicationNotOwnedError} from '@app/api/oauth/ApplicationService'; +import type {BotAuthService} from '@app/api/oauth/BotAuthService'; +import { + mapApplicationToResponse, + mapBotProfileToResponse, + mapBotTokenResetResponse, + mapBotUserToResponse, +} from '@app/api/oauth/OAuth2Mappers'; +import {filterOAuth2Scopes} from '@app/api/oauth/OAuth2ScopeUtils'; +import {ACCESS_TOKEN_TTL_SECONDS, type OAuth2Service} from '@app/api/oauth/OAuth2Service'; +import type {IApplicationRepository} from '@app/api/oauth/repositories/IApplicationRepository'; +import type {IOAuth2TokenRepository} from '@app/api/oauth/repositories/IOAuth2TokenRepository'; +import {parseClientCredentials} from '@app/api/oauth/utils/ParseClientCredentials'; +import {mapUserToOAuthResponse, mapUserToPartialResponse} from '@app/api/user/UserMappers'; +import {verifyPassword} from '@app/api/utils/PasswordUtils'; import {canAuthorizeBotInvite, normalizeBotInvitePermissions} from '@fluxer/constants/src/BotPermissionUtils'; import {JoinSourceTypes} from '@fluxer/constants/src/GuildConstants'; import {AccessDeniedError} from '@fluxer/errors/src/domains/core/AccessDeniedError'; @@ -33,30 +57,6 @@ import type { TokenRequest, } from '@fluxer/schema/src/domains/oauth/OAuthSchemas'; import type {Context} from 'hono'; -import type {ApiContext} from '../ApiContext'; -import type {SudoVerificationBody} from '../auth/services/SudoVerificationService'; -import {requireSudoMode} from '../auth/services/SudoVerificationService'; -import {createApplicationID, createChannelID, createGuildID, createRoleID, type UserID} from '../BrandedTypes'; -import type {ChannelService} from '../channel/services/ChannelService'; -import type {GuildService} from '../guild/services/GuildService'; -import {Logger} from '../Logger'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import {mapUserToOAuthResponse, mapUserToPartialResponse} from '../user/UserMappers'; -import {verifyPassword} from '../utils/PasswordUtils'; -import type {ApplicationService} from './ApplicationService'; -import {ApplicationNotOwnedError} from './ApplicationService'; -import type {BotAuthService} from './BotAuthService'; -import { - mapApplicationToResponse, - mapBotProfileToResponse, - mapBotTokenResetResponse, - mapBotUserToResponse, -} from './OAuth2Mappers'; -import {filterOAuth2Scopes} from './OAuth2ScopeUtils'; -import {ACCESS_TOKEN_TTL_SECONDS, type OAuth2Service} from './OAuth2Service'; -import type {IApplicationRepository} from './repositories/IApplicationRepository'; -import type {IOAuth2TokenRepository} from './repositories/IOAuth2TokenRepository'; -import {parseClientCredentials} from './utils/ParseClientCredentials'; const COMPAT_VERIFY_KEY_PLACEHOLDER = '0'.repeat(64); diff --git a/fluxer_api/src/api/oauth/OAuth2Service.ts b/fluxer_api/src/api/oauth/OAuth2Service.ts index e482b79f1..51b6b3fd9 100644 --- a/fluxer_api/src/api/oauth/OAuth2Service.ts +++ b/fluxer_api/src/api/oauth/OAuth2Service.ts @@ -1,6 +1,25 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import type {ApiContext} from '@app/api/ApiContext'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type { + OAuth2AccessTokenRow, + OAuth2AuthorizationCodeRow, + OAuth2RefreshTokenRow, +} from '@app/api/database/types/OAuth2Types'; +import {Logger} from '@app/api/Logger'; +import type {Application} from '@app/api/models/Application'; +import {filterOAuth2ScopeSet, isOAuth2Scope, sortOAuth2Scopes} from '@app/api/oauth/OAuth2ScopeUtils'; +import {ACCESS_TOKEN_TTL_SECONDS} from '@app/api/oauth/OAuth2TokenConstants'; +import {generateOAuthTokenSecret} from '@app/api/oauth/OAuthTokenSecret'; +import {ApplicationRepository} from '@app/api/oauth/repositories/ApplicationRepository'; +import type {IApplicationRepository} from '@app/api/oauth/repositories/IApplicationRepository'; +import type {IOAuth2TokenRepository} from '@app/api/oauth/repositories/IOAuth2TokenRepository'; +import {OAuth2TokenRepository} from '@app/api/oauth/repositories/OAuth2TokenRepository'; +import {mapUserToOAuthResponse} from '@app/api/user/UserMappers'; +import {verifyPassword} from '@app/api/utils/PasswordUtils'; import {InvalidRequestError} from '@fluxer/errors/src/domains/core/InvalidRequestError'; import {InvalidTokenError} from '@fluxer/errors/src/domains/core/InvalidTokenError'; import {BotIsPrivateError} from '@fluxer/errors/src/domains/oauth/BotIsPrivateError'; @@ -11,25 +30,6 @@ import {InvalidRedirectUriError} from '@fluxer/errors/src/domains/oauth/InvalidR import {InvalidScopeError} from '@fluxer/errors/src/domains/oauth/InvalidScopeError'; import {MissingClientSecretError} from '@fluxer/errors/src/domains/oauth/MissingClientSecretError'; import {MissingRedirectUriError} from '@fluxer/errors/src/domains/oauth/MissingRedirectUriError'; -import type {ApiContext} from '../ApiContext'; -import type {ApplicationID, UserID} from '../BrandedTypes'; -import {Config} from '../Config'; -import type { - OAuth2AccessTokenRow, - OAuth2AuthorizationCodeRow, - OAuth2RefreshTokenRow, -} from '../database/types/OAuth2Types'; -import {Logger} from '../Logger'; -import type {Application} from '../models/Application'; -import {mapUserToOAuthResponse} from '../user/UserMappers'; -import {verifyPassword} from '../utils/PasswordUtils'; -import {filterOAuth2ScopeSet, isOAuth2Scope, sortOAuth2Scopes} from './OAuth2ScopeUtils'; -import {ACCESS_TOKEN_TTL_SECONDS} from './OAuth2TokenConstants'; -import {generateOAuthTokenSecret} from './OAuthTokenSecret'; -import {ApplicationRepository} from './repositories/ApplicationRepository'; -import type {IApplicationRepository} from './repositories/IApplicationRepository'; -import type {IOAuth2TokenRepository} from './repositories/IOAuth2TokenRepository'; -import {OAuth2TokenRepository} from './repositories/OAuth2TokenRepository'; interface OAuth2ServiceDeps { applicationRepository?: IApplicationRepository; diff --git a/fluxer_api/src/api/oauth/repositories/ApplicationRepository.ts b/fluxer_api/src/api/oauth/repositories/ApplicationRepository.ts index 9e2f6c480..460e652de 100644 --- a/fluxer_api/src/api/oauth/repositories/ApplicationRepository.ts +++ b/fluxer_api/src/api/oauth/repositories/ApplicationRepository.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ApplicationID, createApplicationID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import {BatchBuilder, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {buildPatchFromData, executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import type {ApplicationByOwnerRow, ApplicationRow} from '@app/api/database/types/OAuth2Types'; +import {APPLICATION_COLUMNS} from '@app/api/database/types/OAuth2Types'; +import {Application} from '@app/api/models/Application'; +import type {IApplicationRepository} from '@app/api/oauth/repositories/IApplicationRepository'; +import {Applications, ApplicationsByOwner} from '@app/api/Tables'; +import {hashPassword} from '@app/api/utils/PasswordUtils'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {ADMIN_OAUTH2_APPLICATION_ID} from '@fluxer/constants/src/Core'; import {ForbiddenError} from '@fluxer/errors/src/domains/core/ForbiddenError'; -import {type ApplicationID, createApplicationID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {SYSTEM_USER_ID} from '../../constants/Core'; -import {BatchBuilder, fetchMany, fetchOne} from '../../database/CassandraQueryExecution'; -import {buildPatchFromData, executeVersionedUpdate} from '../../database/CassandraVersionedUpdate'; -import type {ApplicationByOwnerRow, ApplicationRow} from '../../database/types/OAuth2Types'; -import {APPLICATION_COLUMNS} from '../../database/types/OAuth2Types'; -import {Application} from '../../models/Application'; -import {Applications, ApplicationsByOwner} from '../../Tables'; -import {hashPassword} from '../../utils/PasswordUtils'; -import type {IApplicationRepository} from './IApplicationRepository'; const SELECT_APPLICATION_CQL = Applications.selectCql({ where: Applications.where.eq('application_id'), diff --git a/fluxer_api/src/api/oauth/repositories/IApplicationRepository.ts b/fluxer_api/src/api/oauth/repositories/IApplicationRepository.ts index df59ea8a9..4bb1b675d 100644 --- a/fluxer_api/src/api/oauth/repositories/IApplicationRepository.ts +++ b/fluxer_api/src/api/oauth/repositories/IApplicationRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApplicationID, UserID} from '../../BrandedTypes'; -import type {ApplicationRow} from '../../database/types/OAuth2Types'; -import type {Application} from '../../models/Application'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; +import type {ApplicationRow} from '@app/api/database/types/OAuth2Types'; +import type {Application} from '@app/api/models/Application'; export interface IApplicationRepository { getApplication(applicationId: ApplicationID): Promise; diff --git a/fluxer_api/src/api/oauth/repositories/IOAuth2TokenRepository.ts b/fluxer_api/src/api/oauth/repositories/IOAuth2TokenRepository.ts index 922bac151..a36c6b988 100644 --- a/fluxer_api/src/api/oauth/repositories/IOAuth2TokenRepository.ts +++ b/fluxer_api/src/api/oauth/repositories/IOAuth2TokenRepository.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApplicationID, UserID} from '../../BrandedTypes'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; import type { OAuth2AccessTokenRow, OAuth2AuthorizationCodeRow, OAuth2RefreshTokenRow, -} from '../../database/types/OAuth2Types'; -import type {OAuth2AccessToken} from '../../models/OAuth2AccessToken'; -import type {OAuth2AuthorizationCode} from '../../models/OAuth2AuthorizationCode'; -import type {OAuth2RefreshToken} from '../../models/OAuth2RefreshToken'; +} from '@app/api/database/types/OAuth2Types'; +import type {OAuth2AccessToken} from '@app/api/models/OAuth2AccessToken'; +import type {OAuth2AuthorizationCode} from '@app/api/models/OAuth2AuthorizationCode'; +import type {OAuth2RefreshToken} from '@app/api/models/OAuth2RefreshToken'; export interface IOAuth2TokenRepository { createAuthorizationCode(data: OAuth2AuthorizationCodeRow): Promise; diff --git a/fluxer_api/src/api/oauth/repositories/OAuth2TokenRepository.ts b/fluxer_api/src/api/oauth/repositories/OAuth2TokenRepository.ts index d48740d10..6143bd466 100644 --- a/fluxer_api/src/api/oauth/repositories/OAuth2TokenRepository.ts +++ b/fluxer_api/src/api/oauth/repositories/OAuth2TokenRepository.ts @@ -1,26 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApplicationID, UserID} from '../../BrandedTypes'; -import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; import type { OAuth2AccessTokenByUserRow, OAuth2AccessTokenRow, OAuth2AuthorizationCodeRow, OAuth2RefreshTokenByUserRow, OAuth2RefreshTokenRow, -} from '../../database/types/OAuth2Types'; -import {OAuth2AccessToken} from '../../models/OAuth2AccessToken'; -import {OAuth2AuthorizationCode} from '../../models/OAuth2AuthorizationCode'; -import {OAuth2RefreshToken} from '../../models/OAuth2RefreshToken'; +} from '@app/api/database/types/OAuth2Types'; +import {OAuth2AccessToken} from '@app/api/models/OAuth2AccessToken'; +import {OAuth2AuthorizationCode} from '@app/api/models/OAuth2AuthorizationCode'; +import {OAuth2RefreshToken} from '@app/api/models/OAuth2RefreshToken'; +import {ACCESS_TOKEN_TTL_SECONDS, AUTHORIZATION_CODE_TTL_SECONDS} from '@app/api/oauth/OAuth2TokenConstants'; +import type {IOAuth2TokenRepository} from '@app/api/oauth/repositories/IOAuth2TokenRepository'; import { OAuth2AccessTokens, OAuth2AccessTokensByUser, OAuth2AuthorizationCodes, OAuth2RefreshTokens, OAuth2RefreshTokensByUser, -} from '../../Tables'; -import {ACCESS_TOKEN_TTL_SECONDS, AUTHORIZATION_CODE_TTL_SECONDS} from '../OAuth2TokenConstants'; -import type {IOAuth2TokenRepository} from './IOAuth2TokenRepository'; +} from '@app/api/Tables'; function isAccessTokenExpired(createdAt: Date): boolean { return Date.now() - createdAt.getTime() > ACCESS_TOKEN_TTL_SECONDS * 1000; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2ApplicationCreate.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2ApplicationCreate.test.ts index 0118bd4ec..e2edaadd4 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2ApplicationCreate.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2ApplicationCreate.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {createOAuth2Application, createUniqueApplicationName} from '@app/api/oauth/tests/OAuth2TestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {UsernameType} from '@fluxer/schema/src/primitives/UserValidators'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createOAuth2Application, createUniqueApplicationName} from './OAuth2TestUtils'; interface ValidationErrorResponse { errors?: Array<{ diff --git a/fluxer_api/src/api/oauth/tests/OAuth2ApplicationDelete.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2ApplicationDelete.test.ts index 4b8e17314..7c3791438 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2ApplicationDelete.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2ApplicationDelete.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createOAuth2Application, createUniqueApplicationName, deleteOAuth2Application, getOAuth2Application, listOAuth2Applications, -} from './OAuth2TestUtils'; +} from '@app/api/oauth/tests/OAuth2TestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; +import {beforeEach, describe, expect, test} from 'vitest'; describe('OAuth2 Application Delete', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2ApplicationGet.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2ApplicationGet.test.ts index 1c72ffbb4..503e1c362 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2ApplicationGet.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2ApplicationGet.test.ts @@ -1,15 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, createTotpSecret, generateTotpCode} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import { + createOAuth2Application, + createUniqueApplicationName, + getOAuth2Application, +} from '@app/api/oauth/tests/OAuth2TestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import {UserAuthenticatorTypes} from '@fluxer/constants/src/UserConstants'; import type {ApplicationPublicResponse} from '@fluxer/schema/src/domains/oauth/OAuthSchemas'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, createTotpSecret, generateTotpCode} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../../user/repositories/UserRepository'; -import {createOAuth2Application, createUniqueApplicationName, getOAuth2Application} from './OAuth2TestUtils'; describe('OAuth2 Application Get', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2ApplicationList.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2ApplicationList.test.ts index 928d48051..0f6d9ff17 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2ApplicationList.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2ApplicationList.test.ts @@ -1,11 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + createOAuth2Application, + createUniqueApplicationName, + listOAuth2Applications, +} from '@app/api/oauth/tests/OAuth2TestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createOAuth2Application, createUniqueApplicationName, listOAuth2Applications} from './OAuth2TestUtils'; describe('OAuth2 Application List', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2ApplicationUpdate.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2ApplicationUpdate.test.ts index d66007f31..11850b5db 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2ApplicationUpdate.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2ApplicationUpdate.test.ts @@ -1,11 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + createOAuth2Application, + createUniqueApplicationName, + updateOAuth2Application, +} from '@app/api/oauth/tests/OAuth2TestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createOAuth2Application, createUniqueApplicationName, updateOAuth2Application} from './OAuth2TestUtils'; describe('OAuth2 Application Update', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsDeauthorize.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsDeauthorize.test.ts index 79128db32..082c3d8c1 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsDeauthorize.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsDeauthorize.test.ts @@ -1,10 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { authorizeOAuth2, createOAuth2Application, @@ -13,7 +9,11 @@ import { exchangeOAuth2AuthorizationCode, getOAuth2UserInfo, listOAuth2Authorizations, -} from './OAuthTestUtils'; +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('OAuth2 authorizations deauthorize', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsList.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsList.test.ts index 9c404e323..031cfce9c 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsList.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsList.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { authorizeOAuth2, createOAuth2Application, exchangeOAuth2AuthorizationCode, listOAuth2Authorizations, -} from './OAuthTestUtils'; +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('OAuth2 authorizations list', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsRequiresAuth.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsRequiresAuth.test.ts index cefbd181c..a4df770aa 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsRequiresAuth.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizationsRequiresAuth.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; describe('OAuth2 authorizations requires auth', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeCodeFlow.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeCodeFlow.test.ts index 70ea96c83..c9513fb48 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeCodeFlow.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeCodeFlow.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { authorizeOAuth2, createOAuth2Application, exchangeOAuth2AuthorizationCode, getOAuth2UserInfo, introspectOAuth2Token, -} from './OAuthTestUtils'; +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('OAuth2 authorization code flow', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeRedirectURI.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeRedirectURI.test.ts index 2c4b1fe31..383093940 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeRedirectURI.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeRedirectURI.test.ts @@ -1,11 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + authorizeOAuth2, + createOAuth2Application, + exchangeOAuth2AuthorizationCode, +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {authorizeOAuth2, createOAuth2Application, exchangeOAuth2AuthorizationCode} from './OAuthTestUtils'; describe('OAuth2 authorize redirect URI validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeStateParameter.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeStateParameter.test.ts index 2ccad5359..815d735a9 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeStateParameter.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2AuthorizeStateParameter.test.ts @@ -1,9 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import { + authorizeOAuth2, + createOAuth2Application, + exchangeOAuth2AuthorizationCode, +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {authorizeOAuth2, createOAuth2Application, exchangeOAuth2AuthorizationCode} from './OAuthTestUtils'; describe('OAuth2 authorize state parameter', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2BotGuildAdd.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2BotGuildAdd.test.ts index 8091677b4..b7d5de1d8 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2BotGuildAdd.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2BotGuildAdd.test.ts @@ -1,10 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import type {GuildRoleResponse} from '@fluxer/schema/src/domains/guild/GuildRoleSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, addMemberRole, @@ -15,11 +11,15 @@ import { createRole, getChannel, getMember, -} from '../../channel/tests/ChannelTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createOAuth2Application, createUniqueApplicationName} from './OAuth2TestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {createOAuth2Application, createUniqueApplicationName} from '@app/api/oauth/tests/OAuth2TestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import type {GuildRoleResponse} from '@fluxer/schema/src/domains/guild/GuildRoleSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('OAuth2 Bot Guild Add', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2ClientSecret.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2ClientSecret.test.ts index 5a688dbfb..e9b5fede7 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2ClientSecret.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2ClientSecret.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {authorizeOAuth2, createOAuth2Application, createOAuth2TestSetup} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {authorizeOAuth2, createOAuth2Application, createOAuth2TestSetup} from './OAuthTestUtils'; describe('OAuth2 Client Secret', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2CodeReplay.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2CodeReplay.test.ts index 546633f44..ad3744b1e 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2CodeReplay.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2CodeReplay.test.ts @@ -1,10 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + authorizeOAuth2, + createOAuth2TestSetup, + exchangeOAuth2AuthorizationCode, +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {authorizeOAuth2, createOAuth2TestSetup, exchangeOAuth2AuthorizationCode} from './OAuthTestUtils'; describe('OAuth2 Authorization Code Replay Prevention', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2ScopeEnforcement.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2ScopeEnforcement.test.ts index 458ec2ede..541e981e9 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2ScopeEnforcement.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2ScopeEnforcement.test.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ADMIN_OAUTH2_APPLICATION_ID} from '@fluxer/constants/src/Core'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createAdminApiKey} from '../../admin/tests/AdminTestUtils'; -import {createTestAccount, setUserACLs} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {createGuild, createRole, getRoles} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createAdminApiKey} from '@app/api/admin/tests/AdminTestUtils'; +import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {createGuild, createRole, getRoles} from '@app/api/guild/tests/GuildTestUtils'; import { authorizeOAuth2, createOAuth2Application, createOAuth2TestSetup, exchangeOAuth2AuthorizationCode, -} from './OAuthTestUtils'; +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {ADMIN_OAUTH2_APPLICATION_ID} from '@fluxer/constants/src/Core'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; interface OAuth2TokenResponse { token: string; @@ -582,7 +582,7 @@ describe('OAuth2 Scope Enforcement', () => { test('OAuth2 token from real authorization flow respects scope restrictions', async () => { const {endUser, redirectURI, application} = await createOAuth2TestSetup(harness); await createGuild(harness, endUser.token, 'Test Guild'); - const {authorizeOAuth2, exchangeOAuth2AuthorizationCode} = await import('./OAuthTestUtils'); + const {authorizeOAuth2, exchangeOAuth2AuthorizationCode} = await import('@app/api/oauth/tests/OAuthTestUtils'); const authCodeResponse = await authorizeOAuth2(harness, endUser.token, { client_id: application.id, redirect_uri: redirectURI, @@ -608,7 +608,7 @@ describe('OAuth2 Scope Enforcement', () => { test('OAuth2 token with guilds scope from real flow can access guilds', async () => { const {endUser, redirectURI, application} = await createOAuth2TestSetup(harness); await createGuild(harness, endUser.token, 'Real Flow Guild'); - const {authorizeOAuth2, exchangeOAuth2AuthorizationCode} = await import('./OAuthTestUtils'); + const {authorizeOAuth2, exchangeOAuth2AuthorizationCode} = await import('@app/api/oauth/tests/OAuthTestUtils'); const authCodeResponse = await authorizeOAuth2(harness, endUser.token, { client_id: application.id, redirect_uri: redirectURI, diff --git a/fluxer_api/src/api/oauth/tests/OAuth2ScopeMiddleware.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2ScopeMiddleware.test.ts index cc2a13be6..ff7578cb6 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2ScopeMiddleware.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2ScopeMiddleware.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterEach, beforeEach, describe, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface OAuth2TokenResponse { token: string; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2ScopeValidation.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2ScopeValidation.test.ts index f9d0d0004..9e8387608 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2ScopeValidation.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2ScopeValidation.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ADMIN_OAUTH2_APPLICATION_ID} from '@fluxer/constants/src/Core'; -import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; import { authorizeOAuth2, createOAuth2Application, createOAuth2TestSetup, exchangeOAuth2AuthorizationCode, -} from './OAuthTestUtils'; +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {ADMIN_OAUTH2_APPLICATION_ID} from '@fluxer/constants/src/Core'; +import {beforeEach, describe, expect, test} from 'vitest'; describe('OAuth2 Scope Validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2Scopes.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2Scopes.test.ts index 47f0d01bb..fd6cf5daa 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2Scopes.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2Scopes.test.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; import { authorizeOAuth2, createOAuth2Application, createOAuth2TestSetup, exchangeOAuth2AuthorizationCode, -} from './OAuthTestUtils'; +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; interface OAuth2MeResponse { application: { diff --git a/fluxer_api/src/api/oauth/tests/OAuth2TestUtils.ts b/fluxer_api/src/api/oauth/tests/OAuth2TestUtils.ts index 8d7ea98ca..1d2148d2e 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2TestUtils.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2TestUtils.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {ApplicationResponse} from '@fluxer/schema/src/domains/oauth/OAuthSchemas'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface OAuth2CreateResult { application: ApplicationResponse; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2TokenExchange.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2TokenExchange.test.ts index f897c359f..1d9bad3a1 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2TokenExchange.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2TokenExchange.test.ts @@ -1,10 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + authorizeOAuth2, + createOAuth2TestSetup, + exchangeOAuth2AuthorizationCode, +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {beforeEach, describe, expect, test} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {authorizeOAuth2, createOAuth2TestSetup, exchangeOAuth2AuthorizationCode} from './OAuthTestUtils'; describe('OAuth2 Token Exchange', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2TokenExpiration.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2TokenExpiration.test.ts index dc670ec9d..5b08cbd11 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2TokenExpiration.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2TokenExpiration.test.ts @@ -1,13 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createApplicationID, createUserID} from '../../BrandedTypes'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {ACCESS_TOKEN_TTL_SECONDS} from '../OAuth2TokenConstants'; -import {generateOAuthTokenSecret} from '../OAuthTokenSecret'; -import {OAuth2TokenRepository} from '../repositories/OAuth2TokenRepository'; +import {createApplicationID, createUserID} from '@app/api/BrandedTypes'; +import {ACCESS_TOKEN_TTL_SECONDS} from '@app/api/oauth/OAuth2TokenConstants'; +import {generateOAuthTokenSecret} from '@app/api/oauth/OAuthTokenSecret'; +import {OAuth2TokenRepository} from '@app/api/oauth/repositories/OAuth2TokenRepository'; import { authorizeOAuth2, createOAuth2TestSetup, @@ -15,7 +11,11 @@ import { getOAuth2UserInfo, introspectOAuth2Token, refreshOAuth2Token, -} from './OAuthTestUtils'; +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('OAuth2 Token Expiration', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2TokenIntrospection.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2TokenIntrospection.test.ts index ec79a33cf..d1eacd93e 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2TokenIntrospection.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2TokenIntrospection.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; import { authorizeOAuth2, createOAuth2TestSetup, exchangeOAuth2AuthorizationCode, introspectOAuth2Token, revokeOAuth2Token, -} from './OAuthTestUtils'; +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('OAuth2 Token Introspection', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2TokenRefresh.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2TokenRefresh.test.ts index 75f03b383..598fa3efd 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2TokenRefresh.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2TokenRefresh.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; import { authorizeOAuth2, createOAuth2TestSetup, exchangeOAuth2AuthorizationCode, getOAuth2UserInfo, refreshOAuth2Token, -} from './OAuthTestUtils'; +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('OAuth2 Token Refresh', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuth2TokenRevocation.test.ts b/fluxer_api/src/api/oauth/tests/OAuth2TokenRevocation.test.ts index 97de82a50..2d072c996 100644 --- a/fluxer_api/src/api/oauth/tests/OAuth2TokenRevocation.test.ts +++ b/fluxer_api/src/api/oauth/tests/OAuth2TokenRevocation.test.ts @@ -1,11 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {beforeEach, describe, expect, test} from 'vitest'; -import {createApplicationID} from '../../BrandedTypes'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {generateOAuthTokenSecret} from '../OAuthTokenSecret'; -import {OAuth2TokenRepository} from '../repositories/OAuth2TokenRepository'; +import {createApplicationID} from '@app/api/BrandedTypes'; +import {generateOAuthTokenSecret} from '@app/api/oauth/OAuthTokenSecret'; +import {OAuth2TokenRepository} from '@app/api/oauth/repositories/OAuth2TokenRepository'; import { authorizeOAuth2, createOAuth2TestSetup, @@ -13,7 +10,10 @@ import { getOAuth2UserInfo, introspectOAuth2Token, revokeOAuth2Token, -} from './OAuthTestUtils'; +} from '@app/api/oauth/tests/OAuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {beforeEach, describe, expect, test} from 'vitest'; describe('OAuth2 Token Revocation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/oauth/tests/OAuthTestUtils.ts b/fluxer_api/src/api/oauth/tests/OAuthTestUtils.ts index d670cd8fc..7587cc8ef 100644 --- a/fluxer_api/src/api/oauth/tests/OAuthTestUtils.ts +++ b/fluxer_api/src/api/oauth/tests/OAuthTestUtils.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; +import {createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type { ApplicationResponse, OAuth2ConsentResponse, OAuth2IntrospectResponse, OAuth2TokenResponse, } from '@fluxer/schema/src/domains/oauth/OAuthSchemas'; -import {createTestAccount, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface OAuth2Application extends Omit { client_secret: string; diff --git a/fluxer_api/src/api/oauth/utils/ParseClientCredentials.ts b/fluxer_api/src/api/oauth/utils/ParseClientCredentials.ts index 87a699bca..7a1fdbe8e 100644 --- a/fluxer_api/src/api/oauth/utils/ParseClientCredentials.ts +++ b/fluxer_api/src/api/oauth/utils/ParseClientCredentials.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Logger} from '@app/api/Logger'; import {InvalidRequestError} from '@fluxer/errors/src/domains/core/InvalidRequestError'; import {z} from 'zod'; -import {Logger} from '../../Logger'; const BasicAuthScheme = z .string() diff --git a/fluxer_api/src/api/openapi/OpenAPIController.ts b/fluxer_api/src/api/openapi/OpenAPIController.ts index 36a683b74..4ec72c16e 100644 --- a/fluxer_api/src/api/openapi/OpenAPIController.ts +++ b/fluxer_api/src/api/openapi/OpenAPIController.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import * as fs from 'node:fs'; +import {Config} from '@app/api/Config'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {resolveAssetPath} from '@app/api/utils/AssetPaths'; import type {Hono} from 'hono'; -import {Config} from '../Config'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoEnv} from '../types/HonoEnv'; -import {resolveAssetPath} from '../utils/AssetPaths'; const SPEC_PATH = resolveAssetPath('openapi', 'openapi.json'); const SPEC_DOCUMENT = JSON.parse(fs.readFileSync(SPEC_PATH, 'utf-8')) as Record; diff --git a/fluxer_api/src/api/openapi/tests/OpenAPIServerEntry.test.ts b/fluxer_api/src/api/openapi/tests/OpenAPIServerEntry.test.ts index efa81fd3d..e59cbecc4 100644 --- a/fluxer_api/src/api/openapi/tests/OpenAPIServerEntry.test.ts +++ b/fluxer_api/src/api/openapi/tests/OpenAPIServerEntry.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {buildOpenAPISpecBody, OpenAPIController} from '@app/api/openapi/OpenAPIController'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {Hono} from 'hono'; import {describe, expect, it} from 'vitest'; -import {Config} from '../../Config'; -import type {HonoEnv} from '../../types/HonoEnv'; -import {buildOpenAPISpecBody, OpenAPIController} from '../OpenAPIController'; interface ServerEntry { url: string; diff --git a/fluxer_api/src/api/premium/PremiumController.ts b/fluxer_api/src/api/premium/PremiumController.ts index b5012c97f..962b07e90 100644 --- a/fluxer_api/src/api/premium/PremiumController.ts +++ b/fluxer_api/src/api/premium/PremiumController.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; +import {Validator} from '@app/api/Validator'; import { PremiumStateQueryRequest, PremiumStateResponse, UpdatePremiumPerksDisabledRequest, } from '@fluxer/schema/src/domains/premium/PremiumSchemas'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {lookupGeoip} from '../utils/IpUtils'; -import {Validator} from '../Validator'; export function PremiumController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/push/ApnsPushService.ts b/fluxer_api/src/api/push/ApnsPushService.ts index 93cb66953..11d10f464 100644 --- a/fluxer_api/src/api/push/ApnsPushService.ts +++ b/fluxer_api/src/api/push/ApnsPushService.ts @@ -3,10 +3,10 @@ import {createHash} from 'node:crypto'; import {readFile} from 'node:fs/promises'; import {type ClientHttp2Session, connect, constants} from 'node:http2'; +import {Config} from '@app/api/Config'; +import type {PushProviderEnvironment} from '@app/api/config/APIConfig'; +import {Logger} from '@app/api/Logger'; import {type CryptoKey, importPKCS8, SignJWT} from 'jose'; -import {Config} from '../Config'; -import type {PushProviderEnvironment} from '../config/APIConfig'; -import {Logger} from '../Logger'; const APNS_PROVIDER_TOKEN_TTL_SECONDS = 50 * 60; const APNS_REQUEST_TIMEOUT_MS = 5000; diff --git a/fluxer_api/src/api/push/tests/ApnsPushService.test.ts b/fluxer_api/src/api/push/tests/ApnsPushService.test.ts index 2b9e88641..f392864c6 100644 --- a/fluxer_api/src/api/push/tests/ApnsPushService.test.ts +++ b/fluxer_api/src/api/push/tests/ApnsPushService.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {generateKeyPairSync} from 'node:crypto'; +import {ApnsPushServiceTestHooks, ensureApnsSigningKey} from '@app/api/push/ApnsPushService'; import {describe, expect, it} from 'vitest'; -import {ApnsPushServiceTestHooks, ensureApnsSigningKey} from '../ApnsPushService'; function pkcs8Pem(der: Buffer): string { const base64 = der.toString('base64'); diff --git a/fluxer_api/src/api/rate_limit_configs/AdminRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/AdminRateLimitConfig.ts index f90ccf786..d9196ab53 100644 --- a/fluxer_api/src/api/rate_limit_configs/AdminRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/AdminRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const AdminRateLimitConfigs = { ADMIN_LOOKUP: { diff --git a/fluxer_api/src/api/rate_limit_configs/AuthRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/AuthRateLimitConfig.ts index 35dadf0f8..44bf4d839 100644 --- a/fluxer_api/src/api/rate_limit_configs/AuthRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/AuthRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const AuthRateLimitConfigs = { AUTH_REGISTER: { diff --git a/fluxer_api/src/api/rate_limit_configs/ChannelRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/ChannelRateLimitConfig.ts index ed3c1fe8f..0304a40a2 100644 --- a/fluxer_api/src/api/rate_limit_configs/ChannelRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/ChannelRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const ChannelRateLimitConfigs = { CHANNEL_GET: { diff --git a/fluxer_api/src/api/rate_limit_configs/ConnectionRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/ConnectionRateLimitConfig.ts index 172d7aecb..5308d4410 100644 --- a/fluxer_api/src/api/rate_limit_configs/ConnectionRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/ConnectionRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const ConnectionRateLimitConfigs = { CONNECTION_LIST: { diff --git a/fluxer_api/src/api/rate_limit_configs/DiscoveryRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/DiscoveryRateLimitConfig.ts index a8061f638..149b1958a 100644 --- a/fluxer_api/src/api/rate_limit_configs/DiscoveryRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/DiscoveryRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const DiscoveryRateLimitConfigs = { DISCOVERY_SEARCH: { diff --git a/fluxer_api/src/api/rate_limit_configs/DonationRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/DonationRateLimitConfig.ts index 0c003c69c..ebc2360f4 100644 --- a/fluxer_api/src/api/rate_limit_configs/DonationRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/DonationRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const DonationRateLimitConfigs = { DONATION_REQUEST_LINK: { diff --git a/fluxer_api/src/api/rate_limit_configs/GuildRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/GuildRateLimitConfig.ts index 2e3923a96..b1d0b84ec 100644 --- a/fluxer_api/src/api/rate_limit_configs/GuildRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/GuildRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const GuildRateLimitConfigs = { GUILD_CREATE: { diff --git a/fluxer_api/src/api/rate_limit_configs/IntegrationRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/IntegrationRateLimitConfig.ts index bf1645ed3..c687fa542 100644 --- a/fluxer_api/src/api/rate_limit_configs/IntegrationRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/IntegrationRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const IntegrationRateLimitConfigs = { GIF_SEARCH: { diff --git a/fluxer_api/src/api/rate_limit_configs/InviteRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/InviteRateLimitConfig.ts index 79d9251a5..d328bf1e6 100644 --- a/fluxer_api/src/api/rate_limit_configs/InviteRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/InviteRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const InviteRateLimitConfigs = { INVITE_GET: { diff --git a/fluxer_api/src/api/rate_limit_configs/MiscRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/MiscRateLimitConfig.ts index 9fa0f10f5..932677362 100644 --- a/fluxer_api/src/api/rate_limit_configs/MiscRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/MiscRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const MiscRateLimitConfigs = { INSTANCE_INFO: { diff --git a/fluxer_api/src/api/rate_limit_configs/OAuthRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/OAuthRateLimitConfig.ts index 78621b697..67c5adccd 100644 --- a/fluxer_api/src/api/rate_limit_configs/OAuthRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/OAuthRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const OAuthRateLimitConfigs = { OAUTH_AUTHORIZE: { diff --git a/fluxer_api/src/api/rate_limit_configs/RateLimitHelpers.ts b/fluxer_api/src/api/rate_limit_configs/RateLimitHelpers.ts index c815fe64f..e7a1806b6 100644 --- a/fluxer_api/src/api/rate_limit_configs/RateLimitHelpers.ts +++ b/fluxer_api/src/api/rate_limit_configs/RateLimitHelpers.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; export type RateLimitSection = { readonly [key: string]: RouteRateLimitConfig; diff --git a/fluxer_api/src/api/rate_limit_configs/UserRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/UserRateLimitConfig.ts index 282a8044f..c82dba64f 100644 --- a/fluxer_api/src/api/rate_limit_configs/UserRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/UserRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const UserRateLimitConfigs = { USER_GET: { diff --git a/fluxer_api/src/api/rate_limit_configs/WebhookRateLimitConfig.ts b/fluxer_api/src/api/rate_limit_configs/WebhookRateLimitConfig.ts index 197d06b66..c5842f828 100644 --- a/fluxer_api/src/api/rate_limit_configs/WebhookRateLimitConfig.ts +++ b/fluxer_api/src/api/rate_limit_configs/WebhookRateLimitConfig.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {RouteRateLimitConfig} from '@app/api/middleware/RateLimitMiddleware'; import {ms} from 'itty-time'; -import type {RouteRateLimitConfig} from '../middleware/RateLimitMiddleware'; export const WebhookRateLimitConfigs = { WEBHOOK_LIST_GUILD: { diff --git a/fluxer_api/src/api/read_state/IReadStateRepository.ts b/fluxer_api/src/api/read_state/IReadStateRepository.ts index 2587cd562..724943b1b 100644 --- a/fluxer_api/src/api/read_state/IReadStateRepository.ts +++ b/fluxer_api/src/api/read_state/IReadStateRepository.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, MessageID, UserID} from '../BrandedTypes'; -import type {ReadState} from '../models/ReadState'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {ReadState} from '@app/api/models/ReadState'; export abstract class IReadStateRepository { abstract listReadStates(userId: UserID): Promise>; diff --git a/fluxer_api/src/api/read_state/ReadStateAckResponsePayload.test.ts b/fluxer_api/src/api/read_state/ReadStateAckResponsePayload.test.ts index 0102547c1..b3bf2778c 100644 --- a/fluxer_api/src/api/read_state/ReadStateAckResponsePayload.test.ts +++ b/fluxer_api/src/api/read_state/ReadStateAckResponsePayload.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannel, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {sendMessage} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../auth/tests/AuthTestUtils'; -import {createChannel, createGuild} from '../guild/tests/GuildTestUtils'; -import {sendMessage} from '../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../test/ApiTestHarness'; -import {HTTP_STATUS} from '../test/TestConstants'; -import {createBuilder} from '../test/TestRequestBuilder'; interface AckResponse { read_states: Array<{ diff --git a/fluxer_api/src/api/read_state/ReadStateController.ts b/fluxer_api/src/api/read_state/ReadStateController.ts index 97eff5891..c9c526d39 100644 --- a/fluxer_api/src/api/read_state/ReadStateController.ts +++ b/fluxer_api/src/api/read_state/ReadStateController.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import { ReadStateAckBulkRequest, ReadStateAckRequest, ReadStateAckResponse, } from '@fluxer/schema/src/domains/channel/ChannelRequestSchemas'; import type {Hono} from 'hono'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoEnv} from '../types/HonoEnv'; -import {Validator} from '../Validator'; export function ReadStateController(app: Hono): void { app.post( diff --git a/fluxer_api/src/api/read_state/ReadStateRepository.test.ts b/fluxer_api/src/api/read_state/ReadStateRepository.test.ts index d214947de..dfe6015f3 100644 --- a/fluxer_api/src/api/read_state/ReadStateRepository.test.ts +++ b/fluxer_api/src/api/read_state/ReadStateRepository.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createChannelID, createMessageID, createUserID, type UserID} from '@app/api/BrandedTypes'; +import {getKvMeta} from '@app/api/database/CassandraMetaRegistry'; +import {fetchOne, setCassandraQueryExecutorForTesting, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {defineTable} from '@app/api/database/CassandraTableDsl'; +import type {CassandraParams, KvQueryMeta, PreparedQuery} from '@app/api/database/CassandraTypes'; +import type {ReadStateRow} from '@app/api/database/types/ChannelTypes'; +import {READ_STATE_COLUMNS} from '@app/api/database/types/ChannelTypes'; +import {ReadStateRepository} from '@app/api/read_state/ReadStateRepository'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {type ChannelID, createChannelID, createMessageID, createUserID, type UserID} from '../BrandedTypes'; -import {getKvMeta} from '../database/CassandraMetaRegistry'; -import {fetchOne, setCassandraQueryExecutorForTesting, upsertOne} from '../database/CassandraQueryExecution'; -import {defineTable} from '../database/CassandraTableDsl'; -import type {CassandraParams, KvQueryMeta, PreparedQuery} from '../database/CassandraTypes'; -import type {ReadStateRow} from '../database/types/ChannelTypes'; -import {READ_STATE_COLUMNS} from '../database/types/ChannelTypes'; -import {InMemoryCassandraQueryExecutor} from '../test/InMemoryCassandraQueryExecutor'; -import {ReadStateRepository} from './ReadStateRepository'; const ReadStates = defineTable({ name: 'read_states', diff --git a/fluxer_api/src/api/read_state/ReadStateRepository.ts b/fluxer_api/src/api/read_state/ReadStateRepository.ts index 5a581c7ed..29972c158 100644 --- a/fluxer_api/src/api/read_state/ReadStateRepository.ts +++ b/fluxer_api/src/api/read_state/ReadStateRepository.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, MessageID, UserID} from '../BrandedTypes'; -import {channelIdToMessageId} from '../BrandedTypes'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {channelIdToMessageId} from '@app/api/BrandedTypes'; import { BatchBuilder, deleteOneOrMany, @@ -9,13 +9,13 @@ import { fetchManyInChunks, fetchOne, upsertOne, -} from '../database/CassandraQueryExecution'; -import {defineTable} from '../database/CassandraTableDsl'; -import {Db, type DbOp} from '../database/CassandraTypes'; -import type {ReadStateRow} from '../database/types/ChannelTypes'; -import {READ_STATE_COLUMNS} from '../database/types/ChannelTypes'; -import {ReadState} from '../models/ReadState'; -import type {IReadStateRepository} from './IReadStateRepository'; +} from '@app/api/database/CassandraQueryExecution'; +import {defineTable} from '@app/api/database/CassandraTableDsl'; +import {Db, type DbOp} from '@app/api/database/CassandraTypes'; +import type {ReadStateRow} from '@app/api/database/types/ChannelTypes'; +import {READ_STATE_COLUMNS} from '@app/api/database/types/ChannelTypes'; +import {ReadState} from '@app/api/models/ReadState'; +import type {IReadStateRepository} from '@app/api/read_state/IReadStateRepository'; const ReadStates = defineTable({ name: 'read_states', diff --git a/fluxer_api/src/api/read_state/ReadStateRequestService.ts b/fluxer_api/src/api/read_state/ReadStateRequestService.ts index 5c60b2f35..930302606 100644 --- a/fluxer_api/src/api/read_state/ReadStateRequestService.ts +++ b/fluxer_api/src/api/read_state/ReadStateRequestService.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createMessageID} from '@app/api/BrandedTypes'; +import {mapReadStateResponse} from '@app/api/read_state/ReadStateResponseMapper'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; import type { ReadStateAckBulkRequest, ReadStateAckRequest, ReadStateAckResponse, } from '@fluxer/schema/src/domains/channel/ChannelRequestSchemas'; -import type {UserID} from '../BrandedTypes'; -import {createChannelID, createMessageID} from '../BrandedTypes'; -import {mapReadStateResponse} from './ReadStateResponseMapper'; -import type {ReadStateService} from './ReadStateService'; interface ReadStateAckBulkParams { userId: UserID; diff --git a/fluxer_api/src/api/read_state/ReadStateResponseMapper.ts b/fluxer_api/src/api/read_state/ReadStateResponseMapper.ts index 2eabb515f..b2e39e980 100644 --- a/fluxer_api/src/api/read_state/ReadStateResponseMapper.ts +++ b/fluxer_api/src/api/read_state/ReadStateResponseMapper.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ReadState} from '@app/api/models/ReadState'; import type {ReadStateResponse} from '@fluxer/schema/src/domains/gateway/GatewaySchemas'; -import type {ReadState} from '../models/ReadState'; export function mapReadStateResponse(readState: ReadState): ReadStateResponse { return { diff --git a/fluxer_api/src/api/read_state/ReadStateService.test.ts b/fluxer_api/src/api/read_state/ReadStateService.test.ts index 3f535faf6..8668e080e 100644 --- a/fluxer_api/src/api/read_state/ReadStateService.test.ts +++ b/fluxer_api/src/api/read_state/ReadStateService.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {BadGatewayError} from '@fluxer/errors/src/domains/core/BadGatewayError'; -import {describe, expect, it, vi} from 'vitest'; import { type ChannelID, createChannelID, @@ -9,11 +7,13 @@ import { createUserID, type MessageID, type UserID, -} from '../BrandedTypes'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import {ReadState} from '../models/ReadState'; -import type {IReadStateRepository} from './IReadStateRepository'; -import {ReadStateService} from './ReadStateService'; +} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {ReadState} from '@app/api/models/ReadState'; +import type {IReadStateRepository} from '@app/api/read_state/IReadStateRepository'; +import {ReadStateService} from '@app/api/read_state/ReadStateService'; +import {BadGatewayError} from '@fluxer/errors/src/domains/core/BadGatewayError'; +import {describe, expect, it, vi} from 'vitest'; describe('ReadStateService.bulkIncrementMentionCounts', () => { it('invalidates badge counts for touched users in a single bulk call', async () => { diff --git a/fluxer_api/src/api/read_state/ReadStateService.ts b/fluxer_api/src/api/read_state/ReadStateService.ts index 6e899be35..d52216e1d 100644 --- a/fluxer_api/src/api/read_state/ReadStateService.ts +++ b/fluxer_api/src/api/read_state/ReadStateService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, MessageID, UserID} from '../BrandedTypes'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import {Logger} from '../Logger'; -import type {ReadState} from '../models/ReadState'; -import type {IReadStateRepository} from './IReadStateRepository'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import type {ReadState} from '@app/api/models/ReadState'; +import type {IReadStateRepository} from '@app/api/read_state/IReadStateRepository'; export class ReadStateService { constructor( diff --git a/fluxer_api/src/api/report/IReportRepository.ts b/fluxer_api/src/api/report/IReportRepository.ts index 2ab3bdc01..3d115220e 100644 --- a/fluxer_api/src/api/report/IReportRepository.ts +++ b/fluxer_api/src/api/report/IReportRepository.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, MessageID, ReportID, UserID} from '../BrandedTypes'; -import type {MessageAttachment, MessageEmbed, MessageStickerItem} from '../database/types/MessageTypes'; +import type {ChannelID, GuildID, MessageID, ReportID, UserID} from '@app/api/BrandedTypes'; +import type {MessageAttachment, MessageEmbed, MessageStickerItem} from '@app/api/database/types/MessageTypes'; import type { DSAReportEmailVerificationRow, DSAReportTicketRow, IARSubmissionRow, MessageReportSubmissionByReporterRow, -} from '../database/types/ReportTypes'; +} from '@app/api/database/types/ReportTypes'; -export type {IARMessageContextRow, IARSubmissionRow} from '../database/types/ReportTypes'; +export type {IARMessageContextRow, IARSubmissionRow} from '@app/api/database/types/ReportTypes'; export enum ReportStatus { PENDING = 0, diff --git a/fluxer_api/src/api/report/ReportController.ts b/fluxer_api/src/api/report/ReportController.ts index 7c57c9b4d..0fc8e65c3 100644 --- a/fluxer_api/src/api/report/ReportController.ts +++ b/fluxer_api/src/api/report/ReportController.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import { DsaReportEmailSendRequest, DsaReportEmailVerifyRequest, @@ -11,12 +17,6 @@ import { ReportUserRequest, TicketResponse, } from '@fluxer/schema/src/domains/report/ReportSchemas'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; export function ReportController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/report/ReportRepository.ts b/fluxer_api/src/api/report/ReportRepository.ts index a9f2d4e23..dd29bd409 100644 --- a/fluxer_api/src/api/report/ReportRepository.ts +++ b/fluxer_api/src/api/report/ReportRepository.ts @@ -1,29 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ReportAlreadyResolvedError} from '@fluxer/errors/src/domains/moderation/ReportAlreadyResolvedError'; -import {UnknownReportError} from '@fluxer/errors/src/domains/moderation/UnknownReportError'; -import type {ChannelID, MessageID, ReportID, UserID} from '../BrandedTypes'; -import {createChannelID, createGuildID, createMessageID, createReportID, createUserID} from '../BrandedTypes'; -import {fetchMany, fetchOne, upsertOne} from '../database/CassandraQueryExecution'; -import {Db} from '../database/CassandraTypes'; +import type {ChannelID, MessageID, ReportID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createGuildID, createMessageID, createReportID, createUserID} from '@app/api/BrandedTypes'; +import {fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; import type { DSAReportEmailVerificationRow, DSAReportTicketRow, MessageReportSubmissionByReporterRow, -} from '../database/types/ReportTypes'; -import { - DSAReportEmailVerifications, - DSAReportTickets, - IARSubmissions, - MessageReportSubmissionsByReporter, -} from '../Tables'; +} from '@app/api/database/types/ReportTypes'; import type { IARMessageContext, IARMessageContextRow, IARSubmission, IARSubmissionRow, IReportRepository, -} from './IReportRepository'; +} from '@app/api/report/IReportRepository'; +import { + DSAReportEmailVerifications, + DSAReportTickets, + IARSubmissions, + MessageReportSubmissionsByReporter, +} from '@app/api/Tables'; +import {ReportAlreadyResolvedError} from '@fluxer/errors/src/domains/moderation/ReportAlreadyResolvedError'; +import {UnknownReportError} from '@fluxer/errors/src/domains/moderation/UnknownReportError'; const GET_REPORT_QUERY = IARSubmissions.select({ where: IARSubmissions.where.eq('report_id'), diff --git a/fluxer_api/src/api/report/ReportRequestService.ts b/fluxer_api/src/api/report/ReportRequestService.ts index 9f8d5a16b..dcad19b65 100644 --- a/fluxer_api/src/api/report/ReportRequestService.ts +++ b/fluxer_api/src/api/report/ReportRequestService.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireEmailVerified} from '@app/api/auth/EmailVerificationUtils'; +import {createChannelID, createGuildID, createInviteCode, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import type {User} from '@app/api/models/User'; +import {type ReportStatus, reportStatusToString} from '@app/api/report/IReportRepository'; +import type {ReportService} from '@app/api/report/ReportService'; import {UnclaimedAccountCannotSubmitReportsError} from '@fluxer/errors/src/domains/moderation/UnclaimedAccountCannotSubmitReportsError'; import type { DsaReportEmailSendRequest, @@ -11,11 +16,6 @@ import type { ReportUserRequest, TicketResponse, } from '@fluxer/schema/src/domains/report/ReportSchemas'; -import {requireEmailVerified} from '../auth/EmailVerificationUtils'; -import {createChannelID, createGuildID, createInviteCode, createMessageID, createUserID} from '../BrandedTypes'; -import type {User} from '../models/User'; -import {type ReportStatus, reportStatusToString} from './IReportRepository'; -import type {ReportService} from './ReportService'; interface ReportUserRequestContext { user: User; diff --git a/fluxer_api/src/api/report/ReportService.ts b/fluxer_api/src/api/report/ReportService.ts index 9668197ce..ca67083da 100644 --- a/fluxer_api/src/api/report/ReportService.ts +++ b/fluxer_api/src/api/report/ReportService.ts @@ -1,6 +1,50 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash, randomBytes, randomInt} from 'node:crypto'; +import type {ChannelID, GuildID, InviteCode, MessageID, ReportID, UserID} from '@app/api/BrandedTypes'; +import { + createChannelID, + createGuildID, + createInviteCode, + createMessageID, + createReportID, + createUserID, +} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {AuthenticatedChannel} from '@app/api/channel/services/AuthenticatedChannel'; +import {MessageChannelAuthService} from '@app/api/channel/services/message/MessageChannelAuthService'; +import * as MessageHelpers from '@app/api/channel/services/message/MessageHelpers'; +import type {ContentWarningChannelLike} from '@app/api/channel/utils/EffectiveContentWarning'; +import { + channelToContentWarningView, + computeEffectiveChannelNsfw, + computeEffectiveContentWarning, + guildToContentWarningView, +} from '@app/api/channel/utils/EffectiveContentWarning'; +import type {MessageAttachment} from '@app/api/database/types/MessageTypes'; +import type {DSAReportTicketRow} from '@app/api/database/types/ReportTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IEmailDnsValidationService} from '@app/api/infrastructure/IEmailDnsValidationService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {IInviteRepository} from '@app/api/invite/IInviteRepository'; +import {Logger} from '@app/api/Logger'; +import type {Attachment} from '@app/api/models/Attachment'; +import type {Channel} from '@app/api/models/Channel'; +import type {Guild} from '@app/api/models/Guild'; +import type {Message} from '@app/api/models/Message'; +import type {User} from '@app/api/models/User'; +import type { + IARMessageContextRow, + IARSubmission, + IARSubmissionRow, + IReportRepository, +} from '@app/api/report/IReportRepository'; +import {ReportStatus, ReportType} from '@app/api/report/IReportRepository'; +import type {IReportSearchService} from '@app/api/search/IReportSearchService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {InviteTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; @@ -30,45 +74,6 @@ import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import type {IEmailService} from '@pkgs/email/src/IEmailService'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; import {ms} from 'itty-time'; -import type {ChannelID, GuildID, InviteCode, MessageID, ReportID, UserID} from '../BrandedTypes'; -import { - createChannelID, - createGuildID, - createInviteCode, - createMessageID, - createReportID, - createUserID, -} from '../BrandedTypes'; -import {Config} from '../Config'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import type {AuthenticatedChannel} from '../channel/services/AuthenticatedChannel'; -import {MessageChannelAuthService} from '../channel/services/message/MessageChannelAuthService'; -import * as MessageHelpers from '../channel/services/message/MessageHelpers'; -import type {ContentWarningChannelLike} from '../channel/utils/EffectiveContentWarning'; -import { - channelToContentWarningView, - computeEffectiveChannelNsfw, - computeEffectiveContentWarning, - guildToContentWarningView, -} from '../channel/utils/EffectiveContentWarning'; -import type {MessageAttachment} from '../database/types/MessageTypes'; -import type {DSAReportTicketRow} from '../database/types/ReportTypes'; -import type {IGuildRepositoryAggregate} from '../guild/repositories/IGuildRepositoryAggregate'; -import type {IEmailDnsValidationService} from '../infrastructure/IEmailDnsValidationService'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../infrastructure/IStorageService'; -import type {IInviteRepository} from '../invite/IInviteRepository'; -import {Logger} from '../Logger'; -import type {Attachment} from '../models/Attachment'; -import type {Channel} from '../models/Channel'; -import type {Guild} from '../models/Guild'; -import type {Message} from '../models/Message'; -import type {User} from '../models/User'; -import type {IReportSearchService} from '../search/IReportSearchService'; -import type {IUserRepository} from '../user/IUserRepository'; -import type {IARMessageContextRow, IARSubmission, IARSubmissionRow, IReportRepository} from './IReportRepository'; -import {ReportStatus, ReportType} from './IReportRepository'; interface ReporterMetadata { id: UserID | null; diff --git a/fluxer_api/src/api/report/tests/ContentReporting.test.ts b/fluxer_api/src/api/report/tests/ContentReporting.test.ts index a2d879bd5..0a51bc29e 100644 --- a/fluxer_api/src/api/report/tests/ContentReporting.test.ts +++ b/fluxer_api/src/api/report/tests/ContentReporting.test.ts @@ -1,10 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import {getEmailTemplate} from '@pkgs/email/src/email_i18n/EmailI18n'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; import { clearTestEmails, createTestAccount, @@ -13,8 +8,8 @@ import { listTestEmails, setUserACLs, type TestAccount, -} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; +} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; import { acceptInvite, createChannel, @@ -26,13 +21,18 @@ import { getChannel, sendChannelMessage, setupTestGuildWithMembers, -} from '../../channel/tests/ChannelTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {ReadStateRepository} from '../../read_state/ReadStateRepository'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_IDS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {ReportRepository} from '../ReportRepository'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {ReadStateRepository} from '@app/api/read_state/ReadStateRepository'; +import {ReportRepository} from '@app/api/report/ReportRepository'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_IDS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; +import {getEmailTemplate} from '@pkgs/email/src/email_i18n/EmailI18n'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; interface ReportResponse { report_id: string; diff --git a/fluxer_api/src/api/risk/AbusePolicy.ts b/fluxer_api/src/api/risk/AbusePolicy.ts index ceea2da60..269fb5a7b 100644 --- a/fluxer_api/src/api/risk/AbusePolicy.ts +++ b/fluxer_api/src/api/risk/AbusePolicy.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Config} from '../Config'; +import {Config} from '@app/api/Config'; function normalizeCountryCode(countryCode: string | null | undefined): string | null { const trimmed = countryCode?.trim(); diff --git a/fluxer_api/src/api/risk/AbuseProneEmailTlds.ts b/fluxer_api/src/api/risk/AbuseProneEmailTlds.ts index 2ce8c6f0e..770fba6c8 100644 --- a/fluxer_api/src/api/risk/AbuseProneEmailTlds.ts +++ b/fluxer_api/src/api/risk/AbuseProneEmailTlds.ts @@ -4,7 +4,7 @@ import { classifyAccountPolicyEmailTld, isAccountPolicyBlockedRegistrationEmailDomain, isAccountPolicyLowRiskEmailTld, -} from './AccountPolicyService'; +} from '@app/api/risk/AccountPolicyService'; export enum AbuseProneEmailTldRisk { High = 'high', diff --git a/fluxer_api/src/api/risk/AccountPolicyEvaluator.ts b/fluxer_api/src/api/risk/AccountPolicyEvaluator.ts index 346f9b4cf..51ef6c667 100644 --- a/fluxer_api/src/api/risk/AccountPolicyEvaluator.ts +++ b/fluxer_api/src/api/risk/AccountPolicyEvaluator.ts @@ -8,7 +8,7 @@ import { RiskConfidence, RiskDecisionMethod, RiskLevel, -} from './RiskTypes'; +} from '@app/api/risk/RiskTypes'; type JsonScalar = string | number | boolean | null; type JsonRecord = Record; diff --git a/fluxer_api/src/api/risk/AccountPolicyService.ts b/fluxer_api/src/api/risk/AccountPolicyService.ts index 27be18552..16f9b3d90 100644 --- a/fluxer_api/src/api/risk/AccountPolicyService.ts +++ b/fluxer_api/src/api/risk/AccountPolicyService.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Config} from '../Config'; +import {Config} from '@app/api/Config'; import { type AccountPolicyContactCapability, createAccountPolicyContactContext, @@ -8,8 +8,8 @@ import { createAccountPolicyEvaluatorFromConfig, type IAccountPolicyEvaluator, isAccountPolicyConfigMissing, -} from './AccountPolicyEvaluator'; -import type {ReverseDnsClassification} from './RiskTypes'; +} from '@app/api/risk/AccountPolicyEvaluator'; +import type {ReverseDnsClassification} from '@app/api/risk/RiskTypes'; let injectedAccountPolicyEvaluator: IAccountPolicyEvaluator | null = null; let configuredAccountPolicyEvaluator: IAccountPolicyEvaluator | null = null; diff --git a/fluxer_api/src/api/risk/DeferredPhoneGate.test.ts b/fluxer_api/src/api/risk/DeferredPhoneGate.test.ts index 6cff920ac..897bc9d77 100644 --- a/fluxer_api/src/api/risk/DeferredPhoneGate.test.ts +++ b/fluxer_api/src/api/risk/DeferredPhoneGate.test.ts @@ -1,5 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {Guild} from '@app/api/models/Guild'; +import type {User} from '@app/api/models/User'; +import { + canEscapePhoneGate, + type DeferredPhoneGateConfig, + evaluateDeferredPhoneGate, + guildTriggersPhoneGate, + restorePhoneGateDeferral, +} from '@app/api/risk/DeferredPhoneGate'; +import {resolveDeferredPhoneGateEnabled} from '@app/api/risk/DeferredPhoneGateCache'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import { DEFERRED_PHONE_ON_COMMUNITY_JOIN, @@ -9,16 +19,6 @@ import { import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import {ms} from 'itty-time'; import {describe, expect, it} from 'vitest'; -import type {Guild} from '../models/Guild'; -import type {User} from '../models/User'; -import { - canEscapePhoneGate, - type DeferredPhoneGateConfig, - evaluateDeferredPhoneGate, - guildTriggersPhoneGate, - restorePhoneGateDeferral, -} from './DeferredPhoneGate'; -import {resolveDeferredPhoneGateEnabled} from './DeferredPhoneGateCache'; const CONFIG: DeferredPhoneGateConfig = { enabled: true, diff --git a/fluxer_api/src/api/risk/DeferredPhoneGate.ts b/fluxer_api/src/api/risk/DeferredPhoneGate.ts index 3079eb8c4..f849326ea 100644 --- a/fluxer_api/src/api/risk/DeferredPhoneGate.ts +++ b/fluxer_api/src/api/risk/DeferredPhoneGate.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Logger} from '@app/api/Logger'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import type {Guild} from '@app/api/models/Guild'; +import type {User} from '@app/api/models/User'; +import {resolveDeferredPhoneGateEnabled} from '@app/api/risk/DeferredPhoneGateCache'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import { DEFERRABLE_PHONE_FLAGS, @@ -9,11 +14,6 @@ import { } from '@fluxer/constants/src/UserConstants'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import {ms} from 'itty-time'; -import {Logger} from '../Logger'; -import {getInstanceConfigRepository} from '../middleware/ServiceSingletons'; -import type {Guild} from '../models/Guild'; -import type {User} from '../models/User'; -import {resolveDeferredPhoneGateEnabled} from './DeferredPhoneGateCache'; export interface DeferredPhoneGateConfig { enabled: boolean; diff --git a/fluxer_api/src/api/risk/DeterministicRiskEngine.ts b/fluxer_api/src/api/risk/DeterministicRiskEngine.ts index 8f61d461a..d6ef799f4 100644 --- a/fluxer_api/src/api/risk/DeterministicRiskEngine.ts +++ b/fluxer_api/src/api/risk/DeterministicRiskEngine.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {AbuseProneEmailTldRisk, classifyAbuseProneEmailTld} from './AbuseProneEmailTlds'; -import {isMajorEmailProvider} from './MajorEmailProviders'; -import {derivePlusAddressBase} from './PlusAddressUtils'; -import type {RiskToolbox} from './RiskToolbox'; +import {AbuseProneEmailTldRisk, classifyAbuseProneEmailTld} from '@app/api/risk/AbuseProneEmailTlds'; +import {isMajorEmailProvider} from '@app/api/risk/MajorEmailProviders'; +import {derivePlusAddressBase} from '@app/api/risk/PlusAddressUtils'; +import type {RiskToolbox} from '@app/api/risk/RiskToolbox'; import { type HistoricalOutcomeResult, type IpInfoAnonymousResult, @@ -14,8 +14,8 @@ import { RiskDecisionMethod, RiskLevel, type RiskSignals, -} from './RiskTypes'; -import {isTrustedCommercialPrivacyProvider} from './TrustedPrivacyProviders'; +} from '@app/api/risk/RiskTypes'; +import {isTrustedCommercialPrivacyProvider} from '@app/api/risk/TrustedPrivacyProviders'; interface DeterministicRiskEngineLogger { info(payload: object, msg: string): void; diff --git a/fluxer_api/src/api/risk/HistoricalOutcomeRepository.ts b/fluxer_api/src/api/risk/HistoricalOutcomeRepository.ts index 69a7e5f68..651257329 100644 --- a/fluxer_api/src/api/risk/HistoricalOutcomeRepository.ts +++ b/fluxer_api/src/api/risk/HistoricalOutcomeRepository.ts @@ -1,22 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {createUserID, type UserID} from '../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '../database/CassandraQueryExecution'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; import type { LatestRiskContextByUserRow, RiskOutcomeByAsnRow, RiskOutcomeByEmailDomainRow, RiskOutcomeByIpRow, RiskOutcomeBySubnetRow, -} from '../database/types/RiskTypes'; +} from '@app/api/database/types/RiskTypes'; +import type { + HistoricalOutcomeCode, + HistoricalOutcomeRecord, + LatestRiskContextRecord, +} from '@app/api/risk/RiskHistoryTypes'; import { LatestRiskContextByUser, RiskOutcomesByAsn, RiskOutcomesByEmailDomain, RiskOutcomesByIp, RiskOutcomesBySubnet, -} from '../Tables'; -import type {HistoricalOutcomeCode, HistoricalOutcomeRecord, LatestRiskContextRecord} from './RiskHistoryTypes'; +} from '@app/api/Tables'; export interface IRiskHistoryRepository { upsertLatestContext(context: LatestRiskContextRecord): Promise; diff --git a/fluxer_api/src/api/risk/IpBanCgnatGuard.ts b/fluxer_api/src/api/risk/IpBanCgnatGuard.ts index 6a777a4f1..4bcca9fd0 100644 --- a/fluxer_api/src/api/risk/IpBanCgnatGuard.ts +++ b/fluxer_api/src/api/risk/IpBanCgnatGuard.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isTrustedCommercialPrivacyProvider} from '@app/api/risk/TrustedPrivacyProviders'; +import {parseIpBanEntry} from '@app/api/utils/IpRangeUtils'; import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress'; import type {IpInfoLookupResult, IpInfoService} from '@pkgs/geoip/src/IpInfoService'; -import {parseIpBanEntry} from '../utils/IpRangeUtils'; -import {isTrustedCommercialPrivacyProvider} from './TrustedPrivacyProviders'; const VERDICT_CACHE_TTL_MS = 60 * 60 * 1000; diff --git a/fluxer_api/src/api/risk/IpBanExemptions.ts b/fluxer_api/src/api/risk/IpBanExemptions.ts index ec20dc249..9171dee30 100644 --- a/fluxer_api/src/api/risk/IpBanExemptions.ts +++ b/fluxer_api/src/api/risk/IpBanExemptions.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress'; -import {Config} from '../Config'; let exemptDecisionKeys: ReadonlySet | null = null; diff --git a/fluxer_api/src/api/risk/IpInfoBudget.ts b/fluxer_api/src/api/risk/IpInfoBudget.ts index 17bbdc507..24bc66f44 100644 --- a/fluxer_api/src/api/risk/IpInfoBudget.ts +++ b/fluxer_api/src/api/risk/IpInfoBudget.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Logger} from '@app/api/Logger'; import type {IpInfoLookupBudget, IpInfoLookupPriority} from '@pkgs/geoip/src/IpInfoService'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {Logger} from '../Logger'; const BURST_KEY_PREFIX = 'ipinfo:budget:burst:'; const MONTH_KEY_PREFIX = 'ipinfo:budget:month:'; diff --git a/fluxer_api/src/api/risk/IpInfoCacheFactory.ts b/fluxer_api/src/api/risk/IpInfoCacheFactory.ts index a02e50f0c..80b92e223 100644 --- a/fluxer_api/src/api/risk/IpInfoCacheFactory.ts +++ b/fluxer_api/src/api/risk/IpInfoCacheFactory.ts @@ -1,5 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; import {getDefaultCassandraClient} from '@pkgs/cassandra/src/Client'; import {createCassandraIpInfoCache} from '@pkgs/geoip/src/CassandraIpInfoCache'; import {createCassandraIpInfoRequestAuditLogger} from '@pkgs/geoip/src/CassandraIpInfoRequestAudit'; @@ -7,8 +9,6 @@ import {type IpInfoCache, type IpInfoRequestAuditLogger, isCachedIpInfoFailure} import {createPostgresIpInfoCache, createPostgresIpInfoRequestAuditLogger} from '@pkgs/geoip/src/PostgresIpInfoKv'; import {createTieredIpInfoCache} from '@pkgs/geoip/src/TieredIpInfoCache'; import {getDefaultPostgresClient} from '@pkgs/postgres/src/Client'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; interface BuildIpInfoCacheOptions { hot: IpInfoCache; diff --git a/fluxer_api/src/api/risk/RegistrationEventsRepository.ts b/fluxer_api/src/api/risk/RegistrationEventsRepository.ts index 0070c0665..a1e99c87c 100644 --- a/fluxer_api/src/api/risk/RegistrationEventsRepository.ts +++ b/fluxer_api/src/api/risk/RegistrationEventsRepository.ts @@ -1,22 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {getSubnet} from '@fluxer/ip_utils/src/IpAddress'; -import {createUserID} from '../BrandedTypes'; -import {BatchBuilder, fetchMany} from '../database/CassandraQueryExecution'; +import {createUserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany} from '@app/api/database/CassandraQueryExecution'; import type { RegistrationEventByEmailDomainRow, RegistrationEventByIpRow, RegistrationEventByPlusAddressBaseRow, RegistrationEventBySubnetRow, -} from '../database/types/RiskTypes'; +} from '@app/api/database/types/RiskTypes'; +import type {IRegistrationEventsRepository, RegistrationEventRecord} from '@app/api/risk/adapters/VelocityAdapter'; +import {derivePlusAddressBase} from '@app/api/risk/PlusAddressUtils'; import { RegistrationEventsByEmailDomain, RegistrationEventsByIp, RegistrationEventsByPlusAddressBase, RegistrationEventsBySubnet, -} from '../Tables'; -import type {IRegistrationEventsRepository, RegistrationEventRecord} from './adapters/VelocityAdapter'; -import {derivePlusAddressBase} from './PlusAddressUtils'; +} from '@app/api/Tables'; +import {getSubnet} from '@fluxer/ip_utils/src/IpAddress'; const SELECT_BY_IP_CQL = RegistrationEventsByIp.selectCql({ where: [RegistrationEventsByIp.where.eq('ip'), RegistrationEventsByIp.where.gte('created_at')], diff --git a/fluxer_api/src/api/risk/RegistrationIpPrescreen.ts b/fluxer_api/src/api/risk/RegistrationIpPrescreen.ts index c75b2f7f7..bc7100d18 100644 --- a/fluxer_api/src/api/risk/RegistrationIpPrescreen.ts +++ b/fluxer_api/src/api/risk/RegistrationIpPrescreen.ts @@ -4,7 +4,7 @@ import { classifyAccountPolicyReverseDnsHostname, isAccountPolicyEducationOrganizationName, isAccountPolicyTrustedCommercialPrivacyProvider, -} from './AccountPolicyService'; +} from '@app/api/risk/AccountPolicyService'; const ASN_ENTRY_REGEX = /^\d+$/u; diff --git a/fluxer_api/src/api/risk/RiskAssessmentRepository.ts b/fluxer_api/src/api/risk/RiskAssessmentRepository.ts index be244f230..b7b979621 100644 --- a/fluxer_api/src/api/risk/RiskAssessmentRepository.ts +++ b/fluxer_api/src/api/risk/RiskAssessmentRepository.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; -import type {UserID} from '../BrandedTypes'; -import {BatchBuilder} from '../database/CassandraQueryExecution'; -import {RiskAssessments, RiskAssessmentsByUser} from '../Tables'; -import type {RiskAssessment} from './RiskTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder} from '@app/api/database/CassandraQueryExecution'; +import type {RiskAssessment} from '@app/api/risk/RiskTypes'; +import {RiskAssessments, RiskAssessmentsByUser} from '@app/api/Tables'; export interface IRiskAssessmentRepository { recordAssessment(params: { diff --git a/fluxer_api/src/api/risk/RiskBlocklistS3.ts b/fluxer_api/src/api/risk/RiskBlocklistS3.ts index d0402ad10..1701e08ea 100644 --- a/fluxer_api/src/api/risk/RiskBlocklistS3.ts +++ b/fluxer_api/src/api/risk/RiskBlocklistS3.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IStorageService} from '../infrastructure/IStorageService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; const RISK_S3_BUCKET = 'fluxer-geoip'; export const RISK_S3_KEYS = { diff --git a/fluxer_api/src/api/risk/RiskHistoryContext.ts b/fluxer_api/src/api/risk/RiskHistoryContext.ts index cb4e46bb7..443ca9748 100644 --- a/fluxer_api/src/api/risk/RiskHistoryContext.ts +++ b/fluxer_api/src/api/risk/RiskHistoryContext.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {LatestRiskContextRecord} from '@app/api/risk/RiskHistoryTypes'; import {getSubnet} from '@fluxer/ip_utils/src/IpAddress'; -import type {LatestRiskContextRecord} from './RiskHistoryTypes'; export function deriveLatestRiskContext(params: { userId: string; diff --git a/fluxer_api/src/api/risk/RiskToolbox.ts b/fluxer_api/src/api/risk/RiskToolbox.ts index 35927b39d..3e9775921 100644 --- a/fluxer_api/src/api/risk/RiskToolbox.ts +++ b/fluxer_api/src/api/risk/RiskToolbox.ts @@ -15,7 +15,7 @@ import type { SuspiciousIpResult, UserAgentResult, VelocityResult, -} from './RiskTypes'; +} from '@app/api/risk/RiskTypes'; export interface RiskToolbox { analyzeEmailSyntax(args: {email: string}): Promise; diff --git a/fluxer_api/src/api/risk/RiskToolboxFactory.ts b/fluxer_api/src/api/risk/RiskToolboxFactory.ts index 72f64063b..9adadee2d 100644 --- a/fluxer_api/src/api/risk/RiskToolboxFactory.ts +++ b/fluxer_api/src/api/risk/RiskToolboxFactory.ts @@ -1,24 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IAdminRepository} from '@app/api/admin/IAdminRepository'; +import {createDisposableDomainChecker} from '@app/api/risk/adapters/DisposableDomainChecker'; +import {createDnsMxChecker, type MxResolver, NodeDnsMxResolver} from '@app/api/risk/adapters/DnsMxChecker'; +import {createDomainAgeChecker} from '@app/api/risk/adapters/DomainAgeChecker'; +import {analyzeEmailSyntax} from '@app/api/risk/adapters/EmailSyntaxAnalyzer'; +import {createGeoIpAsnAdapter, createGeoIpCityAdapter} from '@app/api/risk/adapters/GeoIpAdapters'; +import {createHistoricalOutcomeAdapter} from '@app/api/risk/adapters/HistoricalOutcomeAdapter'; +import {unavailableIpInfoAnonymousResult} from '@app/api/risk/adapters/IpInfoAdapter'; +import {checkGeoVsLocale} from '@app/api/risk/adapters/LocaleGeoMatcher'; +import {analyzeRegistrationTiming} from '@app/api/risk/adapters/RegistrationTimingAnalyzer'; +import {analyzeUserAgent} from '@app/api/risk/adapters/UserAgentAnalyzer'; +import {createVelocityAdapter, type IRegistrationEventsRepository} from '@app/api/risk/adapters/VelocityAdapter'; +import type {IRiskHistoryRepository} from '@app/api/risk/HistoricalOutcomeRepository'; +import type {RiskToolbox} from '@app/api/risk/RiskToolbox'; +import type {IpInfoAnonymousResult, ReverseDnsResult} from '@app/api/risk/RiskTypes'; +import type {ISuspiciousIpRepository} from '@app/api/risk/SuspiciousIpRepository'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {GeoipAsnResult, GeoipResult} from '@pkgs/geoip/src/GeoipLookup'; import type {IpInfoService} from '@pkgs/geoip/src/IpInfoService'; -import type {IAdminRepository} from '../admin/IAdminRepository'; -import {createDisposableDomainChecker} from './adapters/DisposableDomainChecker'; -import {createDnsMxChecker, type MxResolver, NodeDnsMxResolver} from './adapters/DnsMxChecker'; -import {createDomainAgeChecker} from './adapters/DomainAgeChecker'; -import {analyzeEmailSyntax} from './adapters/EmailSyntaxAnalyzer'; -import {createGeoIpAsnAdapter, createGeoIpCityAdapter} from './adapters/GeoIpAdapters'; -import {createHistoricalOutcomeAdapter} from './adapters/HistoricalOutcomeAdapter'; -import {unavailableIpInfoAnonymousResult} from './adapters/IpInfoAdapter'; -import {checkGeoVsLocale} from './adapters/LocaleGeoMatcher'; -import {analyzeRegistrationTiming} from './adapters/RegistrationTimingAnalyzer'; -import {analyzeUserAgent} from './adapters/UserAgentAnalyzer'; -import {createVelocityAdapter, type IRegistrationEventsRepository} from './adapters/VelocityAdapter'; -import type {IRiskHistoryRepository} from './HistoricalOutcomeRepository'; -import type {RiskToolbox} from './RiskToolbox'; -import type {IpInfoAnonymousResult, ReverseDnsResult} from './RiskTypes'; -import type {ISuspiciousIpRepository} from './SuspiciousIpRepository'; interface RiskToolboxFactoryOptions { adminRepository: Pick; diff --git a/fluxer_api/src/api/risk/SuspiciousIpRepository.ts b/fluxer_api/src/api/risk/SuspiciousIpRepository.ts index bd7eed130..570e7795b 100644 --- a/fluxer_api/src/api/risk/SuspiciousIpRepository.ts +++ b/fluxer_api/src/api/risk/SuspiciousIpRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {SuspiciousIpRow} from '@app/api/database/types/RiskTypes'; +import type {SuspiciousIpResult} from '@app/api/risk/RiskTypes'; +import {SuspiciousIps} from '@app/api/Tables'; import {getSameIpDecisionKey, normalizeIpString} from '@fluxer/ip_utils/src/IpAddress'; -import type {UserID} from '../BrandedTypes'; -import {fetchOne, upsertOne} from '../database/CassandraQueryExecution'; -import type {SuspiciousIpRow} from '../database/types/RiskTypes'; -import {SuspiciousIps} from '../Tables'; -import type {SuspiciousIpResult} from './RiskTypes'; const SUSPICIOUS_IP_TTL_SECONDS = 180 * 24 * 60 * 60; const SELECT_SUSPICIOUS_IP_CQL = SuspiciousIps.selectCql({ diff --git a/fluxer_api/src/api/risk/TrustedPrivacyProviders.ts b/fluxer_api/src/api/risk/TrustedPrivacyProviders.ts index 6d70a4b8c..781ed0534 100644 --- a/fluxer_api/src/api/risk/TrustedPrivacyProviders.ts +++ b/fluxer_api/src/api/risk/TrustedPrivacyProviders.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {isAccountPolicyTrustedCommercialPrivacyProvider} from './AccountPolicyService'; +import {isAccountPolicyTrustedCommercialPrivacyProvider} from '@app/api/risk/AccountPolicyService'; export function isTrustedCommercialPrivacyProvider(providerName: string | null | undefined): boolean { return isAccountPolicyTrustedCommercialPrivacyProvider(providerName); diff --git a/fluxer_api/src/api/risk/TwilioInboundSmsWebhook.ts b/fluxer_api/src/api/risk/TwilioInboundSmsWebhook.ts index b96941516..edb33e761 100644 --- a/fluxer_api/src/api/risk/TwilioInboundSmsWebhook.ts +++ b/fluxer_api/src/api/risk/TwilioInboundSmsWebhook.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHmac, timingSafeEqual} from 'node:crypto'; +import {phonePrefixBanCache} from '@app/api/auth/PhonePrefixBanCache'; +import {PhoneVerificationReuseStore} from '@app/api/auth/PhoneVerificationReuseStore'; +import type {InboundSmsChallengeService} from '@app/api/auth/services/InboundSmsChallengeService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import {resolveRequestClientIp} from '@app/api/utils/IpUtils'; import {PHONE_ADD_CLEARABLE_FLAGS} from '@fluxer/constants/src/UserConstants'; import {PHONE_E164_REGEX} from '@fluxer/schema/src/primitives/UserValidators'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import {phonePrefixBanCache} from '../auth/PhonePrefixBanCache'; -import {PhoneVerificationReuseStore} from '../auth/PhoneVerificationReuseStore'; -import type {InboundSmsChallengeService} from '../auth/services/InboundSmsChallengeService'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import {Logger} from '../Logger'; -import type {HonoApp} from '../types/HonoEnv'; -import type {IUserRepository} from '../user/IUserRepository'; -import {mapUserToPrivateResponse} from '../user/UserMappers'; -import {resolveRequestClientIp} from '../utils/IpUtils'; interface TwilioInboundSmsWebhookContext { authToken: string; diff --git a/fluxer_api/src/api/risk/__tests__/AbuseProneEmailTlds.test.ts b/fluxer_api/src/api/risk/__tests__/AbuseProneEmailTlds.test.ts index dd84f55e3..ef8636588 100644 --- a/fluxer_api/src/api/risk/__tests__/AbuseProneEmailTlds.test.ts +++ b/fluxer_api/src/api/risk/__tests__/AbuseProneEmailTlds.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createCurrentBehaviorTestAccountPolicyEvaluator} from '../../test/AccountPolicyTestEvaluator'; import { AbuseProneEmailTldRisk, classifyAbuseProneEmailTld, isBlockedRegistrationEmailDomain, isLowRiskEmailTld, -} from '../AbuseProneEmailTlds'; -import {setInjectedAccountPolicyEvaluator} from '../AccountPolicyService'; +} from '@app/api/risk/AbuseProneEmailTlds'; +import {setInjectedAccountPolicyEvaluator} from '@app/api/risk/AccountPolicyService'; +import {createCurrentBehaviorTestAccountPolicyEvaluator} from '@app/api/test/AccountPolicyTestEvaluator'; +import {afterEach, beforeEach, describe, expect, it} from 'vitest'; beforeEach(() => { setInjectedAccountPolicyEvaluator(createCurrentBehaviorTestAccountPolicyEvaluator()); diff --git a/fluxer_api/src/api/risk/__tests__/AccountPolicyEvaluator.test.ts b/fluxer_api/src/api/risk/__tests__/AccountPolicyEvaluator.test.ts index 93c6f191e..035169ce4 100644 --- a/fluxer_api/src/api/risk/__tests__/AccountPolicyEvaluator.test.ts +++ b/fluxer_api/src/api/risk/__tests__/AccountPolicyEvaluator.test.ts @@ -1,21 +1,27 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {SuspiciousActivityFlags} from '@fluxer/constants/src/UserConstants'; -import {describe, expect, it} from 'vitest'; -import { - createCurrentBehaviorTestAccountPolicyEvaluator, - TEST_POLICY_CONTACT_DOMAIN, - TEST_POLICY_CONTACT_SUBDOMAIN, - TEST_POLICY_REPUTATION_EXEMPT_DOMAIN, -} from '../../test/AccountPolicyTestEvaluator'; import { type AccountPolicyContext, createAccountPolicyContactContext, createAccountPolicyContactDomainContext, createAccountPolicyEvaluatorFromConfig, normalizePolicyContactDomain, -} from '../AccountPolicyEvaluator'; -import {RecommendedAction, type RiskAssessment, RiskConfidence, RiskDecisionMethod, RiskLevel} from '../RiskTypes'; +} from '@app/api/risk/AccountPolicyEvaluator'; +import { + RecommendedAction, + type RiskAssessment, + RiskConfidence, + RiskDecisionMethod, + RiskLevel, +} from '@app/api/risk/RiskTypes'; +import { + createCurrentBehaviorTestAccountPolicyEvaluator, + TEST_POLICY_CONTACT_DOMAIN, + TEST_POLICY_CONTACT_SUBDOMAIN, + TEST_POLICY_REPUTATION_EXEMPT_DOMAIN, +} from '@app/api/test/AccountPolicyTestEvaluator'; +import {SuspiciousActivityFlags} from '@fluxer/constants/src/UserConstants'; +import {describe, expect, it} from 'vitest'; function createAssessment(params: {level?: RiskLevel; action?: RecommendedAction; score?: number}): RiskAssessment { const level = params.level ?? RiskLevel.Low; diff --git a/fluxer_api/src/api/risk/__tests__/AccountPolicyService.test.ts b/fluxer_api/src/api/risk/__tests__/AccountPolicyService.test.ts index 4c45d00ed..3d0277e83 100644 --- a/fluxer_api/src/api/risk/__tests__/AccountPolicyService.test.ts +++ b/fluxer_api/src/api/risk/__tests__/AccountPolicyService.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {APIConfig} from '@app/api/config/APIConfig'; import {describe, expect, it, vi} from 'vitest'; -import type {APIConfig} from '../../config/APIConfig'; function createRuntimePolicyConfig(params: { nodeEnv: 'development' | 'production'; @@ -26,9 +26,9 @@ function createRuntimePolicyConfig(params: { async function loadIsolatedAccountPolicyService(config: APIConfig) { vi.resetModules(); - const {initializeConfig} = await import('../../Config'); + const {initializeConfig} = await import('@app/api/Config'); initializeConfig(config); - return import('../AccountPolicyService'); + return import('@app/api/risk/AccountPolicyService'); } describe('AccountPolicyService runtime config', () => { diff --git a/fluxer_api/src/api/risk/__tests__/DeterministicRiskEngine.test.ts b/fluxer_api/src/api/risk/__tests__/DeterministicRiskEngine.test.ts index a017edc2b..e92f98a7e 100644 --- a/fluxer_api/src/api/risk/__tests__/DeterministicRiskEngine.test.ts +++ b/fluxer_api/src/api/risk/__tests__/DeterministicRiskEngine.test.ts @@ -1,11 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {setInjectedAccountPolicyEvaluator} from '@app/api/risk/AccountPolicyService'; +import {DeterministicRiskEngine} from '@app/api/risk/DeterministicRiskEngine'; +import type {RiskToolbox} from '@app/api/risk/RiskToolbox'; +import { + type IpInfoAnonymousResult, + RecommendedAction, + type RegistrationEvent, + RiskLevel, +} from '@app/api/risk/RiskTypes'; +import {createCurrentBehaviorTestAccountPolicyEvaluator} from '@app/api/test/AccountPolicyTestEvaluator'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createCurrentBehaviorTestAccountPolicyEvaluator} from '../../test/AccountPolicyTestEvaluator'; -import {setInjectedAccountPolicyEvaluator} from '../AccountPolicyService'; -import {DeterministicRiskEngine} from '../DeterministicRiskEngine'; -import type {RiskToolbox} from '../RiskToolbox'; -import {type IpInfoAnonymousResult, RecommendedAction, type RegistrationEvent, RiskLevel} from '../RiskTypes'; const BASE_EVENT: RegistrationEvent = { email: null, diff --git a/fluxer_api/src/api/risk/__tests__/EmailSyntaxAnalyzer.test.ts b/fluxer_api/src/api/risk/__tests__/EmailSyntaxAnalyzer.test.ts index 9d29ae5c3..78b6b9a34 100644 --- a/fluxer_api/src/api/risk/__tests__/EmailSyntaxAnalyzer.test.ts +++ b/fluxer_api/src/api/risk/__tests__/EmailSyntaxAnalyzer.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {analyzeEmailSyntax} from '@app/api/risk/adapters/EmailSyntaxAnalyzer'; import {describe, expect, it} from 'vitest'; -import {analyzeEmailSyntax} from '../adapters/EmailSyntaxAnalyzer'; describe('analyzeEmailSyntax', () => { it('rejects malformed addresses', () => { diff --git a/fluxer_api/src/api/risk/__tests__/GeoIpAdapters.test.ts b/fluxer_api/src/api/risk/__tests__/GeoIpAdapters.test.ts index 56051b2d8..8f6d6adae 100644 --- a/fluxer_api/src/api/risk/__tests__/GeoIpAdapters.test.ts +++ b/fluxer_api/src/api/risk/__tests__/GeoIpAdapters.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGeoIpAsnAdapter, createGeoIpCityAdapter} from '@app/api/risk/adapters/GeoIpAdapters'; import type {GeoipAsnResult, GeoipResult} from '@pkgs/geoip/src/GeoipLookup'; import type {IpInfoLookupResult, IpInfoService} from '@pkgs/geoip/src/IpInfoService'; import {describe, expect, it} from 'vitest'; -import {createGeoIpAsnAdapter, createGeoIpCityAdapter} from '../adapters/GeoIpAdapters'; function throwingIpInfoService(): IpInfoService { return { diff --git a/fluxer_api/src/api/risk/__tests__/HistoricalOutcomeAdapter.test.ts b/fluxer_api/src/api/risk/__tests__/HistoricalOutcomeAdapter.test.ts index 5fceea143..176811c5d 100644 --- a/fluxer_api/src/api/risk/__tests__/HistoricalOutcomeAdapter.test.ts +++ b/fluxer_api/src/api/risk/__tests__/HistoricalOutcomeAdapter.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createHistoricalOutcomeAdapter, type HistoricalOutcomeAdapterContext, -} from '../adapters/HistoricalOutcomeAdapter'; -import type {IRiskHistoryRepository} from '../HistoricalOutcomeRepository'; -import type {HistoricalOutcomeRecord} from '../RiskHistoryTypes'; +} from '@app/api/risk/adapters/HistoricalOutcomeAdapter'; +import type {IRiskHistoryRepository} from '@app/api/risk/HistoricalOutcomeRepository'; +import type {HistoricalOutcomeRecord} from '@app/api/risk/RiskHistoryTypes'; +import {describe, expect, it} from 'vitest'; function makeRepository(records: ReadonlyArray): IRiskHistoryRepository { return { diff --git a/fluxer_api/src/api/risk/__tests__/IpBanCgnatGuard.test.ts b/fluxer_api/src/api/risk/__tests__/IpBanCgnatGuard.test.ts index 982ac02a1..1324d8fe5 100644 --- a/fluxer_api/src/api/risk/__tests__/IpBanCgnatGuard.test.ts +++ b/fluxer_api/src/api/risk/__tests__/IpBanCgnatGuard.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IpInfoLookupResult} from '@pkgs/geoip/src/IpInfoService'; -import {describe, expect, it} from 'vitest'; import { isHighCgnatBlastRadiusRisk, isHighSharedAccessBlastRadiusRisk, isSingleIpBanCandidate, -} from '../IpBanCgnatGuard'; +} from '@app/api/risk/IpBanCgnatGuard'; +import type {IpInfoLookupResult} from '@pkgs/geoip/src/IpInfoService'; +import {describe, expect, it} from 'vitest'; function ipInfoResult(overrides: Partial = {}): IpInfoLookupResult { return { diff --git a/fluxer_api/src/api/risk/__tests__/IpInfoAdapterPrescreen.test.ts b/fluxer_api/src/api/risk/__tests__/IpInfoAdapterPrescreen.test.ts index 1d3d34f2d..5a26ae9bf 100644 --- a/fluxer_api/src/api/risk/__tests__/IpInfoAdapterPrescreen.test.ts +++ b/fluxer_api/src/api/risk/__tests__/IpInfoAdapterPrescreen.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {setInjectedAccountPolicyEvaluator} from '@app/api/risk/AccountPolicyService'; +import {createIpInfoChecker, unavailableIpInfoAnonymousResult} from '@app/api/risk/adapters/IpInfoAdapter'; +import {createCurrentBehaviorTestAccountPolicyEvaluator} from '@app/api/test/AccountPolicyTestEvaluator'; import type {IpInfoLookupContext, IpInfoLookupResult, IpInfoService} from '@pkgs/geoip/src/IpInfoService'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createCurrentBehaviorTestAccountPolicyEvaluator} from '../../test/AccountPolicyTestEvaluator'; -import {setInjectedAccountPolicyEvaluator} from '../AccountPolicyService'; -import {createIpInfoChecker, unavailableIpInfoAnonymousResult} from '../adapters/IpInfoAdapter'; function ipInfoResult(overrides: Partial = {}): IpInfoLookupResult { return { diff --git a/fluxer_api/src/api/risk/__tests__/IpInfoBudget.test.ts b/fluxer_api/src/api/risk/__tests__/IpInfoBudget.test.ts index 176f19796..6319452df 100644 --- a/fluxer_api/src/api/risk/__tests__/IpInfoBudget.test.ts +++ b/fluxer_api/src/api/risk/__tests__/IpInfoBudget.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createKvIpInfoLookupBudget} from '@app/api/risk/IpInfoBudget'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; -import {MockKVProvider} from '../../test/mocks/MockKVProvider'; -import {createKvIpInfoLookupBudget} from '../IpInfoBudget'; const BUDGET_ENV_KEYS = [ 'FLUXER_IPINFO_BUDGET_ENABLED', diff --git a/fluxer_api/src/api/risk/__tests__/IpInfoServiceCache.test.ts b/fluxer_api/src/api/risk/__tests__/IpInfoServiceCache.test.ts index 98019eafb..dd471a4fd 100644 --- a/fluxer_api/src/api/risk/__tests__/IpInfoServiceCache.test.ts +++ b/fluxer_api/src/api/risk/__tests__/IpInfoServiceCache.test.ts @@ -1,5 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {server} from '@app/api/test/msw/server'; import type { CachedIpInfoFailure, IpInfoCache, @@ -11,7 +12,6 @@ import type { import {createIpInfoService, resolveIpInfoLookupPriority} from '@pkgs/geoip/src/IpInfoService'; import {delay, HttpResponse, http} from 'msw'; import {describe, expect, it} from 'vitest'; -import {server} from '../../test/msw/server'; interface RecordedSet { key: string; diff --git a/fluxer_api/src/api/risk/__tests__/LocaleGeoMatcher.test.ts b/fluxer_api/src/api/risk/__tests__/LocaleGeoMatcher.test.ts index 0a06b90b4..244406ca9 100644 --- a/fluxer_api/src/api/risk/__tests__/LocaleGeoMatcher.test.ts +++ b/fluxer_api/src/api/risk/__tests__/LocaleGeoMatcher.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {checkGeoVsLocale} from '@app/api/risk/adapters/LocaleGeoMatcher'; import {describe, expect, it} from 'vitest'; -import {checkGeoVsLocale} from '../adapters/LocaleGeoMatcher'; describe('checkGeoVsLocale', () => { it('matches en-US to US', async () => { diff --git a/fluxer_api/src/api/risk/__tests__/RegistrationIpPrescreen.test.ts b/fluxer_api/src/api/risk/__tests__/RegistrationIpPrescreen.test.ts index c8f8077e6..92bc1470d 100644 --- a/fluxer_api/src/api/risk/__tests__/RegistrationIpPrescreen.test.ts +++ b/fluxer_api/src/api/risk/__tests__/RegistrationIpPrescreen.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createCurrentBehaviorTestAccountPolicyEvaluator} from '../../test/AccountPolicyTestEvaluator'; -import {setInjectedAccountPolicyEvaluator} from '../AccountPolicyService'; +import {setInjectedAccountPolicyEvaluator} from '@app/api/risk/AccountPolicyService'; import { type IpInfoPrescreenOptions, ipInfoPrescreenOptionsFromEnv, type LocalIpIntel, prescreenIpInfoLookup, -} from '../RegistrationIpPrescreen'; +} from '@app/api/risk/RegistrationIpPrescreen'; +import {createCurrentBehaviorTestAccountPolicyEvaluator} from '@app/api/test/AccountPolicyTestEvaluator'; +import {afterEach, beforeEach, describe, expect, it} from 'vitest'; const CLEAN_LOCAL: LocalIpIntel = {countryIso: 'SE', asn: 64500, asnOrg: 'Example Broadband ISP'}; diff --git a/fluxer_api/src/api/risk/__tests__/TorReverseDnsChecker.test.ts b/fluxer_api/src/api/risk/__tests__/TorReverseDnsChecker.test.ts index 85040587c..e6b92b22a 100644 --- a/fluxer_api/src/api/risk/__tests__/TorReverseDnsChecker.test.ts +++ b/fluxer_api/src/api/risk/__tests__/TorReverseDnsChecker.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {matchTorHostname} from '@app/api/risk/adapters/TorReverseDnsChecker'; import {describe, expect, it} from 'vitest'; -import {matchTorHostname} from '../adapters/TorReverseDnsChecker'; describe('matchTorHostname', () => { it.each([ diff --git a/fluxer_api/src/api/risk/__tests__/VelocityAdapter.test.ts b/fluxer_api/src/api/risk/__tests__/VelocityAdapter.test.ts index eaa86c5b6..9a09b3716 100644 --- a/fluxer_api/src/api/risk/__tests__/VelocityAdapter.test.ts +++ b/fluxer_api/src/api/risk/__tests__/VelocityAdapter.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createVelocityAdapter, type IRegistrationEventsRepository, type RegistrationEventRecord, -} from '../adapters/VelocityAdapter'; +} from '@app/api/risk/adapters/VelocityAdapter'; +import {describe, expect, it} from 'vitest'; function makeMockRepo(records: ReadonlyArray): IRegistrationEventsRepository { return { diff --git a/fluxer_api/src/api/risk/adapters/DisposableDomainChecker.ts b/fluxer_api/src/api/risk/adapters/DisposableDomainChecker.ts index 423039b6d..205a7104f 100644 --- a/fluxer_api/src/api/risk/adapters/DisposableDomainChecker.ts +++ b/fluxer_api/src/api/risk/adapters/DisposableDomainChecker.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IAdminRepository} from '../../admin/IAdminRepository'; -import type {DisposableCheckResult} from '../RiskTypes'; +import type {IAdminRepository} from '@app/api/admin/IAdminRepository'; +import type {DisposableCheckResult} from '@app/api/risk/RiskTypes'; interface DisposableDomainCheckerContext { adminRepository: Pick; diff --git a/fluxer_api/src/api/risk/adapters/DnsMxChecker.ts b/fluxer_api/src/api/risk/adapters/DnsMxChecker.ts index 4ccbda30f..a6b844097 100644 --- a/fluxer_api/src/api/risk/adapters/DnsMxChecker.ts +++ b/fluxer_api/src/api/risk/adapters/DnsMxChecker.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {Resolver} from 'node:dns/promises'; -import type {MxCheckResult} from '../RiskTypes'; +import type {MxCheckResult} from '@app/api/risk/RiskTypes'; export interface MxResolver { resolveMx(domain: string): Promise< diff --git a/fluxer_api/src/api/risk/adapters/DomainAgeChecker.ts b/fluxer_api/src/api/risk/adapters/DomainAgeChecker.ts index 97d4908d5..3039d5013 100644 --- a/fluxer_api/src/api/risk/adapters/DomainAgeChecker.ts +++ b/fluxer_api/src/api/risk/adapters/DomainAgeChecker.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isMajorEmailProvider} from '@app/api/risk/MajorEmailProviders'; +import type {DomainAgeResult} from '@app/api/risk/RiskTypes'; +import {EXTERNAL_RESPONSE_LIMITS} from '@app/api/utils/ExternalResponseLimits'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; +import {isJsonRecord, parseJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import {EXTERNAL_RESPONSE_LIMITS} from '../../utils/ExternalResponseLimits'; -import * as FetchUtils from '../../utils/FetchUtils'; -import {isJsonRecord, parseJsonRecord} from '../../utils/JsonBoundaryUtils'; -import {isMajorEmailProvider} from '../MajorEmailProviders'; -import type {DomainAgeResult} from '../RiskTypes'; const RDAP_TIMEOUT_MS = 4000; const CACHE_KEY_PREFIX = 'risk:domain_age:'; diff --git a/fluxer_api/src/api/risk/adapters/EmailSyntaxAnalyzer.ts b/fluxer_api/src/api/risk/adapters/EmailSyntaxAnalyzer.ts index dbe53b01a..d7ba6bfdd 100644 --- a/fluxer_api/src/api/risk/adapters/EmailSyntaxAnalyzer.ts +++ b/fluxer_api/src/api/risk/adapters/EmailSyntaxAnalyzer.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {EmailSyntaxResult} from '../RiskTypes'; +import type {EmailSyntaxResult} from '@app/api/risk/RiskTypes'; const KEYBOARD_ROWS = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm', '1234567890']; const COMMON_BIGRAMS = new Set([ diff --git a/fluxer_api/src/api/risk/adapters/GeoIpAdapters.ts b/fluxer_api/src/api/risk/adapters/GeoIpAdapters.ts index 8fd13bb4b..b2b055f4a 100644 --- a/fluxer_api/src/api/risk/adapters/GeoIpAdapters.ts +++ b/fluxer_api/src/api/risk/adapters/GeoIpAdapters.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GeoIpAsnResult, GeoIpCityResult} from '@app/api/risk/RiskTypes'; import {parseIpAddress} from '@fluxer/ip_utils/src/IpAddress'; import type {GeoipAsnResult, GeoipResult} from '@pkgs/geoip/src/GeoipLookup'; import type {IpInfoService} from '@pkgs/geoip/src/IpInfoService'; -import type {GeoIpAsnResult, GeoIpCityResult} from '../RiskTypes'; interface GeoIpCityContext { ipInfoService: IpInfoService; diff --git a/fluxer_api/src/api/risk/adapters/HistoricalOutcomeAdapter.ts b/fluxer_api/src/api/risk/adapters/HistoricalOutcomeAdapter.ts index 63ee41ac2..01ac0bdc6 100644 --- a/fluxer_api/src/api/risk/adapters/HistoricalOutcomeAdapter.ts +++ b/fluxer_api/src/api/risk/adapters/HistoricalOutcomeAdapter.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IRiskHistoryRepository} from '@app/api/risk/HistoricalOutcomeRepository'; +import type {HistoricalOutcomeRecord} from '@app/api/risk/RiskHistoryTypes'; +import type {HistoricalOutcomeResult} from '@app/api/risk/RiskTypes'; import {getSubnet} from '@fluxer/ip_utils/src/IpAddress'; -import type {IRiskHistoryRepository} from '../HistoricalOutcomeRepository'; -import type {HistoricalOutcomeRecord} from '../RiskHistoryTypes'; -import type {HistoricalOutcomeResult} from '../RiskTypes'; const DEFAULT_LIST_LIMIT = 200; diff --git a/fluxer_api/src/api/risk/adapters/IpInfoAdapter.ts b/fluxer_api/src/api/risk/adapters/IpInfoAdapter.ts index 5db5e4576..3541f20a5 100644 --- a/fluxer_api/src/api/risk/adapters/IpInfoAdapter.ts +++ b/fluxer_api/src/api/risk/adapters/IpInfoAdapter.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isAccountPolicyEducationOrganizationName} from '@app/api/risk/AccountPolicyService'; +import type {IpInfoPrescreenVerdict} from '@app/api/risk/RegistrationIpPrescreen'; +import type {IpConnectionType, IpInfoAnonymousResult} from '@app/api/risk/RiskTypes'; import type {IpInfoService} from '@pkgs/geoip/src/IpInfoService'; -import {isAccountPolicyEducationOrganizationName} from '../AccountPolicyService'; -import type {IpInfoPrescreenVerdict} from '../RegistrationIpPrescreen'; -import type {IpConnectionType, IpInfoAnonymousResult} from '../RiskTypes'; interface IpInfoCheckerContext { ipInfoService: IpInfoService; diff --git a/fluxer_api/src/api/risk/adapters/LocaleGeoMatcher.ts b/fluxer_api/src/api/risk/adapters/LocaleGeoMatcher.ts index bcf4bee91..dae7504c3 100644 --- a/fluxer_api/src/api/risk/adapters/LocaleGeoMatcher.ts +++ b/fluxer_api/src/api/risk/adapters/LocaleGeoMatcher.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {LocaleGeoMatchResult} from '../RiskTypes'; +import type {LocaleGeoMatchResult} from '@app/api/risk/RiskTypes'; const LOCALE_TO_COUNTRIES: Record> = { 'en-us': ['US', 'PR', 'GU', 'VI', 'AS', 'MP'], diff --git a/fluxer_api/src/api/risk/adapters/RegistrationTimingAnalyzer.ts b/fluxer_api/src/api/risk/adapters/RegistrationTimingAnalyzer.ts index 6f056a7df..9e30e9047 100644 --- a/fluxer_api/src/api/risk/adapters/RegistrationTimingAnalyzer.ts +++ b/fluxer_api/src/api/risk/adapters/RegistrationTimingAnalyzer.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {RegistrationTimingResult} from '../RiskTypes'; +import type {RegistrationTimingResult} from '@app/api/risk/RiskTypes'; const TZ_OFFSETS: Record = { 'Pacific/Midway': -11, diff --git a/fluxer_api/src/api/risk/adapters/ReverseDnsAdapter.ts b/fluxer_api/src/api/risk/adapters/ReverseDnsAdapter.ts index 380f79936..eab880bbd 100644 --- a/fluxer_api/src/api/risk/adapters/ReverseDnsAdapter.ts +++ b/fluxer_api/src/api/risk/adapters/ReverseDnsAdapter.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {classifyAccountPolicyReverseDnsHostname} from '@app/api/risk/AccountPolicyService'; +import type {ReverseDnsResult} from '@app/api/risk/RiskTypes'; +import {getIpAddressReverse} from '@app/api/utils/IpUtils'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import {getIpAddressReverse} from '../../utils/IpUtils'; -import {classifyAccountPolicyReverseDnsHostname} from '../AccountPolicyService'; -import type {ReverseDnsResult} from '../RiskTypes'; interface ReverseDnsAdapterContext { cacheService?: ICacheService; diff --git a/fluxer_api/src/api/risk/adapters/UserAgentAnalyzer.ts b/fluxer_api/src/api/risk/adapters/UserAgentAnalyzer.ts index 5719c44d1..52264b938 100644 --- a/fluxer_api/src/api/risk/adapters/UserAgentAnalyzer.ts +++ b/fluxer_api/src/api/risk/adapters/UserAgentAnalyzer.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserAgentResult} from '../RiskTypes'; +import type {UserAgentResult} from '@app/api/risk/RiskTypes'; const BOT_PATTERNS: ReadonlyArray = [ /\bbot\b/i, diff --git a/fluxer_api/src/api/risk/adapters/VelocityAdapter.ts b/fluxer_api/src/api/risk/adapters/VelocityAdapter.ts index ea12a700e..394fc2a5d 100644 --- a/fluxer_api/src/api/risk/adapters/VelocityAdapter.ts +++ b/fluxer_api/src/api/risk/adapters/VelocityAdapter.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {VelocityResult} from '@app/api/risk/RiskTypes'; import {getSubnet} from '@fluxer/ip_utils/src/IpAddress'; -import type {VelocityResult} from '../RiskTypes'; export interface RegistrationEventRecord { userId: string; diff --git a/fluxer_api/src/api/rpc/InternalRpcController.ts b/fluxer_api/src/api/rpc/InternalRpcController.ts index c177ff7ba..48888c02e 100644 --- a/fluxer_api/src/api/rpc/InternalRpcController.ts +++ b/fluxer_api/src/api/rpc/InternalRpcController.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {timingSafeEqual} from 'node:crypto'; +import {Config} from '@app/api/Config'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {UnauthorizedError} from '@fluxer/errors/src/domains/core/UnauthorizedError'; import {RpcRequest} from '@fluxer/schema/src/domains/rpc/RpcSchemas'; -import {Config} from '../Config'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; const INTERNAL_RPC_AUTH_HEADER = 'x-fluxer-rpc-auth'; diff --git a/fluxer_api/src/api/rpc/RpcService.ts b/fluxer_api/src/api/rpc/RpcService.ts index 8ec7aca41..72ec89f66 100644 --- a/fluxer_api/src/api/rpc/RpcService.ts +++ b/fluxer_api/src/api/rpc/RpcService.ts @@ -1,6 +1,89 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import { + createChannelID, + createGuildID, + createMessageID, + createUserID, + userIdToChannelId, + vanityCodeToInviteCode, +} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {buildBroadcastMessageData} from '@app/api/channel/services/message/MessageGatewayDispatch'; +import {ensurePersonalNotesChannelExists} from '@app/api/channel/services/PersonalNotesChannelRepair'; +import {mapFavoriteMemeToResponse} from '@app/api/favorite_meme/FavoriteMemeModel'; +import type {IFavoriteMemeRepository} from '@app/api/favorite_meme/IFavoriteMemeRepository'; +import { + mapGuildEmojiToResponse, + mapGuildMemberToResponse, + mapGuildRoleToResponse, + mapGuildStickerToResponse, + mapGuildToGuildResponse, +} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ListParticipantsResult} from '@app/api/infrastructure/ILiveKitService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {PremiumStateReconciliationQueueService} from '@app/api/infrastructure/PremiumStateReconciliationQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {InstanceConfigRepository} from '@app/api/instance/InstanceConfigRepository'; +import type {IInviteRepository} from '@app/api/invite/IInviteRepository'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {AuthSession as AuthSessionModel} from '@app/api/models/AuthSession'; +import type {Channel} from '@app/api/models/Channel'; +import type {FavoriteMeme} from '@app/api/models/FavoriteMeme'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {GuildSticker} from '@app/api/models/GuildSticker'; +import type {ReadState} from '@app/api/models/ReadState'; +import type {Relationship} from '@app/api/models/Relationship'; +import type {User} from '@app/api/models/User'; +import type {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import {UserSettings} from '@app/api/models/UserSettings'; +import type {WebAuthnCredential} from '@app/api/models/WebAuthnCredential'; +import type {BotAuthService} from '@app/api/oauth/BotAuthService'; +import {sendApnsPush} from '@app/api/push/ApnsPushService'; +import {mapReadStateResponse} from '@app/api/read_state/ReadStateResponseMapper'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import {RpcSessionStartService} from '@app/api/rpc/RpcSessionStartService'; +import { + createRpcTimingNode, + RpcTimingRecorder, + type RpcTimingSteps, + startRpcTiming, + timeRpcStep, + timeRpcStepSync, +} from '@app/api/rpc/RpcTimings'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {PaymentRepository} from '@app/api/user/repositories/PaymentRepository'; +import {CustomStatusValidator} from '@app/api/user/services/CustomStatusValidator'; +import {getCachedUserPartialResponse} from '@app/api/user/UserCacheHelpers'; +import { + mapRelationshipToResponse, + mapUserGuildSettingsToResponse, + mapUserSettingsToResponse, + mapUserToPrivateResponse, +} from '@app/api/user/UserMappers'; +import {isUserAdult} from '@app/api/utils/AgeUtils'; +import {deriveDominantAvatarColor} from '@app/api/utils/AvatarColorUtils'; +import {calculateDistance, parseCoordinate} from '@app/api/utils/GeoUtils'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; +import type {VoiceAccessContext, VoiceAvailabilityService} from '@app/api/voice/VoiceAvailabilityService'; +import type {VoiceService} from '@app/api/voice/VoiceService'; +import type {IWebhookRepository} from '@app/api/webhook/IWebhookRepository'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import {AUTOMATIC_VOICE_REGION_ID, ChannelTypes, MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; import {MAX_PRIVATE_CHANNELS_PER_USER} from '@fluxer/constants/src/LimitConstants'; @@ -31,89 +114,6 @@ import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import {ms} from 'itty-time'; import sharp from 'sharp'; import {uint8ArrayToBase64} from 'uint8array-extras'; -import type {ApiContext} from '../ApiContext'; -import * as AuthSession from '../auth/AuthSession'; -import type {ChannelID, GuildID, UserID} from '../BrandedTypes'; -import { - createChannelID, - createGuildID, - createMessageID, - createUserID, - userIdToChannelId, - vanityCodeToInviteCode, -} from '../BrandedTypes'; -import {Config} from '../Config'; -import {mapChannelToResponse} from '../channel/ChannelMappers'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import {buildBroadcastMessageData} from '../channel/services/message/MessageGatewayDispatch'; -import {ensurePersonalNotesChannelExists} from '../channel/services/PersonalNotesChannelRepair'; -import {mapFavoriteMemeToResponse} from '../favorite_meme/FavoriteMemeModel'; -import type {IFavoriteMemeRepository} from '../favorite_meme/IFavoriteMemeRepository'; -import { - mapGuildEmojiToResponse, - mapGuildMemberToResponse, - mapGuildRoleToResponse, - mapGuildStickerToResponse, - mapGuildToGuildResponse, -} from '../guild/GuildModel'; -import type {IGuildRepositoryAggregate} from '../guild/repositories/IGuildRepositoryAggregate'; -import type {AvatarService} from '../infrastructure/AvatarService'; -import type {IDiscriminatorService} from '../infrastructure/DiscriminatorService'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {ListParticipantsResult} from '../infrastructure/ILiveKitService'; -import type {IStorageService} from '../infrastructure/IStorageService'; -import type {PremiumStateReconciliationQueueService} from '../infrastructure/PremiumStateReconciliationQueueService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {InstanceConfigRepository} from '../instance/InstanceConfigRepository'; -import type {IInviteRepository} from '../invite/IInviteRepository'; -import {Logger} from '../Logger'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import {resolveLimitSafe} from '../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {AuthSession as AuthSessionModel} from '../models/AuthSession'; -import type {Channel} from '../models/Channel'; -import type {FavoriteMeme} from '../models/FavoriteMeme'; -import type {Guild} from '../models/Guild'; -import type {GuildMember} from '../models/GuildMember'; -import type {GuildSticker} from '../models/GuildSticker'; -import type {ReadState} from '../models/ReadState'; -import type {Relationship} from '../models/Relationship'; -import type {User} from '../models/User'; -import type {UserGuildSettings} from '../models/UserGuildSettings'; -import {UserSettings} from '../models/UserSettings'; -import type {WebAuthnCredential} from '../models/WebAuthnCredential'; -import type {BotAuthService} from '../oauth/BotAuthService'; -import {sendApnsPush} from '../push/ApnsPushService'; -import {mapReadStateResponse} from '../read_state/ReadStateResponseMapper'; -import type {ReadStateService} from '../read_state/ReadStateService'; -import type {IUserRepository} from '../user/IUserRepository'; -import {PaymentRepository} from '../user/repositories/PaymentRepository'; -import {CustomStatusValidator} from '../user/services/CustomStatusValidator'; -import {getCachedUserPartialResponse} from '../user/UserCacheHelpers'; -import { - mapRelationshipToResponse, - mapUserGuildSettingsToResponse, - mapUserSettingsToResponse, - mapUserToPrivateResponse, -} from '../user/UserMappers'; -import {isUserAdult} from '../utils/AgeUtils'; -import {deriveDominantAvatarColor} from '../utils/AvatarColorUtils'; -import {calculateDistance, parseCoordinate} from '../utils/GeoUtils'; -import {lookupGeoip} from '../utils/IpUtils'; -import type {VoiceAccessContext, VoiceAvailabilityService} from '../voice/VoiceAvailabilityService'; -import type {VoiceService} from '../voice/VoiceService'; -import type {IWebhookRepository} from '../webhook/IWebhookRepository'; -import type {WorkerTaskName} from '../worker/WorkerLaneConfig'; -import {RpcSessionStartService} from './RpcSessionStartService'; -import { - createRpcTimingNode, - RpcTimingRecorder, - type RpcTimingSteps, - startRpcTiming, - timeRpcStep, - timeRpcStepSync, -} from './RpcTimings'; interface HandleRpcRequestParams { request: RpcRequest; diff --git a/fluxer_api/src/api/rpc/RpcSessionStartService.ts b/fluxer_api/src/api/rpc/RpcSessionStartService.ts index da4ac3787..98bf14069 100644 --- a/fluxer_api/src/api/rpc/RpcSessionStartService.ts +++ b/fluxer_api/src/api/rpc/RpcSessionStartService.ts @@ -1,5 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {mapGuildMemberToResponse} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; +import {countryRequiresInboundPhoneVerification} from '@app/api/risk/AbusePolicy'; +import { + createRpcTimingNode, + RpcTimingRecorder, + type RpcTimingSteps, + startRpcTiming, + timeRpcStep, + timeRpcStepSync, +} from '@app/api/rpc/RpcTimings'; +import type {UserData} from '@app/api/rpc/RpcTypes'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {PaymentRepository} from '@app/api/user/repositories/PaymentRepository'; +import {createPremiumClearPatch, shouldStripExpiredPremium} from '@app/api/user/UserHelpers'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; import { DEFERRED_PHONE_ON_COMMUNITY_JOIN, imposePhoneRequirements, @@ -8,30 +32,6 @@ import { UserFlags, } from '@fluxer/constants/src/UserConstants'; import type {RpcSessionTimings} from '@fluxer/schema/src/domains/rpc/RpcSchemas'; -import {Config} from '../Config'; -import type {UserRow} from '../database/types/UserTypes'; -import {mapGuildMemberToResponse} from '../guild/GuildModel'; -import type {IGuildRepositoryAggregate} from '../guild/repositories/IGuildRepositoryAggregate'; -import type {IDiscriminatorService} from '../infrastructure/DiscriminatorService'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import {Logger} from '../Logger'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {User} from '../models/User'; -import {countryRequiresInboundPhoneVerification} from '../risk/AbusePolicy'; -import type {IUserRepository} from '../user/IUserRepository'; -import type {PaymentRepository} from '../user/repositories/PaymentRepository'; -import {createPremiumClearPatch, shouldStripExpiredPremium} from '../user/UserHelpers'; -import {mapUserToPrivateResponse} from '../user/UserMappers'; -import { - createRpcTimingNode, - RpcTimingRecorder, - type RpcTimingSteps, - startRpcTiming, - timeRpcStep, - timeRpcStepSync, -} from './RpcTimings'; -import type {UserData} from './RpcTypes'; interface SessionStartUserRepository extends Pick< diff --git a/fluxer_api/src/api/rpc/RpcTypes.ts b/fluxer_api/src/api/rpc/RpcTypes.ts index b6370657f..c2e09986b 100644 --- a/fluxer_api/src/api/rpc/RpcTypes.ts +++ b/fluxer_api/src/api/rpc/RpcTypes.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, UserID} from '../BrandedTypes'; -import type {Channel} from '../models/Channel'; -import type {FavoriteMeme} from '../models/FavoriteMeme'; -import type {ReadState} from '../models/ReadState'; -import type {Relationship} from '../models/Relationship'; -import type {User} from '../models/User'; -import type {UserGuildSettings} from '../models/UserGuildSettings'; -import type {UserSettings} from '../models/UserSettings'; -import type {WebAuthnCredential} from '../models/WebAuthnCredential'; +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import type {Channel} from '@app/api/models/Channel'; +import type {FavoriteMeme} from '@app/api/models/FavoriteMeme'; +import type {ReadState} from '@app/api/models/ReadState'; +import type {Relationship} from '@app/api/models/Relationship'; +import type {User} from '@app/api/models/User'; +import type {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import type {UserSettings} from '@app/api/models/UserSettings'; +import type {WebAuthnCredential} from '@app/api/models/WebAuthnCredential'; export interface UserData { user: User; diff --git a/fluxer_api/src/api/rpc/tests/RpcGuildCollectionMembers.test.ts b/fluxer_api/src/api/rpc/tests/RpcGuildCollectionMembers.test.ts index 5a80f0d67..3e584fe45 100644 --- a/fluxer_api/src/api/rpc/tests/RpcGuildCollectionMembers.test.ts +++ b/fluxer_api/src/api/rpc/tests/RpcGuildCollectionMembers.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {setupTestGuildWithMembers} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_IDS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {RpcRequest} from '@fluxer/schema/src/domains/rpc/RpcSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {setupTestGuildWithMembers} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_IDS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface RpcGuildCollectionMembersResponse { type: 'guild_collection'; diff --git a/fluxer_api/src/api/rpc/tests/RpcGuildMemberCountRepair.test.ts b/fluxer_api/src/api/rpc/tests/RpcGuildMemberCountRepair.test.ts index 7bf67a1c3..e663bf3ff 100644 --- a/fluxer_api/src/api/rpc/tests/RpcGuildMemberCountRepair.test.ts +++ b/fluxer_api/src/api/rpc/tests/RpcGuildMemberCountRepair.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuildID} from '@app/api/BrandedTypes'; +import {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuildID} from '../../BrandedTypes'; -import {GuildRepository} from '../../guild/repositories/GuildRepository'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface RpcGuildCollectionResponse { type: 'guild_collection'; diff --git a/fluxer_api/src/api/rpc/tests/RpcSessionInitHarnessAccess.test.ts b/fluxer_api/src/api/rpc/tests/RpcSessionInitHarnessAccess.test.ts index 261769180..5e6979d92 100644 --- a/fluxer_api/src/api/rpc/tests/RpcSessionInitHarnessAccess.test.ts +++ b/fluxer_api/src/api/rpc/tests/RpcSessionInitHarnessAccess.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; const HARNESS_TOKEN = 'rpc-session-init-harness-token'; const TEST_AUTH_HEADER = 'x-test-token'; diff --git a/fluxer_api/src/api/rpc/tests/RpcSessionReadStates.test.ts b/fluxer_api/src/api/rpc/tests/RpcSessionReadStates.test.ts index 633c138dc..8c8fa28b7 100644 --- a/fluxer_api/src/api/rpc/tests/RpcSessionReadStates.test.ts +++ b/fluxer_api/src/api/rpc/tests/RpcSessionReadStates.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannel, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {sendMessage} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannel, createGuild} from '../../guild/tests/GuildTestUtils'; -import {sendMessage} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface RpcSessionResponse { type: 'session'; diff --git a/fluxer_api/src/api/rpc/tests/RpcSessionTimingsVisibility.test.ts b/fluxer_api/src/api/rpc/tests/RpcSessionTimingsVisibility.test.ts index 96afb5bd4..05feb3e40 100644 --- a/fluxer_api/src/api/rpc/tests/RpcSessionTimingsVisibility.test.ts +++ b/fluxer_api/src/api/rpc/tests/RpcSessionTimingsVisibility.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface RpcSessionResponse { type: 'session'; diff --git a/fluxer_api/src/api/rpc/tests/RpcTimings.test.ts b/fluxer_api/src/api/rpc/tests/RpcTimings.test.ts index 48b217772..6c337a2e0 100644 --- a/fluxer_api/src/api/rpc/tests/RpcTimings.test.ts +++ b/fluxer_api/src/api/rpc/tests/RpcTimings.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {RpcTimingRecorder} from '@app/api/rpc/RpcTimings'; import {afterEach, describe, expect, test} from 'vitest'; -import {RpcTimingRecorder} from '../RpcTimings'; const ORIGINAL_ENV = { POD_NAME: process.env.POD_NAME, diff --git a/fluxer_api/src/api/rpc/tests/RpcUserBatchFanout.test.ts b/fluxer_api/src/api/rpc/tests/RpcUserBatchFanout.test.ts index c46e65972..b5c0293c4 100644 --- a/fluxer_api/src/api/rpc/tests/RpcUserBatchFanout.test.ts +++ b/fluxer_api/src/api/rpc/tests/RpcUserBatchFanout.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {blockUser} from '@app/api/user/tests/RelationshipTestUtils'; import {UserNotificationSettings} from '@fluxer/constants/src/UserConstants'; import {RpcRequest} from '@fluxer/schema/src/domains/rpc/RpcSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {blockUser} from '../../user/tests/RelationshipTestUtils'; interface RpcUserGuildSettingsResponse { type: 'get_user_guild_settings'; diff --git a/fluxer_api/src/api/search/GlobalSearchService.ts b/fluxer_api/src/api/search/GlobalSearchService.ts index 0a2a60589..a6d34ea5c 100644 --- a/fluxer_api/src/api/search/GlobalSearchService.ts +++ b/fluxer_api/src/api/search/GlobalSearchService.ts @@ -1,5 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import { + type DmSearchScope, + getDmChannelIdsForScope, + isDmScopeChannelForUser, +} from '@app/api/channel/services/message/DmScopeUtils'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import {getMessageSearchService} from '@app/api/SearchFactory'; +import {buildMessageSearchFilters} from '@app/api/search/BuildMessageSearchFilters'; +import {channelNeedsReindexing} from '@app/api/search/ChannelIndexingUtils'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import {MessageSearchResponseMapper} from '@app/api/search/MessageSearchResponseMapper'; +import {searchExistingMessages} from '@app/api/search/MessageSearchResultReconciler'; +import {channelRequiresAgeVerification} from '@app/api/search/SearchNsfwUtils'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {canUserAccessNsfwContent} from '@app/api/utils/AgeUtils'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {GuildNSFWLevel} from '@fluxer/constants/src/GuildConstants'; import {FeatureTemporarilyDisabledError} from '@fluxer/errors/src/domains/core/FeatureTemporarilyDisabledError'; @@ -8,29 +31,6 @@ import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError import type {MessageSearchRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {MessageSearchResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import type {ChannelID, UserID} from '../BrandedTypes'; -import {createChannelID} from '../BrandedTypes'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import { - type DmSearchScope, - getDmChannelIdsForScope, - isDmScopeChannelForUser, -} from '../channel/services/message/DmScopeUtils'; -import type {GuildService} from '../guild/services/GuildService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Channel} from '../models/Channel'; -import {getMessageSearchService} from '../SearchFactory'; -import type {IUserRepository} from '../user/IUserRepository'; -import {canUserAccessNsfwContent} from '../utils/AgeUtils'; -import {mapWithConcurrency} from '../utils/ConcurrencyUtils'; -import type {WorkerTaskName} from '../worker/WorkerLaneConfig'; -import {buildMessageSearchFilters} from './BuildMessageSearchFilters'; -import {channelNeedsReindexing} from './ChannelIndexingUtils'; -import type {IMessageSearchService} from './IMessageSearchService'; -import {MessageSearchResponseMapper} from './MessageSearchResponseMapper'; -import {searchExistingMessages} from './MessageSearchResultReconciler'; -import {channelRequiresAgeVerification} from './SearchNsfwUtils'; const CHANNEL_INDEX_CHECK_CONCURRENCY = 32; const CHANNEL_INDEX_JOB_ENQUEUE_CONCURRENCY = 16; diff --git a/fluxer_api/src/api/search/IAuditLogSearchService.ts b/fluxer_api/src/api/search/IAuditLogSearchService.ts index 41bf8f1be..bab994161 100644 --- a/fluxer_api/src/api/search/IAuditLogSearchService.ts +++ b/fluxer_api/src/api/search/IAuditLogSearchService.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditLog} from '@app/api/admin/IAdminRepository'; import type { ISearchAdapter as SchemaISearchAdapter, SearchResult as SchemaSearchResult, } from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {AuditLogSearchFilters, SearchableAuditLog} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {AdminAuditLog} from '../admin/IAdminRepository'; export interface IAuditLogSearchService extends SchemaISearchAdapter { indexAuditLog(log: AdminAuditLog): Promise; diff --git a/fluxer_api/src/api/search/IGuildMemberSearchService.ts b/fluxer_api/src/api/search/IGuildMemberSearchService.ts index 997426da8..f36de8c7a 100644 --- a/fluxer_api/src/api/search/IGuildMemberSearchService.ts +++ b/fluxer_api/src/api/search/IGuildMemberSearchService.ts @@ -1,5 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {User} from '@app/api/models/User'; import type { ISearchAdapter as SchemaISearchAdapter, SearchResult as SchemaSearchResult, @@ -8,9 +11,6 @@ import type { GuildMemberSearchFilters, SearchableGuildMember, } from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {GuildID, UserID} from '../BrandedTypes'; -import type {GuildMember} from '../models/GuildMember'; -import type {User} from '../models/User'; export interface IGuildMemberSearchService extends SchemaISearchAdapter { diff --git a/fluxer_api/src/api/search/IGuildSearchService.ts b/fluxer_api/src/api/search/IGuildSearchService.ts index cdd2a8eec..86c1113d4 100644 --- a/fluxer_api/src/api/search/IGuildSearchService.ts +++ b/fluxer_api/src/api/search/IGuildSearchService.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID} from '@app/api/BrandedTypes'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildDiscoveryContext} from '@app/api/search/guild/GuildSearchSerializer'; import type { ISearchAdapter as SchemaISearchAdapter, SearchOptions as SchemaSearchOptions, SearchResult as SchemaSearchResult, } from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {GuildSearchFilters, SearchableGuild} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {GuildID} from '../BrandedTypes'; -import type {Guild} from '../models/Guild'; -import type {GuildDiscoveryContext} from './guild/GuildSearchSerializer'; export interface IGuildSearchService extends SchemaISearchAdapter { indexGuild(guild: Guild, discovery?: GuildDiscoveryContext): Promise; diff --git a/fluxer_api/src/api/search/IMessageSearchService.ts b/fluxer_api/src/api/search/IMessageSearchService.ts index 74bd7b7cb..a5138ff95 100644 --- a/fluxer_api/src/api/search/IMessageSearchService.ts +++ b/fluxer_api/src/api/search/IMessageSearchService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {Message} from '@app/api/models/Message'; import type { ISearchAdapter as SchemaISearchAdapter, SearchResult as SchemaSearchResult, } from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {MessageSearchFilters, SearchableMessage} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {ChannelID, GuildID, MessageID, UserID} from '../BrandedTypes'; -import type {Message} from '../models/Message'; export interface IMessageSearchService extends SchemaISearchAdapter { indexMessage(message: Message, authorIsBot?: boolean): Promise; diff --git a/fluxer_api/src/api/search/IReportSearchService.ts b/fluxer_api/src/api/search/IReportSearchService.ts index 4dad2e2af..85c818571 100644 --- a/fluxer_api/src/api/search/IReportSearchService.ts +++ b/fluxer_api/src/api/search/IReportSearchService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, MessageID, ReportID, UserID} from '@app/api/BrandedTypes'; +import type {IARSubmission} from '@app/api/report/IReportRepository'; import type { ISearchAdapter as SchemaISearchAdapter, SearchResult as SchemaSearchResult, } from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {ReportSearchFilters, SearchableReport} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {GuildID, MessageID, ReportID, UserID} from '../BrandedTypes'; -import type {IARSubmission} from '../report/IReportRepository'; export interface IReportSearchService extends SchemaISearchAdapter { indexReport(report: IARSubmission): Promise; diff --git a/fluxer_api/src/api/search/ISearchProvider.ts b/fluxer_api/src/api/search/ISearchProvider.ts index 9ca65a354..1065104e4 100644 --- a/fluxer_api/src/api/search/ISearchProvider.ts +++ b/fluxer_api/src/api/search/ISearchProvider.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IAuditLogSearchService} from './IAuditLogSearchService'; -import type {IGuildMemberSearchService} from './IGuildMemberSearchService'; -import type {IGuildSearchService} from './IGuildSearchService'; -import type {IMessageSearchService} from './IMessageSearchService'; -import type {IReportSearchService} from './IReportSearchService'; -import type {IUserSearchService} from './IUserSearchService'; +import type {IAuditLogSearchService} from '@app/api/search/IAuditLogSearchService'; +import type {IGuildMemberSearchService} from '@app/api/search/IGuildMemberSearchService'; +import type {IGuildSearchService} from '@app/api/search/IGuildSearchService'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import type {IReportSearchService} from '@app/api/search/IReportSearchService'; +import type {IUserSearchService} from '@app/api/search/IUserSearchService'; export interface ISearchProvider { initialize(): Promise; diff --git a/fluxer_api/src/api/search/IUserSearchService.ts b/fluxer_api/src/api/search/IUserSearchService.ts index eac403dab..a691517a6 100644 --- a/fluxer_api/src/api/search/IUserSearchService.ts +++ b/fluxer_api/src/api/search/IUserSearchService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {User} from '@app/api/models/User'; import type { ISearchAdapter as SchemaISearchAdapter, SearchResult as SchemaSearchResult, } from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {SearchableUser, UserSearchFilters} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {UserID} from '../BrandedTypes'; -import type {User} from '../models/User'; export interface IUserSearchService extends SchemaISearchAdapter { indexUser(user: User): Promise; diff --git a/fluxer_api/src/api/search/MessageSearchIndexCleanup.ts b/fluxer_api/src/api/search/MessageSearchIndexCleanup.ts index 8e4784890..1b852386f 100644 --- a/fluxer_api/src/api/search/MessageSearchIndexCleanup.ts +++ b/fluxer_api/src/api/search/MessageSearchIndexCleanup.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {type ChannelID, createMessageID, type MessageID} from '../BrandedTypes'; -import {Logger} from '../Logger'; -import {getMessageSearchService} from '../SearchFactory'; -import type {IMessageSearchService} from './IMessageSearchService'; +import {type ChannelID, createMessageID, type MessageID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import {getMessageSearchService} from '@app/api/SearchFactory'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; const MESSAGE_DELETE_BATCH_SIZE = 1000; diff --git a/fluxer_api/src/api/search/MessageSearchResponseMapper.ts b/fluxer_api/src/api/search/MessageSearchResponseMapper.ts index 0f2525e4b..b543e0b53 100644 --- a/fluxer_api/src/api/search/MessageSearchResponseMapper.ts +++ b/fluxer_api/src/api/search/MessageSearchResponseMapper.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {createChannelID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import {createMessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; import type {MessageSearchResultsResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import type {UserID} from '../BrandedTypes'; -import {createChannelID} from '../BrandedTypes'; -import {mapChannelToResponse} from '../channel/ChannelMappers'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import {createMessageResponseDataService} from '../channel/services/message/MessageResponseDataService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Channel} from '../models/Channel'; -import type {Message} from '../models/Message'; -import {mapWithConcurrency} from '../utils/ConcurrencyUtils'; const CHANNEL_LOOKUP_CONCURRENCY = 16; diff --git a/fluxer_api/src/api/search/MessageSearchResultReconciler.ts b/fluxer_api/src/api/search/MessageSearchResultReconciler.ts index 8ab6b77ed..287ad8adb 100644 --- a/fluxer_api/src/api/search/MessageSearchResultReconciler.ts +++ b/fluxer_api/src/api/search/MessageSearchResultReconciler.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createChannelID, createMessageID, type MessageID} from '@app/api/BrandedTypes'; +import type {IMessageRepository} from '@app/api/channel/repositories/IMessageRepository'; +import {Logger} from '@app/api/Logger'; +import type {Message} from '@app/api/models/Message'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import {deleteMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; import type {SearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {MessageSearchFilters, SearchableMessage} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import {type ChannelID, createChannelID, createMessageID, type MessageID} from '../BrandedTypes'; -import type {IMessageRepository} from '../channel/repositories/IMessageRepository'; -import {Logger} from '../Logger'; -import type {Message} from '../models/Message'; -import {mapWithConcurrency} from '../utils/ConcurrencyUtils'; -import type {IMessageSearchService} from './IMessageSearchService'; -import {deleteMessageSearchDocuments} from './MessageSearchIndexCleanup'; const RECONCILE_BATCH_SIZE = 250; const MAX_RECONCILE_PAGES = 40; diff --git a/fluxer_api/src/api/search/SearchAdapterServiceBase.ts b/fluxer_api/src/api/search/SearchAdapterServiceBase.ts index cc21742f9..10ed43dcc 100644 --- a/fluxer_api/src/api/search/SearchAdapterServiceBase.ts +++ b/fluxer_api/src/api/search/SearchAdapterServiceBase.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {trackSearchTask} from '@app/api/search/SearchTaskTracker'; import type {ISearchAdapter, SearchOptions, SearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; -import {trackSearchTask} from './SearchTaskTracker'; export abstract class SearchAdapterServiceBase< TFilters, diff --git a/fluxer_api/src/api/search/SearchNsfwUtils.ts b/fluxer_api/src/api/search/SearchNsfwUtils.ts index e952ff6fb..4a8a0d458 100644 --- a/fluxer_api/src/api/search/SearchNsfwUtils.ts +++ b/fluxer_api/src/api/search/SearchNsfwUtils.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {channelToContentWarningView, computeEffectiveChannelNsfw} from '@app/api/channel/utils/EffectiveContentWarning'; +import type {Channel} from '@app/api/models/Channel'; import {ContentWarningLevel} from '@fluxer/constants/src/GuildConstants'; -import {channelToContentWarningView, computeEffectiveChannelNsfw} from '../channel/utils/EffectiveContentWarning'; -import type {Channel} from '../models/Channel'; export function channelRequiresAgeVerification( channel: Channel, diff --git a/fluxer_api/src/api/search/SearchService.ts b/fluxer_api/src/api/search/SearchService.ts index f8a53e700..d30662d87 100644 --- a/fluxer_api/src/api/search/SearchService.ts +++ b/fluxer_api/src/api/search/SearchService.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createGuildID, type UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {GlobalSearchService} from '@app/api/search/GlobalSearchService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {GlobalSearchMessagesRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {MessageResponse, MessageSearchResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import {createChannelID, createGuildID, type UserID} from '../BrandedTypes'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import type {ChannelService} from '../channel/services/ChannelService'; -import type {GuildService} from '../guild/services/GuildService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {IUserRepository} from '../user/IUserRepository'; -import type {WorkerTaskName} from '../worker/WorkerLaneConfig'; -import {GlobalSearchService} from './GlobalSearchService'; function omitReferencedMessages(result: MessageSearchResponse): MessageSearchResponse { if (!('messages' in result)) { diff --git a/fluxer_api/src/api/search/SearchWarmup.ts b/fluxer_api/src/api/search/SearchWarmup.ts index 24e305193..2d646858a 100644 --- a/fluxer_api/src/api/search/SearchWarmup.ts +++ b/fluxer_api/src/api/search/SearchWarmup.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, ReportID} from '../BrandedTypes'; -import type {IGuildDataRepository} from '../guild/repositories/IGuildDataRepository'; -import type {ILogger} from '../ILogger'; -import type {IReportRepository} from '../report/IReportRepository'; +import type {GuildID, ReportID} from '@app/api/BrandedTypes'; +import type {IGuildDataRepository} from '@app/api/guild/repositories/IGuildDataRepository'; +import type {ILogger} from '@app/api/ILogger'; +import type {IReportRepository} from '@app/api/report/IReportRepository'; import { getAuditLogSearchService, getGuildSearchService, getReportSearchService, getUserSearchService, -} from '../SearchFactory'; -import type {IUserRepository} from '../user/IUserRepository'; -import type {IGuildSearchService} from './IGuildSearchService'; -import type {IReportSearchService} from './IReportSearchService'; -import type {IUserSearchService} from './IUserSearchService'; +} from '@app/api/SearchFactory'; +import type {IGuildSearchService} from '@app/api/search/IGuildSearchService'; +import type {IReportSearchService} from '@app/api/search/IReportSearchService'; +import type {IUserSearchService} from '@app/api/search/IUserSearchService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; const BATCH_SIZE = 100; diff --git a/fluxer_api/src/api/search/auditlog/AuditLogSearchSerializer.ts b/fluxer_api/src/api/search/auditlog/AuditLogSearchSerializer.ts index 841aaf28a..8c2da9177 100644 --- a/fluxer_api/src/api/search/auditlog/AuditLogSearchSerializer.ts +++ b/fluxer_api/src/api/search/auditlog/AuditLogSearchSerializer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditLog} from '@app/api/admin/IAdminRepository'; import type {SearchableAuditLog} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import type {AdminAuditLog} from '../../admin/IAdminRepository'; export function convertToSearchableAuditLog(log: AdminAuditLog): SearchableAuditLog { const createdAt = Math.floor(snowflakeToDate(BigInt(log.logId)).getTime() / 1000); diff --git a/fluxer_api/src/api/search/controllers/SearchController.ts b/fluxer_api/src/api/search/controllers/SearchController.ts index 2f8c8b48c..f423fc23d 100644 --- a/fluxer_api/src/api/search/controllers/SearchController.ts +++ b/fluxer_api/src/api/search/controllers/SearchController.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {GlobalSearchMessagesRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import {MessageSearchResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function SearchController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/search/elasticsearch/ElasticsearchAuditLogSearchService.ts b/fluxer_api/src/api/search/elasticsearch/ElasticsearchAuditLogSearchService.ts index ce7f72b5d..4ee009611 100644 --- a/fluxer_api/src/api/search/elasticsearch/ElasticsearchAuditLogSearchService.ts +++ b/fluxer_api/src/api/search/elasticsearch/ElasticsearchAuditLogSearchService.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditLog} from '@app/api/admin/IAdminRepository'; +import {convertToSearchableAuditLog} from '@app/api/search/auditlog/AuditLogSearchSerializer'; +import type {IAuditLogSearchService} from '@app/api/search/IAuditLogSearchService'; +import {SearchAdapterServiceBase} from '@app/api/search/SearchAdapterServiceBase'; import type {SearchResult as SchemaSearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {AuditLogSearchFilters, SearchableAuditLog} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import { ElasticsearchAuditLogAdapter, type ElasticsearchAuditLogAdapterOptions, } from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchAuditLogAdapter'; -import type {AdminAuditLog} from '../../admin/IAdminRepository'; -import {convertToSearchableAuditLog} from '../auditlog/AuditLogSearchSerializer'; -import type {IAuditLogSearchService} from '../IAuditLogSearchService'; -import {SearchAdapterServiceBase} from '../SearchAdapterServiceBase'; interface ElasticsearchAuditLogSearchServiceOptions extends ElasticsearchAuditLogAdapterOptions {} diff --git a/fluxer_api/src/api/search/elasticsearch/ElasticsearchGuildMemberSearchService.ts b/fluxer_api/src/api/search/elasticsearch/ElasticsearchGuildMemberSearchService.ts index 8ef2a880b..0c5c04381 100644 --- a/fluxer_api/src/api/search/elasticsearch/ElasticsearchGuildMemberSearchService.ts +++ b/fluxer_api/src/api/search/elasticsearch/ElasticsearchGuildMemberSearchService.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {User} from '@app/api/models/User'; +import {convertToSearchableGuildMember} from '@app/api/search/guild_member/GuildMemberSearchSerializer'; +import type {IGuildMemberSearchService} from '@app/api/search/IGuildMemberSearchService'; +import {SearchAdapterServiceBase} from '@app/api/search/SearchAdapterServiceBase'; import type {SearchResult as SchemaSearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type { GuildMemberSearchFilters, @@ -9,12 +15,6 @@ import { ElasticsearchGuildMemberAdapter, type ElasticsearchGuildMemberAdapterOptions, } from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchGuildMemberAdapter'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {GuildMember} from '../../models/GuildMember'; -import type {User} from '../../models/User'; -import {convertToSearchableGuildMember} from '../guild_member/GuildMemberSearchSerializer'; -import type {IGuildMemberSearchService} from '../IGuildMemberSearchService'; -import {SearchAdapterServiceBase} from '../SearchAdapterServiceBase'; const DEFAULT_LIMIT = 25; diff --git a/fluxer_api/src/api/search/elasticsearch/ElasticsearchGuildSearchService.ts b/fluxer_api/src/api/search/elasticsearch/ElasticsearchGuildSearchService.ts index 2aaa85730..e27582017 100644 --- a/fluxer_api/src/api/search/elasticsearch/ElasticsearchGuildSearchService.ts +++ b/fluxer_api/src/api/search/elasticsearch/ElasticsearchGuildSearchService.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID} from '@app/api/BrandedTypes'; +import type {IGuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import type {Guild} from '@app/api/models/Guild'; +import {convertToSearchableGuild, type GuildDiscoveryContext} from '@app/api/search/guild/GuildSearchSerializer'; +import {resolveDiscoveryContextForIndexing} from '@app/api/search/guild/LazyDiscoveryMigration'; +import type {IGuildSearchService} from '@app/api/search/IGuildSearchService'; +import {SearchAdapterServiceBase} from '@app/api/search/SearchAdapterServiceBase'; import type { SearchOptions as SchemaSearchOptions, SearchResult as SchemaSearchResult, @@ -9,13 +16,6 @@ import { ElasticsearchGuildAdapter, type ElasticsearchGuildAdapterOptions, } from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchGuildAdapter'; -import type {GuildID} from '../../BrandedTypes'; -import type {IGuildDiscoveryRepository} from '../../guild/repositories/GuildDiscoveryRepository'; -import type {Guild} from '../../models/Guild'; -import {convertToSearchableGuild, type GuildDiscoveryContext} from '../guild/GuildSearchSerializer'; -import {resolveDiscoveryContextForIndexing} from '../guild/LazyDiscoveryMigration'; -import type {IGuildSearchService} from '../IGuildSearchService'; -import {SearchAdapterServiceBase} from '../SearchAdapterServiceBase'; interface ElasticsearchGuildSearchServiceOptions extends ElasticsearchGuildAdapterOptions { discoveryRepository?: IGuildDiscoveryRepository; diff --git a/fluxer_api/src/api/search/elasticsearch/ElasticsearchMessageSearchService.ts b/fluxer_api/src/api/search/elasticsearch/ElasticsearchMessageSearchService.ts index a66a00a7c..bccfc654e 100644 --- a/fluxer_api/src/api/search/elasticsearch/ElasticsearchMessageSearchService.ts +++ b/fluxer_api/src/api/search/elasticsearch/ElasticsearchMessageSearchService.ts @@ -1,16 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {Message} from '@app/api/models/Message'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import { + convertMessagesToSearchableMessages, + convertToSearchableMessage, +} from '@app/api/search/message/MessageSearchSerializer'; +import {SearchAdapterServiceBase} from '@app/api/search/SearchAdapterServiceBase'; import type {SearchResult as SchemaSearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {MessageSearchFilters, SearchableMessage} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import { ElasticsearchMessageAdapter, type ElasticsearchMessageAdapterOptions, } from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchMessageAdapter'; -import type {ChannelID, GuildID, MessageID, UserID} from '../../BrandedTypes'; -import type {Message} from '../../models/Message'; -import type {IMessageSearchService} from '../IMessageSearchService'; -import {convertMessagesToSearchableMessages, convertToSearchableMessage} from '../message/MessageSearchSerializer'; -import {SearchAdapterServiceBase} from '../SearchAdapterServiceBase'; const DEFAULT_HITS_PER_PAGE = 25; diff --git a/fluxer_api/src/api/search/elasticsearch/ElasticsearchReportSearchService.ts b/fluxer_api/src/api/search/elasticsearch/ElasticsearchReportSearchService.ts index 5106fc6c6..eda9a2724 100644 --- a/fluxer_api/src/api/search/elasticsearch/ElasticsearchReportSearchService.ts +++ b/fluxer_api/src/api/search/elasticsearch/ElasticsearchReportSearchService.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, MessageID, ReportID, UserID} from '@app/api/BrandedTypes'; +import type {IARSubmission} from '@app/api/report/IReportRepository'; +import type {IReportSearchService} from '@app/api/search/IReportSearchService'; +import {convertToSearchableReport} from '@app/api/search/report/ReportSearchSerializer'; +import {SearchAdapterServiceBase} from '@app/api/search/SearchAdapterServiceBase'; import type {SearchResult as SchemaSearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {ReportSearchFilters, SearchableReport} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import { ElasticsearchReportAdapter, type ElasticsearchReportAdapterOptions, } from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchReportAdapter'; -import type {GuildID, MessageID, ReportID, UserID} from '../../BrandedTypes'; -import type {IARSubmission} from '../../report/IReportRepository'; -import type {IReportSearchService} from '../IReportSearchService'; -import {convertToSearchableReport} from '../report/ReportSearchSerializer'; -import {SearchAdapterServiceBase} from '../SearchAdapterServiceBase'; interface ElasticsearchReportSearchServiceOptions extends ElasticsearchReportAdapterOptions {} diff --git a/fluxer_api/src/api/search/elasticsearch/ElasticsearchUserSearchService.ts b/fluxer_api/src/api/search/elasticsearch/ElasticsearchUserSearchService.ts index 863e6380d..e1634150e 100644 --- a/fluxer_api/src/api/search/elasticsearch/ElasticsearchUserSearchService.ts +++ b/fluxer_api/src/api/search/elasticsearch/ElasticsearchUserSearchService.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {User} from '@app/api/models/User'; +import type {IUserSearchService} from '@app/api/search/IUserSearchService'; +import {SearchAdapterServiceBase} from '@app/api/search/SearchAdapterServiceBase'; +import {convertToSearchableUser} from '@app/api/search/user/UserSearchSerializer'; import type {SearchResult as SchemaSearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type {SearchableUser, UserSearchFilters} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import { ElasticsearchUserAdapter, type ElasticsearchUserAdapterOptions, } from '@pkgs/elasticsearch_search/src/adapters/ElasticsearchUserAdapter'; -import type {UserID} from '../../BrandedTypes'; -import type {User} from '../../models/User'; -import type {IUserSearchService} from '../IUserSearchService'; -import {SearchAdapterServiceBase} from '../SearchAdapterServiceBase'; -import {convertToSearchableUser} from '../user/UserSearchSerializer'; interface ElasticsearchUserSearchServiceOptions extends ElasticsearchUserAdapterOptions {} diff --git a/fluxer_api/src/api/search/guild/GuildSearchSerializer.ts b/fluxer_api/src/api/search/guild/GuildSearchSerializer.ts index b2e137a54..fc6898ceb 100644 --- a/fluxer_api/src/api/search/guild/GuildSearchSerializer.ts +++ b/fluxer_api/src/api/search/guild/GuildSearchSerializer.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {Guild} from '@app/api/models/Guild'; import {normalizeDiscoveryTag} from '@fluxer/constants/src/DiscoveryConstants'; import {GuildFeatures, getEffectiveGuildVerificationLevel} from '@fluxer/constants/src/GuildConstants'; import type {SearchableGuild} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import type {Guild} from '../../models/Guild'; export interface GuildDiscoveryContext { description: string | null; diff --git a/fluxer_api/src/api/search/guild/LazyDiscoveryMigration.ts b/fluxer_api/src/api/search/guild/LazyDiscoveryMigration.ts index fb11262d7..6534bf494 100644 --- a/fluxer_api/src/api/search/guild/LazyDiscoveryMigration.ts +++ b/fluxer_api/src/api/search/guild/LazyDiscoveryMigration.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IGuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildDiscoveryContext} from '@app/api/search/guild/GuildSearchSerializer'; import {DiscoveryApplicationStatus} from '@fluxer/constants/src/DiscoveryConstants'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; -import type {IGuildDiscoveryRepository} from '../../guild/repositories/GuildDiscoveryRepository'; -import type {Guild} from '../../models/Guild'; -import type {GuildDiscoveryContext} from './GuildSearchSerializer'; export async function resolveDiscoveryContextForIndexing( guild: Guild, diff --git a/fluxer_api/src/api/search/guild/tests/GuildSearchSerializer.test.ts b/fluxer_api/src/api/search/guild/tests/GuildSearchSerializer.test.ts index d473cb0ab..44ff70ba2 100644 --- a/fluxer_api/src/api/search/guild/tests/GuildSearchSerializer.test.ts +++ b/fluxer_api/src/api/search/guild/tests/GuildSearchSerializer.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createGuildID, createUserID} from '@app/api/BrandedTypes'; +import type {GuildRow} from '@app/api/database/types/GuildTypes'; +import {Guild} from '@app/api/models/Guild'; +import {convertToSearchableGuild} from '@app/api/search/guild/GuildSearchSerializer'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import {describe, expect, it} from 'vitest'; -import {createChannelID, createGuildID, createUserID} from '../../../BrandedTypes'; -import type {GuildRow} from '../../../database/types/GuildTypes'; -import {Guild} from '../../../models/Guild'; -import {convertToSearchableGuild} from '../GuildSearchSerializer'; function guildRow(features: Set): GuildRow { return { diff --git a/fluxer_api/src/api/search/guild_member/GuildMemberSearchSerializer.ts b/fluxer_api/src/api/search/guild_member/GuildMemberSearchSerializer.ts index 5afa8b479..a35d4af5c 100644 --- a/fluxer_api/src/api/search/guild_member/GuildMemberSearchSerializer.ts +++ b/fluxer_api/src/api/search/guild_member/GuildMemberSearchSerializer.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {User} from '@app/api/models/User'; import type {SearchableGuildMember} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import {extractTimestampFromSnowflake} from '@fluxer/snowflake/src/SnowflakeUtils'; -import type {GuildMember} from '../../models/GuildMember'; -import type {User} from '../../models/User'; const MIN_USERNAME_SUFFIX_LENGTH = 2; diff --git a/fluxer_api/src/api/search/meilisearch/MeilisearchDomainAdapters.ts b/fluxer_api/src/api/search/meilisearch/MeilisearchDomainAdapters.ts index 6f607896e..2fd35cbea 100644 --- a/fluxer_api/src/api/search/meilisearch/MeilisearchDomainAdapters.ts +++ b/fluxer_api/src/api/search/meilisearch/MeilisearchDomainAdapters.ts @@ -1,5 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {MeilisearchClient} from '@app/api/search/meilisearch/MeilisearchClient'; +import { + compactMeiliFilters, + type MeilisearchFilter, + meiliAndTerms, + meiliExcludeAny, + meiliExistsFilter, + meiliNotExistsFilter, + meiliRangeFilter, + meiliTermFilter, + meiliTermsFilter, +} from '@app/api/search/meilisearch/MeilisearchFilterUtils'; +import {MeilisearchIndexAdapter} from '@app/api/search/meilisearch/MeilisearchIndexAdapter'; +import {MEILISEARCH_INDEX_DEFINITIONS} from '@app/api/search/meilisearch/MeilisearchIndexDefinitions'; import type { AuditLogSearchFilters, GuildMemberSearchFilters, @@ -15,20 +29,6 @@ import type { UserSearchFilters, } from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import type {MeilisearchClient} from './MeilisearchClient'; -import { - compactMeiliFilters, - type MeilisearchFilter, - meiliAndTerms, - meiliExcludeAny, - meiliExistsFilter, - meiliNotExistsFilter, - meiliRangeFilter, - meiliTermFilter, - meiliTermsFilter, -} from './MeilisearchFilterUtils'; -import {MeilisearchIndexAdapter} from './MeilisearchIndexAdapter'; -import {MEILISEARCH_INDEX_DEFINITIONS} from './MeilisearchIndexDefinitions'; const HAS_FIELD_MAP: Record = { image: 'hasImage', diff --git a/fluxer_api/src/api/search/meilisearch/MeilisearchIndexAdapter.test.ts b/fluxer_api/src/api/search/meilisearch/MeilisearchIndexAdapter.test.ts index 1acb8895b..1383506bf 100644 --- a/fluxer_api/src/api/search/meilisearch/MeilisearchIndexAdapter.test.ts +++ b/fluxer_api/src/api/search/meilisearch/MeilisearchIndexAdapter.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {MeilisearchClient, MeilisearchTask} from '@app/api/search/meilisearch/MeilisearchClient'; +import {MeilisearchMessageAdapter} from '@app/api/search/meilisearch/MeilisearchDomainAdapters'; +import {MEILISEARCH_MAX_TRACKED_BULK_TASKS} from '@app/api/search/meilisearch/MeilisearchIndexAdapter'; import type {SearchableMessage} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import {describe, expect, it} from 'vitest'; -import type {MeilisearchClient, MeilisearchTask} from './MeilisearchClient'; -import {MeilisearchMessageAdapter} from './MeilisearchDomainAdapters'; -import {MEILISEARCH_MAX_TRACKED_BULK_TASKS} from './MeilisearchIndexAdapter'; interface RecordedMeilisearchRequest { method: string; diff --git a/fluxer_api/src/api/search/meilisearch/MeilisearchIndexAdapter.ts b/fluxer_api/src/api/search/meilisearch/MeilisearchIndexAdapter.ts index 0293d2391..04f948d3f 100644 --- a/fluxer_api/src/api/search/meilisearch/MeilisearchIndexAdapter.ts +++ b/fluxer_api/src/api/search/meilisearch/MeilisearchIndexAdapter.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {MeilisearchClient, MeilisearchTask} from '@app/api/search/meilisearch/MeilisearchClient'; +import type {MeilisearchFilter} from '@app/api/search/meilisearch/MeilisearchFilterUtils'; +import {joinMeiliFilters} from '@app/api/search/meilisearch/MeilisearchFilterUtils'; +import type {MeilisearchIndexDefinition} from '@app/api/search/meilisearch/MeilisearchIndexDefinitions'; import type {SearchOptions, SearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; -import type {MeilisearchClient, MeilisearchTask} from './MeilisearchClient'; -import type {MeilisearchFilter} from './MeilisearchFilterUtils'; -import {joinMeiliFilters} from './MeilisearchFilterUtils'; -import type {MeilisearchIndexDefinition} from './MeilisearchIndexDefinitions'; const MAX_SEARCH_LIMIT = 1000; const MAX_TOTAL_HITS = 10000; diff --git a/fluxer_api/src/api/search/meilisearch/MeilisearchSearchServices.ts b/fluxer_api/src/api/search/meilisearch/MeilisearchSearchServices.ts index d42d8d65c..ba03922bf 100644 --- a/fluxer_api/src/api/search/meilisearch/MeilisearchSearchServices.ts +++ b/fluxer_api/src/api/search/meilisearch/MeilisearchSearchServices.ts @@ -1,5 +1,40 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditLog} from '@app/api/admin/IAdminRepository'; +import type {ChannelID, GuildID, MessageID, ReportID, UserID} from '@app/api/BrandedTypes'; +import type {IGuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {Message} from '@app/api/models/Message'; +import type {User} from '@app/api/models/User'; +import type {IARSubmission} from '@app/api/report/IReportRepository'; +import {convertToSearchableAuditLog} from '@app/api/search/auditlog/AuditLogSearchSerializer'; +import {convertToSearchableGuild, type GuildDiscoveryContext} from '@app/api/search/guild/GuildSearchSerializer'; +import {resolveDiscoveryContextForIndexing} from '@app/api/search/guild/LazyDiscoveryMigration'; +import {convertToSearchableGuildMember} from '@app/api/search/guild_member/GuildMemberSearchSerializer'; +import type {IAuditLogSearchService} from '@app/api/search/IAuditLogSearchService'; +import type {IGuildMemberSearchService} from '@app/api/search/IGuildMemberSearchService'; +import type {IGuildSearchService} from '@app/api/search/IGuildSearchService'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import type {IReportSearchService} from '@app/api/search/IReportSearchService'; +import type {IUserSearchService} from '@app/api/search/IUserSearchService'; +import type {MeilisearchClient} from '@app/api/search/meilisearch/MeilisearchClient'; +import { + MeilisearchAuditLogAdapter, + MeilisearchGuildAdapter, + MeilisearchGuildMemberAdapter, + MeilisearchMessageAdapter, + MeilisearchReportAdapter, + MeilisearchUserAdapter, +} from '@app/api/search/meilisearch/MeilisearchDomainAdapters'; +import {meiliTermFilter} from '@app/api/search/meilisearch/MeilisearchFilterUtils'; +import { + convertMessagesToSearchableMessages, + convertToSearchableMessage, +} from '@app/api/search/message/MessageSearchSerializer'; +import {convertToSearchableReport} from '@app/api/search/report/ReportSearchSerializer'; +import {SearchAdapterServiceBase} from '@app/api/search/SearchAdapterServiceBase'; +import {convertToSearchableUser} from '@app/api/search/user/UserSearchSerializer'; import type { SearchOptions as SchemaSearchOptions, SearchResult as SchemaSearchResult, @@ -18,38 +53,6 @@ import type { SearchableUser, UserSearchFilters, } from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {AdminAuditLog} from '../../admin/IAdminRepository'; -import type {ChannelID, GuildID, MessageID, ReportID, UserID} from '../../BrandedTypes'; -import type {IGuildDiscoveryRepository} from '../../guild/repositories/GuildDiscoveryRepository'; -import type {Guild} from '../../models/Guild'; -import type {GuildMember} from '../../models/GuildMember'; -import type {Message} from '../../models/Message'; -import type {User} from '../../models/User'; -import type {IARSubmission} from '../../report/IReportRepository'; -import {convertToSearchableAuditLog} from '../auditlog/AuditLogSearchSerializer'; -import {convertToSearchableGuild, type GuildDiscoveryContext} from '../guild/GuildSearchSerializer'; -import {resolveDiscoveryContextForIndexing} from '../guild/LazyDiscoveryMigration'; -import {convertToSearchableGuildMember} from '../guild_member/GuildMemberSearchSerializer'; -import type {IAuditLogSearchService} from '../IAuditLogSearchService'; -import type {IGuildMemberSearchService} from '../IGuildMemberSearchService'; -import type {IGuildSearchService} from '../IGuildSearchService'; -import type {IMessageSearchService} from '../IMessageSearchService'; -import type {IReportSearchService} from '../IReportSearchService'; -import type {IUserSearchService} from '../IUserSearchService'; -import {convertMessagesToSearchableMessages, convertToSearchableMessage} from '../message/MessageSearchSerializer'; -import {convertToSearchableReport} from '../report/ReportSearchSerializer'; -import {SearchAdapterServiceBase} from '../SearchAdapterServiceBase'; -import {convertToSearchableUser} from '../user/UserSearchSerializer'; -import type {MeilisearchClient} from './MeilisearchClient'; -import { - MeilisearchAuditLogAdapter, - MeilisearchGuildAdapter, - MeilisearchGuildMemberAdapter, - MeilisearchMessageAdapter, - MeilisearchReportAdapter, - MeilisearchUserAdapter, -} from './MeilisearchDomainAdapters'; -import {meiliTermFilter} from './MeilisearchFilterUtils'; const DEFAULT_HITS_PER_PAGE = 25; const DEFAULT_MEMBER_LIMIT = 25; diff --git a/fluxer_api/src/api/search/message/MessageSearchSerializer.ts b/fluxer_api/src/api/search/message/MessageSearchSerializer.ts index ac2b4c6f0..d92bab3bc 100644 --- a/fluxer_api/src/api/search/message/MessageSearchSerializer.ts +++ b/fluxer_api/src/api/search/message/MessageSearchSerializer.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {Attachment} from '@app/api/models/Attachment'; +import type {Embed} from '@app/api/models/Embed'; +import type {Message} from '@app/api/models/Message'; +import type {MessageSnapshot} from '@app/api/models/MessageSnapshot'; import type {SearchableMessage} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import type {UserID} from '../../BrandedTypes'; -import type {Attachment} from '../../models/Attachment'; -import type {Embed} from '../../models/Embed'; -import type {Message} from '../../models/Message'; -import type {MessageSnapshot} from '../../models/MessageSnapshot'; const LINK_URL_MATCHER = /https?:\/\/[^\s<>"']+/gi; const HAS_LINK_REGEX = /https?:\/\/[^\s/]+/i; diff --git a/fluxer_api/src/api/search/message/tests/MessageSearchSerializer.test.ts b/fluxer_api/src/api/search/message/tests/MessageSearchSerializer.test.ts index 2898efef4..389a5616d 100644 --- a/fluxer_api/src/api/search/message/tests/MessageSearchSerializer.test.ts +++ b/fluxer_api/src/api/search/message/tests/MessageSearchSerializer.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAttachmentID, createChannelID, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import type {MessageRow} from '@app/api/database/types/MessageTypes'; +import {Message} from '@app/api/models/Message'; +import {convertToSearchableMessage} from '@app/api/search/message/MessageSearchSerializer'; import {describe, expect, it} from 'vitest'; -import {createAttachmentID, createChannelID, createMessageID, createUserID} from '../../../BrandedTypes'; -import type {MessageRow} from '../../../database/types/MessageTypes'; -import {Message} from '../../../models/Message'; -import {convertToSearchableMessage} from '../MessageSearchSerializer'; describe('MessageSearchSerializer', () => { it('extracts unique hosts and attachment metadata when indexing a message', () => { diff --git a/fluxer_api/src/api/search/report/ReportSearchSerializer.ts b/fluxer_api/src/api/search/report/ReportSearchSerializer.ts index d165bd40b..274cc4aba 100644 --- a/fluxer_api/src/api/search/report/ReportSearchSerializer.ts +++ b/fluxer_api/src/api/search/report/ReportSearchSerializer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IARSubmission} from '@app/api/report/IReportRepository'; import type {SearchableReport} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import type {IARSubmission} from '../../report/IReportRepository'; export function convertToSearchableReport(report: IARSubmission): SearchableReport { const createdAt = Math.floor(snowflakeToDate(BigInt(report.reportId)).getTime() / 1000); diff --git a/fluxer_api/src/api/search/tests/GuildMemberSearchEndpoint.test.ts b/fluxer_api/src/api/search/tests/GuildMemberSearchEndpoint.test.ts index 1563b59cc..632f67fd7 100644 --- a/fluxer_api/src/api/search/tests/GuildMemberSearchEndpoint.test.ts +++ b/fluxer_api/src/api/search/tests/GuildMemberSearchEndpoint.test.ts @@ -1,12 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {GuildMFALevel, JoinSourceTypes} from '@fluxer/constants/src/GuildConstants'; -import type {GuildMemberSearchResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSearchSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, type TestAccount, totpCodeNow} from '../../auth/tests/AuthTestUtils'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import {GuildRepository} from '../../guild/repositories/GuildRepository'; +import {createTestAccount, type TestAccount, totpCodeNow} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; import { acceptInvite, createChannel, @@ -15,10 +11,14 @@ import { createRole, setupTestGuildWithMembers, updateMember, -} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, wait} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; +} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, wait} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {GuildMFALevel, JoinSourceTypes} from '@fluxer/constants/src/GuildConstants'; +import type {GuildMemberSearchResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSearchSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; const TOTP_SECRET = 'JBSWY3DPEHPK3PXP'; diff --git a/fluxer_api/src/api/search/tests/MessageSearchEndpoint.test.ts b/fluxer_api/src/api/search/tests/MessageSearchEndpoint.test.ts index fcb2e0c20..037095283 100644 --- a/fluxer_api/src/api/search/tests/MessageSearchEndpoint.test.ts +++ b/fluxer_api/src/api/search/tests/MessageSearchEndpoint.test.ts @@ -1,21 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannelID, createMessageID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {ChannelRepository} from '../../channel/ChannelRepository'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannelID, createMessageID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {ChannelRepository} from '@app/api/channel/ChannelRepository'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; import { deleteMessage, ensureSessionStarted, markChannelAsIndexed, sendMessage, -} from '../../message/tests/MessageTestUtils'; -import {getMessageSearchService} from '../../SearchFactory'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_TIMEOUTS, wait} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +} from '@app/api/message/tests/MessageTestUtils'; +import {getMessageSearchService} from '@app/api/SearchFactory'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_TIMEOUTS, wait} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; interface MessageSearchResult { messages: Array<{ diff --git a/fluxer_api/src/api/search/tests/MessageSearchExactPhrase.test.ts b/fluxer_api/src/api/search/tests/MessageSearchExactPhrase.test.ts index f31469476..f0b86022b 100644 --- a/fluxer_api/src/api/search/tests/MessageSearchExactPhrase.test.ts +++ b/fluxer_api/src/api/search/tests/MessageSearchExactPhrase.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {markChannelAsIndexed, sendMessage} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {markChannelAsIndexed, sendMessage} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface MessageSearchResult { messages: Array<{ diff --git a/fluxer_api/src/api/search/tests/MessageSearchFilters.test.ts b/fluxer_api/src/api/search/tests/MessageSearchFilters.test.ts index 3c93b9250..0f14fb321 100644 --- a/fluxer_api/src/api/search/tests/MessageSearchFilters.test.ts +++ b/fluxer_api/src/api/search/tests/MessageSearchFilters.test.ts @@ -1,26 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {MessageReferenceTypes} from '@fluxer/constants/src/ChannelConstants'; -import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {loadFixture, sendMessageWithAttachments} from '../../channel/tests/AttachmentTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {loadFixture, sendMessageWithAttachments} from '@app/api/channel/tests/AttachmentTestUtils'; import { acceptInvite, createChannel, createChannelInvite, createGuild, getChannel, -} from '../../guild/tests/GuildTestUtils'; +} from '@app/api/guild/tests/GuildTestUtils'; import { markChannelAsIndexed, markGuildChannelsAsIndexed, pinMessage, sendMessage, -} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {MessageReferenceTypes} from '@fluxer/constants/src/ChannelConstants'; +import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; interface MessageSearchResult { messages: Array<{ diff --git a/fluxer_api/src/api/search/tests/MessageSearchPermissions.test.ts b/fluxer_api/src/api/search/tests/MessageSearchPermissions.test.ts index 4f4f27654..08747260f 100644 --- a/fluxer_api/src/api/search/tests/MessageSearchPermissions.test.ts +++ b/fluxer_api/src/api/search/tests/MessageSearchPermissions.test.ts @@ -1,10 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {GuildNSFWLevel} from '@fluxer/constants/src/GuildConstants'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, addMemberRole, @@ -22,16 +18,20 @@ import { sendChannelMessage, updateChannel, updateRole, -} from '../../channel/tests/ChannelTestUtils'; -import {getRoles, updateGuild} from '../../guild/tests/GuildTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {getRoles, updateGuild} from '@app/api/guild/tests/GuildTestUtils'; import { markChannelAsIndexed, markGuildChannelsAsIndexed, markUserDmChannelsAsIndexed, -} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {GuildNSFWLevel} from '@fluxer/constants/src/GuildConstants'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; interface MessageSearchResult { channels: Array<{ diff --git a/fluxer_api/src/api/search/tests/MessageSearchReferencedMessage.test.ts b/fluxer_api/src/api/search/tests/MessageSearchReferencedMessage.test.ts index 72b8d4318..a1c0da863 100644 --- a/fluxer_api/src/api/search/tests/MessageSearchReferencedMessage.test.ts +++ b/fluxer_api/src/api/search/tests/MessageSearchReferencedMessage.test.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {markChannelAsIndexed, markGuildChannelsAsIndexed, sendMessage} from '@app/api/message/tests/MessageTestUtils'; +import {SearchService} from '@app/api/search/SearchService'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {MessageReferenceTypes} from '@fluxer/constants/src/ChannelConstants'; import type { MessageResponse, @@ -7,13 +14,6 @@ import type { MessageSearchResultsResponse, } from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import {afterEach, beforeEach, describe, expect, test, vi} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {markChannelAsIndexed, markGuildChannelsAsIndexed, sendMessage} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {SearchService} from '../SearchService'; function isSearchResult(response: MessageSearchResponse): response is MessageSearchResultsResponse { return 'messages' in response; diff --git a/fluxer_api/src/api/search/tests/MessageSearchSorting.test.ts b/fluxer_api/src/api/search/tests/MessageSearchSorting.test.ts index 5f48811e4..4cf253eae 100644 --- a/fluxer_api/src/api/search/tests/MessageSearchSorting.test.ts +++ b/fluxer_api/src/api/search/tests/MessageSearchSorting.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {ensureSessionStarted, markChannelAsIndexed, sendMessage} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {ensureSessionStarted, markChannelAsIndexed, sendMessage} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface MessageSearchResult { messages: Array<{ diff --git a/fluxer_api/src/api/search/user/UserSearchSerializer.ts b/fluxer_api/src/api/search/user/UserSearchSerializer.ts index 27293eea0..5acc988d5 100644 --- a/fluxer_api/src/api/search/user/UserSearchSerializer.ts +++ b/fluxer_api/src/api/search/user/UserSearchSerializer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {User} from '@app/api/models/User'; import type {SearchableUser} from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import type {User} from '../../models/User'; export function convertToSearchableUser(user: User): SearchableUser { const createdAt = Math.floor(snowflakeToDate(BigInt(user.id)).getTime() / 1000); diff --git a/fluxer_api/src/api/stripe/ProductRegistry.ts b/fluxer_api/src/api/stripe/ProductRegistry.ts index 8354a8c07..6294e4bbd 100644 --- a/fluxer_api/src/api/stripe/ProductRegistry.ts +++ b/fluxer_api/src/api/stripe/ProductRegistry.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; +import type {Currency} from '@app/api/utils/CurrencyUtils'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import type {Currency} from '../utils/CurrencyUtils'; export enum ProductType { MONTHLY_SUBSCRIPTION = 'monthly_subscription', diff --git a/fluxer_api/src/api/stripe/StripeController.ts b/fluxer_api/src/api/stripe/StripeController.ts index 620552d58..d7e74342c 100644 --- a/fluxer_api/src/api/stripe/StripeController.ts +++ b/fluxer_api/src/api/stripe/StripeController.ts @@ -1,5 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {CaptchaMiddleware} from '@app/api/middleware/CaptchaMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import {mapGiftCodeToMetadataResponse, mapGiftCodeToResponse} from '@app/api/stripe/StripeModel'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; +import {Validator} from '@app/api/Validator'; import {StripeWebhookNotAvailableError} from '@fluxer/errors/src/domains/payment/StripeWebhookNotAvailableError'; import {StripeWebhookSignatureInvalidError} from '@fluxer/errors/src/domains/payment/StripeWebhookSignatureInvalidError'; import {StripeWebhookSignatureMissingError} from '@fluxer/errors/src/domains/payment/StripeWebhookSignatureMissingError'; @@ -23,17 +33,6 @@ import { WebhookReceivedResponse, } from '@fluxer/schema/src/domains/premium/PremiumSchemas'; -import {Config} from '../Config'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {CaptchaMiddleware} from '../middleware/CaptchaMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {lookupGeoip} from '../utils/IpUtils'; -import {Validator} from '../Validator'; -import {mapGiftCodeToMetadataResponse, mapGiftCodeToResponse} from './StripeModel'; - async function getPurchaseGeoipCountryCode(request: Request): Promise { const geoip = await lookupGeoip(request); return geoip.countryCode ?? null; diff --git a/fluxer_api/src/api/stripe/StripeModel.ts b/fluxer_api/src/api/stripe/StripeModel.ts index 6f5590dfe..9ff803f88 100644 --- a/fluxer_api/src/api/stripe/StripeModel.ts +++ b/fluxer_api/src/api/stripe/StripeModel.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {GiftCode} from '@app/api/models/GiftCode'; +import {getCachedUserPartialResponse} from '@app/api/user/UserCacheHelpers'; import type {GiftCodeMetadataResponse, GiftCodeResponse} from '@fluxer/schema/src/domains/premium/GiftCodeSchemas'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {GiftCode} from '../models/GiftCode'; -import {getCachedUserPartialResponse} from '../user/UserCacheHelpers'; interface MapGiftCodeToResponseParams { giftCode: GiftCode; diff --git a/fluxer_api/src/api/stripe/StripeService.ts b/fluxer_api/src/api/stripe/StripeService.ts index 5dccd1102..17811dfd9 100644 --- a/fluxer_api/src/api/stripe/StripeService.ts +++ b/fluxer_api/src/api/stripe/StripeService.ts @@ -1,5 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {BillingRepository} from '@app/api/billing/repositories/BillingRepository'; +import {Config} from '@app/api/Config'; +import type {GiftCodeDurationType} from '@app/api/database/types/PaymentTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {GiftCode} from '@app/api/models/GiftCode'; +import type {User} from '@app/api/models/User'; +import {ProductRegistry} from '@app/api/stripe/ProductRegistry'; +import {STRIPE_API_VERSION} from '@app/api/stripe/StripeApiVersion'; +import {PremiumStateService} from '@app/api/stripe/services/PremiumStateService'; +import type { + ContinueLocalizedCardPreapprovalResult, + CreateCheckoutSessionParams, +} from '@app/api/stripe/services/StripeCheckoutService'; +import {StripeCheckoutService} from '@app/api/stripe/services/StripeCheckoutService'; +import {StripeGiftService} from '@app/api/stripe/services/StripeGiftService'; +import {StripePremiumService} from '@app/api/stripe/services/StripePremiumService'; +import {StripeRefundService} from '@app/api/stripe/services/StripeRefundService'; +import {StripeSubscriptionService} from '@app/api/stripe/services/StripeSubscriptionService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {Currency} from '@app/api/utils/CurrencyUtils'; import {PremiumPurchaseBlockedError} from '@fluxer/errors/src/domains/payment/PremiumPurchaseBlockedError'; import type { CurrentSubscriptionPriceResponse, @@ -10,29 +33,6 @@ import type { } from '@fluxer/schema/src/domains/premium/PremiumSchemas'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import Stripe from 'stripe'; -import type {UserID} from '../BrandedTypes'; -import type {BillingRepository} from '../billing/repositories/BillingRepository'; -import {Config} from '../Config'; -import type {GiftCodeDurationType} from '../database/types/PaymentTypes'; -import type {IGuildRepositoryAggregate} from '../guild/repositories/IGuildRepositoryAggregate'; -import type {GuildService} from '../guild/services/GuildService'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {GiftCode} from '../models/GiftCode'; -import type {User} from '../models/User'; -import type {IUserRepository} from '../user/IUserRepository'; -import type {Currency} from '../utils/CurrencyUtils'; -import {ProductRegistry} from './ProductRegistry'; -import {STRIPE_API_VERSION} from './StripeApiVersion'; -import {PremiumStateService} from './services/PremiumStateService'; -import type { - ContinueLocalizedCardPreapprovalResult, - CreateCheckoutSessionParams, -} from './services/StripeCheckoutService'; -import {StripeCheckoutService} from './services/StripeCheckoutService'; -import {StripeGiftService} from './services/StripeGiftService'; -import {StripePremiumService} from './services/StripePremiumService'; -import {StripeRefundService} from './services/StripeRefundService'; -import {StripeSubscriptionService} from './services/StripeSubscriptionService'; export class StripeService { private stripe: Stripe | null = null; diff --git a/fluxer_api/src/api/stripe/VisionarySlotInitializer.ts b/fluxer_api/src/api/stripe/VisionarySlotInitializer.ts index 42f868e27..bba8cd149 100644 --- a/fluxer_api/src/api/stripe/VisionarySlotInitializer.ts +++ b/fluxer_api/src/api/stripe/VisionarySlotInitializer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import {getVisionarySlotRepository} from '../middleware/ServiceSingletons'; +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; +import {getVisionarySlotRepository} from '@app/api/middleware/ServiceSingletons'; const DEFAULT_SLOT_COUNT = 100; diff --git a/fluxer_api/src/api/stripe/services/AgeVerificationService.ts b/fluxer_api/src/api/stripe/services/AgeVerificationService.ts index 1b7d03db1..dd67302b3 100644 --- a/fluxer_api/src/api/stripe/services/AgeVerificationService.ts +++ b/fluxer_api/src/api/stripe/services/AgeVerificationService.ts @@ -1,5 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import type {User} from '@app/api/models/User'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {AgeVerificationAlreadyVerifiedError} from '@fluxer/errors/src/domains/payment/AgeVerificationAlreadyVerifiedError'; import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; @@ -8,14 +16,6 @@ import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {seconds} from 'itty-time'; import type Stripe from 'stripe'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; const CUSTOMER_LOCK_TTL_SECONDS = seconds('30 seconds'); diff --git a/fluxer_api/src/api/stripe/services/PremiumStateService.ts b/fluxer_api/src/api/stripe/services/PremiumStateService.ts index 3ce51ca09..648703d65 100644 --- a/fluxer_api/src/api/stripe/services/PremiumStateService.ts +++ b/fluxer_api/src/api/stripe/services/PremiumStateService.ts @@ -1,5 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {BillingRepository} from '@app/api/billing/repositories/BillingRepository'; +import {Config} from '@app/api/Config'; +import type { + BillingInvoiceRow, + BillingPaymentMethodRow, + BillingRefundRow, + BillingSubscriptionRow, +} from '@app/api/database/types/BillingTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import type {RecurringBillingCycle} from '@app/api/stripe/ProductRegistry'; +import {ProductRegistry} from '@app/api/stripe/ProductRegistry'; +import {getPrimarySubscriptionItem} from '@app/api/stripe/StripeSubscriptionPeriod'; +import { + SELF_SERVE_REFUND_COOLDOWN_DAYS, + SELF_SERVE_REFUND_WINDOW_DAYS, +} from '@app/api/stripe/services/StripeRefundService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {checkHasActivePaidPremium} from '@app/api/user/UserHelpers'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import {type Currency, getCurrencyPreferences, getGiftCurrencyPreferences} from '@app/api/utils/CurrencyUtils'; import {PremiumFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import type { @@ -17,26 +40,6 @@ import type { SelfServeRefundIneligibilityReason, } from '@fluxer/schema/src/domains/premium/PremiumSchemas'; import type Stripe from 'stripe'; -import type {UserID} from '../../BrandedTypes'; -import type {BillingRepository} from '../../billing/repositories/BillingRepository'; -import {Config} from '../../Config'; -import type { - BillingInvoiceRow, - BillingPaymentMethodRow, - BillingRefundRow, - BillingSubscriptionRow, -} from '../../database/types/BillingTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {Logger} from '../../Logger'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {checkHasActivePaidPremium} from '../../user/UserHelpers'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import {type Currency, getCurrencyPreferences, getGiftCurrencyPreferences} from '../../utils/CurrencyUtils'; -import type {RecurringBillingCycle} from '../ProductRegistry'; -import {ProductRegistry} from '../ProductRegistry'; -import {getPrimarySubscriptionItem} from '../StripeSubscriptionPeriod'; -import {SELF_SERVE_REFUND_COOLDOWN_DAYS, SELF_SERVE_REFUND_WINDOW_DAYS} from './StripeRefundService'; const INVOICE_LIMIT = 12; const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000; diff --git a/fluxer_api/src/api/stripe/services/StripeCheckoutService.ts b/fluxer_api/src/api/stripe/services/StripeCheckoutService.ts index f44d777ba..9aaee7465 100644 --- a/fluxer_api/src/api/stripe/services/StripeCheckoutService.ts +++ b/fluxer_api/src/api/stripe/services/StripeCheckoutService.ts @@ -1,6 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {getContentMessage} from '@app/api/content_i18n/ContentI18n'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import type {User} from '@app/api/models/User'; +import type {ProductInfo, ProductRegistry} from '@app/api/stripe/ProductRegistry'; +import { + canProvisionPremiumFromSubscriptionStatus, + getPremiumWillCancelFromSubscription, +} from '@app/api/stripe/StripeSubscriptionAccessPolicy'; +import { + getPrimarySubscriptionItem, + getSubscriptionPremiumPeriodEnd, + getSubscriptionStartDate, +} from '@app/api/stripe/StripeSubscriptionPeriod'; +import {extractId} from '@app/api/stripe/StripeUtils'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {type Currency, getCurrencyPreferences, getGiftCurrencyPreferences} from '@app/api/utils/CurrencyUtils'; import {isEuEeaCountryCode} from '@fluxer/constants/src/EuropeanEconomicArea'; import {PremiumFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {PurchaseEmailVerificationRequiredError} from '@fluxer/errors/src/domains/auth/EmailVerificationRequiredError'; @@ -16,26 +36,6 @@ import type {CheckoutPaymentMethod} from '@fluxer/schema/src/domains/premium/Gif import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {seconds} from 'itty-time'; import type Stripe from 'stripe'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {getContentMessage} from '../../content_i18n/ContentI18n'; -import type {UserRow} from '../../database/types/UserTypes'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {type Currency, getCurrencyPreferences, getGiftCurrencyPreferences} from '../../utils/CurrencyUtils'; -import type {ProductInfo, ProductRegistry} from '../ProductRegistry'; -import { - canProvisionPremiumFromSubscriptionStatus, - getPremiumWillCancelFromSubscription, -} from '../StripeSubscriptionAccessPolicy'; -import { - getPrimarySubscriptionItem, - getSubscriptionPremiumPeriodEnd, - getSubscriptionStartDate, -} from '../StripeSubscriptionPeriod'; -import {extractId} from '../StripeUtils'; const PRODUCT_NAME = 'Fluxer'; const PREMIUM_TIER_NAME = 'Plutonium'; diff --git a/fluxer_api/src/api/stripe/services/StripeCheckoutWebhookHandler.ts b/fluxer_api/src/api/stripe/services/StripeCheckoutWebhookHandler.ts index e05d6bfda..1e91ced73 100644 --- a/fluxer_api/src/api/stripe/services/StripeCheckoutWebhookHandler.ts +++ b/fluxer_api/src/api/stripe/services/StripeCheckoutWebhookHandler.ts @@ -1,34 +1,34 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {BillingSubscriptionRow} from '@app/api/database/types/BillingTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {IDonationRepository} from '@app/api/donation/IDonationRepository'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import type {Payment} from '@app/api/models/Payment'; +import type {User} from '@app/api/models/User'; +import type {ProductInfo, ProductRegistry} from '@app/api/stripe/ProductRegistry'; +import { + getFirstInvoicePaymentIntentId, + getPrimarySubscriptionItem, + getSubscriptionItemPeriodEnd, + getSubscriptionPremiumPeriodEnd, +} from '@app/api/stripe/StripeSubscriptionPeriod'; +import {extractId} from '@app/api/stripe/StripeUtils'; +import {EU_WITHDRAWAL_WAIVER_TEXT_VERSION} from '@app/api/stripe/services/StripeCheckoutService'; +import type {StripeGiftService} from '@app/api/stripe/services/StripeGiftService'; +import type {StripePremiumService} from '@app/api/stripe/services/StripePremiumService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {IEmailService} from '@pkgs/email/src/IEmailService'; import {seconds} from 'itty-time'; import type Stripe from 'stripe'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {BillingSubscriptionRow} from '../../database/types/BillingTypes'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {IDonationRepository} from '../../donation/IDonationRepository'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import type {Payment} from '../../models/Payment'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import type {ProductInfo, ProductRegistry} from '../ProductRegistry'; -import { - getFirstInvoicePaymentIntentId, - getPrimarySubscriptionItem, - getSubscriptionItemPeriodEnd, - getSubscriptionPremiumPeriodEnd, -} from '../StripeSubscriptionPeriod'; -import {extractId} from '../StripeUtils'; -import {EU_WITHDRAWAL_WAIVER_TEXT_VERSION} from './StripeCheckoutService'; -import type {StripeGiftService} from './StripeGiftService'; -import type {StripePremiumService} from './StripePremiumService'; interface DonationCustomerDetails { businessName: string | null; diff --git a/fluxer_api/src/api/stripe/services/StripeDisputeWebhookHandler.ts b/fluxer_api/src/api/stripe/services/StripeDisputeWebhookHandler.ts index c47719aa1..2904da287 100644 --- a/fluxer_api/src/api/stripe/services/StripeDisputeWebhookHandler.ts +++ b/fluxer_api/src/api/stripe/services/StripeDisputeWebhookHandler.ts @@ -1,25 +1,25 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {IDonationRepository} from '@app/api/donation/IDonationRepository'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import type {GiftCode} from '@app/api/models/GiftCode'; +import type {User} from '@app/api/models/User'; +import {extractId} from '@app/api/stripe/StripeUtils'; +import type {StripeGiftReversalHandler} from '@app/api/stripe/services/StripeGiftReversalHandler'; +import type {StripePaymentFraudService} from '@app/api/stripe/services/StripePaymentFraudService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {clearPendingDeletion} from '@app/api/user/services/PendingDeletionCoordinator'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; import {DeletionReasons} from '@fluxer/constants/src/Core'; import {PremiumFlags, UserFlags} from '@fluxer/constants/src/UserConstants'; import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; import type {IEmailService} from '@pkgs/email/src/IEmailService'; import type Stripe from 'stripe'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {IDonationRepository} from '../../donation/IDonationRepository'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import type {GiftCode} from '../../models/GiftCode'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {clearPendingDeletion} from '../../user/services/PendingDeletionCoordinator'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import {extractId} from '../StripeUtils'; -import type {StripeGiftReversalHandler} from './StripeGiftReversalHandler'; -import type {StripePaymentFraudService} from './StripePaymentFraudService'; export const REFUND_ALLOWANCE_CLAIM_PREFIX = 'refund-allowance'; diff --git a/fluxer_api/src/api/stripe/services/StripeGiftReversalHandler.ts b/fluxer_api/src/api/stripe/services/StripeGiftReversalHandler.ts index c9aeae19b..bbc278b76 100644 --- a/fluxer_api/src/api/stripe/services/StripeGiftReversalHandler.ts +++ b/fluxer_api/src/api/stripe/services/StripeGiftReversalHandler.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {PremiumStateReconciliationQueueService} from '@app/api/infrastructure/PremiumStateReconciliationQueueService'; +import {Logger} from '@app/api/Logger'; +import {addGiftCodeDuration, type GiftCode} from '@app/api/models/GiftCode'; +import type {User} from '@app/api/models/User'; +import type {StripePremiumService} from '@app/api/stripe/services/StripePremiumService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; -import type {UserID} from '../../BrandedTypes'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {PremiumStateReconciliationQueueService} from '../../infrastructure/PremiumStateReconciliationQueueService'; -import {Logger} from '../../Logger'; -import {addGiftCodeDuration, type GiftCode} from '../../models/GiftCode'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import type {StripePremiumService} from './StripePremiumService'; interface RemainingGiftEntitlement { hasLifetimeGift: boolean; diff --git a/fluxer_api/src/api/stripe/services/StripeGiftService.ts b/fluxer_api/src/api/stripe/services/StripeGiftService.ts index 9d3b5d4a1..4b442a4de 100644 --- a/fluxer_api/src/api/stripe/services/StripeGiftService.ts +++ b/fluxer_api/src/api/stripe/services/StripeGiftService.ts @@ -1,5 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {createUserID} from '@app/api/BrandedTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import {type GiftCode, mapGiftDurationMonthsToFields} from '@app/api/models/GiftCode'; +import type {User} from '@app/api/models/User'; +import type {ProductInfo} from '@app/api/stripe/ProductRegistry'; +import type {StripeCheckoutService} from '@app/api/stripe/services/StripeCheckoutService'; +import type {StripePremiumService} from '@app/api/stripe/services/StripePremiumService'; +import type {StripeSubscriptionService} from '@app/api/stripe/services/StripeSubscriptionService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import * as RandomUtils from '@app/api/utils/RandomUtils'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {CannotRedeemPlutoniumWithVisionaryError} from '@fluxer/errors/src/domains/payment/CannotRedeemPlutoniumWithVisionaryError'; import {GiftCodeAlreadyRedeemedError} from '@fluxer/errors/src/domains/payment/GiftCodeAlreadyRedeemedError'; @@ -11,21 +26,6 @@ import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {seconds} from 'itty-time'; import type Stripe from 'stripe'; -import type {UserID} from '../../BrandedTypes'; -import {createUserID} from '../../BrandedTypes'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import {type GiftCode, mapGiftDurationMonthsToFields} from '../../models/GiftCode'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import * as RandomUtils from '../../utils/RandomUtils'; -import type {ProductInfo} from '../ProductRegistry'; -import type {StripeCheckoutService} from './StripeCheckoutService'; -import type {StripePremiumService} from './StripePremiumService'; -import type {StripeSubscriptionService} from './StripeSubscriptionService'; export class StripeGiftService { constructor( diff --git a/fluxer_api/src/api/stripe/services/StripePaymentFraudService.ts b/fluxer_api/src/api/stripe/services/StripePaymentFraudService.ts index 691fb926d..fac2c49bd 100644 --- a/fluxer_api/src/api/stripe/services/StripePaymentFraudService.ts +++ b/fluxer_api/src/api/stripe/services/StripePaymentFraudService.ts @@ -1,5 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {ISessionTerminator} from '@app/api/auth/ISessionTerminator'; +import type {UserID} from '@app/api/BrandedTypes'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import type {IDonationRepository} from '@app/api/donation/IDonationRepository'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import type {User} from '@app/api/models/User'; +import {extractId} from '@app/api/stripe/StripeUtils'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {reschedulePendingDeletion} from '@app/api/user/services/PendingDeletionCoordinator'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; import {DeletionReasons} from '@fluxer/constants/src/Core'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; @@ -7,21 +22,6 @@ import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {IEmailService} from '@pkgs/email/src/IEmailService'; import {ms, seconds} from 'itty-time'; import type Stripe from 'stripe'; -import type {AdminAuditService} from '../../admin/services/AdminAuditService'; -import type {ISessionTerminator} from '../../auth/ISessionTerminator'; -import type {UserID} from '../../BrandedTypes'; -import {SYSTEM_USER_ID} from '../../constants/Core'; -import type {IDonationRepository} from '../../donation/IDonationRepository'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {reschedulePendingDeletion} from '../../user/services/PendingDeletionCoordinator'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import {extractId} from '../StripeUtils'; type RadarValueListCreateParams = Stripe.Radar.ValueListCreateParams; type RadarValueListItemType = RadarValueListCreateParams['item_type']; diff --git a/fluxer_api/src/api/stripe/services/StripePremiumService.ts b/fluxer_api/src/api/stripe/services/StripePremiumService.ts index de4d0bf79..18350ded2 100644 --- a/fluxer_api/src/api/stripe/services/StripePremiumService.ts +++ b/fluxer_api/src/api/stripe/services/StripePremiumService.ts @@ -1,24 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {createGuildID, createRoleID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import type {GiftCodeDurationType} from '@app/api/database/types/PaymentTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {addGiftCodeDuration} from '@app/api/models/GiftCode'; +import type {User} from '@app/api/models/User'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {createPremiumClearPatch, getEffectivePremiumUntil} from '@app/api/user/UserHelpers'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {MissingAccessError} from '@fluxer/errors/src/domains/core/MissingAccessError'; import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; -import type {UserID} from '../../BrandedTypes'; -import {createGuildID, createRoleID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {SYSTEM_USER_ID} from '../../constants/Core'; -import type {GiftCodeDurationType} from '../../database/types/PaymentTypes'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {GuildService} from '../../guild/services/GuildService'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {Logger} from '../../Logger'; -import {createRequestCache} from '../../middleware/RequestCacheMiddleware'; -import {addGiftCodeDuration} from '../../models/GiftCode'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {createPremiumClearPatch, getEffectivePremiumUntil} from '../../user/UserHelpers'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; export class StripePremiumService { constructor( diff --git a/fluxer_api/src/api/stripe/services/StripeRefundService.ts b/fluxer_api/src/api/stripe/services/StripeRefundService.ts index c0a1ee3dd..c0a19d8a6 100644 --- a/fluxer_api/src/api/stripe/services/StripeRefundService.ts +++ b/fluxer_api/src/api/stripe/services/StripeRefundService.ts @@ -1,5 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import type {User} from '@app/api/models/User'; +import {extractId} from '@app/api/stripe/StripeUtils'; +import {REFUND_ALLOWANCE_CLAIM_PREFIX} from '@app/api/stripe/services/StripeDisputeWebhookHandler'; +import type {StripeSubscriptionService} from '@app/api/stripe/services/StripeSubscriptionService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {PremiumFlags} from '@fluxer/constants/src/UserConstants'; import {FeatureNotAvailableSelfHostedError} from '@fluxer/errors/src/domains/core/FeatureNotAvailableSelfHostedError'; import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; @@ -14,16 +24,6 @@ import type { SelfServeRefundResponse, } from '@fluxer/schema/src/domains/premium/PremiumSchemas'; import type Stripe from 'stripe'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {UserRow} from '../../database/types/UserTypes'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {extractId} from '../StripeUtils'; -import {REFUND_ALLOWANCE_CLAIM_PREFIX} from './StripeDisputeWebhookHandler'; -import type {StripeSubscriptionService} from './StripeSubscriptionService'; const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000; export const SELF_SERVE_REFUND_WINDOW_DAYS = 3; diff --git a/fluxer_api/src/api/stripe/services/StripeSubscriptionReconciler.ts b/fluxer_api/src/api/stripe/services/StripeSubscriptionReconciler.ts index 610e60865..80654bc16 100644 --- a/fluxer_api/src/api/stripe/services/StripeSubscriptionReconciler.ts +++ b/fluxer_api/src/api/stripe/services/StripeSubscriptionReconciler.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import type {ProductInfo, ProductRegistry} from '@app/api/stripe/ProductRegistry'; +import {getPrimarySubscriptionItem, getSubscriptionStartDate} from '@app/api/stripe/StripeSubscriptionPeriod'; +import {extractId} from '@app/api/stripe/StripeUtils'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; import type Stripe from 'stripe'; -import type {UserID} from '../../BrandedTypes'; -import type {UserRow} from '../../database/types/UserTypes'; -import {Logger} from '../../Logger'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {ProductInfo, ProductRegistry} from '../ProductRegistry'; -import {getPrimarySubscriptionItem, getSubscriptionStartDate} from '../StripeSubscriptionPeriod'; -import {extractId} from '../StripeUtils'; interface InvoiceRenewalContext { userId: UserID; diff --git a/fluxer_api/src/api/stripe/services/StripeSubscriptionService.ts b/fluxer_api/src/api/stripe/services/StripeSubscriptionService.ts index ea3a4993b..d3d886357 100644 --- a/fluxer_api/src/api/stripe/services/StripeSubscriptionService.ts +++ b/fluxer_api/src/api/stripe/services/StripeSubscriptionService.ts @@ -1,5 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {GiftCodeDurationType} from '@app/api/database/types/PaymentTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import {addGiftCodeDuration} from '@app/api/models/GiftCode'; +import type {User} from '@app/api/models/User'; +import type {ProductInfo, RecurringBillingCycle} from '@app/api/stripe/ProductRegistry'; +import { + getPrimarySubscriptionItem, + getSubscriptionEntitlementPeriodEndUnix, + getSubscriptionItemPeriodEndUnix, + getSubscriptionPremiumPeriodEnd, +} from '@app/api/stripe/StripeSubscriptionPeriod'; +import {extractId} from '@app/api/stripe/StripeUtils'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import type {Currency} from '@app/api/utils/CurrencyUtils'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {NoActiveSubscriptionError} from '@fluxer/errors/src/domains/payment/NoActiveSubscriptionError'; import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; @@ -17,25 +36,6 @@ import type { import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {seconds} from 'itty-time'; import type Stripe from 'stripe'; -import type {UserID} from '../../BrandedTypes'; -import type {GiftCodeDurationType} from '../../database/types/PaymentTypes'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import {addGiftCodeDuration} from '../../models/GiftCode'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import type {Currency} from '../../utils/CurrencyUtils'; -import type {ProductInfo, RecurringBillingCycle} from '../ProductRegistry'; -import { - getPrimarySubscriptionItem, - getSubscriptionEntitlementPeriodEndUnix, - getSubscriptionItemPeriodEndUnix, - getSubscriptionPremiumPeriodEnd, -} from '../StripeSubscriptionPeriod'; -import {extractId} from '../StripeUtils'; type BillingCycleChangeEffectiveAt = 'now' | 'period_end'; diff --git a/fluxer_api/src/api/stripe/services/StripeSubscriptionWebhookHandler.ts b/fluxer_api/src/api/stripe/services/StripeSubscriptionWebhookHandler.ts index c1ac766db..43e321593 100644 --- a/fluxer_api/src/api/stripe/services/StripeSubscriptionWebhookHandler.ts +++ b/fluxer_api/src/api/stripe/services/StripeSubscriptionWebhookHandler.ts @@ -1,40 +1,40 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; -import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; -import type Stripe from 'stripe'; -import type {UserID} from '../../BrandedTypes'; -import type {BillingRepository} from '../../billing/repositories/BillingRepository'; -import {nextVersion} from '../../database/CassandraTypes'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {IDonationRepository} from '../../donation/IDonationRepository'; -import {Donor} from '../../donation/models/Donor'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {PremiumStateReconciliationQueueService} from '../../infrastructure/PremiumStateReconciliationQueueService'; -import {Logger} from '../../Logger'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {PaymentRepository} from '../../user/repositories/PaymentRepository'; -import {PREMIUM_GRACE_PERIOD_MS} from '../../user/UserHelpers'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import type {ProductInfo} from '../ProductRegistry'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {BillingRepository} from '@app/api/billing/repositories/BillingRepository'; +import {nextVersion} from '@app/api/database/CassandraTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {IDonationRepository} from '@app/api/donation/IDonationRepository'; +import {Donor} from '@app/api/donation/models/Donor'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {PremiumStateReconciliationQueueService} from '@app/api/infrastructure/PremiumStateReconciliationQueueService'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import type {ProductInfo} from '@app/api/stripe/ProductRegistry'; import { canProvisionPremiumFromSubscriptionStatus, getPremiumWillCancelFromSubscription, shouldTreatInvoiceCollectionIssueAsAccessChange, shouldTreatInvoicePaymentFailureAsAccessChange, shouldTreatInvoiceUpdatedAsCollectionIssue, -} from '../StripeSubscriptionAccessPolicy'; +} from '@app/api/stripe/StripeSubscriptionAccessPolicy'; import { getInvoiceLatestLinePeriodEnd, getPrimarySubscriptionItem, getSubscriptionItemPeriodEnd, getSubscriptionPremiumPeriodEnd, getSubscriptionStartDate, -} from '../StripeSubscriptionPeriod'; -import {extractId} from '../StripeUtils'; -import type {StripePremiumService} from './StripePremiumService'; -import type {StripeSubscriptionReconciler} from './StripeSubscriptionReconciler'; +} from '@app/api/stripe/StripeSubscriptionPeriod'; +import {extractId} from '@app/api/stripe/StripeUtils'; +import type {StripePremiumService} from '@app/api/stripe/services/StripePremiumService'; +import type {StripeSubscriptionReconciler} from '@app/api/stripe/services/StripeSubscriptionReconciler'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {PaymentRepository} from '@app/api/user/repositories/PaymentRepository'; +import {PREMIUM_GRACE_PERIOD_MS} from '@app/api/user/UserHelpers'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; +import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; +import type Stripe from 'stripe'; export class StripeSubscriptionWebhookHandler { private readonly paymentRepository = new PaymentRepository(); diff --git a/fluxer_api/src/api/stripe/services/StripeWebhookService.ts b/fluxer_api/src/api/stripe/services/StripeWebhookService.ts index 976e0f424..906694f18 100644 --- a/fluxer_api/src/api/stripe/services/StripeWebhookService.ts +++ b/fluxer_api/src/api/stripe/services/StripeWebhookService.ts @@ -1,36 +1,36 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminRepository} from '@app/api/admin/AdminRepository'; +import {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import type {ISessionTerminator} from '@app/api/auth/ISessionTerminator'; +import type {BillingRepository} from '@app/api/billing/repositories/BillingRepository'; +import {Config} from '@app/api/Config'; +import type {IDonationRepository} from '@app/api/donation/IDonationRepository'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import type {PremiumStateReconciliationQueueService} from '@app/api/infrastructure/PremiumStateReconciliationQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {ProductRegistry} from '@app/api/stripe/ProductRegistry'; +import type {AgeVerificationService} from '@app/api/stripe/services/AgeVerificationService'; +import type {StripeCheckoutService} from '@app/api/stripe/services/StripeCheckoutService'; +import {StripeCheckoutWebhookHandler} from '@app/api/stripe/services/StripeCheckoutWebhookHandler'; +import {StripeDisputeWebhookHandler} from '@app/api/stripe/services/StripeDisputeWebhookHandler'; +import {StripeGiftReversalHandler} from '@app/api/stripe/services/StripeGiftReversalHandler'; +import type {StripeGiftService} from '@app/api/stripe/services/StripeGiftService'; +import {StripePaymentFraudService} from '@app/api/stripe/services/StripePaymentFraudService'; +import type {StripePremiumService} from '@app/api/stripe/services/StripePremiumService'; +import type {StripeRefundService} from '@app/api/stripe/services/StripeRefundService'; +import {StripeSubscriptionReconciler} from '@app/api/stripe/services/StripeSubscriptionReconciler'; +import {StripeSubscriptionWebhookHandler} from '@app/api/stripe/services/StripeSubscriptionWebhookHandler'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; import {StripeError} from '@fluxer/errors/src/domains/payment/StripeError'; import {StripeWebhookNotAvailableError} from '@fluxer/errors/src/domains/payment/StripeWebhookNotAvailableError'; import {StripeWebhookSignatureInvalidError} from '@fluxer/errors/src/domains/payment/StripeWebhookSignatureInvalidError'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {IEmailService} from '@pkgs/email/src/IEmailService'; import type Stripe from 'stripe'; -import type {AdminRepository} from '../../admin/AdminRepository'; -import {AdminAuditService} from '../../admin/services/AdminAuditService'; -import type {ISessionTerminator} from '../../auth/ISessionTerminator'; -import type {BillingRepository} from '../../billing/repositories/BillingRepository'; -import {Config} from '../../Config'; -import type {IDonationRepository} from '../../donation/IDonationRepository'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import type {PremiumStateReconciliationQueueService} from '../../infrastructure/PremiumStateReconciliationQueueService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {Logger} from '../../Logger'; -import type {IUserRepository} from '../../user/IUserRepository'; -import type {ProductRegistry} from '../ProductRegistry'; -import type {AgeVerificationService} from './AgeVerificationService'; -import type {StripeCheckoutService} from './StripeCheckoutService'; -import {StripeCheckoutWebhookHandler} from './StripeCheckoutWebhookHandler'; -import {StripeDisputeWebhookHandler} from './StripeDisputeWebhookHandler'; -import {StripeGiftReversalHandler} from './StripeGiftReversalHandler'; -import type {StripeGiftService} from './StripeGiftService'; -import {StripePaymentFraudService} from './StripePaymentFraudService'; -import type {StripePremiumService} from './StripePremiumService'; -import type {StripeRefundService} from './StripeRefundService'; -import {StripeSubscriptionReconciler} from './StripeSubscriptionReconciler'; -import {StripeSubscriptionWebhookHandler} from './StripeSubscriptionWebhookHandler'; interface HandleWebhookParams { body: string; diff --git a/fluxer_api/src/api/stripe/tests/GiftCodeRedeemCaptcha.test.ts b/fluxer_api/src/api/stripe/tests/GiftCodeRedeemCaptcha.test.ts index 74c5df0cb..6ff2b0432 100644 --- a/fluxer_api/src/api/stripe/tests/GiftCodeRedeemCaptcha.test.ts +++ b/fluxer_api/src/api/stripe/tests/GiftCodeRedeemCaptcha.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterEach, beforeEach, describe, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; async function withCaptchaEnabled(run: () => Promise): Promise { const previousEnabled = Config.captcha.enabled; diff --git a/fluxer_api/src/api/stripe/tests/PremiumStatePricing.test.ts b/fluxer_api/src/api/stripe/tests/PremiumStatePricing.test.ts index fe8a52368..08f917b47 100644 --- a/fluxer_api/src/api/stripe/tests/PremiumStatePricing.test.ts +++ b/fluxer_api/src/api/stripe/tests/PremiumStatePricing.test.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import {STRIPE_API_VERSION} from '@app/api/stripe/StripeApiVersion'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createStripeApiHandlers, type StripeApiHandlers} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {PremiumStateResponse} from '@fluxer/schema/src/domains/premium/PremiumSchemas'; import Stripe from 'stripe'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createStripeApiHandlers, type StripeApiHandlers} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {STRIPE_API_VERSION} from '../StripeApiVersion'; const MOCK_PRICES = { monthlyUsd: 'price_state_pricing_monthly_usd', diff --git a/fluxer_api/src/api/stripe/tests/PremiumStateService.test.ts b/fluxer_api/src/api/stripe/tests/PremiumStateService.test.ts index 61608da65..6a4a40fcb 100644 --- a/fluxer_api/src/api/stripe/tests/PremiumStateService.test.ts +++ b/fluxer_api/src/api/stripe/tests/PremiumStateService.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createStripeApiHandlers, type StripeApiHandlers} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import type {PremiumStateResponse} from '@fluxer/schema/src/domains/premium/PremiumSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createStripeApiHandlers, type StripeApiHandlers} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface PremiumStatePaymentMethodResponse { billing: { diff --git a/fluxer_api/src/api/stripe/tests/ProductRegistryLegacyPrices.test.ts b/fluxer_api/src/api/stripe/tests/ProductRegistryLegacyPrices.test.ts index 6a391a790..861165ec8 100644 --- a/fluxer_api/src/api/stripe/tests/ProductRegistryLegacyPrices.test.ts +++ b/fluxer_api/src/api/stripe/tests/ProductRegistryLegacyPrices.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {ProductRegistry, ProductType} from '@app/api/stripe/ProductRegistry'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {afterAll, beforeAll, describe, expect, test} from 'vitest'; -import {Config} from '../../Config'; -import {ProductRegistry, ProductType} from '../ProductRegistry'; // Mirrors the live BRL/TRY configuration after the repricing: the BRL slots point at the new list // prices, TRY is not configured at all (production has no TRY prices), and every retired price id diff --git a/fluxer_api/src/api/stripe/tests/StripeCheckoutCountryEnforcement.test.ts b/fluxer_api/src/api/stripe/tests/StripeCheckoutCountryEnforcement.test.ts index 38207bfc8..3aad226ce 100644 --- a/fluxer_api/src/api/stripe/tests/StripeCheckoutCountryEnforcement.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeCheckoutCountryEnforcement.test.ts @@ -1,22 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createStripeApiHandlers, type StripeApiHandlers} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import type {GeoipResult} from '@pkgs/geoip/src/GeoipLookup'; import {afterAll, beforeAll, beforeEach, describe, expect, test, vi} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createStripeApiHandlers, type StripeApiHandlers} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; const {lookupGeoipMock} = vi.hoisted(() => ({ lookupGeoipMock: vi.fn(), })); -vi.mock('../../utils/IpUtils', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@app/api/utils/IpUtils', async (importOriginal) => ({ + ...(await importOriginal()), lookupGeoip: lookupGeoipMock, })); diff --git a/fluxer_api/src/api/stripe/tests/StripeNordicCurrencies.test.ts b/fluxer_api/src/api/stripe/tests/StripeNordicCurrencies.test.ts index c900ad142..b591b6fcc 100644 --- a/fluxer_api/src/api/stripe/tests/StripeNordicCurrencies.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeNordicCurrencies.test.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createStripeApiHandlers, type StripeApiHandlers} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import type { CurrentSubscriptionPriceResponse, @@ -7,20 +14,13 @@ import type { } from '@fluxer/schema/src/domains/premium/PremiumSchemas'; import type {GeoipResult} from '@pkgs/geoip/src/GeoipLookup'; import {afterAll, beforeAll, beforeEach, describe, expect, test, vi} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createStripeApiHandlers, type StripeApiHandlers} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; const {lookupGeoipMock} = vi.hoisted(() => ({ lookupGeoipMock: vi.fn(), })); -vi.mock('../../utils/IpUtils', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@app/api/utils/IpUtils', async (importOriginal) => ({ + ...(await importOriginal()), lookupGeoip: lookupGeoipMock, })); diff --git a/fluxer_api/src/api/stripe/tests/StripePremiumService.test.ts b/fluxer_api/src/api/stripe/tests/StripePremiumService.test.ts index 4a5cf8340..5d62e08df 100644 --- a/fluxer_api/src/api/stripe/tests/StripePremiumService.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripePremiumService.test.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import {createGuild, createRole, getMember} from '@app/api/guild/tests/GuildTestUtils'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {StripePremiumService} from '@app/api/stripe/services/StripePremiumService'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {GuildService} from '../../guild/services/GuildService'; -import {createGuild, createRole, getMember} from '../../guild/tests/GuildTestUtils'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../../user/repositories/UserRepository'; -import {StripePremiumService} from '../services/StripePremiumService'; describe('StripePremiumService', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/stripe/tests/StripeRefundService.test.ts b/fluxer_api/src/api/stripe/tests/StripeRefundService.test.ts index e1cda3cb3..3d2374f8e 100644 --- a/fluxer_api/src/api/stripe/tests/StripeRefundService.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeRefundService.test.ts @@ -1,6 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; +import {createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {setupSyncStripeWebhookWorker} from '@app/api/stripe/tests/StripeWebhookTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import { + createMockWebhookPayload, + createStripeApiHandlers, + type StripeWebhookEventData, +} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {PremiumFlags} from '@fluxer/constants/src/UserConstants'; import type { @@ -9,19 +22,6 @@ import type { } from '@fluxer/schema/src/domains/premium/PremiumSchemas'; import {HttpResponse, http} from 'msw'; import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import { - createMockWebhookPayload, - createStripeApiHandlers, - type StripeWebhookEventData, -} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../../user/repositories/UserRepository'; -import {setupSyncStripeWebhookWorker} from './StripeWebhookTestUtils'; const MOCK_CUSTOMER_ID = 'cus_self_serve_refund'; const MOCK_SUBSCRIPTION_ID = 'sub_self_serve_refund'; @@ -350,7 +350,7 @@ describe('StripeRefundService self-serve refund', () => { expect(response.status).toBe('pending'); expect(response.refunded_amount_cents).toBe(0); expect(response.subscription_id).toBeNull(); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const updatedUser = await new UserRepository().findUnique(createUserID(BigInt(account.userId))); expect(updatedUser!.firstRefundAt).toBeNull(); }); @@ -371,7 +371,7 @@ describe('StripeRefundService self-serve refund', () => { expect(response.status).toBe('failed'); expect(response.refunded_amount_cents).toBe(0); expect(response.subscription_id).toBeNull(); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const updatedUser = await new UserRepository().findUnique(createUserID(BigInt(account.userId))); expect(updatedUser!.firstRefundAt).toBeNull(); }); diff --git a/fluxer_api/src/api/stripe/tests/StripeSubscriptionListPriceSwitch.test.ts b/fluxer_api/src/api/stripe/tests/StripeSubscriptionListPriceSwitch.test.ts index 2e81ed49a..d0e7776d2 100644 --- a/fluxer_api/src/api/stripe/tests/StripeSubscriptionListPriceSwitch.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeSubscriptionListPriceSwitch.test.ts @@ -1,5 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import {STRIPE_API_VERSION} from '@app/api/stripe/StripeApiVersion'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createPwnedPasswordsRangeHandler} from '@app/api/test/msw/handlers/PwnedPasswordsHandlers'; +import {createStripeApiHandlers, type StripeApiHandlers} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import type { ListPriceSwitchIneligibilityReason, @@ -9,16 +19,6 @@ import type { import {HttpResponse, http} from 'msw'; import Stripe from 'stripe'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createPwnedPasswordsRangeHandler} from '../../test/msw/handlers/PwnedPasswordsHandlers'; -import {createStripeApiHandlers, type StripeApiHandlers} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {STRIPE_API_VERSION} from '../StripeApiVersion'; const MOCK_PRICES = { monthlyUsd: 'price_list_monthly_usd', diff --git a/fluxer_api/src/api/stripe/tests/StripeSubscriptionService.test.ts b/fluxer_api/src/api/stripe/tests/StripeSubscriptionService.test.ts index 9865a4314..0237ce068 100644 --- a/fluxer_api/src/api/stripe/tests/StripeSubscriptionService.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeSubscriptionService.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createPwnedPasswordsRangeHandler} from '@app/api/test/msw/handlers/PwnedPasswordsHandlers'; +import {createStripeApiHandlers, type StripeApiHandlers} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {HttpResponse, http} from 'msw'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createPwnedPasswordsRangeHandler} from '../../test/msw/handlers/PwnedPasswordsHandlers'; -import {createStripeApiHandlers, type StripeApiHandlers} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {createBuilder} from '../../test/TestRequestBuilder'; const MOCK_PRICES = { monthlyUsd: 'price_monthly_usd', diff --git a/fluxer_api/src/api/stripe/tests/StripeUtils.test.ts b/fluxer_api/src/api/stripe/tests/StripeUtils.test.ts index 5472754fd..e44af0e39 100644 --- a/fluxer_api/src/api/stripe/tests/StripeUtils.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {addMonthsClamp} from '@app/api/stripe/StripeUtils'; import {describe, expect, it} from 'vitest'; -import {addMonthsClamp} from '../StripeUtils'; describe('addMonthsClamp', () => { it('adds months normally when no overflow occurs', () => { diff --git a/fluxer_api/src/api/stripe/tests/StripeWebhookCheckout.test.ts b/fluxer_api/src/api/stripe/tests/StripeWebhookCheckout.test.ts index c1c73e187..4f3248abb 100644 --- a/fluxer_api/src/api/stripe/tests/StripeWebhookCheckout.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeWebhookCheckout.test.ts @@ -1,26 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; -import {HttpResponse, http} from 'msw'; -import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {clearDonationTestEmails, listDonationTestEmails} from '../../donation/tests/DonationTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {clearDonationTestEmails, listDonationTestEmails} from '@app/api/donation/tests/DonationTestUtils'; +import {ProductType} from '@app/api/stripe/ProductRegistry'; +import {setupSyncStripeWebhookWorker} from '@app/api/stripe/tests/StripeWebhookTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import { createCheckoutCompletedEvent, createMockWebhookPayload, createStripeApiHandlers, type StripeApiHandlers, type StripeWebhookEventData, -} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {ProductType} from '../ProductRegistry'; -import {setupSyncStripeWebhookWorker} from './StripeWebhookTestUtils'; +} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; +import {HttpResponse, http} from 'msw'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test} from 'vitest'; const MOCK_PRICES = { monthlyUsd: 'price_monthly_usd', @@ -194,8 +194,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { test('processes completed premium checkout session successfully', async () => { const account = await createTestAccount(harness); const sessionId = 'cs_premium_success_123'; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -229,8 +229,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { test('allows localized BRL checkout when the card is issued in Brazil', async () => { const account = await createTestAccount(harness); const sessionId = 'cs_localized_brl_card_br'; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -268,8 +268,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { test('allows localized BRL PIX subscription checkout when checkout.session.completed has no payment intent', async () => { const account = await createTestAccount(harness); const sessionId = 'cs_localized_brl_pix_subscription'; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -313,8 +313,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { test('allows localized TRY card subscription checkout when checkout.session.completed has no payment intent', async () => { const account = await createTestAccount(harness); const sessionId = 'cs_localized_try_card_no_payment_intent'; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -413,8 +413,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { test('rejects localized BRL checkout when the card is issued outside Brazil', async () => { const account = await createTestAccount(harness); const sessionId = 'cs_localized_brl_card_us'; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -580,8 +580,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { test('updates user with Stripe customer ID on first purchase', async () => { const account = await createTestAccount(harness); const sessionId = 'cs_first_purchase_customer_123'; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -605,8 +605,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { }); test('processes duplicate checkout delivery idempotently across concurrency and retry', async () => { const account = await createTestAccount(harness); - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -666,8 +666,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { test('skips already processed payment', async () => { const account = await createTestAccount(harness); const sessionId = 'cs_already_completed_123'; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -738,8 +738,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { test('handles gift purchase correctly', async () => { const account = await createTestAccount(harness); const sessionId = 'cs_gift_purchase_123'; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -770,8 +770,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { test('allows localized BRL gift checkout when the card is issued in Brazil', async () => { const account = await createTestAccount(harness); const sessionId = 'cs_gift_brl_card_br'; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -802,8 +802,8 @@ describe('StripeWebhookService - checkout.session.completed', () => { test('rejects localized BRL gift checkout when the card is issued outside Brazil', async () => { const account = await createTestAccount(harness); const sessionId = 'cs_gift_brl_card_us'; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); await paymentRepository.createPayment({ @@ -849,7 +849,7 @@ describe('StripeWebhookService - checkout.session.completed', () => { }); const result = await sendWebhook(eventData); expect(result.received).toBe(true); - const {DonationRepository} = await import('../../donation/DonationRepository'); + const {DonationRepository} = await import('@app/api/donation/DonationRepository'); const donationRepository = new DonationRepository(); const donor = await donationRepository.findDonorByEmail(donationEmail); expect(donor).not.toBeNull(); diff --git a/fluxer_api/src/api/stripe/tests/StripeWebhookCore.test.ts b/fluxer_api/src/api/stripe/tests/StripeWebhookCore.test.ts index 1d24f1e2c..b91e39bca 100644 --- a/fluxer_api/src/api/stripe/tests/StripeWebhookCore.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeWebhookCore.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; +import {Config} from '@app/api/Config'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createMockWebhookPayload, type StripeWebhookEventData} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createMockWebhookPayload, type StripeWebhookEventData} from '../../test/msw/handlers/StripeApiHandlers'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('Stripe Webhook - Core Handling', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/stripe/tests/StripeWebhookDispute.test.ts b/fluxer_api/src/api/stripe/tests/StripeWebhookDispute.test.ts index 77289f4fc..426a3b971 100644 --- a/fluxer_api/src/api/stripe/tests/StripeWebhookDispute.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeWebhookDispute.test.ts @@ -1,28 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {DeletionReasons} from '@fluxer/constants/src/Core'; -import {UserFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; -import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import { - createMockWebhookPayload, - createStripeApiHandlers, - type StripeWebhookEventData, -} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {PaymentRepository} from '../../user/repositories/PaymentRepository'; -import {UserRepository} from '../../user/repositories/UserRepository'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; import { mockStripeWebhookSecret, restoreStripeWebhookSecret, setupSyncStripeWebhookWorker, -} from './StripeWebhookTestUtils'; +} from '@app/api/stripe/tests/StripeWebhookTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import { + createMockWebhookPayload, + createStripeApiHandlers, + type StripeWebhookEventData, +} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {PaymentRepository} from '@app/api/user/repositories/PaymentRepository'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {DeletionReasons} from '@fluxer/constants/src/Core'; +import {UserFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test} from 'vitest'; interface UserDataExistsResponse { user_exists: boolean; diff --git a/fluxer_api/src/api/stripe/tests/StripeWebhookEarlyFraudWarning.test.ts b/fluxer_api/src/api/stripe/tests/StripeWebhookEarlyFraudWarning.test.ts index df2286bab..38f50906c 100644 --- a/fluxer_api/src/api/stripe/tests/StripeWebhookEarlyFraudWarning.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeWebhookEarlyFraudWarning.test.ts @@ -1,22 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; -import {DeletionReasons} from '@fluxer/constants/src/Core'; -import {UserFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; -import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {AdminRepository} from '../../admin/AdminRepository'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; +import {AdminRepository} from '@app/api/admin/AdminRepository'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import { + createTestPayment, + createTestUserWithPremium, + setupSyncStripeWebhookWorker, +} from '@app/api/stripe/tests/StripeWebhookTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import { createMockWebhookPayload, createStripeApiHandlers, type StripeWebhookEventData, -} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../../user/repositories/UserRepository'; -import {createTestPayment, createTestUserWithPremium, setupSyncStripeWebhookWorker} from './StripeWebhookTestUtils'; +} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {DeletionReasons} from '@fluxer/constants/src/Core'; +import {UserFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test} from 'vitest'; describe('Stripe Webhook Early Fraud Warning', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/stripe/tests/StripeWebhookEdgeCases.test.ts b/fluxer_api/src/api/stripe/tests/StripeWebhookEdgeCases.test.ts index 020c5c4c2..52b63c1d1 100644 --- a/fluxer_api/src/api/stripe/tests/StripeWebhookEdgeCases.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeWebhookEdgeCases.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {Config} from '@app/api/Config'; +import {createGuild, createRole, getMember} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {Config} from '../../Config'; -import {createGuild, createRole, getMember} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('Stripe Webhook Edge Cases', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/stripe/tests/StripeWebhookInvoice.test.ts b/fluxer_api/src/api/stripe/tests/StripeWebhookInvoice.test.ts index 3d561afbf..8b5c5a358 100644 --- a/fluxer_api/src/api/stripe/tests/StripeWebhookInvoice.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeWebhookInvoice.test.ts @@ -1,17 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; -import {HttpResponse, http} from 'msw'; -import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {NoopLogger} from '../../test/mocks/NoopLogger'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import {ProductType} from '@app/api/stripe/ProductRegistry'; +import {setupSyncStripeWebhookWorker} from '@app/api/stripe/tests/StripeWebhookTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; import { createInvoiceFinalizationFailedEvent, createInvoicePaidEvent, @@ -22,11 +20,13 @@ import { createStripeApiHandlers, type StripeApiHandlers, type StripeWebhookEventData, -} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {ProductType} from '../ProductRegistry'; -import {setupSyncStripeWebhookWorker} from './StripeWebhookTestUtils'; +} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; +import {HttpResponse, http} from 'msw'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi} from 'vitest'; const MOCK_PRICES = { monthlyUsd: 'price_monthly_usd', @@ -119,7 +119,7 @@ describe('Stripe Webhook - Invoice Events', () => { }): Promise { const {userId, subscriptionId, priceId, productType} = params; const checkoutSessionId = `cs_test_${crypto.randomUUID()}`; - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); const paymentRepo = new PaymentRepository(); await paymentRepo.createPayment({ checkout_session_id: checkoutSessionId, @@ -148,7 +148,7 @@ describe('Stripe Webhook - Invoice Events', () => { premiumUntil: Date; premiumWillCancel?: boolean; }): Promise { - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const userRepository = new UserRepository(); const userId = createUserID(BigInt(params.accountUserId)); await userRepository.patchUpsert( @@ -550,7 +550,7 @@ describe('Stripe Webhook - Invoice Events', () => { priceId: MOCK_PRICES.monthlyUsd, productType: ProductType.MONTHLY_SUBSCRIPTION, }); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const userRepository = new UserRepository(); const userId = createUserID(BigInt(account.userId)); await userRepository.patchUpsert( @@ -609,7 +609,7 @@ describe('Stripe Webhook - Invoice Events', () => { priceId: MOCK_PRICES.monthlyUsd, productType: ProductType.MONTHLY_SUBSCRIPTION, }); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const userRepository = new UserRepository(); const userId = createUserID(BigInt(account.userId)); await userRepository.patchUpsert( @@ -923,7 +923,7 @@ describe('Stripe Webhook - Invoice Events', () => { expect(new Date(me.premium_until!).toISOString()).toBe( new Date((currentPeriodStart + 30 * 24 * 60 * 60) * 1000).toISOString(), ); - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); const payment = await new PaymentRepository().getPaymentByCheckoutSession(checkoutSessionId); expect(payment?.invoiceId).toBe(invoiceId); }); @@ -1077,7 +1077,7 @@ describe('Stripe Webhook - Invoice Events', () => { priceId: MOCK_PRICES.monthlyUsd, productType: ProductType.MONTHLY_SUBSCRIPTION, }); - const {DonationRepository} = await import('../../donation/DonationRepository'); + const {DonationRepository} = await import('@app/api/donation/DonationRepository'); await new DonationRepository().createDonor({ email: 'donor-invoice-guard@example.com', stripeCustomerId: 'cus_donation_recurring', @@ -1118,7 +1118,7 @@ describe('Stripe Webhook - Invoice Events', () => { priceId: MOCK_PRICES.monthlyUsd, productType: ProductType.MONTHLY_SUBSCRIPTION, }); - const {DonationRepository} = await import('../../donation/DonationRepository'); + const {DonationRepository} = await import('@app/api/donation/DonationRepository'); await new DonationRepository().createDonor({ email: 'donor-and-subscriber@example.com', stripeCustomerId: sharedCustomerId, diff --git a/fluxer_api/src/api/stripe/tests/StripeWebhookRefund.test.ts b/fluxer_api/src/api/stripe/tests/StripeWebhookRefund.test.ts index 433c1b304..e0d0fcd85 100644 --- a/fluxer_api/src/api/stripe/tests/StripeWebhookRefund.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeWebhookRefund.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {setupSyncStripeWebhookWorker} from '@app/api/stripe/tests/StripeWebhookTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createMockWebhookPayload, type StripeWebhookEventData} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import {PremiumFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {HttpResponse, http} from 'msw'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createMockWebhookPayload, type StripeWebhookEventData} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../../user/repositories/UserRepository'; -import {setupSyncStripeWebhookWorker} from './StripeWebhookTestUtils'; describe('Stripe Webhook Refund', () => { let harness: ApiTestHarness; @@ -67,8 +67,8 @@ describe('Stripe Webhook Refund', () => { test('revokes premium and records first refund', async () => { const account = await createTestAccount(harness); const userId = createUserID(BigInt(account.userId)); - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); const paymentIntentId = 'pi_test_refund_first_123'; @@ -108,7 +108,7 @@ describe('Stripe Webhook Refund', () => { test('applies permanent purchase block on second refund', async () => { const account = await createTestAccount(harness); const userId = createUserID(BigInt(account.userId)); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const userRepository = new UserRepository(); const firstRefundDate = new Date('2024-01-01'); await userRepository.patchUpsert( @@ -118,7 +118,7 @@ describe('Stripe Webhook Refund', () => { }, (await userRepository.findUnique(userId))!.toRow(), ); - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); const paymentRepository = new PaymentRepository(); const paymentIntentId = 'pi_test_refund_second_456'; const checkoutSessionId = 'cs_test_refund_second_456'; @@ -158,8 +158,8 @@ describe('Stripe Webhook Refund', () => { test('counts a refund once when the same charge.refunded event is redelivered', async () => { const account = await createTestAccount(harness); const userId = createUserID(BigInt(account.userId)); - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); const paymentIntentId = 'pi_test_refund_retry_123'; @@ -211,8 +211,8 @@ describe('Stripe Webhook Refund', () => { test('counts a refund once when charge.refunded lands before the refund record exists', async () => { const account = await createTestAccount(harness); const userId = createUserID(BigInt(account.userId)); - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); const paymentIntentId = 'pi_test_refund_late_record'; @@ -273,8 +273,8 @@ describe('Stripe Webhook Refund', () => { test('does not count a refund Fluxer issued itself against the refund allowance', async () => { const account = await createTestAccount(harness); const userId = createUserID(BigInt(account.userId)); - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); const paymentIntentId = 'pi_test_refund_system_123'; @@ -324,8 +324,8 @@ describe('Stripe Webhook Refund', () => { test('does not count a refund Fluxer issued for a localized card country mismatch', async () => { const account = await createTestAccount(harness); const userId = createUserID(BigInt(account.userId)); - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); const paymentIntentId = 'pi_test_refund_card_mismatch'; @@ -377,8 +377,8 @@ describe('Stripe Webhook Refund', () => { test('counts only the customer refund when Fluxer issued a later system refund on the same charge', async () => { const account = await createTestAccount(harness); const userId = createUserID(BigInt(account.userId)); - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); const paymentIntentId = 'pi_test_refund_mixed'; @@ -450,8 +450,8 @@ describe('Stripe Webhook Refund', () => { test('counts a second, distinct refund against the allowance after the first one was already counted', async () => { const account = await createTestAccount(harness); const userId = createUserID(BigInt(account.userId)); - const {PaymentRepository} = await import('../../user/repositories/PaymentRepository'); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {PaymentRepository} = await import('@app/api/user/repositories/PaymentRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const paymentRepository = new PaymentRepository(); const userRepository = new UserRepository(); const paymentIntentId = 'pi_test_refund_ladder'; @@ -518,7 +518,7 @@ describe('Stripe Webhook Refund', () => { test('falls back to customer ID when payment intent is not indexed (subscription mode)', async () => { const account = await createTestAccount(harness); const userId = createUserID(BigInt(account.userId)); - const {UserRepository} = await import('../../user/repositories/UserRepository'); + const {UserRepository} = await import('@app/api/user/repositories/UserRepository'); const userRepository = new UserRepository(); const stripeCustomerId = 'cus_test_subscription_fallback'; await userRepository.patchUpsert( @@ -544,7 +544,7 @@ describe('Stripe Webhook Refund', () => { }); test('skips premium action for donation customer refund', async () => { const donationCustomerId = 'cus_test_donation_refund'; - const {DonationRepository} = await import('../../donation/DonationRepository'); + const {DonationRepository} = await import('@app/api/donation/DonationRepository'); const donationRepository = new DonationRepository(); await donationRepository.createDonor({ email: 'donor-refund-test@example.com', diff --git a/fluxer_api/src/api/stripe/tests/StripeWebhookSubscription.test.ts b/fluxer_api/src/api/stripe/tests/StripeWebhookSubscription.test.ts index c5bb884f4..b36f1c0ae 100644 --- a/fluxer_api/src/api/stripe/tests/StripeWebhookSubscription.test.ts +++ b/fluxer_api/src/api/stripe/tests/StripeWebhookSubscription.test.ts @@ -1,14 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; -import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; -import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; -import {HttpResponse, http} from 'msw'; -import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {ProductType} from '@app/api/stripe/ProductRegistry'; +import {setupSyncStripeWebhookWorker} from '@app/api/stripe/tests/StripeWebhookTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import { createMockWebhookPayload, createStripeApiHandlers, @@ -16,13 +14,15 @@ import { createSubscriptionUpdatedEvent, type StripeApiHandlers, type StripeWebhookEventData, -} from '../../test/msw/handlers/StripeApiHandlers'; -import {server} from '../../test/msw/server'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {PaymentRepository} from '../../user/repositories/PaymentRepository'; -import {UserRepository} from '../../user/repositories/UserRepository'; -import {ProductType} from '../ProductRegistry'; -import {setupSyncStripeWebhookWorker} from './StripeWebhookTestUtils'; +} from '@app/api/test/msw/handlers/StripeApiHandlers'; +import {server} from '@app/api/test/msw/server'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {PaymentRepository} from '@app/api/user/repositories/PaymentRepository'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; +import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; +import {HttpResponse, http} from 'msw'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, test} from 'vitest'; const MOCK_PRICES = { monthlyUsd: 'price_monthly_usd', @@ -498,7 +498,7 @@ describe('Stripe Webhook Subscription Lifecycle', () => { expect(afterUser?.premiumUntil?.getTime()).toBe(endedAt * 1000); expect(afterUser?.premiumGraceEndsAt?.getTime()).toBe(endedAt * 1000); expect(afterUser?.stripeSubscriptionId).toBeNull(); - const {checkHasActivePaidPremium} = await import('../../user/UserHelpers'); + const {checkHasActivePaidPremium} = await import('@app/api/user/UserHelpers'); expect(checkHasActivePaidPremium(afterUser!)).toBe(false); }); test('grants standard grace when the subscription is cancelled at the end of its paid period', async () => { @@ -525,13 +525,13 @@ describe('Stripe Webhook Subscription Lifecycle', () => { expect(afterUser?.premiumUntil?.getTime()).toBe(premiumUntil.getTime()); expect(afterUser?.premiumGraceEndsAt).not.toBeNull(); expect(afterUser!.premiumGraceEndsAt!.getTime()).toBe(endedAt * 1000 + 3 * 24 * 60 * 60 * 1000); - const {checkHasActivePaidPremium} = await import('../../user/UserHelpers'); + const {checkHasActivePaidPremium} = await import('@app/api/user/UserHelpers'); expect(checkHasActivePaidPremium(afterUser!)).toBe(true); }); test('processes donation subscription deletion', async () => { const subscriptionId = 'sub_donor_delete_test'; const donorEmail = 'donor-delete@example.com'; - const {DonationRepository} = await import('../../donation/DonationRepository'); + const {DonationRepository} = await import('@app/api/donation/DonationRepository'); const donationRepository = new DonationRepository(); await donationRepository.createDonor({ email: donorEmail, diff --git a/fluxer_api/src/api/stripe/tests/StripeWebhookTestUtils.ts b/fluxer_api/src/api/stripe/tests/StripeWebhookTestUtils.ts index d6725ab44..2e14d2f7f 100644 --- a/fluxer_api/src/api/stripe/tests/StripeWebhookTestUtils.ts +++ b/fluxer_api/src/api/stripe/tests/StripeWebhookTestUtils.ts @@ -1,15 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import Stripe from 'stripe'; -import {createTestAccount, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import type {UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; +import {createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; import { getBillingRepository, getGatewayService, getSnowflakeService, setInjectedWorkerService, -} from '../../middleware/ServiceRegistry'; +} from '@app/api/middleware/ServiceRegistry'; import { createUserCacheService, getAdminRepository, @@ -20,14 +19,15 @@ import { getKVAccountDeletionQueue, getPremiumStateReconciliationQueueService, getUserRepository, -} from '../../middleware/ServiceSingletons'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {SyncTaskWorkerService} from '../../test/SyncTaskWorkerService'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {PaymentRepository} from '../../user/repositories/PaymentRepository'; -import processStripeWebhook from '../../worker/tasks/ProcessStripeWebhook'; -import {setWorkerDependenciesForTest} from '../../worker/WorkerContext'; -import {STRIPE_API_VERSION} from '../StripeApiVersion'; +} from '@app/api/middleware/ServiceSingletons'; +import {STRIPE_API_VERSION} from '@app/api/stripe/StripeApiVersion'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {SyncTaskWorkerService} from '@app/api/test/SyncTaskWorkerService'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {PaymentRepository} from '@app/api/user/repositories/PaymentRepository'; +import processStripeWebhook from '@app/api/worker/tasks/ProcessStripeWebhook'; +import {setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; +import Stripe from 'stripe'; export async function createTestUserWithPremium( harness: ApiTestHarness, @@ -136,4 +136,4 @@ export function restoreStripeWebhookSecret(): void { ).webhookSecret; } -export {} from '../../test/msw/handlers/StripeApiHandlers'; +export {} from '@app/api/test/msw/handlers/StripeApiHandlers'; diff --git a/fluxer_api/src/api/test/AccountPolicyTestEvaluator.ts b/fluxer_api/src/api/test/AccountPolicyTestEvaluator.ts index 3246b0efb..969bdcf12 100644 --- a/fluxer_api/src/api/test/AccountPolicyTestEvaluator.ts +++ b/fluxer_api/src/api/test/AccountPolicyTestEvaluator.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {createAccountPolicyEvaluator, type IAccountPolicyEvaluator} from '../risk/AccountPolicyEvaluator'; +import {createAccountPolicyEvaluator, type IAccountPolicyEvaluator} from '@app/api/risk/AccountPolicyEvaluator'; export const TEST_POLICY_CONTACT_DOMAIN = 'policy-exempt.example'; export const TEST_POLICY_CONTACT_SUBDOMAIN = `sub.${TEST_POLICY_CONTACT_DOMAIN}`; diff --git a/fluxer_api/src/api/test/ApiTestHarness.ts b/fluxer_api/src/api/test/ApiTestHarness.ts index 6c261a1b4..6e1524ed7 100644 --- a/fluxer_api/src/api/test/ApiTestHarness.ts +++ b/fluxer_api/src/api/test/ApiTestHarness.ts @@ -1,21 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {createAPIApp} from '../App'; -import {Config} from '../Config'; -import {resetApiServicesForTesting} from '../CreateApiContext'; +import {createAPIApp} from '@app/api/App'; +import {Config} from '@app/api/Config'; +import {resetApiServicesForTesting} from '@app/api/CreateApiContext'; import { resetCassandraQueryExecutorForTesting, setCassandraQueryExecutorForTesting, -} from '../database/CassandraQueryExecution'; -import {NullSearchProvider} from '../infrastructure/NullSearchProvider'; -import {resetAbuseTrackingForTests} from '../middleware/AbusiveIpAutoBanner'; -import {ipBanCache} from '../middleware/IpBanMiddleware'; +} from '@app/api/database/CassandraQueryExecution'; +import {NullSearchProvider} from '@app/api/infrastructure/NullSearchProvider'; +import {resetAbuseTrackingForTests} from '@app/api/middleware/AbusiveIpAutoBanner'; +import {ipBanCache} from '@app/api/middleware/IpBanMiddleware'; import { setInjectedAccountPolicyEvaluator, setInjectedIpInfoService, setInjectedRegistrationRiskEvaluator, -} from '../middleware/ServiceMiddleware'; +} from '@app/api/middleware/ServiceMiddleware'; import { setInjectedBlueskyOAuthService, setInjectedGatewayService, @@ -23,28 +22,29 @@ import { setInjectedMediaService, setInjectedSearchProviderService, setInjectedWorkerService, -} from '../middleware/ServiceRegistry'; +} from '@app/api/middleware/ServiceRegistry'; import { getInstanceConfigRepository, setInjectedStorageService, setInjectedUnfurlerService, -} from '../middleware/ServiceSingletons'; -import {torExitListCache} from '../middleware/TorExitListCache'; -import type {ISearchProvider} from '../search/ISearchProvider'; -import {drainSearchTasks} from '../search/SearchTaskTracker'; -import type {HonoApp} from '../types/HonoEnv'; -import {createCurrentBehaviorTestAccountPolicyEvaluator} from './AccountPolicyTestEvaluator'; -import {InMemoryCassandraQueryExecutor} from './InMemoryCassandraQueryExecutor'; -import {MockBlueskyOAuthService} from './mocks/MockBlueskyOAuthService'; -import {MockKVProvider} from './mocks/MockKVProvider'; -import {MockStorageService} from './mocks/MockStorageService'; -import {NoopLogger} from './mocks/NoopLogger'; -import {NoopUnfurlerService} from './mocks/NoopUnfurlerService'; -import {NoopGatewayService} from './NoopGatewayService'; -import {NoopWorkerService} from './NoopWorkerService'; -import {resetServiceStateForTesting} from './ResetServiceState'; -import {InMemorySearchProvider} from './search/InMemorySearchProvider'; -import {TestMediaService} from './TestMediaService'; +} from '@app/api/middleware/ServiceSingletons'; +import {torExitListCache} from '@app/api/middleware/TorExitListCache'; +import type {ISearchProvider} from '@app/api/search/ISearchProvider'; +import {drainSearchTasks} from '@app/api/search/SearchTaskTracker'; +import {createCurrentBehaviorTestAccountPolicyEvaluator} from '@app/api/test/AccountPolicyTestEvaluator'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; +import {MockBlueskyOAuthService} from '@app/api/test/mocks/MockBlueskyOAuthService'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import {MockStorageService} from '@app/api/test/mocks/MockStorageService'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import {NoopUnfurlerService} from '@app/api/test/mocks/NoopUnfurlerService'; +import {NoopGatewayService} from '@app/api/test/NoopGatewayService'; +import {NoopWorkerService} from '@app/api/test/NoopWorkerService'; +import {resetServiceStateForTesting} from '@app/api/test/ResetServiceState'; +import {InMemorySearchProvider} from '@app/api/test/search/InMemorySearchProvider'; +import {TestMediaService} from '@app/api/test/TestMediaService'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; export interface ApiTestHarness { app: HonoApp; diff --git a/fluxer_api/src/api/test/InMemoryCassandraQueryExecutor.ts b/fluxer_api/src/api/test/InMemoryCassandraQueryExecutor.ts index 61be7906e..4a83c7afb 100644 --- a/fluxer_api/src/api/test/InMemoryCassandraQueryExecutor.ts +++ b/fluxer_api/src/api/test/InMemoryCassandraQueryExecutor.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {getKvMeta} from '../database/CassandraMetaRegistry'; -import type {CassandraQueryExecutorForTesting} from '../database/CassandraQueryExecution'; +import {getKvMeta} from '@app/api/database/CassandraMetaRegistry'; +import type {CassandraQueryExecutorForTesting} from '@app/api/database/CassandraQueryExecution'; import type { CassandraParams, KvQueryCondition, KvQueryMeta, PreparedQuery, WhereExpr, -} from '../database/CassandraTypes'; -import {isConditionalQuery} from '../database/CassandraTypes'; +} from '@app/api/database/CassandraTypes'; +import {isConditionalQuery} from '@app/api/database/CassandraTypes'; type Row = Record; diff --git a/fluxer_api/src/api/test/NoopGatewayService.ts b/fluxer_api/src/api/test/NoopGatewayService.ts index 62a776512..5adf2c123 100644 --- a/fluxer_api/src/api/test/NoopGatewayService.ts +++ b/fluxer_api/src/api/test/NoopGatewayService.ts @@ -1,20 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ALL_PERMISSIONS, Permissions} from '@fluxer/constants/src/ChannelConstants'; -import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; -import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; -import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; -import {type ChannelID, type GuildID, guildIdToRoleId, type MessageID, type RoleID, type UserID} from '../BrandedTypes'; -import type {GatewayDispatchEvent} from '../constants/Gateway'; +import { + type ChannelID, + type GuildID, + guildIdToRoleId, + type MessageID, + type RoleID, + type UserID, +} from '@app/api/BrandedTypes'; +import type {GatewayDispatchEvent} from '@app/api/constants/Gateway'; import { mapGuildEmojiToResponse, mapGuildRoleToResponse, mapGuildStickerToResponse, mapGuildToGuildResponse, -} from '../guild/GuildModel'; -import {GuildMemberRepository} from '../guild/repositories/GuildMemberRepository'; -import {GuildRepository} from '../guild/repositories/GuildRepository'; -import {GuildRoleRepository} from '../guild/repositories/GuildRoleRepository'; +} from '@app/api/guild/GuildModel'; +import {GuildMemberRepository} from '@app/api/guild/repositories/GuildMemberRepository'; +import {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; +import {GuildRoleRepository} from '@app/api/guild/repositories/GuildRoleRepository'; import { type CallData, type GatewayActiveVoiceRooms, @@ -27,9 +30,13 @@ import { type GatewayVoiceStateEntry, type GuildChannelAuthContext, IGatewayService, -} from '../infrastructure/IGatewayService'; -import {UserRepository} from '../user/repositories/UserRepository'; -import {mapUserToPartialResponse} from '../user/UserMappers'; +} from '@app/api/infrastructure/IGatewayService'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {mapUserToPartialResponse} from '@app/api/user/UserMappers'; +import {ALL_PERMISSIONS, Permissions} from '@fluxer/constants/src/ChannelConstants'; +import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildError'; +import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; +import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; const guildOwners = new Map(); const guildMembers = new Map>(); @@ -260,7 +267,7 @@ export class NoopGatewayService extends IGatewayService { } const roles = await roleRepository.listRoles(params.guildId); const basePermissions = this.calculateGuildPermissions(new Set(), roles, params.guildId); - const {ChannelDataRepository} = await import('../channel/repositories/ChannelDataRepository'); + const {ChannelDataRepository} = await import('@app/api/channel/repositories/ChannelDataRepository'); const channelRepo = new ChannelDataRepository(); const channels = await channelRepo.listGuildChannels(params.guildId); const channelsById = new Map(channels.map((channel) => [channel.id, channel])); @@ -301,7 +308,7 @@ export class NoopGatewayService extends IGatewayService { if (!channelId) { return guildPermissions; } - const {ChannelDataRepository} = await import('../channel/repositories/ChannelDataRepository'); + const {ChannelDataRepository} = await import('@app/api/channel/repositories/ChannelDataRepository'); const channelRepo = new ChannelDataRepository(); const channel = await channelRepo.findUnique(channelId); if (!channel) { @@ -470,7 +477,7 @@ export class NoopGatewayService extends IGatewayService { async getViewableChannels(params: {guildId: GuildID; userId: UserID}): Promise> { const {guildId, userId} = params; const guild = await guildRepository.findUnique(guildId); - const {ChannelDataRepository} = await import('../channel/repositories/ChannelDataRepository'); + const {ChannelDataRepository} = await import('@app/api/channel/repositories/ChannelDataRepository'); const channelRepo = new ChannelDataRepository(); const channels = await channelRepo.listGuildChannels(guildId); if (guild?.ownerId === userId) { @@ -533,7 +540,7 @@ export class NoopGatewayService extends IGatewayService { ? Promise.resolve>([]) : this.getViewableChannels({guildId: params.guildId, userId: params.userId}), ]); - const {ChannelDataRepository} = await import('../channel/repositories/ChannelDataRepository'); + const {ChannelDataRepository} = await import('@app/api/channel/repositories/ChannelDataRepository'); const channelRepo = new ChannelDataRepository(); const allChannels = await channelRepo.listGuildChannels(params.guildId); const viewableChannelIdSet = new Set( @@ -681,7 +688,7 @@ export class NoopGatewayService extends IGatewayService { } let userPermissions = guildPermissions; if (channelId) { - const {ChannelDataRepository} = await import('../channel/repositories/ChannelDataRepository'); + const {ChannelDataRepository} = await import('@app/api/channel/repositories/ChannelDataRepository'); const channelRepo = new ChannelDataRepository(); const channel = await channelRepo.findUnique(channelId); if (channel) { diff --git a/fluxer_api/src/api/test/ResetServiceState.ts b/fluxer_api/src/api/test/ResetServiceState.ts index 91b302203..3c657b21c 100644 --- a/fluxer_api/src/api/test/ResetServiceState.ts +++ b/fluxer_api/src/api/test/ResetServiceState.ts @@ -1,22 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {resetSudoModeServiceForTesting} from '@app/api/auth/services/SudoModeService'; +import {resetSsoRequestUrlPolicyForTesting} from '@app/api/instance/SsoConfigValidation'; +import {resetGlobalLimitConfigServiceForTesting} from '@app/api/limits/LimitConfigService'; +import {bannedAvatarHashCache} from '@app/api/middleware/BannedAvatarHashCache'; +import {fileShaCache} from '@app/api/middleware/FileShaCache'; +import {ipBanCache} from '@app/api/middleware/IpBanMiddleware'; +import {phraseBlocklistCache} from '@app/api/middleware/PhraseBlocklistCache'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import {resetServiceMiddlewareForTesting} from '@app/api/middleware/ServiceMiddleware'; +import {resetServiceRegistryForTesting} from '@app/api/middleware/ServiceRegistry'; +import {resetServiceSingletonsForTesting} from '@app/api/middleware/ServiceSingletons'; +import {torExitListCache} from '@app/api/middleware/TorExitListCache'; +import {urlBlocklistCache} from '@app/api/middleware/UrlBlocklistCache'; +import {resetAdminSecretHashForTesting} from '@app/api/oauth/repositories/ApplicationRepository'; +import {resetIpBanExemptionsForTesting} from '@app/api/risk/IpBanExemptions'; +import {setThemeCssMaxBytesForTesting} from '@app/api/theme/ThemeService'; import {resetGeoipReadersForTesting} from '@pkgs/geoip/src/GeoipLookup'; -import {resetSudoModeServiceForTesting} from '../auth/services/SudoModeService'; -import {resetSsoRequestUrlPolicyForTesting} from '../instance/SsoConfigValidation'; -import {resetGlobalLimitConfigServiceForTesting} from '../limits/LimitConfigService'; -import {bannedAvatarHashCache} from '../middleware/BannedAvatarHashCache'; -import {fileShaCache} from '../middleware/FileShaCache'; -import {ipBanCache} from '../middleware/IpBanMiddleware'; -import {phraseBlocklistCache} from '../middleware/PhraseBlocklistCache'; -import {profileSubstringBlocklistCache} from '../middleware/ProfileSubstringBlocklistCache'; -import {resetServiceMiddlewareForTesting} from '../middleware/ServiceMiddleware'; -import {resetServiceRegistryForTesting} from '../middleware/ServiceRegistry'; -import {resetServiceSingletonsForTesting} from '../middleware/ServiceSingletons'; -import {torExitListCache} from '../middleware/TorExitListCache'; -import {urlBlocklistCache} from '../middleware/UrlBlocklistCache'; -import {resetAdminSecretHashForTesting} from '../oauth/repositories/ApplicationRepository'; -import {resetIpBanExemptionsForTesting} from '../risk/IpBanExemptions'; -import {setThemeCssMaxBytesForTesting} from '../theme/ThemeService'; export async function resetServiceStateForTesting(): Promise { resetServiceRegistryForTesting(); diff --git a/fluxer_api/src/api/test/Setup.ts b/fluxer_api/src/api/test/Setup.ts index d8734180e..ee0ea4a5d 100644 --- a/fluxer_api/src/api/test/Setup.ts +++ b/fluxer_api/src/api/test/Setup.ts @@ -1,31 +1,31 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {existsSync} from 'node:fs'; -import {loadConfig} from '@fluxer/config/src/ConfigLoader'; -import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import {afterAll, afterEach, beforeAll} from 'vitest'; -import type {UserID} from '../BrandedTypes'; -import {buildAPIConfigFromMaster, initializeConfig} from '../Config'; -import {setInjectedMessageResponseDataService} from '../channel/services/message/MessageResponseDataService'; +import type {UserID} from '@app/api/BrandedTypes'; +import {buildAPIConfigFromMaster, initializeConfig} from '@app/api/Config'; +import {setInjectedMessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; import { resetCassandraQueryExecutorForTesting, setCassandraQueryExecutorForTesting, shutdownCassandraQueryExecutorForTesting, -} from '../database/CassandraQueryExecution'; -import type {IUsersServiceClient} from '../infrastructure/UsersServiceClient'; -import {setInjectedUsersServiceClient} from '../infrastructure/UsersServiceClient'; -import {initializeLogger} from '../Logger'; -import {setInjectedKVProvider, setInjectedSnowflakeService} from '../middleware/ServiceRegistry'; -import {getInstanceConfigRepository, getUserRepository} from '../middleware/ServiceSingletons'; -import {drainSearchTasks, enableSearchTaskTracking} from '../search/SearchTaskTracker'; -import {mapUserToPartialResponse} from '../user/UserMappers'; -import {InMemoryCassandraQueryExecutor} from './InMemoryCassandraQueryExecutor'; -import {MockKVProvider} from './mocks/MockKVProvider'; -import {MockSnowflakeService} from './mocks/MockSnowflakeService'; -import {NoopLogger} from './mocks/NoopLogger'; -import {RepositoryBackedMessageResponseDataService} from './mocks/RepositoryBackedMessageResponseDataService'; -import {fakeNcmecServer} from './msw/handlers/NcmecHandlers'; -import {server} from './msw/server'; +} from '@app/api/database/CassandraQueryExecution'; +import type {IUsersServiceClient} from '@app/api/infrastructure/UsersServiceClient'; +import {setInjectedUsersServiceClient} from '@app/api/infrastructure/UsersServiceClient'; +import {initializeLogger} from '@app/api/Logger'; +import {setInjectedKVProvider, setInjectedSnowflakeService} from '@app/api/middleware/ServiceRegistry'; +import {getInstanceConfigRepository, getUserRepository} from '@app/api/middleware/ServiceSingletons'; +import {drainSearchTasks, enableSearchTaskTracking} from '@app/api/search/SearchTaskTracker'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import {MockSnowflakeService} from '@app/api/test/mocks/MockSnowflakeService'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import {RepositoryBackedMessageResponseDataService} from '@app/api/test/mocks/RepositoryBackedMessageResponseDataService'; +import {fakeNcmecServer} from '@app/api/test/msw/handlers/NcmecHandlers'; +import {server} from '@app/api/test/msw/server'; +import {mapUserToPartialResponse} from '@app/api/user/UserMappers'; +import {loadConfig} from '@fluxer/config/src/ConfigLoader'; +import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; +import {afterAll, afterEach, beforeAll} from 'vitest'; function defaultNatsUrl(): string { return `nats://${existsSync('/.dockerenv') ? 'nats' : '127.0.0.1'}:4222`; diff --git a/fluxer_api/src/api/test/SyncTaskWorkerService.ts b/fluxer_api/src/api/test/SyncTaskWorkerService.ts index a90a58f15..fa8756a57 100644 --- a/fluxer_api/src/api/test/SyncTaskWorkerService.ts +++ b/fluxer_api/src/api/test/SyncTaskWorkerService.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import type {WorkerJobOptions, WorkerJobPayload} from '@pkgs/worker/src/contracts/WorkerTypes'; -import {NoopLogger} from './mocks/NoopLogger'; type TaskHandlerMap = Record; diff --git a/fluxer_api/src/api/test/TestHarnessController.ts b/fluxer_api/src/api/test/TestHarnessController.ts index eb08ac2ac..74bf0bdc5 100644 --- a/fluxer_api/src/api/test/TestHarnessController.ts +++ b/fluxer_api/src/api/test/TestHarnessController.ts @@ -1,5 +1,65 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AttachmentDecayRepository} from '@app/api/attachment/AttachmentDecayRepository'; +import type {IpAuthorizationTicketCache} from '@app/api/auth/AuthLogin'; +import {getTicketCacheKey} from '@app/api/auth/AuthLogin'; +import { + type ChannelID, + createApplicationID, + createAttachmentID, + createChannelID, + createGuildID, + createMessageID, + createUserID, + type GuildID, + type MessageID, + type UserID, +} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {ChannelRepository} from '@app/api/channel/ChannelRepository'; +import {createMessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; +import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {defineTable} from '@app/api/database/CassandraTableDsl'; +import type {ChannelRow} from '@app/api/database/types/ChannelTypes'; +import { + CHANNEL_EMPTY_BUCKET_COLUMNS, + CHANNEL_MESSAGE_BUCKET_COLUMNS, + CHANNEL_STATE_COLUMNS, + type ChannelEmptyBucketRow, + type ChannelMessageBucketRow, + type ChannelStateRow, + MESSAGE_BY_AUTHOR_COLUMNS, + MESSAGE_COLUMNS, + type MessageByAuthorRow, + type MessageRow, +} from '@app/api/database/types/MessageTypes'; +import type {GiftCodeDurationType} from '@app/api/database/types/PaymentTypes'; +import {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import {KVActivityTracker} from '@app/api/infrastructure/KVActivityTracker'; +import {StorageService} from '@app/api/infrastructure/StorageService'; +import {Logger} from '@app/api/Logger'; +import {requireOAuth2Scope} from '@app/api/middleware/OAuth2ScopeMiddleware'; +import {getKVClient, getSnowflakeService} from '@app/api/middleware/ServiceRegistry'; +import {mapGiftDurationMonthsToFields} from '@app/api/models/GiftCode'; +import {OAuth2TokenRepository} from '@app/api/oauth/repositories/OAuth2TokenRepository'; +import {IpAuthorizationTokens, OAuth2AccessTokensByUser} from '@app/api/Tables'; +import {resetTestHarnessState} from '@app/api/test/TestHarnessReset'; +import type {HonoApp, HonoEnv} from '@app/api/types/HonoEnv'; +import {UserSearchRepository} from '@app/api/user/repositories/account/crud/UserSearchRepository'; +import {AuthSessionRepository} from '@app/api/user/repositories/auth/AuthSessionRepository'; +import type {UserDeletionScheduleUpdate} from '@app/api/user/repositories/IUserAccountRepository'; +import {UserChannelRepository} from '@app/api/user/repositories/UserChannelRepository'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {processUserDeletion} from '@app/api/user/services/UserDeletionService'; +import {UserHarvestRepository} from '@app/api/user/UserHarvestRepository'; +import {getExpiryBucket} from '@app/api/utils/AttachmentDecay'; +import {parseReportedClientOs} from '@app/api/utils/SessionClientIdentity'; +import {processExpiredAttachments} from '@app/api/worker/tasks/ExpireAttachments'; +import {processInactivityDeletionsCore} from '@app/api/worker/tasks/ProcessInactivityDeletions'; +import {setWorkerDependencies} from '@app/api/worker/WorkerContext'; +import {initializeWorkerDependencies} from '@app/api/worker/WorkerDependencies'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {MAX_GUILD_MEMBERS_VERY_LARGE_GUILD} from '@fluxer/constants/src/LimitConstants'; import {PremiumFlags, SuspiciousActivityFlags, UserFlags} from '@fluxer/constants/src/UserConstants'; @@ -32,66 +92,6 @@ import type {IEmailService} from '@pkgs/email/src/IEmailService'; import type {ITestEmailService, SentEmailRecord} from '@pkgs/email/src/ITestEmailService'; import type {Context} from 'hono'; import {seconds} from 'itty-time'; -import {AttachmentDecayRepository} from '../attachment/AttachmentDecayRepository'; -import type {IpAuthorizationTicketCache} from '../auth/AuthLogin'; -import {getTicketCacheKey} from '../auth/AuthLogin'; -import { - type ChannelID, - createApplicationID, - createAttachmentID, - createChannelID, - createGuildID, - createMessageID, - createUserID, - type GuildID, - type MessageID, - type UserID, -} from '../BrandedTypes'; -import {Config} from '../Config'; -import {ChannelRepository} from '../channel/ChannelRepository'; -import {createMessageResponseDataService} from '../channel/services/message/MessageResponseDataService'; -import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne} from '../database/CassandraQueryExecution'; -import {defineTable} from '../database/CassandraTableDsl'; -import type {ChannelRow} from '../database/types/ChannelTypes'; -import { - CHANNEL_EMPTY_BUCKET_COLUMNS, - CHANNEL_MESSAGE_BUCKET_COLUMNS, - CHANNEL_STATE_COLUMNS, - type ChannelEmptyBucketRow, - type ChannelMessageBucketRow, - type ChannelStateRow, - MESSAGE_BY_AUTHOR_COLUMNS, - MESSAGE_COLUMNS, - type MessageByAuthorRow, - type MessageRow, -} from '../database/types/MessageTypes'; -import type {GiftCodeDurationType} from '../database/types/PaymentTypes'; -import {GuildRepository} from '../guild/repositories/GuildRepository'; -import type {ISnowflakeService} from '../infrastructure/ISnowflakeService'; -import {KVAccountDeletionQueueService} from '../infrastructure/KVAccountDeletionQueueService'; -import {KVActivityTracker} from '../infrastructure/KVActivityTracker'; -import {StorageService} from '../infrastructure/StorageService'; -import {Logger} from '../Logger'; -import {requireOAuth2Scope} from '../middleware/OAuth2ScopeMiddleware'; -import {getKVClient, getSnowflakeService} from '../middleware/ServiceRegistry'; -import {mapGiftDurationMonthsToFields} from '../models/GiftCode'; -import {OAuth2TokenRepository} from '../oauth/repositories/OAuth2TokenRepository'; -import {IpAuthorizationTokens, OAuth2AccessTokensByUser} from '../Tables'; -import type {HonoApp, HonoEnv} from '../types/HonoEnv'; -import {UserSearchRepository} from '../user/repositories/account/crud/UserSearchRepository'; -import {AuthSessionRepository} from '../user/repositories/auth/AuthSessionRepository'; -import type {UserDeletionScheduleUpdate} from '../user/repositories/IUserAccountRepository'; -import {UserChannelRepository} from '../user/repositories/UserChannelRepository'; -import {UserRepository} from '../user/repositories/UserRepository'; -import {processUserDeletion} from '../user/services/UserDeletionService'; -import {UserHarvestRepository} from '../user/UserHarvestRepository'; -import {getExpiryBucket} from '../utils/AttachmentDecay'; -import {parseReportedClientOs} from '../utils/SessionClientIdentity'; -import {processExpiredAttachments} from '../worker/tasks/ExpireAttachments'; -import {processInactivityDeletionsCore} from '../worker/tasks/ProcessInactivityDeletions'; -import {setWorkerDependencies} from '../worker/WorkerContext'; -import {initializeWorkerDependencies} from '../worker/WorkerDependencies'; -import {resetTestHarnessState} from './TestHarnessReset'; const TEST_EMAIL_ENDPOINT = '/test/emails'; const TEST_AUTH_HEADER = 'x-test-token'; @@ -2466,7 +2466,7 @@ export function TestHarnessController(app: HonoApp) { if (!channel) { return ctx.json({error: 'Channel not found'}, 404); } - const {getMessageSearchService} = await import('../SearchFactory'); + const {getMessageSearchService} = await import('@app/api/SearchFactory'); const searchService = getMessageSearchService(); let messagesIndexed = 0; if (searchService) { @@ -2525,7 +2525,7 @@ export function TestHarnessController(app: HonoApp) { if (!guild) { return ctx.json({error: 'Guild not found'}, 404); } - const {getGuildMemberSearchService} = await import('../SearchFactory'); + const {getGuildMemberSearchService} = await import('@app/api/SearchFactory'); const searchService = getGuildMemberSearchService(); let membersIndexed = 0; if (searchService) { diff --git a/fluxer_api/src/api/test/TestMediaService.ts b/fluxer_api/src/api/test/TestMediaService.ts index 9ddf1a8a2..1bf91b95b 100644 --- a/fluxer_api/src/api/test/TestMediaService.ts +++ b/fluxer_api/src/api/test/TestMediaService.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; -import {Config} from '../Config'; +import {Config} from '@app/api/Config'; import { IMediaService, type MediaProxyFrameRequest, type MediaProxyFrameResponse, type MediaProxyMetadataRequest, type MediaProxyMetadataResponse, -} from '../infrastructure/IMediaService'; -import type {IStorageService} from '../infrastructure/IStorageService'; +} from '@app/api/infrastructure/IMediaService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; export class TestMediaService extends IMediaService { constructor(private readonly storageService: IStorageService) { diff --git a/fluxer_api/src/api/test/TestRequestBuilder.ts b/fluxer_api/src/api/test/TestRequestBuilder.ts index f906e2c95..11b082f08 100644 --- a/fluxer_api/src/api/test/TestRequestBuilder.ts +++ b/fluxer_api/src/api/test/TestRequestBuilder.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {drainSearchTasks} from '../search/SearchTaskTracker'; -import type {ApiTestHarness} from './ApiTestHarness'; +import {drainSearchTasks} from '@app/api/search/SearchTaskTracker'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; export class TestRequestBuilder { private path: string = ''; diff --git a/fluxer_api/src/api/test/mocks/BatchRecordingKVProvider.ts b/fluxer_api/src/api/test/mocks/BatchRecordingKVProvider.ts index d7b0b937a..73d388c46 100644 --- a/fluxer_api/src/api/test/mocks/BatchRecordingKVProvider.ts +++ b/fluxer_api/src/api/test/mocks/BatchRecordingKVProvider.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; import type {IKVPipeline} from '@pkgs/kv_client/src/IKVProvider'; import {computeHashSlot} from '@pkgs/kv_client/src/KVHashSlots'; -import {MockKVProvider} from './MockKVProvider'; type BatchMode = 'multi' | 'pipeline'; diff --git a/fluxer_api/src/api/test/mocks/MockBlueskyOAuthService.ts b/fluxer_api/src/api/test/mocks/MockBlueskyOAuthService.ts index 3fe6008de..c734bfc11 100644 --- a/fluxer_api/src/api/test/mocks/MockBlueskyOAuthService.ts +++ b/fluxer_api/src/api/test/mocks/MockBlueskyOAuthService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {vi} from 'vitest'; -import type {UserID} from '../../BrandedTypes'; +import type {UserID} from '@app/api/BrandedTypes'; import type { BlueskyAuthorizeResult, BlueskyCallbackResult, IBlueskyOAuthService, -} from '../../bluesky/IBlueskyOAuthService'; +} from '@app/api/bluesky/IBlueskyOAuthService'; +import {vi} from 'vitest'; interface MockBlueskyOAuthServiceOptions { authorizeResult?: BlueskyAuthorizeResult; diff --git a/fluxer_api/src/api/test/mocks/MockSnowflakeService.ts b/fluxer_api/src/api/test/mocks/MockSnowflakeService.ts index b34520a06..0c402bfc7 100644 --- a/fluxer_api/src/api/test/mocks/MockSnowflakeService.ts +++ b/fluxer_api/src/api/test/mocks/MockSnowflakeService.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; import {createSnowflake} from '@fluxer/snowflake/src/Snowflake'; import {vi} from 'vitest'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; interface MockSnowflakeServiceConfig { initialCounter?: bigint; diff --git a/fluxer_api/src/api/test/mocks/MockStorageService.ts b/fluxer_api/src/api/test/mocks/MockStorageService.ts index 63543d291..e6cbf9cb9 100644 --- a/fluxer_api/src/api/test/mocks/MockStorageService.ts +++ b/fluxer_api/src/api/test/mocks/MockStorageService.ts @@ -3,16 +3,16 @@ import crypto, {createHash} from 'node:crypto'; import fs from 'node:fs'; import {Readable} from 'node:stream'; -import {S3ServiceException} from '@aws-sdk/client-s3'; -import {isSupportedMediaContentType} from '@pkgs/mime_utils/src/ContentTypeUtils'; -import {vi} from 'vitest'; -import {Config} from '../../Config'; +import {Config} from '@app/api/Config'; import { type IStorageService, type ProcessedStorageObjectMetadata, StorageObjectListingOverflowError, StorageObjectRangeNotSatisfiableError, -} from '../../infrastructure/IStorageService'; +} from '@app/api/infrastructure/IStorageService'; +import {S3ServiceException} from '@aws-sdk/client-s3'; +import {isSupportedMediaContentType} from '@pkgs/mime_utils/src/ContentTypeUtils'; +import {vi} from 'vitest'; const OBJECT_ID_SEPARATOR = '\u0000'; const BYTE_RANGE_PATTERN = /^bytes=(\d*)-(\d*)$/u; diff --git a/fluxer_api/src/api/test/mocks/NoopLogger.ts b/fluxer_api/src/api/test/mocks/NoopLogger.ts index 860b9b133..587690bc8 100644 --- a/fluxer_api/src/api/test/mocks/NoopLogger.ts +++ b/fluxer_api/src/api/test/mocks/NoopLogger.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ILogger} from '@app/api/ILogger'; import type {LoggerInterface} from '@fluxer/logger/src/LoggerInterface'; -import type {ILogger} from '../../ILogger'; function noop(): void {} diff --git a/fluxer_api/src/api/test/mocks/NoopUnfurlerService.ts b/fluxer_api/src/api/test/mocks/NoopUnfurlerService.ts index f81e9daf8..d5f5b7c51 100644 --- a/fluxer_api/src/api/test/mocks/NoopUnfurlerService.ts +++ b/fluxer_api/src/api/test/mocks/NoopUnfurlerService.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MediaProxyNsfwMode} from '../../infrastructure/IMediaService'; -import {IUnfurlerService, type UnfurlOptions, type UnfurlResult} from '../../infrastructure/IUnfurlerService'; +import type {MediaProxyNsfwMode} from '@app/api/infrastructure/IMediaService'; +import {IUnfurlerService, type UnfurlOptions, type UnfurlResult} from '@app/api/infrastructure/IUnfurlerService'; export class NoopUnfurlerService extends IUnfurlerService { override async unfurlWithCachePolicy( diff --git a/fluxer_api/src/api/test/mocks/RepositoryBackedMessageResponseDataService.ts b/fluxer_api/src/api/test/mocks/RepositoryBackedMessageResponseDataService.ts index 34e789973..68565740b 100644 --- a/fluxer_api/src/api/test/mocks/RepositoryBackedMessageResponseDataService.ts +++ b/fluxer_api/src/api/test/mocks/RepositoryBackedMessageResponseDataService.ts @@ -1,5 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AttachmentDecayRepository} from '@app/api/attachment/AttachmentDecayRepository'; +import {AttachmentDecayService} from '@app/api/attachment/AttachmentDecayService'; +import type {ChannelID, GuildID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import { + type MessageResponseAccessContext, + MessageResponseDataService, + messageResponseAccessForChannel, +} from '@app/api/channel/services/message/MessageResponseDataService'; +import {getChannelRepository, getUserRepository} from '@app/api/middleware/ServiceSingletons'; +import type {Attachment} from '@app/api/models/Attachment'; +import type {CallInfo} from '@app/api/models/CallInfo'; +import type {Embed} from '@app/api/models/Embed'; +import type {EmbedAuthor} from '@app/api/models/EmbedAuthor'; +import type {EmbedField} from '@app/api/models/EmbedField'; +import type {EmbedFooter} from '@app/api/models/EmbedFooter'; +import type {EmbedMedia} from '@app/api/models/EmbedMedia'; +import type {EmbedProvider} from '@app/api/models/EmbedProvider'; +import type {Message} from '@app/api/models/Message'; +import type {MessageSnapshot} from '@app/api/models/MessageSnapshot'; +import type {StickerItem} from '@app/api/models/StickerItem'; +import {mapUserToPartialResponse} from '@app/api/user/UserMappers'; +import {assertSafeByteSize} from '@app/api/utils/ByteSizeUtils'; import {MessageFlags} from '@fluxer/constants/src/ChannelConstants'; import { DELETED_USER_DISCRIMINATOR, @@ -19,30 +43,6 @@ import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResp import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import type {INatsConnectionManager} from '@pkgs/nats/src/INatsConnectionManager'; import type {NatsConnection} from 'nats'; -import {AttachmentDecayRepository} from '../../attachment/AttachmentDecayRepository'; -import {AttachmentDecayService} from '../../attachment/AttachmentDecayService'; -import type {ChannelID, GuildID, MessageID, UserID} from '../../BrandedTypes'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import { - type MessageResponseAccessContext, - MessageResponseDataService, - messageResponseAccessForChannel, -} from '../../channel/services/message/MessageResponseDataService'; -import {getChannelRepository, getUserRepository} from '../../middleware/ServiceSingletons'; -import type {Attachment} from '../../models/Attachment'; -import type {CallInfo} from '../../models/CallInfo'; -import type {Embed} from '../../models/Embed'; -import type {EmbedAuthor} from '../../models/EmbedAuthor'; -import type {EmbedField} from '../../models/EmbedField'; -import type {EmbedFooter} from '../../models/EmbedFooter'; -import type {EmbedMedia} from '../../models/EmbedMedia'; -import type {EmbedProvider} from '../../models/EmbedProvider'; -import type {Message} from '../../models/Message'; -import type {MessageSnapshot} from '../../models/MessageSnapshot'; -import type {StickerItem} from '../../models/StickerItem'; -import {mapUserToPartialResponse} from '../../user/UserMappers'; -import {assertSafeByteSize} from '../../utils/ByteSizeUtils'; class NoopNatsConnectionManager implements INatsConnectionManager { async connect(): Promise {} diff --git a/fluxer_api/src/api/test/msw/handlers/StripeApiHandlers.ts b/fluxer_api/src/api/test/msw/handlers/StripeApiHandlers.ts index ea5218c39..279f6cc86 100644 --- a/fluxer_api/src/api/test/msw/handlers/StripeApiHandlers.ts +++ b/fluxer_api/src/api/test/msw/handlers/StripeApiHandlers.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {STRIPE_API_VERSION} from '@app/api/stripe/StripeApiVersion'; import {HttpResponse, http, type RequestHandler} from 'msw'; -import {STRIPE_API_VERSION} from '../../../stripe/StripeApiVersion'; const STRIPE_API_BASE = 'https://api.stripe.com'; diff --git a/fluxer_api/src/api/test/msw/server.ts b/fluxer_api/src/api/test/msw/server.ts index f202a25c7..79407da08 100644 --- a/fluxer_api/src/api/test/msw/server.ts +++ b/fluxer_api/src/api/test/msw/server.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createBunnyEdgeHandlers} from '@app/api/test/msw/handlers/BunnyEdgeHandlers'; +import {createIpInfoLookupHandler} from '@app/api/test/msw/handlers/IpInfoHandlers'; +import {createNcmecHandlers} from '@app/api/test/msw/handlers/NcmecHandlers'; +import {createOnionooDetailsHandler} from '@app/api/test/msw/handlers/OnionooHandlers'; +import {createOpenNsfwHandlers} from '@app/api/test/msw/handlers/OpenNsfwHandlers'; +import {createPwnedPasswordsRangeHandler} from '@app/api/test/msw/handlers/PwnedPasswordsHandlers'; import {setupServer} from 'msw/node'; -import {createBunnyEdgeHandlers} from './handlers/BunnyEdgeHandlers'; -import {createIpInfoLookupHandler} from './handlers/IpInfoHandlers'; -import {createNcmecHandlers} from './handlers/NcmecHandlers'; -import {createOnionooDetailsHandler} from './handlers/OnionooHandlers'; -import {createOpenNsfwHandlers} from './handlers/OpenNsfwHandlers'; -import {createPwnedPasswordsRangeHandler} from './handlers/PwnedPasswordsHandlers'; export const server = setupServer( ...createBunnyEdgeHandlers(), diff --git a/fluxer_api/src/api/test/search/InMemorySearchProvider.ts b/fluxer_api/src/api/test/search/InMemorySearchProvider.ts index 8c180dc15..a7c58ef2b 100644 --- a/fluxer_api/src/api/test/search/InMemorySearchProvider.ts +++ b/fluxer_api/src/api/test/search/InMemorySearchProvider.ts @@ -1,5 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {AdminAuditLog} from '@app/api/admin/IAdminRepository'; +import type {ChannelID, GuildID, MessageID, ReportID, UserID} from '@app/api/BrandedTypes'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {Message} from '@app/api/models/Message'; +import type {User} from '@app/api/models/User'; +import type {IARSubmission} from '@app/api/report/IReportRepository'; +import {convertToSearchableAuditLog} from '@app/api/search/auditlog/AuditLogSearchSerializer'; +import type {GuildDiscoveryContext} from '@app/api/search/guild/GuildSearchSerializer'; +import {convertToSearchableGuild} from '@app/api/search/guild/GuildSearchSerializer'; +import {convertToSearchableGuildMember} from '@app/api/search/guild_member/GuildMemberSearchSerializer'; +import type {IAuditLogSearchService} from '@app/api/search/IAuditLogSearchService'; +import type {IGuildMemberSearchService} from '@app/api/search/IGuildMemberSearchService'; +import type {IGuildSearchService} from '@app/api/search/IGuildSearchService'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import type {IReportSearchService} from '@app/api/search/IReportSearchService'; +import type {ISearchProvider} from '@app/api/search/ISearchProvider'; +import type {IUserSearchService} from '@app/api/search/IUserSearchService'; +import {convertToSearchableMessage} from '@app/api/search/message/MessageSearchSerializer'; +import {convertToSearchableReport} from '@app/api/search/report/ReportSearchSerializer'; +import {convertToSearchableUser} from '@app/api/search/user/UserSearchSerializer'; import type {SearchOptions, SearchResult} from '@fluxer/schema/src/contracts/search/SearchAdapterTypes'; import type { AuditLogSearchFilters, @@ -15,27 +36,6 @@ import type { SearchableUser, UserSearchFilters, } from '@fluxer/schema/src/contracts/search/SearchDocumentTypes'; -import type {AdminAuditLog} from '../../admin/IAdminRepository'; -import type {ChannelID, GuildID, MessageID, ReportID, UserID} from '../../BrandedTypes'; -import type {Guild} from '../../models/Guild'; -import type {GuildMember} from '../../models/GuildMember'; -import type {Message} from '../../models/Message'; -import type {User} from '../../models/User'; -import type {IARSubmission} from '../../report/IReportRepository'; -import {convertToSearchableAuditLog} from '../../search/auditlog/AuditLogSearchSerializer'; -import type {GuildDiscoveryContext} from '../../search/guild/GuildSearchSerializer'; -import {convertToSearchableGuild} from '../../search/guild/GuildSearchSerializer'; -import {convertToSearchableGuildMember} from '../../search/guild_member/GuildMemberSearchSerializer'; -import type {IAuditLogSearchService} from '../../search/IAuditLogSearchService'; -import type {IGuildMemberSearchService} from '../../search/IGuildMemberSearchService'; -import type {IGuildSearchService} from '../../search/IGuildSearchService'; -import type {IMessageSearchService} from '../../search/IMessageSearchService'; -import type {IReportSearchService} from '../../search/IReportSearchService'; -import type {ISearchProvider} from '../../search/ISearchProvider'; -import type {IUserSearchService} from '../../search/IUserSearchService'; -import {convertToSearchableMessage} from '../../search/message/MessageSearchSerializer'; -import {convertToSearchableReport} from '../../search/report/ReportSearchSerializer'; -import {convertToSearchableUser} from '../../search/user/UserSearchSerializer'; interface SearchableDocument { id: string; diff --git a/fluxer_api/src/api/theme/ThemeController.ts b/fluxer_api/src/api/theme/ThemeController.ts index 44f642488..5746c87bd 100644 --- a/fluxer_api/src/api/theme/ThemeController.ts +++ b/fluxer_api/src/api/theme/ThemeController.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {ThemeCreateRequest, ThemeCreateResponse} from '@fluxer/schema/src/domains/theme/ThemeSchemas'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; export function ThemeController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/theme/ThemeService.ts b/fluxer_api/src/api/theme/ThemeService.ts index d141a1799..2d04dbd66 100644 --- a/fluxer_api/src/api/theme/ThemeService.ts +++ b/fluxer_api/src/api/theme/ThemeService.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomBytes} from 'node:crypto'; +import {Config} from '@app/api/Config'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; import {FileSizeTooLargeError} from '@fluxer/errors/src/domains/core/FileSizeTooLargeError'; -import {Config} from '../Config'; -import type {IStorageService} from '../infrastructure/IStorageService'; export const THEME_CSS_MAX_BYTES = 8 * 1024 * 1024; diff --git a/fluxer_api/src/api/theme/tests/ThemeAuthRequired.test.ts b/fluxer_api/src/api/theme/tests/ThemeAuthRequired.test.ts index 1493fc23b..c55a96eb0 100644 --- a/fluxer_api/src/api/theme/tests/ThemeAuthRequired.test.ts +++ b/fluxer_api/src/api/theme/tests/ThemeAuthRequired.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createFakeAuthToken} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createFakeAuthToken} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; describe('Theme authentication required', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/theme/tests/ThemeBotUserDenied.test.ts b/fluxer_api/src/api/theme/tests/ThemeBotUserDenied.test.ts index 6f5087dad..70287b8ed 100644 --- a/fluxer_api/src/api/theme/tests/ThemeBotUserDenied.test.ts +++ b/fluxer_api/src/api/theme/tests/ThemeBotUserDenied.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestBotAccount} from '@app/api/bot/tests/BotTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestBotAccount} from '../../bot/tests/BotTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('Theme bot user denied', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/theme/tests/ThemeCreation.test.ts b/fluxer_api/src/api/theme/tests/ThemeCreation.test.ts index 5697dc1ca..1d050fd8f 100644 --- a/fluxer_api/src/api/theme/tests/ThemeCreation.test.ts +++ b/fluxer_api/src/api/theme/tests/ThemeCreation.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface ThemeCreateResponse { id: string; diff --git a/fluxer_api/src/api/theme/tests/ThemeCssSizeLimit.test.ts b/fluxer_api/src/api/theme/tests/ThemeCssSizeLimit.test.ts index 6119762ff..e4731b4a0 100644 --- a/fluxer_api/src/api/theme/tests/ThemeCssSizeLimit.test.ts +++ b/fluxer_api/src/api/theme/tests/ThemeCssSizeLimit.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {getConfig} from '@app/api/Config'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {resolveThemeCssMaxBytes, setThemeCssMaxBytesForTesting, THEME_CSS_MAX_BYTES} from '@app/api/theme/ThemeService'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {getConfig} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {resolveThemeCssMaxBytes, setThemeCssMaxBytesForTesting, THEME_CSS_MAX_BYTES} from '../ThemeService'; interface ThemeCreateResponse { id: string; diff --git a/fluxer_api/src/api/theme/tests/ThemeValidation.test.ts b/fluxer_api/src/api/theme/tests/ThemeValidation.test.ts index de0839ff6..a22b01f87 100644 --- a/fluxer_api/src/api/theme/tests/ThemeValidation.test.ts +++ b/fluxer_api/src/api/theme/tests/ThemeValidation.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('Theme validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/types/AttachmentDecayTypes.ts b/fluxer_api/src/api/types/AttachmentDecayTypes.ts index 31c3a0404..34192bbeb 100644 --- a/fluxer_api/src/api/types/AttachmentDecayTypes.ts +++ b/fluxer_api/src/api/types/AttachmentDecayTypes.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AttachmentID, ChannelID, MessageID} from '../BrandedTypes'; +import type {AttachmentID, ChannelID, MessageID} from '@app/api/BrandedTypes'; export interface AttachmentDecayRow { attachment_id: AttachmentID; diff --git a/fluxer_api/src/api/types/HonoEnv.ts b/fluxer_api/src/api/types/HonoEnv.ts index 7d2907bdb..3a04f3f3b 100644 --- a/fluxer_api/src/api/types/HonoEnv.ts +++ b/fluxer_api/src/api/types/HonoEnv.ts @@ -1,91 +1,91 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {AdminService} from '@app/api/admin/AdminService'; +import type {AdminApiKeyService} from '@app/api/admin/services/AdminApiKeyService'; +import type {AdminArchiveService} from '@app/api/admin/services/AdminArchiveService'; +import type {AuthRequestService} from '@app/api/auth/AuthRequestService'; +import type {DesktopHandoffService} from '@app/api/auth/services/DesktopHandoffService'; +import type {SsoService} from '@app/api/auth/services/SsoService'; +import type {ApplicationID, UserID} from '@app/api/BrandedTypes'; +import type {IBlueskyOAuthService} from '@app/api/bluesky/IBlueskyOAuthService'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelRequestService} from '@app/api/channel/services/ChannelRequestService'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {MessageRequestService} from '@app/api/channel/services/message/MessageRequestService'; +import type {StreamPreviewService} from '@app/api/channel/services/StreamPreviewService'; +import type {StreamService} from '@app/api/channel/services/StreamService'; +import type {ConnectionRequestService} from '@app/api/connection/ConnectionRequestService'; +import type {ConnectionService} from '@app/api/connection/ConnectionService'; +import type {NcmecSubmissionService} from '@app/api/csam/NcmecSubmissionService'; +import type {DonationService} from '@app/api/donation/DonationService'; +import type {DownloadService} from '@app/api/download/DownloadService'; +import type {FavoriteMemeRequestService} from '@app/api/favorite_meme/FavoriteMemeRequestService'; +import type {FavoriteMemeService} from '@app/api/favorite_meme/FavoriteMemeService'; +import type {GatewayRequestService} from '@app/api/gateway/GatewayRequestService'; +import type {GifService} from '@app/api/gif/GifService'; +import type {IGuildDiscoveryService} from '@app/api/guild/services/GuildDiscoveryService'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {EmbedService} from '@app/api/infrastructure/EmbedService'; +import type {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import type {ErrorI18nService} from '@app/api/infrastructure/ErrorI18nService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {KVActivityTracker} from '@app/api/infrastructure/KVActivityTracker'; +import type {LiveKitWebhookService} from '@app/api/infrastructure/LiveKitWebhookService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {InstanceConfigRepository} from '@app/api/instance/InstanceConfigRepository'; +import type {SingleCommunityService} from '@app/api/instance/SingleCommunityService'; +import type {InviteRequestService} from '@app/api/invite/InviteRequestService'; +import type {InviteService} from '@app/api/invite/InviteService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {OpenAPIRouteMetadata} from '@app/api/middleware/ResponseTypeMiddleware'; +import type {AuthSession} from '@app/api/models/AuthSession'; +import type {User} from '@app/api/models/User'; +import type {ApplicationService} from '@app/api/oauth/ApplicationService'; +import type {BotAuthService} from '@app/api/oauth/BotAuthService'; +import type {OAuth2ApplicationsRequestService} from '@app/api/oauth/OAuth2ApplicationsRequestService'; +import type {OAuth2RequestService} from '@app/api/oauth/OAuth2RequestService'; +import type {OAuth2Service} from '@app/api/oauth/OAuth2Service'; +import type {IApplicationRepository} from '@app/api/oauth/repositories/IApplicationRepository'; +import type {IOAuth2TokenRepository} from '@app/api/oauth/repositories/IOAuth2TokenRepository'; +import type {ReadStateRequestService} from '@app/api/read_state/ReadStateRequestService'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import type {ReportRequestService} from '@app/api/report/ReportRequestService'; +import type {ReportService} from '@app/api/report/ReportService'; +import type {RpcService} from '@app/api/rpc/RpcService'; +import type {SearchService} from '@app/api/search/SearchService'; +import type {StripeService} from '@app/api/stripe/StripeService'; +import type {AgeVerificationService} from '@app/api/stripe/services/AgeVerificationService'; +import type {ThemeService} from '@app/api/theme/ThemeService'; +import type {EntranceSoundPlayService} from '@app/api/user/entrance_sound/EntranceSoundPlayService'; +import type {EntranceSoundService} from '@app/api/user/entrance_sound/EntranceSoundService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {EmailChangeService} from '@app/api/user/services/EmailChangeService'; +import type {MfaBackupCodesChallengeService} from '@app/api/user/services/MfaBackupCodesChallengeService'; +import type {PasswordChangeService} from '@app/api/user/services/PasswordChangeService'; +import type {UserAccountRequestService} from '@app/api/user/services/UserAccountRequestService'; +import type {UserActivityBuffer} from '@app/api/user/services/UserActivityBuffer'; +import type {UserAuthRequestService} from '@app/api/user/services/UserAuthRequestService'; +import type {UserChannelRequestService} from '@app/api/user/services/UserChannelRequestService'; +import type {UserContactChangeLogService} from '@app/api/user/services/UserContactChangeLogService'; +import type {UserContentRequestService} from '@app/api/user/services/UserContentRequestService'; +import type {UserRelationshipRequestService} from '@app/api/user/services/UserRelationshipRequestService'; +import type {UserService} from '@app/api/user/services/UserService'; +import type {ClientIpResolution} from '@app/api/utils/RequestClientIp'; +import type {SweegoWebhookService} from '@app/api/webhook/SweegoWebhookService'; +import type {WebhookRequestService} from '@app/api/webhook/WebhookRequestService'; +import type {WebhookService} from '@app/api/webhook/WebhookService'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {IEmailService} from '@pkgs/email/src/IEmailService'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import type {Hono} from 'hono'; import type {ZodType} from 'zod'; -import type {ApiContext} from '../ApiContext'; -import type {AdminService} from '../admin/AdminService'; -import type {AdminApiKeyService} from '../admin/services/AdminApiKeyService'; -import type {AdminArchiveService} from '../admin/services/AdminArchiveService'; -import type {AuthRequestService} from '../auth/AuthRequestService'; -import type {DesktopHandoffService} from '../auth/services/DesktopHandoffService'; -import type {SsoService} from '../auth/services/SsoService'; -import type {ApplicationID, UserID} from '../BrandedTypes'; -import type {IBlueskyOAuthService} from '../bluesky/IBlueskyOAuthService'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import type {ChannelRequestService} from '../channel/services/ChannelRequestService'; -import type {ChannelService} from '../channel/services/ChannelService'; -import type {MessageRequestService} from '../channel/services/message/MessageRequestService'; -import type {StreamPreviewService} from '../channel/services/StreamPreviewService'; -import type {StreamService} from '../channel/services/StreamService'; -import type {ConnectionRequestService} from '../connection/ConnectionRequestService'; -import type {ConnectionService} from '../connection/ConnectionService'; -import type {NcmecSubmissionService} from '../csam/NcmecSubmissionService'; -import type {DonationService} from '../donation/DonationService'; -import type {DownloadService} from '../download/DownloadService'; -import type {FavoriteMemeRequestService} from '../favorite_meme/FavoriteMemeRequestService'; -import type {FavoriteMemeService} from '../favorite_meme/FavoriteMemeService'; -import type {GatewayRequestService} from '../gateway/GatewayRequestService'; -import type {GifService} from '../gif/GifService'; -import type {IGuildDiscoveryService} from '../guild/services/GuildDiscoveryService'; -import type {GuildService} from '../guild/services/GuildService'; -import type {EmbedService} from '../infrastructure/EmbedService'; -import type {EntityAssetService} from '../infrastructure/EntityAssetService'; -import type {ErrorI18nService} from '../infrastructure/ErrorI18nService'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {IMediaService} from '../infrastructure/IMediaService'; -import type {ISnowflakeService} from '../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../infrastructure/IStorageService'; -import type {KVActivityTracker} from '../infrastructure/KVActivityTracker'; -import type {LiveKitWebhookService} from '../infrastructure/LiveKitWebhookService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {InstanceConfigRepository} from '../instance/InstanceConfigRepository'; -import type {SingleCommunityService} from '../instance/SingleCommunityService'; -import type {InviteRequestService} from '../invite/InviteRequestService'; -import type {InviteService} from '../invite/InviteService'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {OpenAPIRouteMetadata} from '../middleware/ResponseTypeMiddleware'; -import type {AuthSession} from '../models/AuthSession'; -import type {User} from '../models/User'; -import type {ApplicationService} from '../oauth/ApplicationService'; -import type {BotAuthService} from '../oauth/BotAuthService'; -import type {OAuth2ApplicationsRequestService} from '../oauth/OAuth2ApplicationsRequestService'; -import type {OAuth2RequestService} from '../oauth/OAuth2RequestService'; -import type {OAuth2Service} from '../oauth/OAuth2Service'; -import type {IApplicationRepository} from '../oauth/repositories/IApplicationRepository'; -import type {IOAuth2TokenRepository} from '../oauth/repositories/IOAuth2TokenRepository'; -import type {ReadStateRequestService} from '../read_state/ReadStateRequestService'; -import type {ReadStateService} from '../read_state/ReadStateService'; -import type {ReportRequestService} from '../report/ReportRequestService'; -import type {ReportService} from '../report/ReportService'; -import type {RpcService} from '../rpc/RpcService'; -import type {SearchService} from '../search/SearchService'; -import type {StripeService} from '../stripe/StripeService'; -import type {AgeVerificationService} from '../stripe/services/AgeVerificationService'; -import type {ThemeService} from '../theme/ThemeService'; -import type {EntranceSoundPlayService} from '../user/entrance_sound/EntranceSoundPlayService'; -import type {EntranceSoundService} from '../user/entrance_sound/EntranceSoundService'; -import type {IUserRepository} from '../user/IUserRepository'; -import type {EmailChangeService} from '../user/services/EmailChangeService'; -import type {MfaBackupCodesChallengeService} from '../user/services/MfaBackupCodesChallengeService'; -import type {PasswordChangeService} from '../user/services/PasswordChangeService'; -import type {UserAccountRequestService} from '../user/services/UserAccountRequestService'; -import type {UserActivityBuffer} from '../user/services/UserActivityBuffer'; -import type {UserAuthRequestService} from '../user/services/UserAuthRequestService'; -import type {UserChannelRequestService} from '../user/services/UserChannelRequestService'; -import type {UserContactChangeLogService} from '../user/services/UserContactChangeLogService'; -import type {UserContentRequestService} from '../user/services/UserContentRequestService'; -import type {UserRelationshipRequestService} from '../user/services/UserRelationshipRequestService'; -import type {UserService} from '../user/services/UserService'; -import type {ClientIpResolution} from '../utils/RequestClientIp'; -import type {SweegoWebhookService} from '../webhook/SweegoWebhookService'; -import type {WebhookRequestService} from '../webhook/WebhookRequestService'; -import type {WebhookService} from '../webhook/WebhookService'; -import type {WorkerTaskName} from '../worker/WorkerLaneConfig'; export interface HonoEnv { Variables: { diff --git a/fluxer_api/src/api/unfurl/UnfurlController.ts b/fluxer_api/src/api/unfurl/UnfurlController.ts index 80ad21994..a860b49f6 100644 --- a/fluxer_api/src/api/unfurl/UnfurlController.ts +++ b/fluxer_api/src/api/unfurl/UnfurlController.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {getUnfurlerService} from '@app/api/middleware/ServiceSingletons'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {UnfurlRequest, UnfurlResponse} from '@fluxer/schema/src/domains/unfurl/UnfurlSchemas'; -import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {getUnfurlerService} from '../middleware/ServiceSingletons'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp} from '../types/HonoEnv'; -import {Validator} from '../Validator'; export function UnfurlController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/unfurl/tests/UnfurlController.test.ts b/fluxer_api/src/api/unfurl/tests/UnfurlController.test.ts index ea8fd4135..2af7ab47d 100644 --- a/fluxer_api/src/api/unfurl/tests/UnfurlController.test.ts +++ b/fluxer_api/src/api/unfurl/tests/UnfurlController.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import type {MediaProxyNsfwMode} from '@app/api/infrastructure/IMediaService'; +import {IUnfurlerService, type UnfurlOptions, type UnfurlResult} from '@app/api/infrastructure/IUnfurlerService'; +import {setInjectedUnfurlerService} from '@app/api/middleware/ServiceSingletons'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import type {MessageEmbedResponse} from '@fluxer/schema/src/domains/message/EmbedSchemas'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import type {MediaProxyNsfwMode} from '../../infrastructure/IMediaService'; -import {IUnfurlerService, type UnfurlOptions, type UnfurlResult} from '../../infrastructure/IUnfurlerService'; -import {setInjectedUnfurlerService} from '../../middleware/ServiceSingletons'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; class RecordingUnfurlerService extends IUnfurlerService { readonly calls: Array<{url: string; nsfwMode?: MediaProxyNsfwMode; options: UnfurlOptions}> = []; diff --git a/fluxer_api/src/api/user/FluxerTagChangeRateLimit.ts b/fluxer_api/src/api/user/FluxerTagChangeRateLimit.ts index 367edfcc8..84653a86b 100644 --- a/fluxer_api/src/api/user/FluxerTagChangeRateLimit.ts +++ b/fluxer_api/src/api/user/FluxerTagChangeRateLimit.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {getRetryAfterSeconds} from '@app/api/utils/RateLimitUtils'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; import {ms} from 'itty-time'; -import type {UserID} from '../BrandedTypes'; -import {getRetryAfterSeconds} from '../utils/RateLimitUtils'; const FLUXER_TAG_CHANGE_MAX_ATTEMPTS = 5; const FLUXER_TAG_CHANGE_WINDOW_MS = ms('3 hours'); diff --git a/fluxer_api/src/api/user/IUserRepository.ts b/fluxer_api/src/api/user/IUserRepository.ts index 921523301..bd74efa80 100644 --- a/fluxer_api/src/api/user/IUserRepository.ts +++ b/fluxer_api/src/api/user/IUserRepository.ts @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IUserRepositoryAggregate} from './repositories/IUserRepositoryAggregate'; +import type {IUserRepositoryAggregate} from '@app/api/user/repositories/IUserRepositoryAggregate'; export interface IUserRepository extends IUserRepositoryAggregate {} diff --git a/fluxer_api/src/api/user/UserCacheHelpers.ts b/fluxer_api/src/api/user/UserCacheHelpers.ts index 93ec2c0ff..0b37fcc9b 100644 --- a/fluxer_api/src/api/user/UserCacheHelpers.ts +++ b/fluxer_api/src/api/user/UserCacheHelpers.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import type {UserID} from '../BrandedTypes'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {User} from '../models/User'; export async function getCachedUserPartialResponse(params: { userId: UserID; diff --git a/fluxer_api/src/api/user/UserHarvestModel.ts b/fluxer_api/src/api/user/UserHarvestModel.ts index 60b38bbcd..116264a47 100644 --- a/fluxer_api/src/api/user/UserHarvestModel.ts +++ b/fluxer_api/src/api/user/UserHarvestModel.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {UserHarvestRow} from '@app/api/database/types/UserTypes'; import type {HarvestStatus, HarvestStatusResponse} from '@fluxer/schema/src/domains/user/UserHarvestSchemas'; -import type {UserID} from '../BrandedTypes'; -import type {UserHarvestRow} from '../database/types/UserTypes'; export class UserHarvest { userId: UserID; diff --git a/fluxer_api/src/api/user/UserHarvestRepository.ts b/fluxer_api/src/api/user/UserHarvestRepository.ts index ff01e187f..ecd866d22 100644 --- a/fluxer_api/src/api/user/UserHarvestRepository.ts +++ b/fluxer_api/src/api/user/UserHarvestRepository.ts @@ -2,15 +2,15 @@ import assert from 'node:assert/strict'; import {randomUUID} from 'node:crypto'; +import {ArchiveAttemptSupersededError} from '@app/api/archive/ArchiveAttemptSupersededError'; +import type {UserID} from '@app/api/BrandedTypes'; +import {executeConditional, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {Db, type DbOp} from '@app/api/database/CassandraTypes'; +import type {UserHarvestRow} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import {UserHarvests} from '@app/api/Tables'; +import {UserHarvest} from '@app/api/user/UserHarvestModel'; import {UnknownHarvestError} from '@fluxer/errors/src/domains/moderation/UnknownHarvestError'; -import {ArchiveAttemptSupersededError} from '../archive/ArchiveAttemptSupersededError'; -import type {UserID} from '../BrandedTypes'; -import {executeConditional, fetchMany, fetchOne} from '../database/CassandraQueryExecution'; -import {Db, type DbOp} from '../database/CassandraTypes'; -import type {UserHarvestRow} from '../database/types/UserTypes'; -import {Logger} from '../Logger'; -import {UserHarvests} from '../Tables'; -import {UserHarvest} from './UserHarvestModel'; const FIND_HARVEST_CQL = UserHarvests.selectCql({ where: [UserHarvests.where.eq('user_id'), UserHarvests.where.eq('harvest_id')], diff --git a/fluxer_api/src/api/user/UserHelpers.test.ts b/fluxer_api/src/api/user/UserHelpers.test.ts index 816681c8c..80dc9ae82 100644 --- a/fluxer_api/src/api/user/UserHelpers.test.ts +++ b/fluxer_api/src/api/user/UserHelpers.test.ts @@ -1,5 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {User} from '@app/api/models/User'; +import {setInjectedAccountPolicyEvaluator} from '@app/api/risk/AccountPolicyService'; +import {setCachedDeferredPhoneGateEnabled} from '@app/api/risk/DeferredPhoneGateCache'; +import { + createCurrentBehaviorTestAccountPolicyEvaluator, + TEST_POLICY_CONTACT_DOMAIN, + TEST_POLICY_CONTACT_SUBDOMAIN, +} from '@app/api/test/AccountPolicyTestEvaluator'; +import { + checkIsPremium, + getEffectivePremiumUntil, + getEffectiveSuspiciousFlags, + getRequiredActions, +} from '@app/api/user/UserHelpers'; import { DEFERRED_PHONE_ON_COMMUNITY_JOIN, imposePhoneRequirements, @@ -9,15 +23,6 @@ import { UserPremiumTypes, } from '@fluxer/constants/src/UserConstants'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import type {User} from '../models/User'; -import {setInjectedAccountPolicyEvaluator} from '../risk/AccountPolicyService'; -import {setCachedDeferredPhoneGateEnabled} from '../risk/DeferredPhoneGateCache'; -import { - createCurrentBehaviorTestAccountPolicyEvaluator, - TEST_POLICY_CONTACT_DOMAIN, - TEST_POLICY_CONTACT_SUBDOMAIN, -} from '../test/AccountPolicyTestEvaluator'; -import {checkIsPremium, getEffectivePremiumUntil, getEffectiveSuspiciousFlags, getRequiredActions} from './UserHelpers'; function createUser( overrides: Partial> = {}, diff --git a/fluxer_api/src/api/user/UserHelpers.ts b/fluxer_api/src/api/user/UserHelpers.ts index c9d03cfed..37b2fe17a 100644 --- a/fluxer_api/src/api/user/UserHelpers.ts +++ b/fluxer_api/src/api/user/UserHelpers.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {getCachedInstancePremiumMode} from '@app/api/limits/InstancePremiumModeCache'; +import type {User} from '@app/api/models/User'; +import {accountPolicyContactHasCapability} from '@app/api/risk/AccountPolicyService'; +import {getCachedDeferredPhoneGateEnabled} from '@app/api/risk/DeferredPhoneGateCache'; import { DEFERRABLE_PHONE_FLAGS, DEFERRED_PHONE_ON_COMMUNITY_JOIN, @@ -9,12 +15,6 @@ import { } from '@fluxer/constants/src/UserConstants'; import type {RequiredAction} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {ms} from 'itty-time'; -import {Config} from '../Config'; -import type {UserRow} from '../database/types/UserTypes'; -import {getCachedInstancePremiumMode} from '../limits/InstancePremiumModeCache'; -import type {User} from '../models/User'; -import {accountPolicyContactHasCapability} from '../risk/AccountPolicyService'; -import {getCachedDeferredPhoneGateEnabled} from '../risk/DeferredPhoneGateCache'; type ClauseAction = Exclude; type VerificationChannel = 'email' | 'phone'; diff --git a/fluxer_api/src/api/user/UserMappers.ts b/fluxer_api/src/api/user/UserMappers.ts index 9a3f04b1a..548b3c08d 100644 --- a/fluxer_api/src/api/user/UserMappers.ts +++ b/fluxer_api/src/api/user/UserMappers.ts @@ -1,5 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID, type UserID} from '@app/api/BrandedTypes'; +import {stripAvatarForUser, stripBannerForUser} from '@app/api/infrastructure/AssetEntitlementUtils'; +import type {GuildChannelOverride} from '@app/api/models/GuildChannelOverride'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {MuteConfiguration} from '@app/api/models/MuteConfiguration'; +import type {Relationship} from '@app/api/models/Relationship'; +import type {User} from '@app/api/models/User'; +import type {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import type {UserSettings} from '@app/api/models/UserSettings'; +import {canUseProfileTimezone, getRequiredActions} from '@app/api/user/UserHelpers'; +import {canUserAccessNsfwContent} from '@app/api/utils/AgeUtils'; import type {ChannelMessageNotifications} from '@fluxer/constants/src/NotificationConstants'; import { DEFAULT_GUILD_FOLDER_ICON, @@ -23,17 +34,6 @@ import type { UserProfileResponse, UserSettingsResponse, } from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import {createGuildID, type UserID} from '../BrandedTypes'; -import {stripAvatarForUser, stripBannerForUser} from '../infrastructure/AssetEntitlementUtils'; -import type {GuildChannelOverride} from '../models/GuildChannelOverride'; -import type {GuildMember} from '../models/GuildMember'; -import type {MuteConfiguration} from '../models/MuteConfiguration'; -import type {Relationship} from '../models/Relationship'; -import type {User} from '../models/User'; -import type {UserGuildSettings} from '../models/UserGuildSettings'; -import type {UserSettings} from '../models/UserSettings'; -import {canUserAccessNsfwContent} from '../utils/AgeUtils'; -import {canUseProfileTimezone, getRequiredActions} from './UserHelpers'; const PUBLIC_USER_FLAGS_WITHOUT_STAFF = PUBLIC_USER_FLAGS & ~UserFlags.STAFF; diff --git a/fluxer_api/src/api/user/UserTraits.test.ts b/fluxer_api/src/api/user/UserTraits.test.ts index 3769a2afe..86742eb89 100644 --- a/fluxer_api/src/api/user/UserTraits.test.ts +++ b/fluxer_api/src/api/user/UserTraits.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isDerivedTrait, isServerManagedTrait, resolveAssignedTraits} from '@app/api/user/UserTraits'; import {describe, expect, it} from 'vitest'; -import {isDerivedTrait, isServerManagedTrait, resolveAssignedTraits} from './UserTraits'; describe('UserTraits', () => { it('treats premium as derived rather than assignable', () => { diff --git a/fluxer_api/src/api/user/controllers/UserAccountController.ts b/fluxer_api/src/api/user/controllers/UserAccountController.ts index 589db2ad9..94fbdb13b 100644 --- a/fluxer_api/src/api/user/controllers/UserAccountController.ts +++ b/fluxer_api/src/api/user/controllers/UserAccountController.ts @@ -1,5 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import * as AuthSession from '@app/api/auth/AuthSession'; +import {requireSudoMode} from '@app/api/auth/services/SudoVerificationService'; +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {DefaultUserOnly, LoginRequired, LoginRequiredAllowSuspicious} from '@app/api/middleware/AuthMiddleware'; +import {requireOAuth2ScopeForBearer} from '@app/api/middleware/OAuth2ScopeMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {SudoModeMiddleware} from '@app/api/middleware/SudoModeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {getCachedUserPartialResponse} from '@app/api/user/UserCacheHelpers'; +import { + mapUserGuildSettingsToResponse, + mapUserSettingsToResponse, + mapUserToPrivateResponse, +} from '@app/api/user/UserMappers'; +import {Validator} from '@app/api/Validator'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {MissingAccessError} from '@fluxer/errors/src/domains/core/MissingAccessError'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; @@ -62,19 +79,6 @@ import { UserTagCheckResponse, } from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {uint8ArrayToBase64} from 'uint8array-extras'; -import * as AuthSession from '../../auth/AuthSession'; -import {requireSudoMode} from '../../auth/services/SudoVerificationService'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import {DefaultUserOnly, LoginRequired, LoginRequiredAllowSuspicious} from '../../middleware/AuthMiddleware'; -import {requireOAuth2ScopeForBearer} from '../../middleware/OAuth2ScopeMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {SudoModeMiddleware} from '../../middleware/SudoModeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; -import {getCachedUserPartialResponse} from '../UserCacheHelpers'; -import {mapUserGuildSettingsToResponse, mapUserSettingsToResponse, mapUserToPrivateResponse} from '../UserMappers'; export function UserAccountController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/user/controllers/UserAuthController.ts b/fluxer_api/src/api/user/controllers/UserAuthController.ts index 5edb572cb..f5ddcb5a8 100644 --- a/fluxer_api/src/api/user/controllers/UserAuthController.ts +++ b/fluxer_api/src/api/user/controllers/UserAuthController.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireSudoMode} from '@app/api/auth/services/SudoVerificationService'; +import {Config} from '@app/api/Config'; +import {DefaultUserOnly, LoginRequired, LoginRequiredAllowSuspicious} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {SudoModeMiddleware} from '@app/api/middleware/SudoModeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {requireClientIp} from '@fluxer/ip_utils/src/ClientIp'; import { DisableTotpRequest, @@ -25,15 +34,6 @@ import { } from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {CredentialIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import {EmptyBodyRequest} from '@fluxer/schema/src/domains/user/UserRequestSchemas'; -import {requireSudoMode} from '../../auth/services/SudoVerificationService'; -import {Config} from '../../Config'; -import {DefaultUserOnly, LoginRequired, LoginRequiredAllowSuspicious} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {SudoModeMiddleware} from '../../middleware/SudoModeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function UserAuthController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/user/controllers/UserChannelController.ts b/fluxer_api/src/api/user/controllers/UserChannelController.ts index 2a5060836..7521c5337 100644 --- a/fluxer_api/src/api/user/controllers/UserChannelController.ts +++ b/fluxer_api/src/api/user/controllers/UserChannelController.ts @@ -1,19 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID} from '@app/api/BrandedTypes'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {GroupDmCreateProtectionMiddleware} from '@app/api/middleware/GroupDmProtectionMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {DirectMessagesDisabledError} from '@fluxer/errors/src/domains/channel/DirectMessagesDisabledError'; import {ChannelListResponse, ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import {ChannelIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import {CreatePrivateChannelRequest} from '@fluxer/schema/src/domains/user/UserRequestSchemas'; -import {createChannelID} from '../../BrandedTypes'; -import {LoginRequired} from '../../middleware/AuthMiddleware'; -import {GroupDmCreateProtectionMiddleware} from '../../middleware/GroupDmProtectionMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; - export function UserChannelController(app: HonoApp) { app.get( '/users/@me/channels', diff --git a/fluxer_api/src/api/user/controllers/UserContentController.ts b/fluxer_api/src/api/user/controllers/UserContentController.ts index b96d84b78..f5db7a11d 100644 --- a/fluxer_api/src/api/user/controllers/UserContentController.ts +++ b/fluxer_api/src/api/user/controllers/UserContentController.ts @@ -1,6 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {Readable} from 'node:stream'; +import {createChannelID, createMessageID} from '@app/api/BrandedTypes'; +import {StorageObjectRangeNotSatisfiableError} from '@app/api/infrastructure/IStorageService'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {HarvestIdParam, MessageIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import {MessageListResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import { @@ -18,14 +26,6 @@ import { UserSavedMessagesQueryRequest, } from '@fluxer/schema/src/domains/user/UserRequestSchemas'; import {SavedMessageEntryListResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import {createChannelID, createMessageID} from '../../BrandedTypes'; -import {StorageObjectRangeNotSatisfiableError} from '../../infrastructure/IStorageService'; -import {DefaultUserOnly, LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; export function UserContentController(app: HonoApp) { app.get( diff --git a/fluxer_api/src/api/user/controllers/UserController.ts b/fluxer_api/src/api/user/controllers/UserController.ts index 07486f153..c2b33ebf3 100644 --- a/fluxer_api/src/api/user/controllers/UserController.ts +++ b/fluxer_api/src/api/user/controllers/UserController.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {HonoApp} from '../../types/HonoEnv'; -import {EntranceSoundController} from '../entrance_sound/EntranceSoundController'; -import {EntranceSoundPlayController} from '../entrance_sound/EntranceSoundPlayController'; -import {UserAccountController} from './UserAccountController'; -import {UserAuthController} from './UserAuthController'; -import {UserChannelController} from './UserChannelController'; -import {UserContentController} from './UserContentController'; -import {UserRelationshipController} from './UserRelationshipController'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {UserAccountController} from '@app/api/user/controllers/UserAccountController'; +import {UserAuthController} from '@app/api/user/controllers/UserAuthController'; +import {UserChannelController} from '@app/api/user/controllers/UserChannelController'; +import {UserContentController} from '@app/api/user/controllers/UserContentController'; +import {UserRelationshipController} from '@app/api/user/controllers/UserRelationshipController'; +import {EntranceSoundController} from '@app/api/user/entrance_sound/EntranceSoundController'; +import {EntranceSoundPlayController} from '@app/api/user/entrance_sound/EntranceSoundPlayController'; export function UserController(app: HonoApp) { UserAccountController(app); diff --git a/fluxer_api/src/api/user/controllers/UserRelationshipController.ts b/fluxer_api/src/api/user/controllers/UserRelationshipController.ts index aa2209f1b..c1f0ea58b 100644 --- a/fluxer_api/src/api/user/controllers/UserRelationshipController.ts +++ b/fluxer_api/src/api/user/controllers/UserRelationshipController.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import {Validator} from '@app/api/Validator'; import {UserIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import { BulkIgnoreFriendRequestsRequest, @@ -14,14 +21,6 @@ import { RelationshipResponse, } from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import {createUserID} from '../../BrandedTypes'; -import {DefaultUserOnly, LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; - export function UserRelationshipController(app: HonoApp) { app.get( '/users/@me/relationships', diff --git a/fluxer_api/src/api/user/entrance_sound/EntranceSoundController.ts b/fluxer_api/src/api/user/entrance_sound/EntranceSoundController.ts index 19e924dba..824f8d167 100644 --- a/fluxer_api/src/api/user/entrance_sound/EntranceSoundController.ts +++ b/fluxer_api/src/api/user/entrance_sound/EntranceSoundController.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createEntranceSoundID} from '@app/api/BrandedTypes'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import type {EntranceSoundSelection} from '@app/api/models/EntranceSound'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import type {EntranceSoundLibraryEntry, EntranceSoundService} from '@app/api/user/entrance_sound/EntranceSoundService'; +import {Validator} from '@app/api/Validator'; import { EntranceSoundIdParam, EntranceSoundLibraryResponse, @@ -8,15 +17,6 @@ import { EntranceSoundSelectionRequest, EntranceSoundUploadRequest, } from '@fluxer/schema/src/domains/user/EntranceSoundSchemas'; -import {createEntranceSoundID} from '../../BrandedTypes'; -import {DefaultUserOnly, LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import type {EntranceSoundSelection} from '../../models/EntranceSound'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; -import type {EntranceSoundLibraryEntry, EntranceSoundService} from './EntranceSoundService'; function serializeSound(entry: EntranceSoundLibraryEntry) { return { diff --git a/fluxer_api/src/api/user/entrance_sound/EntranceSoundDurationProbe.ts b/fluxer_api/src/api/user/entrance_sound/EntranceSoundDurationProbe.ts index 5f738fe3b..c88f9041a 100644 --- a/fluxer_api/src/api/user/entrance_sound/EntranceSoundDurationProbe.ts +++ b/fluxer_api/src/api/user/entrance_sound/EntranceSoundDurationProbe.ts @@ -3,10 +3,10 @@ import {execFile} from 'node:child_process'; import fs from 'node:fs/promises'; import {promisify} from 'node:util'; +import {Logger} from '@app/api/Logger'; +import {isJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; import type {EntranceSoundExtension} from '@fluxer/constants/src/EntranceSoundConstants'; import {temporaryFile} from 'tempy'; -import {Logger} from '../../Logger'; -import {isJsonRecord, parseJsonWithGuard} from '../../utils/JsonBoundaryUtils'; const execFilePromise = promisify(execFile); const FFPROBE_TIMEOUT_MS = 5_000; diff --git a/fluxer_api/src/api/user/entrance_sound/EntranceSoundPlayController.ts b/fluxer_api/src/api/user/entrance_sound/EntranceSoundPlayController.ts index fb17863c1..33f1bee7c 100644 --- a/fluxer_api/src/api/user/entrance_sound/EntranceSoundPlayController.ts +++ b/fluxer_api/src/api/user/entrance_sound/EntranceSoundPlayController.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createEntranceSoundID} from '@app/api/BrandedTypes'; +import {DefaultUserOnly, LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp} from '@app/api/types/HonoEnv'; +import type {EntranceSoundPlayService} from '@app/api/user/entrance_sound/EntranceSoundPlayService'; +import {Validator} from '@app/api/Validator'; import {ChannelIdParam} from '@fluxer/schema/src/domains/common/CommonParamSchemas'; import {EntranceSoundPlayRequest} from '@fluxer/schema/src/domains/user/EntranceSoundSchemas'; -import {createChannelID, createEntranceSoundID} from '../../BrandedTypes'; -import {DefaultUserOnly, LoginRequired} from '../../middleware/AuthMiddleware'; -import {RateLimitMiddleware} from '../../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../../RateLimitConfig'; -import type {HonoApp} from '../../types/HonoEnv'; -import {Validator} from '../../Validator'; -import type {EntranceSoundPlayService} from './EntranceSoundPlayService'; export function EntranceSoundPlayController(app: HonoApp) { app.post( diff --git a/fluxer_api/src/api/user/entrance_sound/EntranceSoundPlayService.ts b/fluxer_api/src/api/user/entrance_sound/EntranceSoundPlayService.ts index 2167d40b2..295c7d625 100644 --- a/fluxer_api/src/api/user/entrance_sound/EntranceSoundPlayService.ts +++ b/fluxer_api/src/api/user/entrance_sound/EntranceSoundPlayService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createUserID, type EntranceSoundID, type UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import type {EntranceSoundService} from '@app/api/user/entrance_sound/EntranceSoundService'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; -import {type ChannelID, createUserID, type EntranceSoundID, type UserID} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import {Logger} from '../../Logger'; -import type {EntranceSoundService} from './EntranceSoundService'; interface PlayEntranceSoundParams { userId: UserID; diff --git a/fluxer_api/src/api/user/entrance_sound/EntranceSoundRepository.ts b/fluxer_api/src/api/user/entrance_sound/EntranceSoundRepository.ts index 12a26c3d4..daae8252b 100644 --- a/fluxer_api/src/api/user/entrance_sound/EntranceSoundRepository.ts +++ b/fluxer_api/src/api/user/entrance_sound/EntranceSoundRepository.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {EntranceSoundID, UserID} from '../../BrandedTypes'; -import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import type {UserEntranceSoundRow, UserEntranceSoundSelectionRow} from '../../database/types/UserTypes'; -import {EntranceSound, EntranceSoundSelection} from '../../models/EntranceSound'; -import {UserEntranceSoundSelections, UserEntranceSounds} from '../../Tables'; +import type {EntranceSoundID, UserID} from '@app/api/BrandedTypes'; +import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {UserEntranceSoundRow, UserEntranceSoundSelectionRow} from '@app/api/database/types/UserTypes'; +import {EntranceSound, EntranceSoundSelection} from '@app/api/models/EntranceSound'; +import {UserEntranceSoundSelections, UserEntranceSounds} from '@app/api/Tables'; const LIST_SOUNDS_CQL = UserEntranceSounds.select({ where: UserEntranceSounds.where.eq('user_id'), diff --git a/fluxer_api/src/api/user/entrance_sound/EntranceSoundService.test.ts b/fluxer_api/src/api/user/entrance_sound/EntranceSoundService.test.ts index 076cfd821..2d2aa245c 100644 --- a/fluxer_api/src/api/user/entrance_sound/EntranceSoundService.test.ts +++ b/fluxer_api/src/api/user/entrance_sound/EntranceSoundService.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type EntranceSoundID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {EntranceSound} from '@app/api/models/EntranceSound'; +import type {EntranceSoundRepository} from '@app/api/user/entrance_sound/EntranceSoundRepository'; +import {EntranceSoundService} from '@app/api/user/entrance_sound/EntranceSoundService'; import {describe, expect, it, vi} from 'vitest'; -import {createUserID, type EntranceSoundID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {IMediaService} from '../../infrastructure/IMediaService'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import type {EntranceSound} from '../../models/EntranceSound'; -import type {EntranceSoundRepository} from './EntranceSoundRepository'; -import {EntranceSoundService} from './EntranceSoundService'; const USER_ID = createUserID(1234567890123456n); diff --git a/fluxer_api/src/api/user/entrance_sound/EntranceSoundService.ts b/fluxer_api/src/api/user/entrance_sound/EntranceSoundService.ts index 1560d34f2..f0b8e9c3a 100644 --- a/fluxer_api/src/api/user/entrance_sound/EntranceSoundService.ts +++ b/fluxer_api/src/api/user/entrance_sound/EntranceSoundService.ts @@ -1,6 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; +import {createEntranceSoundID, type EntranceSoundID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import {EntranceSound, EntranceSoundSelection} from '@app/api/models/EntranceSound'; +import {resolveEntranceSoundDurationMs} from '@app/api/user/entrance_sound/EntranceSoundDurationProbe'; +import type {EntranceSoundRepository} from '@app/api/user/entrance_sound/EntranceSoundRepository'; import { ENTRANCE_SOUND_EXT_TO_MIME, ENTRANCE_SOUND_MAX_BYTES, @@ -16,14 +24,6 @@ import { import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {generateSnowflake} from '@fluxer/snowflake/src/Snowflake'; -import {createEntranceSoundID, type EntranceSoundID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {IMediaService} from '../../infrastructure/IMediaService'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {Logger} from '../../Logger'; -import {EntranceSound, EntranceSoundSelection} from '../../models/EntranceSound'; -import {resolveEntranceSoundDurationMs} from './EntranceSoundDurationProbe'; -import type {EntranceSoundRepository} from './EntranceSoundRepository'; interface UploadEntranceSoundParams { userId: UserID; diff --git a/fluxer_api/src/api/user/repositories/GiftCodeRepository.ts b/fluxer_api/src/api/user/repositories/GiftCodeRepository.ts index a7e54e26f..9ecb78ca0 100644 --- a/fluxer_api/src/api/user/repositories/GiftCodeRepository.ts +++ b/fluxer_api/src/api/user/repositories/GiftCodeRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import {Db, type DbOp} from '../../database/CassandraTypes'; -import type {GiftCodeRow} from '../../database/types/PaymentTypes'; -import {GiftCode, mapGiftCodeDurationToMonths, mapGiftDurationMonthsToFields} from '../../models/GiftCode'; -import {GiftCodes, GiftCodesByCreator, GiftCodesByPaymentIntent, GiftCodesByRedeemer} from '../../Tables'; +import type {UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db, type DbOp} from '@app/api/database/CassandraTypes'; +import type {GiftCodeRow} from '@app/api/database/types/PaymentTypes'; +import {GiftCode, mapGiftCodeDurationToMonths, mapGiftDurationMonthsToFields} from '@app/api/models/GiftCode'; +import {GiftCodes, GiftCodesByCreator, GiftCodesByPaymentIntent, GiftCodesByRedeemer} from '@app/api/Tables'; const FETCH_GIFT_CODES_BY_CREATOR_QUERY = GiftCodesByCreator.selectCql({ where: GiftCodesByCreator.where.eq('created_by_user_id'), diff --git a/fluxer_api/src/api/user/repositories/IUserAccountRepository.ts b/fluxer_api/src/api/user/repositories/IUserAccountRepository.ts index f4225e31b..b778341fb 100644 --- a/fluxer_api/src/api/user/repositories/IUserAccountRepository.ts +++ b/fluxer_api/src/api/user/repositories/IUserAccountRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {User} from '../../models/User'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {User} from '@app/api/models/User'; export interface UserDeletionScheduleUpdate { pending_deletion_at: Date | null; diff --git a/fluxer_api/src/api/user/repositories/IUserAuthRepository.ts b/fluxer_api/src/api/user/repositories/IUserAuthRepository.ts index cd2d92fab..cf82cae4d 100644 --- a/fluxer_api/src/api/user/repositories/IUserAuthRepository.ts +++ b/fluxer_api/src/api/user/repositories/IUserAuthRepository.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {PhoneVerificationToken, UserID} from '../../BrandedTypes'; +import type {PhoneVerificationToken, UserID} from '@app/api/BrandedTypes'; import type { AuthSessionRow, EmailRevertTokenRow, EmailVerificationTokenRow, PasswordResetTokenRow, PhoneTokenRow, -} from '../../database/types/AuthTypes'; -import type {AuthSession, AuthSessionTombstone} from '../../models/AuthSession'; -import type {EmailRevertToken} from '../../models/EmailRevertToken'; -import type {EmailVerificationToken} from '../../models/EmailVerificationToken'; -import type {MfaBackupCode} from '../../models/MfaBackupCode'; -import type {PasswordResetToken} from '../../models/PasswordResetToken'; -import type {WebAuthnCredential} from '../../models/WebAuthnCredential'; +} from '@app/api/database/types/AuthTypes'; +import type {AuthSession, AuthSessionTombstone} from '@app/api/models/AuthSession'; +import type {EmailRevertToken} from '@app/api/models/EmailRevertToken'; +import type {EmailVerificationToken} from '@app/api/models/EmailVerificationToken'; +import type {MfaBackupCode} from '@app/api/models/MfaBackupCode'; +import type {PasswordResetToken} from '@app/api/models/PasswordResetToken'; +import type {WebAuthnCredential} from '@app/api/models/WebAuthnCredential'; export interface IUserAuthRepository { listAuthSessions(userId: UserID): Promise>; diff --git a/fluxer_api/src/api/user/repositories/IUserChannelRepository.ts b/fluxer_api/src/api/user/repositories/IUserChannelRepository.ts index 556745e5e..d250db69a 100644 --- a/fluxer_api/src/api/user/repositories/IUserChannelRepository.ts +++ b/fluxer_api/src/api/user/repositories/IUserChannelRepository.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import type {Channel} from '../../models/Channel'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {Channel} from '@app/api/models/Channel'; export interface PrivateChannelSummary { channelId: ChannelID; diff --git a/fluxer_api/src/api/user/repositories/IUserContentRepository.ts b/fluxer_api/src/api/user/repositories/IUserContentRepository.ts index 163fe495a..9205b1495 100644 --- a/fluxer_api/src/api/user/repositories/IUserContentRepository.ts +++ b/fluxer_api/src/api/user/repositories/IUserContentRepository.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import type {ExactRow} from '../../database/types/DatabaseRowTypes'; -import type {GiftCodeRow, PaymentBySubscriptionRow, PaymentRow} from '../../database/types/PaymentTypes'; -import type {PushSubscriptionRow, RecentMentionRow} from '../../database/types/UserTypes'; -import type {GiftCode} from '../../models/GiftCode'; -import type {Payment} from '../../models/Payment'; -import type {PushSubscription} from '../../models/PushSubscription'; -import type {RecentMention} from '../../models/RecentMention'; -import type {SavedMessage} from '../../models/SavedMessage'; -import type {VisionarySlot} from '../../models/VisionarySlot'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {ExactRow} from '@app/api/database/types/DatabaseRowTypes'; +import type {GiftCodeRow, PaymentBySubscriptionRow, PaymentRow} from '@app/api/database/types/PaymentTypes'; +import type {PushSubscriptionRow, RecentMentionRow} from '@app/api/database/types/UserTypes'; +import type {GiftCode} from '@app/api/models/GiftCode'; +import type {Payment} from '@app/api/models/Payment'; +import type {PushSubscription} from '@app/api/models/PushSubscription'; +import type {RecentMention} from '@app/api/models/RecentMention'; +import type {SavedMessage} from '@app/api/models/SavedMessage'; +import type {VisionarySlot} from '@app/api/models/VisionarySlot'; export interface IUserContentRepository { getRecentMention(userId: UserID, messageId: MessageID): Promise; diff --git a/fluxer_api/src/api/user/repositories/IUserRelationshipRepository.ts b/fluxer_api/src/api/user/repositories/IUserRelationshipRepository.ts index b7c5dc93e..15c11332e 100644 --- a/fluxer_api/src/api/user/repositories/IUserRelationshipRepository.ts +++ b/fluxer_api/src/api/user/repositories/IUserRelationshipRepository.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import type {RelationshipRow} from '../../database/types/UserTypes'; -import type {Relationship} from '../../models/Relationship'; -import type {UserNote} from '../../models/UserNote'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {RelationshipRow} from '@app/api/database/types/UserTypes'; +import type {Relationship} from '@app/api/models/Relationship'; +import type {UserNote} from '@app/api/models/UserNote'; export interface IUserRelationshipRepository { listRelationships(sourceUserId: UserID): Promise>; diff --git a/fluxer_api/src/api/user/repositories/IUserRepositoryAggregate.ts b/fluxer_api/src/api/user/repositories/IUserRepositoryAggregate.ts index e7e22fae7..953a66cfc 100644 --- a/fluxer_api/src/api/user/repositories/IUserRepositoryAggregate.ts +++ b/fluxer_api/src/api/user/repositories/IUserRepositoryAggregate.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IUserAccountRepository} from './IUserAccountRepository'; -import type {IUserAuthRepository} from './IUserAuthRepository'; -import type {IUserChannelRepository} from './IUserChannelRepository'; -import type {IUserContentRepository} from './IUserContentRepository'; -import type {IUserRelationshipRepository} from './IUserRelationshipRepository'; -import type {IUserSettingsRepository} from './IUserSettingsRepository'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import type {IUserAuthRepository} from '@app/api/user/repositories/IUserAuthRepository'; +import type {IUserChannelRepository} from '@app/api/user/repositories/IUserChannelRepository'; +import type {IUserContentRepository} from '@app/api/user/repositories/IUserContentRepository'; +import type {IUserRelationshipRepository} from '@app/api/user/repositories/IUserRelationshipRepository'; +import type {IUserSettingsRepository} from '@app/api/user/repositories/IUserSettingsRepository'; export interface IUserRepositoryAggregate extends IUserAccountRepository, diff --git a/fluxer_api/src/api/user/repositories/IUserSettingsRepository.ts b/fluxer_api/src/api/user/repositories/IUserSettingsRepository.ts index 07f1b4e4a..dfeb84984 100644 --- a/fluxer_api/src/api/user/repositories/IUserSettingsRepository.ts +++ b/fluxer_api/src/api/user/repositories/IUserSettingsRepository.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {ExactRow} from '../../database/types/DatabaseRowTypes'; -import type {UserGuildSettingsRow, UserSettingsRow} from '../../database/types/UserTypes'; -import type {UserGuildSettings} from '../../models/UserGuildSettings'; -import type {UserSettings} from '../../models/UserSettings'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {ExactRow} from '@app/api/database/types/DatabaseRowTypes'; +import type {UserGuildSettingsRow, UserSettingsRow} from '@app/api/database/types/UserTypes'; +import type {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import type {UserSettings} from '@app/api/models/UserSettings'; export interface IUserSettingsRepository { findSettings(userId: UserID): Promise; diff --git a/fluxer_api/src/api/user/repositories/PaymentRepository.ts b/fluxer_api/src/api/user/repositories/PaymentRepository.ts index e0c3669b1..255aad4b3 100644 --- a/fluxer_api/src/api/user/repositories/PaymentRepository.ts +++ b/fluxer_api/src/api/user/repositories/PaymentRepository.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne} from '../../database/CassandraQueryExecution'; -import {Db, type DbOp} from '../../database/CassandraTypes'; -import {executeVersionedUpdate} from '../../database/CassandraVersionedUpdate'; -import type {PaymentBySubscriptionRow, PaymentRow} from '../../database/types/PaymentTypes'; -import {Payment} from '../../models/Payment'; -import {Payments, PaymentsByPaymentIntent, PaymentsBySubscription, PaymentsByUser} from '../../Tables'; +import type {UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {Db, type DbOp} from '@app/api/database/CassandraTypes'; +import {executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import type {PaymentBySubscriptionRow, PaymentRow} from '@app/api/database/types/PaymentTypes'; +import {Payment} from '@app/api/models/Payment'; +import {Payments, PaymentsByPaymentIntent, PaymentsBySubscription, PaymentsByUser} from '@app/api/Tables'; const FETCH_PAYMENT_BY_CHECKOUT_SESSION_QUERY = Payments.selectCql({ where: Payments.where.eq('checkout_session_id'), diff --git a/fluxer_api/src/api/user/repositories/PushSubscriptionRepository.ts b/fluxer_api/src/api/user/repositories/PushSubscriptionRepository.ts index c0586862d..f8b513c83 100644 --- a/fluxer_api/src/api/user/repositories/PushSubscriptionRepository.ts +++ b/fluxer_api/src/api/user/repositories/PushSubscriptionRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import {deleteOneOrMany, fetchMany, upsertOne} from '../../database/CassandraQueryExecution'; -import type {PushSubscriptionRow} from '../../database/types/UserTypes'; -import {PushSubscription} from '../../models/PushSubscription'; -import {PushSubscriptions} from '../../Tables'; -import {awaitAll} from '../../utils/ConcurrencyUtils'; +import type {UserID} from '@app/api/BrandedTypes'; +import {deleteOneOrMany, fetchMany, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {PushSubscriptionRow} from '@app/api/database/types/UserTypes'; +import {PushSubscription} from '@app/api/models/PushSubscription'; +import {PushSubscriptions} from '@app/api/Tables'; +import {awaitAll} from '@app/api/utils/ConcurrencyUtils'; const FETCH_PUSH_SUBSCRIPTIONS_CQL = PushSubscriptions.selectCql({ where: PushSubscriptions.where.eq('user_id'), diff --git a/fluxer_api/src/api/user/repositories/RecentMentionRepository.ts b/fluxer_api/src/api/user/repositories/RecentMentionRepository.ts index 4fc4f931e..70a9254e3 100644 --- a/fluxer_api/src/api/user/repositories/RecentMentionRepository.ts +++ b/fluxer_api/src/api/user/repositories/RecentMentionRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createMessageID, type MessageID, type UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import type {RecentMentionRow} from '@app/api/database/types/UserTypes'; +import {RecentMention} from '@app/api/models/RecentMention'; +import {RecentMentions, RecentMentionsByGuild} from '@app/api/Tables'; import {generateSnowflake} from '@fluxer/snowflake/src/Snowflake'; -import {createMessageID, type MessageID, type UserID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne} from '../../database/CassandraQueryExecution'; -import type {RecentMentionRow} from '../../database/types/UserTypes'; -import {RecentMention} from '../../models/RecentMention'; -import {RecentMentions, RecentMentionsByGuild} from '../../Tables'; const FETCH_RECENT_MENTION_CQL = RecentMentions.selectCql({ where: [RecentMentions.where.eq('user_id'), RecentMentions.where.eq('message_id')], diff --git a/fluxer_api/src/api/user/repositories/SavedMessageRepository.test.ts b/fluxer_api/src/api/user/repositories/SavedMessageRepository.test.ts index 62143f85d..75b0b8f88 100644 --- a/fluxer_api/src/api/user/repositories/SavedMessageRepository.test.ts +++ b/fluxer_api/src/api/user/repositories/SavedMessageRepository.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createMessageID, createUserID, type UserID} from '@app/api/BrandedTypes'; +import {setCassandraQueryExecutorForTesting} from '@app/api/database/CassandraQueryExecution'; +import {InMemoryCassandraQueryExecutor} from '@app/api/test/InMemoryCassandraQueryExecutor'; +import {SavedMessageRepository} from '@app/api/user/repositories/SavedMessageRepository'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createChannelID, createMessageID, createUserID, type UserID} from '../../BrandedTypes'; -import {setCassandraQueryExecutorForTesting} from '../../database/CassandraQueryExecution'; -import {InMemoryCassandraQueryExecutor} from '../../test/InMemoryCassandraQueryExecutor'; -import {SavedMessageRepository} from './SavedMessageRepository'; const CHANNEL_ID = createChannelID(10n); diff --git a/fluxer_api/src/api/user/repositories/SavedMessageRepository.ts b/fluxer_api/src/api/user/repositories/SavedMessageRepository.ts index e3fa2a2b6..e09b20b28 100644 --- a/fluxer_api/src/api/user/repositories/SavedMessageRepository.ts +++ b/fluxer_api/src/api/user/repositories/SavedMessageRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createMessageID, type MessageID, type UserID} from '@app/api/BrandedTypes'; +import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {SavedMessageRow} from '@app/api/database/types/UserTypes'; +import {SavedMessage} from '@app/api/models/SavedMessage'; +import {SavedMessages} from '@app/api/Tables'; import {generateSnowflake} from '@fluxer/snowflake/src/Snowflake'; -import {type ChannelID, createMessageID, type MessageID, type UserID} from '../../BrandedTypes'; -import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import type {SavedMessageRow} from '../../database/types/UserTypes'; -import {SavedMessage} from '../../models/SavedMessage'; -import {SavedMessages} from '../../Tables'; const createFetchSavedMessagesQuery = (limit: number) => SavedMessages.select({ diff --git a/fluxer_api/src/api/user/repositories/UserAccountRepository.ts b/fluxer_api/src/api/user/repositories/UserAccountRepository.ts index 4baeca1a1..47eb8523e 100644 --- a/fluxer_api/src/api/user/repositories/UserAccountRepository.ts +++ b/fluxer_api/src/api/user/repositories/UserAccountRepository.ts @@ -1,16 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {User} from '@app/api/models/User'; +import {UserEmailOwnershipRepository} from '@app/api/user/repositories/account/crud/UserEmailOwnershipRepository'; +import {UserAccountRepository as UserAccountCrudRepository} from '@app/api/user/repositories/account/UserAccountRepository'; +import {UserDeletionRepository} from '@app/api/user/repositories/account/UserDeletionRepository'; +import {UserGuildRepository} from '@app/api/user/repositories/account/UserGuildRepository'; +import {UserLookupRepository} from '@app/api/user/repositories/account/UserLookupRepository'; +import {TokenRepository} from '@app/api/user/repositories/auth/TokenRepository'; +import type { + IUserAccountRepository, + UserDeletionScheduleUpdate, +} from '@app/api/user/repositories/IUserAccountRepository'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {User} from '../../models/User'; -import {UserEmailOwnershipRepository} from './account/crud/UserEmailOwnershipRepository'; -import {UserAccountRepository as UserAccountCrudRepository} from './account/UserAccountRepository'; -import {UserDeletionRepository} from './account/UserDeletionRepository'; -import {UserGuildRepository} from './account/UserGuildRepository'; -import {UserLookupRepository} from './account/UserLookupRepository'; -import {TokenRepository} from './auth/TokenRepository'; -import type {IUserAccountRepository, UserDeletionScheduleUpdate} from './IUserAccountRepository'; export class UserAccountRepository implements IUserAccountRepository { private accountRepo: UserAccountCrudRepository; diff --git a/fluxer_api/src/api/user/repositories/UserAuthRepository.ts b/fluxer_api/src/api/user/repositories/UserAuthRepository.ts index 145ad23ae..46bbcf57e 100644 --- a/fluxer_api/src/api/user/repositories/UserAuthRepository.ts +++ b/fluxer_api/src/api/user/repositories/UserAuthRepository.ts @@ -1,26 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {PhoneVerificationToken, UserID} from '../../BrandedTypes'; +import type {PhoneVerificationToken, UserID} from '@app/api/BrandedTypes'; import type { AuthSessionRow, EmailRevertTokenRow, EmailVerificationTokenRow, PasswordResetTokenRow, PhoneTokenRow, -} from '../../database/types/AuthTypes'; -import type {AuthSession, AuthSessionTombstone} from '../../models/AuthSession'; -import type {EmailRevertToken} from '../../models/EmailRevertToken'; -import type {EmailVerificationToken} from '../../models/EmailVerificationToken'; -import type {MfaBackupCode} from '../../models/MfaBackupCode'; -import type {PasswordResetToken} from '../../models/PasswordResetToken'; -import type {WebAuthnCredential} from '../../models/WebAuthnCredential'; -import {AuthSessionRepository} from './auth/AuthSessionRepository'; -import {IpAuthorizationRepository} from './auth/IpAuthorizationRepository'; -import {MfaBackupCodeRepository} from './auth/MfaBackupCodeRepository'; -import {TokenRepository} from './auth/TokenRepository'; -import {WebAuthnRepository} from './auth/WebAuthnRepository'; -import type {IUserAccountRepository} from './IUserAccountRepository'; -import type {IUserAuthRepository} from './IUserAuthRepository'; +} from '@app/api/database/types/AuthTypes'; +import type {AuthSession, AuthSessionTombstone} from '@app/api/models/AuthSession'; +import type {EmailRevertToken} from '@app/api/models/EmailRevertToken'; +import type {EmailVerificationToken} from '@app/api/models/EmailVerificationToken'; +import type {MfaBackupCode} from '@app/api/models/MfaBackupCode'; +import type {PasswordResetToken} from '@app/api/models/PasswordResetToken'; +import type {WebAuthnCredential} from '@app/api/models/WebAuthnCredential'; +import {AuthSessionRepository} from '@app/api/user/repositories/auth/AuthSessionRepository'; +import {IpAuthorizationRepository} from '@app/api/user/repositories/auth/IpAuthorizationRepository'; +import {MfaBackupCodeRepository} from '@app/api/user/repositories/auth/MfaBackupCodeRepository'; +import {TokenRepository} from '@app/api/user/repositories/auth/TokenRepository'; +import {WebAuthnRepository} from '@app/api/user/repositories/auth/WebAuthnRepository'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import type {IUserAuthRepository} from '@app/api/user/repositories/IUserAuthRepository'; export class UserAuthRepository implements IUserAuthRepository { private authSessionRepository: AuthSessionRepository; diff --git a/fluxer_api/src/api/user/repositories/UserChannelRepository.ts b/fluxer_api/src/api/user/repositories/UserChannelRepository.ts index 94721da3a..80892c433 100644 --- a/fluxer_api/src/api/user/repositories/UserChannelRepository.ts +++ b/fluxer_api/src/api/user/repositories/UserChannelRepository.ts @@ -1,8 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import type {ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import {channelRowFromPrivateChannelSnapshot, privateChannelHydrationPatch} from '../../channel/PrivateChannelSnapshot'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import { + channelRowFromPrivateChannelSnapshot, + privateChannelHydrationPatch, +} from '@app/api/channel/PrivateChannelSnapshot'; import { BatchBuilder, deleteOneOrMany, @@ -10,18 +12,19 @@ import { fetchManyInChunks, fetchOne, upsertOne, -} from '../../database/CassandraQueryExecution'; -import {Db} from '../../database/CassandraTypes'; -import type {ChannelRow, DmStateRow, PrivateChannelRow} from '../../database/types/ChannelTypes'; -import {Logger} from '../../Logger'; -import {Channel} from '../../models/Channel'; -import {Channels, DmStates, PinnedDms, PrivateChannels, ReadStates, UserDmHistory} from '../../Tables'; +} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {ChannelRow, DmStateRow, PrivateChannelRow} from '@app/api/database/types/ChannelTypes'; +import {Logger} from '@app/api/Logger'; +import {Channel} from '@app/api/models/Channel'; +import {Channels, DmStates, PinnedDms, PrivateChannels, ReadStates, UserDmHistory} from '@app/api/Tables'; import type { HistoricalDmChannelSummary, IUserChannelRepository, ListHistoricalDmChannelOptions, PrivateChannelSummary, -} from './IUserChannelRepository'; +} from '@app/api/user/repositories/IUserChannelRepository'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; interface PinnedDmRow { user_id: UserID; diff --git a/fluxer_api/src/api/user/repositories/UserContactChangeLogRepository.ts b/fluxer_api/src/api/user/repositories/UserContactChangeLogRepository.ts index 825f921c2..9a2ea1714 100644 --- a/fluxer_api/src/api/user/repositories/UserContactChangeLogRepository.ts +++ b/fluxer_api/src/api/user/repositories/UserContactChangeLogRepository.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {createUserID, type UserID} from '../../BrandedTypes'; -import {fetchMany, upsertOne} from '../../database/CassandraQueryExecution'; -import type {UserContactChangeLogRow} from '../../database/types/UserTypes'; -import {UserContactChangeLogs} from '../../Tables'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {fetchMany, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {UserContactChangeLogRow} from '@app/api/database/types/UserTypes'; +import {UserContactChangeLogs} from '@app/api/Tables'; const createListLogsQuery = (limit: number, includeCursor: boolean) => UserContactChangeLogs.select({ diff --git a/fluxer_api/src/api/user/repositories/UserContentRepository.ts b/fluxer_api/src/api/user/repositories/UserContentRepository.ts index 59273b49a..b750cfc18 100644 --- a/fluxer_api/src/api/user/repositories/UserContentRepository.ts +++ b/fluxer_api/src/api/user/repositories/UserContentRepository.ts @@ -1,21 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import type {GiftCodeRow, PaymentBySubscriptionRow, PaymentRow} from '../../database/types/PaymentTypes'; -import type {PushSubscriptionRow, RecentMentionRow} from '../../database/types/UserTypes'; -import type {GiftCode} from '../../models/GiftCode'; -import type {Payment} from '../../models/Payment'; -import type {PushSubscription} from '../../models/PushSubscription'; -import type {RecentMention} from '../../models/RecentMention'; -import type {SavedMessage} from '../../models/SavedMessage'; -import type {VisionarySlot} from '../../models/VisionarySlot'; -import {GiftCodeRepository} from './GiftCodeRepository'; -import type {IUserContentRepository} from './IUserContentRepository'; -import {PaymentRepository} from './PaymentRepository'; -import {PushSubscriptionRepository} from './PushSubscriptionRepository'; -import {RecentMentionRepository} from './RecentMentionRepository'; -import {SavedMessageRepository} from './SavedMessageRepository'; -import {VisionarySlotRepository} from './VisionarySlotRepository'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {GiftCodeRow, PaymentBySubscriptionRow, PaymentRow} from '@app/api/database/types/PaymentTypes'; +import type {PushSubscriptionRow, RecentMentionRow} from '@app/api/database/types/UserTypes'; +import type {GiftCode} from '@app/api/models/GiftCode'; +import type {Payment} from '@app/api/models/Payment'; +import type {PushSubscription} from '@app/api/models/PushSubscription'; +import type {RecentMention} from '@app/api/models/RecentMention'; +import type {SavedMessage} from '@app/api/models/SavedMessage'; +import type {VisionarySlot} from '@app/api/models/VisionarySlot'; +import {GiftCodeRepository} from '@app/api/user/repositories/GiftCodeRepository'; +import type {IUserContentRepository} from '@app/api/user/repositories/IUserContentRepository'; +import {PaymentRepository} from '@app/api/user/repositories/PaymentRepository'; +import {PushSubscriptionRepository} from '@app/api/user/repositories/PushSubscriptionRepository'; +import {RecentMentionRepository} from '@app/api/user/repositories/RecentMentionRepository'; +import {SavedMessageRepository} from '@app/api/user/repositories/SavedMessageRepository'; +import {VisionarySlotRepository} from '@app/api/user/repositories/VisionarySlotRepository'; export class UserContentRepository implements IUserContentRepository { private giftCodeRepository: GiftCodeRepository; diff --git a/fluxer_api/src/api/user/repositories/UserRelationshipRepository.ts b/fluxer_api/src/api/user/repositories/UserRelationshipRepository.ts index ecab4455e..188db09d6 100644 --- a/fluxer_api/src/api/user/repositories/UserRelationshipRepository.ts +++ b/fluxer_api/src/api/user/repositories/UserRelationshipRepository.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {Db, nextVersion} from '@app/api/database/CassandraTypes'; +import {executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import type {NoteRow, RelationshipRow} from '@app/api/database/types/UserTypes'; +import {Relationship} from '@app/api/models/Relationship'; +import {UserNote} from '@app/api/models/UserNote'; +import {Notes, Relationships, RelationshipsByTarget} from '@app/api/Tables'; +import type {IUserRelationshipRepository} from '@app/api/user/repositories/IUserRelationshipRepository'; import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne} from '../../database/CassandraQueryExecution'; -import {Db, nextVersion} from '../../database/CassandraTypes'; -import {executeVersionedUpdate} from '../../database/CassandraVersionedUpdate'; -import type {NoteRow, RelationshipRow} from '../../database/types/UserTypes'; -import {Relationship} from '../../models/Relationship'; -import {UserNote} from '../../models/UserNote'; -import {Notes, Relationships, RelationshipsByTarget} from '../../Tables'; -import type {IUserRelationshipRepository} from './IUserRelationshipRepository'; const FETCH_ALL_NOTES_CQL = Notes.selectCql({ where: Notes.where.eq('source_user_id'), diff --git a/fluxer_api/src/api/user/repositories/UserRepository.ts b/fluxer_api/src/api/user/repositories/UserRepository.ts index 8992d4587..ef7a76744 100644 --- a/fluxer_api/src/api/user/repositories/UserRepository.ts +++ b/fluxer_api/src/api/user/repositories/UserRepository.ts @@ -1,15 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {ChannelID, GuildID, MessageID, PhoneVerificationToken, UserID} from '../../BrandedTypes'; +import type {ChannelID, GuildID, MessageID, PhoneVerificationToken, UserID} from '@app/api/BrandedTypes'; import type { AuthSessionRow, EmailRevertTokenRow, EmailVerificationTokenRow, PasswordResetTokenRow, PhoneTokenRow, -} from '../../database/types/AuthTypes'; -import type {GiftCodeRow, PaymentBySubscriptionRow, PaymentRow} from '../../database/types/PaymentTypes'; +} from '@app/api/database/types/AuthTypes'; +import type {GiftCodeRow, PaymentBySubscriptionRow, PaymentRow} from '@app/api/database/types/PaymentTypes'; import type { PushSubscriptionRow, RecentMentionRow, @@ -17,41 +16,42 @@ import type { UserGuildSettingsRow, UserRow, UserSettingsRow, -} from '../../database/types/UserTypes'; -import {getKVClient} from '../../middleware/ServiceRegistry'; -import type {AuthSession, AuthSessionTombstone} from '../../models/AuthSession'; -import type {Channel} from '../../models/Channel'; -import type {EmailRevertToken} from '../../models/EmailRevertToken'; -import type {EmailVerificationToken} from '../../models/EmailVerificationToken'; -import type {GiftCode} from '../../models/GiftCode'; -import type {MfaBackupCode} from '../../models/MfaBackupCode'; -import type {PasswordResetToken} from '../../models/PasswordResetToken'; -import type {Payment} from '../../models/Payment'; -import type {PushSubscription} from '../../models/PushSubscription'; -import type {ReadState} from '../../models/ReadState'; -import type {RecentMention} from '../../models/RecentMention'; -import type {Relationship} from '../../models/Relationship'; -import type {SavedMessage} from '../../models/SavedMessage'; -import type {User} from '../../models/User'; -import type {UserGuildSettings} from '../../models/UserGuildSettings'; -import type {UserNote} from '../../models/UserNote'; -import type {UserSettings} from '../../models/UserSettings'; -import type {VisionarySlot} from '../../models/VisionarySlot'; -import type {WebAuthnCredential} from '../../models/WebAuthnCredential'; -import {ReadStateRepository} from '../../read_state/ReadStateRepository'; -import type {UserDeletionScheduleUpdate} from './IUserAccountRepository'; +} from '@app/api/database/types/UserTypes'; +import {getKVClient} from '@app/api/middleware/ServiceRegistry'; +import type {AuthSession, AuthSessionTombstone} from '@app/api/models/AuthSession'; +import type {Channel} from '@app/api/models/Channel'; +import type {EmailRevertToken} from '@app/api/models/EmailRevertToken'; +import type {EmailVerificationToken} from '@app/api/models/EmailVerificationToken'; +import type {GiftCode} from '@app/api/models/GiftCode'; +import type {MfaBackupCode} from '@app/api/models/MfaBackupCode'; +import type {PasswordResetToken} from '@app/api/models/PasswordResetToken'; +import type {Payment} from '@app/api/models/Payment'; +import type {PushSubscription} from '@app/api/models/PushSubscription'; +import type {ReadState} from '@app/api/models/ReadState'; +import type {RecentMention} from '@app/api/models/RecentMention'; +import type {Relationship} from '@app/api/models/Relationship'; +import type {SavedMessage} from '@app/api/models/SavedMessage'; +import type {User} from '@app/api/models/User'; +import type {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import type {UserNote} from '@app/api/models/UserNote'; +import type {UserSettings} from '@app/api/models/UserSettings'; +import type {VisionarySlot} from '@app/api/models/VisionarySlot'; +import type {WebAuthnCredential} from '@app/api/models/WebAuthnCredential'; +import {ReadStateRepository} from '@app/api/read_state/ReadStateRepository'; +import type {UserDeletionScheduleUpdate} from '@app/api/user/repositories/IUserAccountRepository'; import type { HistoricalDmChannelSummary, ListHistoricalDmChannelOptions, PrivateChannelSummary, -} from './IUserChannelRepository'; -import type {IUserRepositoryAggregate} from './IUserRepositoryAggregate'; -import {UserAccountRepository} from './UserAccountRepository'; -import {UserAuthRepository} from './UserAuthRepository'; -import {UserChannelRepository} from './UserChannelRepository'; -import {UserContentRepository} from './UserContentRepository'; -import {UserRelationshipRepository} from './UserRelationshipRepository'; -import {UserSettingsRepository} from './UserSettingsRepository'; +} from '@app/api/user/repositories/IUserChannelRepository'; +import type {IUserRepositoryAggregate} from '@app/api/user/repositories/IUserRepositoryAggregate'; +import {UserAccountRepository} from '@app/api/user/repositories/UserAccountRepository'; +import {UserAuthRepository} from '@app/api/user/repositories/UserAuthRepository'; +import {UserChannelRepository} from '@app/api/user/repositories/UserChannelRepository'; +import {UserContentRepository} from '@app/api/user/repositories/UserContentRepository'; +import {UserRelationshipRepository} from '@app/api/user/repositories/UserRelationshipRepository'; +import {UserSettingsRepository} from '@app/api/user/repositories/UserSettingsRepository'; +import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; export class UserRepository implements IUserRepositoryAggregate { private accountRepo: UserAccountRepository; diff --git a/fluxer_api/src/api/user/repositories/UserSettingsRepository.ts b/fluxer_api/src/api/user/repositories/UserSettingsRepository.ts index b6494bd4d..fb8f0f4e6 100644 --- a/fluxer_api/src/api/user/repositories/UserSettingsRepository.ts +++ b/fluxer_api/src/api/user/repositories/UserSettingsRepository.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../BrandedTypes'; -import {deleteOneOrMany, fetchMany, fetchOne} from '../../database/CassandraQueryExecution'; -import {buildPatchFromData, executeVersionedUpdate} from '../../database/CassandraVersionedUpdate'; -import type {ExactRow} from '../../database/types/DatabaseRowTypes'; -import type {UserGuildSettingsRow, UserSettingsRow} from '../../database/types/UserTypes'; -import {USER_GUILD_SETTINGS_COLUMNS, USER_SETTINGS_COLUMNS} from '../../database/types/UserTypes'; -import {Logger} from '../../Logger'; -import {UserGuildSettings} from '../../models/UserGuildSettings'; -import {UserSettings} from '../../models/UserSettings'; -import {UserGuildSettings as UserGuildSettingsTable, UserSettings as UserSettingsTable} from '../../Tables'; -import type {IUserSettingsRepository} from './IUserSettingsRepository'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {deleteOneOrMany, fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {buildPatchFromData, executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import type {ExactRow} from '@app/api/database/types/DatabaseRowTypes'; +import type {UserGuildSettingsRow, UserSettingsRow} from '@app/api/database/types/UserTypes'; +import {USER_GUILD_SETTINGS_COLUMNS, USER_SETTINGS_COLUMNS} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import {UserSettings} from '@app/api/models/UserSettings'; +import {UserGuildSettings as UserGuildSettingsTable, UserSettings as UserSettingsTable} from '@app/api/Tables'; +import type {IUserSettingsRepository} from '@app/api/user/repositories/IUserSettingsRepository'; const FETCH_USER_SETTINGS_CQL = UserSettingsTable.selectCql({ where: UserSettingsTable.where.eq('user_id'), diff --git a/fluxer_api/src/api/user/repositories/VisionarySlotRepository.ts b/fluxer_api/src/api/user/repositories/VisionarySlotRepository.ts index 675300b19..819807f6d 100644 --- a/fluxer_api/src/api/user/repositories/VisionarySlotRepository.ts +++ b/fluxer_api/src/api/user/repositories/VisionarySlotRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {VisionarySlotRow} from '@app/api/database/types/PaymentTypes'; +import {VisionarySlot} from '@app/api/models/VisionarySlot'; +import {VisionarySlots} from '@app/api/Tables'; import {CannotShrinkReservedSlotsError} from '@fluxer/errors/src/domains/core/CannotShrinkReservedSlotsError'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '../../database/CassandraQueryExecution'; -import type {VisionarySlotRow} from '../../database/types/PaymentTypes'; -import {VisionarySlot} from '../../models/VisionarySlot'; -import {VisionarySlots} from '../../Tables'; const FETCH_ALL_VISIONARY_SLOTS_QUERY = VisionarySlots.selectCql(); const FETCH_VISIONARY_SLOT_QUERY = VisionarySlots.selectCql({ diff --git a/fluxer_api/src/api/user/repositories/account/UserAccountRepository.ts b/fluxer_api/src/api/user/repositories/account/UserAccountRepository.ts index b5fe928a7..387bebf7d 100644 --- a/fluxer_api/src/api/user/repositories/account/UserAccountRepository.ts +++ b/fluxer_api/src/api/user/repositories/account/UserAccountRepository.ts @@ -1,21 +1,27 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {Db, type DbOp} from '@app/api/database/CassandraTypes'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {User} from '@app/api/models/User'; +import { + UserDataRepository, + type UserDeletionTransition, +} from '@app/api/user/repositories/account/crud/UserDataRepository'; +import { + type EmailClaimReservation, + UserEmailOwnershipRepository, +} from '@app/api/user/repositories/account/crud/UserEmailOwnershipRepository'; +import {UserIndexRepository} from '@app/api/user/repositories/account/crud/UserIndexRepository'; +import {UserSearchRepository} from '@app/api/user/repositories/account/crud/UserSearchRepository'; +import {UserLookupRepository} from '@app/api/user/repositories/account/UserLookupRepository'; +import type {UserDeletionScheduleUpdate} from '@app/api/user/repositories/IUserAccountRepository'; import { extractPremiumFlagsFromLegacyUserFlags, LEGACY_DEAD_USER_FLAGS_MASK, LEGACY_PREMIUM_FLAGS_MASK, } from '@fluxer/constants/src/UserConstants'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {UserID} from '../../../BrandedTypes'; -import {Db, type DbOp} from '../../../database/CassandraTypes'; -import type {UserRow} from '../../../database/types/UserTypes'; -import {User} from '../../../models/User'; -import type {UserDeletionScheduleUpdate} from '../IUserAccountRepository'; -import {UserDataRepository, type UserDeletionTransition} from './crud/UserDataRepository'; -import {type EmailClaimReservation, UserEmailOwnershipRepository} from './crud/UserEmailOwnershipRepository'; -import {UserIndexRepository} from './crud/UserIndexRepository'; -import {UserSearchRepository} from './crud/UserSearchRepository'; -import {UserLookupRepository} from './UserLookupRepository'; export class UserAccountRepository { private dataRepo: UserDataRepository; diff --git a/fluxer_api/src/api/user/repositories/account/UserDeletionRepository.ts b/fluxer_api/src/api/user/repositories/account/UserDeletionRepository.ts index 9067fada6..9cfd68a78 100644 --- a/fluxer_api/src/api/user/repositories/account/UserDeletionRepository.ts +++ b/fluxer_api/src/api/user/repositories/account/UserDeletionRepository.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {createUserID, type UserID} from '../../../BrandedTypes'; -import {deleteOneOrMany, fetchMany, upsertOne} from '../../../database/CassandraQueryExecution'; -import type {User} from '../../../models/User'; -import {UsersPendingDeletion} from '../../../Tables'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {deleteOneOrMany, fetchMany, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {User} from '@app/api/models/User'; +import {UsersPendingDeletion} from '@app/api/Tables'; const FETCH_USERS_PENDING_DELETION_BY_DATE_CQL = UsersPendingDeletion.selectCql({ columns: ['user_id', 'pending_deletion_at'], diff --git a/fluxer_api/src/api/user/repositories/account/UserGuildRepository.ts b/fluxer_api/src/api/user/repositories/account/UserGuildRepository.ts index 082b4ecd0..c157186fc 100644 --- a/fluxer_api/src/api/user/repositories/account/UserGuildRepository.ts +++ b/fluxer_api/src/api/user/repositories/account/UserGuildRepository.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../../../BrandedTypes'; -import {BatchBuilder, fetchMany} from '../../../database/CassandraQueryExecution'; -import type {GuildMemberByUserIdRow} from '../../../database/types/GuildTypes'; -import {GuildMembers, GuildMembersByUserId} from '../../../Tables'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany} from '@app/api/database/CassandraQueryExecution'; +import type {GuildMemberByUserIdRow} from '@app/api/database/types/GuildTypes'; +import {GuildMembers, GuildMembersByUserId} from '@app/api/Tables'; const FETCH_GUILD_MEMBERS_BY_USER_CQL = GuildMembersByUserId.selectCql({ where: GuildMembersByUserId.where.eq('user_id'), diff --git a/fluxer_api/src/api/user/repositories/account/UserLookupRepository.ts b/fluxer_api/src/api/user/repositories/account/UserLookupRepository.ts index 014af6aef..17f1da824 100644 --- a/fluxer_api/src/api/user/repositories/account/UserLookupRepository.ts +++ b/fluxer_api/src/api/user/repositories/account/UserLookupRepository.ts @@ -1,24 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {getSameIpDecisionKey, normalizeIpString} from '@fluxer/ip_utils/src/IpAddress'; -import type {UserID} from '../../../BrandedTypes'; -import {fetchMany, fetchOne} from '../../../database/CassandraQueryExecution'; +import type {UserID} from '@app/api/BrandedTypes'; +import {fetchMany, fetchOne} from '@app/api/database/CassandraQueryExecution'; import type { UserByLastActiveIpRow, UserByLastActiveIpTrustKeyRow, UserByStripeCustomerIdRow, UserByStripeSubscriptionIdRow, UserByUsernameRow, -} from '../../../database/types/UserTypes'; -import type {User} from '../../../models/User'; +} from '@app/api/database/types/UserTypes'; +import type {User} from '@app/api/models/User'; import { UserByLastActiveIp, UserByLastActiveIpTrustKey, UserByStripeCustomerId, UserByStripeSubscriptionId, UserByUsername, -} from '../../../Tables'; -import type {UserEmailOwnershipRepository} from './crud/UserEmailOwnershipRepository'; +} from '@app/api/Tables'; +import type {UserEmailOwnershipRepository} from '@app/api/user/repositories/account/crud/UserEmailOwnershipRepository'; +import {getSameIpDecisionKey, normalizeIpString} from '@fluxer/ip_utils/src/IpAddress'; const FETCH_DISCRIMINATORS_BY_USERNAME_QUERY = UserByUsername.select({ columns: ['discriminator', 'user_id'], diff --git a/fluxer_api/src/api/user/repositories/account/crud/UserDataRepository.ts b/fluxer_api/src/api/user/repositories/account/crud/UserDataRepository.ts index 74068af3f..c9abf77c2 100644 --- a/fluxer_api/src/api/user/repositories/account/crud/UserDataRepository.ts +++ b/fluxer_api/src/api/user/repositories/account/crud/UserDataRepository.ts @@ -1,30 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {isSyntheticUserId} from '@app/api/constants/Core'; +import {executeConditional, fetchMany, fetchOne, fetchPage, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db, type DbOp, nextVersion} from '@app/api/database/CassandraTypes'; +import {applyPatchToRow, buildPatchFromData, executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {EMPTY_USER_ROW, USER_COLUMNS} from '@app/api/database/types/UserTypes'; +import {User} from '@app/api/models/User'; +import {Users} from '@app/api/Tables'; +import {isPendingDeletionBlocked} from '@app/api/user/services/PendingDeletionCoordinator'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {DELETED_USER_ID, UserFlags} from '@fluxer/constants/src/UserConstants'; import {ConflictError} from '@fluxer/errors/src/domains/core/ConflictError'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import {BACKGROUND_READ_TIMEOUT_MS} from '@pkgs/cassandra/src/Client'; -import {createUserID, type UserID} from '../../../../BrandedTypes'; -import {isSyntheticUserId} from '../../../../constants/Core'; -import { - executeConditional, - fetchMany, - fetchOne, - fetchPage, - upsertOne, -} from '../../../../database/CassandraQueryExecution'; -import {Db, type DbOp, nextVersion} from '../../../../database/CassandraTypes'; -import { - applyPatchToRow, - buildPatchFromData, - executeVersionedUpdate, -} from '../../../../database/CassandraVersionedUpdate'; -import type {UserRow} from '../../../../database/types/UserTypes'; -import {EMPTY_USER_ROW, USER_COLUMNS} from '../../../../database/types/UserTypes'; -import {User} from '../../../../models/User'; -import {Users} from '../../../../Tables'; -import {isPendingDeletionBlocked} from '../../../services/PendingDeletionCoordinator'; const FLUXER_BOT_USER_ID = 0n; const FETCH_USERS_BY_IDS_CQL = Users.selectCql({ diff --git a/fluxer_api/src/api/user/repositories/account/crud/UserEmailOwnershipRepository.ts b/fluxer_api/src/api/user/repositories/account/crud/UserEmailOwnershipRepository.ts index 7be93f373..be68fb2f7 100644 --- a/fluxer_api/src/api/user/repositories/account/crud/UserEmailOwnershipRepository.ts +++ b/fluxer_api/src/api/user/repositories/account/crud/UserEmailOwnershipRepository.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash, randomUUID} from 'node:crypto'; +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {UserByEmailRow, UserEmailOwnerRow} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import {UserByEmail, UserEmailOwners} from '@app/api/Tables'; +import {isJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {createUserID, type UserID} from '../../../../BrandedTypes'; -import {fetchMany, fetchOne, upsertOne} from '../../../../database/CassandraQueryExecution'; -import {Db} from '../../../../database/CassandraTypes'; -import type {UserByEmailRow, UserEmailOwnerRow} from '../../../../database/types/UserTypes'; -import {Logger} from '../../../../Logger'; -import type {User} from '../../../../models/User'; -import {UserByEmail, UserEmailOwners} from '../../../../Tables'; -import {isJsonRecord, parseJsonWithGuard} from '../../../../utils/JsonBoundaryUtils'; type EmailOwnerLookupRow = Pick; type ValkeyEmailOwnerStatus = 'pending' | 'claimed'; diff --git a/fluxer_api/src/api/user/repositories/account/crud/UserIndexRepository.ts b/fluxer_api/src/api/user/repositories/account/crud/UserIndexRepository.ts index 832c035ae..55f422a7c 100644 --- a/fluxer_api/src/api/user/repositories/account/crud/UserIndexRepository.ts +++ b/fluxer_api/src/api/user/repositories/account/crud/UserIndexRepository.ts @@ -1,9 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress'; -import type {UserID} from '../../../../BrandedTypes'; -import {BatchBuilder} from '../../../../database/CassandraQueryExecution'; -import type {UserRow} from '../../../../database/types/UserTypes'; +import type {UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder} from '@app/api/database/CassandraQueryExecution'; +import type {UserRow} from '@app/api/database/types/UserTypes'; import { UserByEmail, UserByLastActiveIp, @@ -11,7 +10,8 @@ import { UserByStripeCustomerId, UserByStripeSubscriptionId, UserByUsername, -} from '../../../../Tables'; +} from '@app/api/Tables'; +import {getSameIpDecisionKey} from '@fluxer/ip_utils/src/IpAddress'; export class UserIndexRepository { async syncIndices(data: UserRow, oldData?: UserRow | null): Promise { diff --git a/fluxer_api/src/api/user/repositories/account/crud/UserSearchRepository.ts b/fluxer_api/src/api/user/repositories/account/crud/UserSearchRepository.ts index c81b91a76..b2aef9f52 100644 --- a/fluxer_api/src/api/user/repositories/account/crud/UserSearchRepository.ts +++ b/fluxer_api/src/api/user/repositories/account/crud/UserSearchRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Logger} from '../../../../Logger'; -import type {User} from '../../../../models/User'; -import {getUserSearchService} from '../../../../SearchFactory'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import {getUserSearchService} from '@app/api/SearchFactory'; export class UserSearchRepository { async indexUser(user: User): Promise { diff --git a/fluxer_api/src/api/user/repositories/auth/AuthSessionRepository.ts b/fluxer_api/src/api/user/repositories/auth/AuthSessionRepository.ts index 4259c8b73..e5e93ec01 100644 --- a/fluxer_api/src/api/user/repositories/auth/AuthSessionRepository.ts +++ b/fluxer_api/src/api/user/repositories/auth/AuthSessionRepository.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {AuthSessionRow, AuthSessionTombstoneRow, UserCountryHistoryRow} from '@app/api/database/types/AuthTypes'; +import {Logger} from '@app/api/Logger'; +import {getCacheService, getPhoneFraudGraphService} from '@app/api/middleware/ServiceSingletons'; +import {AuthSession, AuthSessionTombstone} from '@app/api/models/AuthSession'; +import {AuthSessions, AuthSessionsByUserId, AuthSessionTombstones, UserCountryHistory} from '@app/api/Tables'; +import {awaitAll} from '@app/api/utils/ConcurrencyUtils'; +import {isValidTimestamp} from '@app/api/utils/TimestampUtils'; import {SnowflakeType} from '@fluxer/schema/src/primitives/SchemaPrimitives'; import {z} from 'zod'; -import {createUserID, type UserID} from '../../../BrandedTypes'; -import {BatchBuilder, fetchMany, fetchOne, upsertOne} from '../../../database/CassandraQueryExecution'; -import {Db} from '../../../database/CassandraTypes'; -import type {AuthSessionRow, AuthSessionTombstoneRow, UserCountryHistoryRow} from '../../../database/types/AuthTypes'; -import {Logger} from '../../../Logger'; -import {getCacheService, getPhoneFraudGraphService} from '../../../middleware/ServiceSingletons'; -import {AuthSession, AuthSessionTombstone} from '../../../models/AuthSession'; -import {AuthSessions, AuthSessionsByUserId, AuthSessionTombstones, UserCountryHistory} from '../../../Tables'; -import {awaitAll} from '../../../utils/ConcurrencyUtils'; -import {isValidTimestamp} from '../../../utils/TimestampUtils'; const AUTH_SESSION_CACHE_TTL_SECONDS = 30; const AUTH_SESSION_MISS_CACHE_TTL_SECONDS = 5; diff --git a/fluxer_api/src/api/user/repositories/auth/EmailChangeRepository.ts b/fluxer_api/src/api/user/repositories/auth/EmailChangeRepository.ts index c0d8e68fb..f24008fce 100644 --- a/fluxer_api/src/api/user/repositories/auth/EmailChangeRepository.ts +++ b/fluxer_api/src/api/user/repositories/auth/EmailChangeRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {deleteOneOrMany, fetchOne, upsertOne} from '../../../database/CassandraQueryExecution'; -import type {EmailChangeTicketRow, EmailChangeTokenRow} from '../../../database/types/AuthTypes'; -import {EmailChangeTickets, EmailChangeTokens} from '../../../Tables'; +import {deleteOneOrMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {EmailChangeTicketRow, EmailChangeTokenRow} from '@app/api/database/types/AuthTypes'; +import {EmailChangeTickets, EmailChangeTokens} from '@app/api/Tables'; const FETCH_TICKET_CQL = EmailChangeTickets.selectCql({ where: EmailChangeTickets.where.eq('ticket'), diff --git a/fluxer_api/src/api/user/repositories/auth/IpAuthorizationRepository.ts b/fluxer_api/src/api/user/repositories/auth/IpAuthorizationRepository.ts index 9b7556c8a..0cbcf0c87 100644 --- a/fluxer_api/src/api/user/repositories/auth/IpAuthorizationRepository.ts +++ b/fluxer_api/src/api/user/repositories/auth/IpAuthorizationRepository.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {UserFlags} from '@fluxer/constants/src/UserConstants'; -import {getSameIpDecisionKey, normalizeIpString, parseIpAddress} from '@fluxer/ip_utils/src/IpAddress'; -import {createIpAuthorizationToken, type UserID} from '../../../BrandedTypes'; -import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../../../database/CassandraQueryExecution'; +import {createIpAuthorizationToken, type UserID} from '@app/api/BrandedTypes'; +import {deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; import type { AuthorizedIpRow, AuthorizedIpTrustKeyRow, IpAuthorizationTokenRow, -} from '../../../database/types/AuthTypes'; -import {AuthorizedIps, AuthorizedIpTrustKeys, IpAuthorizationTokens} from '../../../Tables'; -import type {IUserAccountRepository} from '../IUserAccountRepository'; +} from '@app/api/database/types/AuthTypes'; +import {AuthorizedIps, AuthorizedIpTrustKeys, IpAuthorizationTokens} from '@app/api/Tables'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import {UserFlags} from '@fluxer/constants/src/UserConstants'; +import {getSameIpDecisionKey, normalizeIpString, parseIpAddress} from '@fluxer/ip_utils/src/IpAddress'; const AUTHORIZE_IP_BY_TOKEN_CQL = IpAuthorizationTokens.selectCql({ where: IpAuthorizationTokens.where.eq('token_'), diff --git a/fluxer_api/src/api/user/repositories/auth/MfaBackupCodeRepository.ts b/fluxer_api/src/api/user/repositories/auth/MfaBackupCodeRepository.ts index a069a5a24..d55d56b78 100644 --- a/fluxer_api/src/api/user/repositories/auth/MfaBackupCodeRepository.ts +++ b/fluxer_api/src/api/user/repositories/auth/MfaBackupCodeRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {createMfaBackupCode, type UserID} from '../../../BrandedTypes'; -import {BatchBuilder, deleteOneOrMany, fetchMany, upsertOne} from '../../../database/CassandraQueryExecution'; -import {Db} from '../../../database/CassandraTypes'; -import type {MfaBackupCodeRow} from '../../../database/types/AuthTypes'; -import {MfaBackupCode} from '../../../models/MfaBackupCode'; -import {MfaBackupCodes} from '../../../Tables'; +import {createMfaBackupCode, type UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, deleteOneOrMany, fetchMany, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {MfaBackupCodeRow} from '@app/api/database/types/AuthTypes'; +import {MfaBackupCode} from '@app/api/models/MfaBackupCode'; +import {MfaBackupCodes} from '@app/api/Tables'; const FETCH_MFA_BACKUP_CODES_CQL = MfaBackupCodes.selectCql({ where: MfaBackupCodes.where.eq('user_id'), diff --git a/fluxer_api/src/api/user/repositories/auth/PasswordChangeRepository.ts b/fluxer_api/src/api/user/repositories/auth/PasswordChangeRepository.ts index a263bf654..8cc10e24b 100644 --- a/fluxer_api/src/api/user/repositories/auth/PasswordChangeRepository.ts +++ b/fluxer_api/src/api/user/repositories/auth/PasswordChangeRepository.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {deleteOneOrMany, fetchOne, upsertOne} from '../../../database/CassandraQueryExecution'; -import type {PasswordChangeTicketRow} from '../../../database/types/AuthTypes'; -import {PasswordChangeTickets} from '../../../Tables'; +import {deleteOneOrMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import type {PasswordChangeTicketRow} from '@app/api/database/types/AuthTypes'; +import {PasswordChangeTickets} from '@app/api/Tables'; const FETCH_TICKET_CQL = PasswordChangeTickets.selectCql({ where: PasswordChangeTickets.where.eq('ticket'), diff --git a/fluxer_api/src/api/user/repositories/auth/TokenRepository.ts b/fluxer_api/src/api/user/repositories/auth/TokenRepository.ts index 7e9ad4efc..c2f3b1005 100644 --- a/fluxer_api/src/api/user/repositories/auth/TokenRepository.ts +++ b/fluxer_api/src/api/user/repositories/auth/TokenRepository.ts @@ -1,29 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {seconds} from 'itty-time'; import type { PasswordResetToken as PasswordResetTokenBrand, PhoneVerificationToken, UserID, -} from '../../../BrandedTypes'; -import {createEmailRevertToken, createEmailVerificationToken, createPasswordResetToken} from '../../../BrandedTypes'; -import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../../../database/CassandraQueryExecution'; +} from '@app/api/BrandedTypes'; +import {createEmailRevertToken, createEmailVerificationToken, createPasswordResetToken} from '@app/api/BrandedTypes'; +import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; import type { EmailRevertTokenRow, EmailVerificationTokenRow, PasswordResetTokenRow, PhoneTokenRow, -} from '../../../database/types/AuthTypes'; -import {EmailRevertToken} from '../../../models/EmailRevertToken'; -import {EmailVerificationToken} from '../../../models/EmailVerificationToken'; -import {PasswordResetToken} from '../../../models/PasswordResetToken'; +} from '@app/api/database/types/AuthTypes'; +import {EmailRevertToken} from '@app/api/models/EmailRevertToken'; +import {EmailVerificationToken} from '@app/api/models/EmailVerificationToken'; +import {PasswordResetToken} from '@app/api/models/PasswordResetToken'; import { EmailRevertTokens, EmailVerificationTokens, PasswordResetTokens, PasswordResetTokensByUserId, PhoneTokens, -} from '../../../Tables'; +} from '@app/api/Tables'; +import {seconds} from 'itty-time'; const FETCH_EMAIL_VERIFICATION_TOKEN_CQL = EmailVerificationTokens.selectCql({ where: EmailVerificationTokens.where.eq('token_'), diff --git a/fluxer_api/src/api/user/repositories/auth/WebAuthnRepository.ts b/fluxer_api/src/api/user/repositories/auth/WebAuthnRepository.ts index 2d005cf00..b7f8c7a20 100644 --- a/fluxer_api/src/api/user/repositories/auth/WebAuthnRepository.ts +++ b/fluxer_api/src/api/user/repositories/auth/WebAuthnRepository.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../../BrandedTypes'; -import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../../../database/CassandraQueryExecution'; -import {Db} from '../../../database/CassandraTypes'; -import type {WebAuthnCredentialRow} from '../../../database/types/AuthTypes'; -import {WebAuthnCredential} from '../../../models/WebAuthnCredential'; -import {WebAuthnCredentialLookup, WebAuthnCredentials} from '../../../Tables'; +import type {UserID} from '@app/api/BrandedTypes'; +import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import type {WebAuthnCredentialRow} from '@app/api/database/types/AuthTypes'; +import {WebAuthnCredential} from '@app/api/models/WebAuthnCredential'; +import {WebAuthnCredentialLookup, WebAuthnCredentials} from '@app/api/Tables'; const FETCH_USER_ID_BY_CREDENTIAL_ID_CQL = WebAuthnCredentialLookup.selectCql({ where: WebAuthnCredentialLookup.where.eq('credential_id'), diff --git a/fluxer_api/src/api/user/services/BaseUserUpdatePropagator.ts b/fluxer_api/src/api/user/services/BaseUserUpdatePropagator.ts index f79d087d8..0f6df738a 100644 --- a/fluxer_api/src/api/user/services/BaseUserUpdatePropagator.ts +++ b/fluxer_api/src/api/user/services/BaseUserUpdatePropagator.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {User} from '../../models/User'; -import {invalidateUserCache, updateUserCache} from '../UserCacheHelpers'; -import {mapUserToPrivateResponse} from '../UserMappers'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {User} from '@app/api/models/User'; +import {invalidateUserCache, updateUserCache} from '@app/api/user/UserCacheHelpers'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; interface BaseUserUpdatePropagatorDeps { userCacheService: UserCacheService; diff --git a/fluxer_api/src/api/user/services/CustomStatusValidator.ts b/fluxer_api/src/api/user/services/CustomStatusValidator.ts index 6cd5d26c8..65b3ec7b4 100644 --- a/fluxer_api/src/api/user/services/CustomStatusValidator.ts +++ b/fluxer_api/src/api/user/services/CustomStatusValidator.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createEmojiID, type EmojiID, type UserID} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {CustomStatusPayload} from '@fluxer/schema/src/domains/user/UserRequestSchemas'; -import {createEmojiID, type EmojiID, type UserID} from '../../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import {contentModerationService} from '../../infrastructure/ContentModerationService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../limits/LimitMatchContextBuilder'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; interface ValidatedCustomStatus { text: string | null; diff --git a/fluxer_api/src/api/user/services/DirectMessageSpamMitigationService.ts b/fluxer_api/src/api/user/services/DirectMessageSpamMitigationService.ts index 172716c2a..af85e48ba 100644 --- a/fluxer_api/src/api/user/services/DirectMessageSpamMitigationService.ts +++ b/fluxer_api/src/api/user/services/DirectMessageSpamMitigationService.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import {lookupGeoip} from '@app/api/utils/IpUtils'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {parseIpAddress} from '@fluxer/ip_utils/src/IpAddress'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {ApiContext} from '../../ApiContext'; -import type {UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {UserRow} from '../../database/types/UserTypes'; -import {Logger} from '../../Logger'; -import type {User} from '../../models/User'; -import {lookupGeoip} from '../../utils/IpUtils'; const DIRECT_CONTACT_SPAM_TARGET_KEY_PREFIX = 'direct-contact-spam:distinct-targets:'; diff --git a/fluxer_api/src/api/user/services/EmailChangeService.ts b/fluxer_api/src/api/user/services/EmailChangeService.ts index 842bffbc6..ed69615c8 100644 --- a/fluxer_api/src/api/user/services/EmailChangeService.ts +++ b/fluxer_api/src/api/user/services/EmailChangeService.ts @@ -1,6 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; +import type {ApiContext} from '@app/api/ApiContext'; +import {EMAIL_CLEARABLE_SUSPICIOUS_ACTIVITY_FLAGS} from '@app/api/auth/AuthEmail'; +import * as AuthPassword from '@app/api/auth/AuthPassword'; +import type {User} from '@app/api/models/User'; +import type {EmailChangeRepository} from '@app/api/user/repositories/auth/EmailChangeRepository'; import { assertChangeCooldown, checkChangeRateLimit, @@ -11,11 +16,6 @@ import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {AccessDeniedError} from '@fluxer/errors/src/domains/core/AccessDeniedError'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {ms} from 'itty-time'; -import type {ApiContext} from '../../ApiContext'; -import {EMAIL_CLEARABLE_SUSPICIOUS_ACTIVITY_FLAGS} from '../../auth/AuthEmail'; -import * as AuthPassword from '../../auth/AuthPassword'; -import type {User} from '../../models/User'; -import type {EmailChangeRepository} from '../repositories/auth/EmailChangeRepository'; interface StartEmailChangeResult { ticket: string; diff --git a/fluxer_api/src/api/user/services/HarvestDownloadToken.ts b/fluxer_api/src/api/user/services/HarvestDownloadToken.ts index f30a8c1b4..452a0b4eb 100644 --- a/fluxer_api/src/api/user/services/HarvestDownloadToken.ts +++ b/fluxer_api/src/api/user/services/HarvestDownloadToken.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHmac, timingSafeEqual} from 'node:crypto'; -import {isJsonRecord, parseJsonWithGuard} from '../../utils/JsonBoundaryUtils'; +import {isJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; const KEY_DERIVATION_LABEL = 'fluxer.harvest-download.v1'; diff --git a/fluxer_api/src/api/user/services/HarvestDownloadUrl.ts b/fluxer_api/src/api/user/services/HarvestDownloadUrl.ts index 37f4112be..c7e991704 100644 --- a/fluxer_api/src/api/user/services/HarvestDownloadUrl.ts +++ b/fluxer_api/src/api/user/services/HarvestDownloadUrl.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Config} from '../../Config'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {signHarvestDownloadToken} from './HarvestDownloadToken'; +import {Config} from '@app/api/Config'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {signHarvestDownloadToken} from '@app/api/user/services/HarvestDownloadToken'; const HARVEST_DOWNLOAD_PATH = '/harvest-downloads'; diff --git a/fluxer_api/src/api/user/services/MfaBackupCodesChallengeService.ts b/fluxer_api/src/api/user/services/MfaBackupCodesChallengeService.ts index 93f738581..167effcce 100644 --- a/fluxer_api/src/api/user/services/MfaBackupCodesChallengeService.ts +++ b/fluxer_api/src/api/user/services/MfaBackupCodesChallengeService.ts @@ -1,6 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID, timingSafeEqual} from 'node:crypto'; +import type {ApiContext} from '@app/api/ApiContext'; +import {requireEmailVerified} from '@app/api/auth/EmailVerificationUtils'; +import type {MfaBackupCode} from '@app/api/models/MfaBackupCode'; +import type {User} from '@app/api/models/User'; +import {regenerateMfaBackupCodes} from '@app/api/user/services/UserAuth'; import { assertChangeCooldown, checkChangeRateLimit, @@ -15,11 +20,6 @@ import type { MfaBackupCodesResponse, } from '@fluxer/schema/src/domains/auth/AuthSchemas'; import {ms} from 'itty-time'; -import type {ApiContext} from '../../ApiContext'; -import {requireEmailVerified} from '../../auth/EmailVerificationUtils'; -import type {MfaBackupCode} from '../../models/MfaBackupCode'; -import type {User} from '../../models/User'; -import {regenerateMfaBackupCodes} from './UserAuth'; interface MfaBackupCodesChallengeTicket { user_id: string; diff --git a/fluxer_api/src/api/user/services/PasswordChangeService.ts b/fluxer_api/src/api/user/services/PasswordChangeService.ts index 576379213..3373e8d7f 100644 --- a/fluxer_api/src/api/user/services/PasswordChangeService.ts +++ b/fluxer_api/src/api/user/services/PasswordChangeService.ts @@ -1,6 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthPassword from '@app/api/auth/AuthPassword'; +import type {User} from '@app/api/models/User'; +import type {PasswordChangeRepository} from '@app/api/user/repositories/auth/PasswordChangeRepository'; import { assertChangeCooldown, checkChangeRateLimit, @@ -10,10 +14,6 @@ import { import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import {ms} from 'itty-time'; -import type {ApiContext} from '../../ApiContext'; -import * as AuthPassword from '../../auth/AuthPassword'; -import type {User} from '../../models/User'; -import type {PasswordChangeRepository} from '../repositories/auth/PasswordChangeRepository'; interface StartPasswordChangeResult { ticket: string; diff --git a/fluxer_api/src/api/user/services/PendingDeletionCoordinator.ts b/fluxer_api/src/api/user/services/PendingDeletionCoordinator.ts index aef3e9ee6..30d28fbe8 100644 --- a/fluxer_api/src/api/user/services/PendingDeletionCoordinator.ts +++ b/fluxer_api/src/api/user/services/PendingDeletionCoordinator.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; import {DeletionReasons} from '@fluxer/constants/src/Core'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; -import type {UserID} from '../../BrandedTypes'; interface PendingDeletionRepositoryLike { addPendingDeletion(userId: UserID, pendingDeletionAt: Date, deletionReasonCode: number): Promise; diff --git a/fluxer_api/src/api/user/services/UserAccountLifecycleService.ts b/fluxer_api/src/api/user/services/UserAccountLifecycleService.ts index 5fb3611c1..58f599aba 100644 --- a/fluxer_api/src/api/user/services/UserAccountLifecycleService.ts +++ b/fluxer_api/src/api/user/services/UserAccountLifecycleService.ts @@ -1,5 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import type {UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import {Logger} from '@app/api/Logger'; +import type {Guild} from '@app/api/models/Guild'; +import type {User} from '@app/api/models/User'; +import { + canEscapePhoneGate, + type DeferredPhoneGateStatus, + getDeferredPhoneGateConfig, + guildTriggersPhoneGate, + PHONE_GATE_ESCAPE_MAX_GUILDS, + restorePhoneGateDeferral, +} from '@app/api/risk/DeferredPhoneGate'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import {reschedulePendingDeletion} from '@app/api/user/services/PendingDeletionCoordinator'; +import type {UserAccountUpdatePropagator} from '@app/api/user/services/UserAccountUpdatePropagator'; +import {getEffectiveSuspiciousFlags} from '@app/api/user/UserHelpers'; +import {hasPartialUserFieldsChanged} from '@app/api/user/UserMappers'; import {DeletionReasons} from '@fluxer/constants/src/Core'; import {DEFERRABLE_PHONE_FLAGS, DEFERRED_PHONE_ON_COMMUNITY_JOIN, UserFlags} from '@fluxer/constants/src/UserConstants'; import {UnknownGuildMemberError} from '@fluxer/errors/src/domains/guild/UnknownGuildMemberError'; @@ -9,29 +32,6 @@ import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import type {IEmailService} from '@pkgs/email/src/IEmailService'; import {ms} from 'itty-time'; -import type {ApiContext} from '../../ApiContext'; -import * as AuthSession from '../../auth/AuthSession'; -import type {UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {GuildService} from '../../guild/services/GuildService'; -import type {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import {Logger} from '../../Logger'; -import type {Guild} from '../../models/Guild'; -import type {User} from '../../models/User'; -import { - canEscapePhoneGate, - type DeferredPhoneGateStatus, - getDeferredPhoneGateConfig, - guildTriggersPhoneGate, - PHONE_GATE_ESCAPE_MAX_GUILDS, - restorePhoneGateDeferral, -} from '../../risk/DeferredPhoneGate'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import {getEffectiveSuspiciousFlags} from '../UserHelpers'; -import {hasPartialUserFieldsChanged} from '../UserMappers'; -import {reschedulePendingDeletion} from './PendingDeletionCoordinator'; -import type {UserAccountUpdatePropagator} from './UserAccountUpdatePropagator'; const WRITE_RESTORED_DEFERRAL_ATTEMPTS = 3; diff --git a/fluxer_api/src/api/user/services/UserAccountLookupService.ts b/fluxer_api/src/api/user/services/UserAccountLookupService.ts index f6018bbca..c29f391ed 100644 --- a/fluxer_api/src/api/user/services/UserAccountLookupService.ts +++ b/fluxer_api/src/api/user/services/UserAccountLookupService.ts @@ -1,5 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {IConnectionRepository} from '@app/api/connection/IConnectionRepository'; +import type {UserConnectionRow} from '@app/api/database/types/ConnectionTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {User} from '@app/api/models/User'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import type {IUserChannelRepository} from '@app/api/user/repositories/IUserChannelRepository'; +import type {IUserRelationshipRepository} from '@app/api/user/repositories/IUserRelationshipRepository'; +import type {IUserSettingsRepository} from '@app/api/user/repositories/IUserSettingsRepository'; +import {canUseProfileTimezone} from '@app/api/user/UserHelpers'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import { PremiumFlags, @@ -13,20 +27,6 @@ import { import {MissingAccessError} from '@fluxer/errors/src/domains/core/MissingAccessError'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {IConnectionRepository} from '../../connection/IConnectionRepository'; -import type {UserConnectionRow} from '../../database/types/ConnectionTypes'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {GuildService} from '../../guild/services/GuildService'; -import type {IDiscriminatorService} from '../../infrastructure/DiscriminatorService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {GuildMember} from '../../models/GuildMember'; -import type {User} from '../../models/User'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import type {IUserChannelRepository} from '../repositories/IUserChannelRepository'; -import type {IUserRelationshipRepository} from '../repositories/IUserRelationshipRepository'; -import type {IUserSettingsRepository} from '../repositories/IUserSettingsRepository'; -import {canUseProfileTimezone} from '../UserHelpers'; interface ProfileFieldPrivacyContext { isOwner: boolean; diff --git a/fluxer_api/src/api/user/services/UserAccountNotesService.ts b/fluxer_api/src/api/user/services/UserAccountNotesService.ts index 8f6e3688c..0ac42792c 100644 --- a/fluxer_api/src/api/user/services/UserAccountNotesService.ts +++ b/fluxer_api/src/api/user/services/UserAccountNotesService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import type {IUserRelationshipRepository} from '@app/api/user/repositories/IUserRelationshipRepository'; +import type {UserAccountUpdatePropagator} from '@app/api/user/services/UserAccountUpdatePropagator'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; -import type {UserID} from '../../BrandedTypes'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import type {IUserRelationshipRepository} from '../repositories/IUserRelationshipRepository'; -import type {UserAccountUpdatePropagator} from './UserAccountUpdatePropagator'; interface UserAccountNotesServiceDeps { userAccountRepository: IUserAccountRepository; diff --git a/fluxer_api/src/api/user/services/UserAccountProfileService.ts b/fluxer_api/src/api/user/services/UserAccountProfileService.ts index 76e149af2..2feb07a7b 100644 --- a/fluxer_api/src/api/user/services/UserAccountProfileService.ts +++ b/fluxer_api/src/api/user/services/UserAccountProfileService.ts @@ -1,5 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {EntityAssetService, PreparedAssetUpload} from '@app/api/infrastructure/EntityAssetService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import type {User} from '@app/api/models/User'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import {canUseProfileTimezone, isProfileSubstringExempt} from '@app/api/user/UserHelpers'; +import {deriveDominantAvatarColor} from '@app/api/utils/AvatarColorUtils'; +import * as EmojiUtils from '@app/api/utils/EmojiUtils'; import {MAX_BIO_LENGTH} from '@fluxer/constants/src/LimitConstants'; import {PremiumFlags, ProfileFieldPrivacyFlags, UserFlags} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; @@ -10,19 +23,6 @@ import {MissingAccessError} from '@fluxer/errors/src/domains/core/MissingAccessE import type {UserUpdateRequest} from '@fluxer/schema/src/domains/user/UserRequestSchemas'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; import {ms} from 'itty-time'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import {contentModerationService} from '../../infrastructure/ContentModerationService'; -import type {EntityAssetService, PreparedAssetUpload} from '../../infrastructure/EntityAssetService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../limits/LimitMatchContextBuilder'; -import {profileSubstringBlocklistCache} from '../../middleware/ProfileSubstringBlocklistCache'; -import type {User} from '../../models/User'; -import {deriveDominantAvatarColor} from '../../utils/AvatarColorUtils'; -import * as EmojiUtils from '../../utils/EmojiUtils'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import {canUseProfileTimezone, isProfileSubstringExempt} from '../UserHelpers'; type UserFieldUpdates = Partial; diff --git a/fluxer_api/src/api/user/services/UserAccountRequestService.ts b/fluxer_api/src/api/user/services/UserAccountRequestService.ts index 28b1e25e2..dfb1a86bf 100644 --- a/fluxer_api/src/api/user/services/UserAccountRequestService.ts +++ b/fluxer_api/src/api/user/services/UserAccountRequestService.ts @@ -1,5 +1,47 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import * as AuthEmailRevert from '@app/api/auth/AuthEmailRevert'; +import {requireEmailVerified} from '@app/api/auth/EmailVerificationUtils'; +import type {IRegistrationRiskEvaluator} from '@app/api/auth/services/IRegistrationRiskEvaluator'; +import {requireSudoMode, type SudoVerificationResult} from '@app/api/auth/services/SudoVerificationService'; +import {createChannelID, createGuildID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {UserConnectionRow} from '@app/api/database/types/ConnectionTypes'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {AuthSession} from '@app/api/models/AuthSession'; +import type {User} from '@app/api/models/User'; +import {createAccountPolicyContactContext, type IAccountPolicyEvaluator} from '@app/api/risk/AccountPolicyEvaluator'; +import type {IRegistrationEventsRepository} from '@app/api/risk/adapters/VelocityAdapter'; +import type {IRiskHistoryRepository} from '@app/api/risk/HistoricalOutcomeRepository'; +import {derivePlusAddressBase} from '@app/api/risk/PlusAddressUtils'; +import type {IRiskAssessmentRepository} from '@app/api/risk/RiskAssessmentRepository'; +import {deriveLatestRiskContext} from '@app/api/risk/RiskHistoryContext'; +import { + RecommendedAction, + type RiskAssessment, + RiskConfidence, + RiskDecisionMethod, + RiskLevel, +} from '@app/api/risk/RiskTypes'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import type {EmailChangeService} from '@app/api/user/services/EmailChangeService'; +import type {UserAccountService} from '@app/api/user/services/UserAccountService'; +import type {UserChannelService} from '@app/api/user/services/UserChannelService'; +import {mapUserToPartialResponseWithCache} from '@app/api/user/UserCacheHelpers'; +import { + canUseProfileTimezone, + createPremiumClearPatch, + getEffectiveSuspiciousFlags, + shouldStripExpiredPremium, +} from '@app/api/user/UserHelpers'; +import { + mapGuildMemberToProfileResponse, + mapUserToPrivateResponse, + mapUserToProfileResponse, +} from '@app/api/user/UserMappers'; import {DEFERRED_PHONE_ON_COMMUNITY_JOIN, imposePhoneRequirements} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {getCurrentTimeZoneOffsetMinutes} from '@fluxer/date_utils/src/TimeZoneUtils'; @@ -14,44 +56,6 @@ import type { } from '@fluxer/schema/src/domains/user/UserRequestSchemas'; import type {UserPrivateResponse, UserProfileFullResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import type {Context} from 'hono'; -import * as AuthEmailRevert from '../../auth/AuthEmailRevert'; -import {requireEmailVerified} from '../../auth/EmailVerificationUtils'; -import type {IRegistrationRiskEvaluator} from '../../auth/services/IRegistrationRiskEvaluator'; -import {requireSudoMode, type SudoVerificationResult} from '../../auth/services/SudoVerificationService'; -import {createChannelID, createGuildID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {UserConnectionRow} from '../../database/types/ConnectionTypes'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {Logger} from '../../Logger'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {AuthSession} from '../../models/AuthSession'; -import type {User} from '../../models/User'; -import {createAccountPolicyContactContext, type IAccountPolicyEvaluator} from '../../risk/AccountPolicyEvaluator'; -import type {IRegistrationEventsRepository} from '../../risk/adapters/VelocityAdapter'; -import type {IRiskHistoryRepository} from '../../risk/HistoricalOutcomeRepository'; -import {derivePlusAddressBase} from '../../risk/PlusAddressUtils'; -import type {IRiskAssessmentRepository} from '../../risk/RiskAssessmentRepository'; -import {deriveLatestRiskContext} from '../../risk/RiskHistoryContext'; -import { - RecommendedAction, - type RiskAssessment, - RiskConfidence, - RiskDecisionMethod, - RiskLevel, -} from '../../risk/RiskTypes'; -import type {HonoEnv} from '../../types/HonoEnv'; -import type {IUserRepository} from '../IUserRepository'; -import {mapUserToPartialResponseWithCache} from '../UserCacheHelpers'; -import { - canUseProfileTimezone, - createPremiumClearPatch, - getEffectiveSuspiciousFlags, - shouldStripExpiredPremium, -} from '../UserHelpers'; -import {mapGuildMemberToProfileResponse, mapUserToPrivateResponse, mapUserToProfileResponse} from '../UserMappers'; -import type {EmailChangeService} from './EmailChangeService'; -import type {UserAccountService} from './UserAccountService'; -import type {UserChannelService} from './UserChannelService'; type UserUpdatePayload = Omit< UserUpdateWithVerificationRequest, diff --git a/fluxer_api/src/api/user/services/UserAccountSecurityService.ts b/fluxer_api/src/api/user/services/UserAccountSecurityService.ts index 39566527a..881011fa4 100644 --- a/fluxer_api/src/api/user/services/UserAccountSecurityService.ts +++ b/fluxer_api/src/api/user/services/UserAccountSecurityService.ts @@ -1,5 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthPassword from '@app/api/auth/AuthPassword'; +import * as AuthSession from '@app/api/auth/AuthSession'; +import {deriveSudoMethods, userHasMfa} from '@app/api/auth/services/SudoMethods'; +import type {SudoVerificationResult} from '@app/api/auth/services/SudoVerificationService'; +import {Config} from '@app/api/Config'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import type {AuthSession as AuthSessionModel} from '@app/api/models/AuthSession'; +import type {User} from '@app/api/models/User'; +import {enforceFluxerTagChangeRateLimit} from '@app/api/user/FluxerTagChangeRateLimit'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import {isProfileSubstringExempt} from '@app/api/user/UserHelpers'; import {PremiumFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {SudoModeRequiredError} from '@fluxer/errors/src/domains/auth/SudoModeRequiredError'; @@ -7,23 +24,6 @@ import {ContentBlockedError} from '@fluxer/errors/src/domains/content/ContentBlo import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {UserUpdateRequest} from '@fluxer/schema/src/domains/user/UserRequestSchemas'; import type {IRateLimitService} from '@pkgs/rate_limit/src/IRateLimitService'; -import type {ApiContext} from '../../ApiContext'; -import * as AuthPassword from '../../auth/AuthPassword'; -import * as AuthSession from '../../auth/AuthSession'; -import {deriveSudoMethods, userHasMfa} from '../../auth/services/SudoMethods'; -import type {SudoVerificationResult} from '../../auth/services/SudoVerificationService'; -import {Config} from '../../Config'; -import type {UserRow} from '../../database/types/UserTypes'; -import type {IDiscriminatorService} from '../../infrastructure/DiscriminatorService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../limits/LimitMatchContextBuilder'; -import {profileSubstringBlocklistCache} from '../../middleware/ProfileSubstringBlocklistCache'; -import type {AuthSession as AuthSessionModel} from '../../models/AuthSession'; -import type {User} from '../../models/User'; -import {enforceFluxerTagChangeRateLimit} from '../FluxerTagChangeRateLimit'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import {isProfileSubstringExempt} from '../UserHelpers'; interface UserUpdateMetadata { invalidateAuthSessions?: boolean; diff --git a/fluxer_api/src/api/user/services/UserAccountService.ts b/fluxer_api/src/api/user/services/UserAccountService.ts index 00606bcd7..e4b1d9f83 100644 --- a/fluxer_api/src/api/user/services/UserAccountService.ts +++ b/fluxer_api/src/api/user/services/UserAccountService.ts @@ -1,37 +1,37 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {EMAIL_CLEARABLE_SUSPICIOUS_ACTIVITY_FLAGS} from '@app/api/auth/AuthEmail'; +import type {SudoVerificationResult} from '@app/api/auth/services/SudoVerificationService'; +import type {IConnectionRepository} from '@app/api/connection/IConnectionRepository'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import {GuildMemberSearchIndexService} from '@app/api/guild/services/member/GuildMemberSearchIndexService'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {AuthSession} from '@app/api/models/AuthSession'; +import type {User} from '@app/api/models/User'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import type {IUserChannelRepository} from '@app/api/user/repositories/IUserChannelRepository'; +import type {IUserRelationshipRepository} from '@app/api/user/repositories/IUserRelationshipRepository'; +import type {IUserSettingsRepository} from '@app/api/user/repositories/IUserSettingsRepository'; +import {UserAccountLifecycleService} from '@app/api/user/services/UserAccountLifecycleService'; +import {UserAccountLookupService} from '@app/api/user/services/UserAccountLookupService'; +import {UserAccountNotesService} from '@app/api/user/services/UserAccountNotesService'; +import {UserAccountProfileService} from '@app/api/user/services/UserAccountProfileService'; +import {UserAccountSecurityService} from '@app/api/user/services/UserAccountSecurityService'; +import {UserAccountSettingsService} from '@app/api/user/services/UserAccountSettingsService'; +import {UserAccountUpdatePropagator} from '@app/api/user/services/UserAccountUpdatePropagator'; +import type {UserContactChangeLogService} from '@app/api/user/services/UserContactChangeLogService'; +import {createPremiumClearPatch} from '@app/api/user/UserHelpers'; +import {hasPartialUserFieldsChanged} from '@app/api/user/UserMappers'; +import {runAllInOrder} from '@app/api/utils/ConcurrencyUtils'; import {PremiumFlags} from '@fluxer/constants/src/UserConstants'; import type {UserUpdateRequest} from '@fluxer/schema/src/domains/user/UserRequestSchemas'; -import type {ApiContext} from '../../ApiContext'; -import {EMAIL_CLEARABLE_SUSPICIOUS_ACTIVITY_FLAGS} from '../../auth/AuthEmail'; -import type {SudoVerificationResult} from '../../auth/services/SudoVerificationService'; -import type {IConnectionRepository} from '../../connection/IConnectionRepository'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {GuildService} from '../../guild/services/GuildService'; -import {GuildMemberSearchIndexService} from '../../guild/services/member/GuildMemberSearchIndexService'; -import type {IDiscriminatorService} from '../../infrastructure/DiscriminatorService'; -import type {EntityAssetService} from '../../infrastructure/EntityAssetService'; -import type {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {Logger} from '../../Logger'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {AuthSession} from '../../models/AuthSession'; -import type {User} from '../../models/User'; -import {runAllInOrder} from '../../utils/ConcurrencyUtils'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import type {IUserChannelRepository} from '../repositories/IUserChannelRepository'; -import type {IUserRelationshipRepository} from '../repositories/IUserRelationshipRepository'; -import type {IUserSettingsRepository} from '../repositories/IUserSettingsRepository'; -import {createPremiumClearPatch} from '../UserHelpers'; -import {hasPartialUserFieldsChanged} from '../UserMappers'; -import {UserAccountLifecycleService} from './UserAccountLifecycleService'; -import {UserAccountLookupService} from './UserAccountLookupService'; -import {UserAccountNotesService} from './UserAccountNotesService'; -import {UserAccountProfileService} from './UserAccountProfileService'; -import {UserAccountSecurityService} from './UserAccountSecurityService'; -import {UserAccountSettingsService} from './UserAccountSettingsService'; -import {UserAccountUpdatePropagator} from './UserAccountUpdatePropagator'; -import type {UserContactChangeLogService} from './UserContactChangeLogService'; interface UpdateUserParams { user: User; diff --git a/fluxer_api/src/api/user/services/UserAccountSettingsService.ts b/fluxer_api/src/api/user/services/UserAccountSettingsService.ts index 2efe70543..b9cde998f 100644 --- a/fluxer_api/src/api/user/services/UserAccountSettingsService.ts +++ b/fluxer_api/src/api/user/services/UserAccountSettingsService.ts @@ -1,5 +1,31 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + type ChannelID, + createChannelID, + createGuildID, + createUserID, + type GuildID, + type UserID, +} from '@app/api/BrandedTypes'; +import type {ChannelOverride, UserGuildSettingsRow} from '@app/api/database/types/UserTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; +import type {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import type {UserSettings} from '@app/api/models/UserSettings'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import type {IUserRelationshipRepository} from '@app/api/user/repositories/IUserRelationshipRepository'; +import type {IUserSettingsRepository} from '@app/api/user/repositories/IUserSettingsRepository'; +import {CustomStatusValidator} from '@app/api/user/services/CustomStatusValidator'; +import type {UserAccountUpdatePropagator} from '@app/api/user/services/UserAccountUpdatePropagator'; +import {getCachedUserPartialResponse} from '@app/api/user/UserCacheHelpers'; +import {mapRelationshipToResponse} from '@app/api/user/UserMappers'; +import {dedupeGuildFolders} from '@app/api/user/utils/GuildFolderUtils'; +import {isUserAdult} from '@app/api/utils/AgeUtils'; import { DEFAULT_GUILD_FOLDER_ICON, GroupDmAddPermissionFlags, @@ -26,32 +52,6 @@ import type { UserGuildSettingsUpdateRequest, UserSettingsUpdateRequest, } from '@fluxer/schema/src/domains/user/UserRequestSchemas'; -import { - type ChannelID, - createChannelID, - createGuildID, - createUserID, - type GuildID, - type UserID, -} from '../../BrandedTypes'; -import type {ChannelOverride, UserGuildSettingsRow} from '../../database/types/UserTypes'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {User} from '../../models/User'; -import type {UserGuildSettings} from '../../models/UserGuildSettings'; -import type {UserSettings} from '../../models/UserSettings'; -import {isUserAdult} from '../../utils/AgeUtils'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import type {IUserRelationshipRepository} from '../repositories/IUserRelationshipRepository'; -import type {IUserSettingsRepository} from '../repositories/IUserSettingsRepository'; -import {getCachedUserPartialResponse} from '../UserCacheHelpers'; -import {mapRelationshipToResponse} from '../UserMappers'; -import {dedupeGuildFolders} from '../utils/GuildFolderUtils'; -import {CustomStatusValidator} from './CustomStatusValidator'; -import type {UserAccountUpdatePropagator} from './UserAccountUpdatePropagator'; interface UserAccountSettingsServiceDeps { userAccountRepository: IUserAccountRepository; diff --git a/fluxer_api/src/api/user/services/UserAccountUpdatePropagator.ts b/fluxer_api/src/api/user/services/UserAccountUpdatePropagator.ts index 604feaca0..87feb9311 100644 --- a/fluxer_api/src/api/user/services/UserAccountUpdatePropagator.ts +++ b/fluxer_api/src/api/user/services/UserAccountUpdatePropagator.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {IMediaService} from '../../infrastructure/IMediaService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {UserGuildSettings} from '../../models/UserGuildSettings'; -import type {UserSettings} from '../../models/UserSettings'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import {mapUserGuildSettingsToResponse, mapUserSettingsToResponse} from '../UserMappers'; -import {BaseUserUpdatePropagator} from './BaseUserUpdatePropagator'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import type {UserSettings} from '@app/api/models/UserSettings'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import {BaseUserUpdatePropagator} from '@app/api/user/services/BaseUserUpdatePropagator'; +import {mapUserGuildSettingsToResponse, mapUserSettingsToResponse} from '@app/api/user/UserMappers'; interface UserAccountUpdatePropagatorDeps { userCacheService: UserCacheService; diff --git a/fluxer_api/src/api/user/services/UserActivityBuffer.ts b/fluxer_api/src/api/user/services/UserActivityBuffer.ts index 09c6dbdef..6075c91a6 100644 --- a/fluxer_api/src/api/user/services/UserActivityBuffer.ts +++ b/fluxer_api/src/api/user/services/UserActivityBuffer.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import {Logger} from '@app/api/Logger'; +import {AuthSessions} from '@app/api/Tables'; +import {UserAccountRepository} from '@app/api/user/repositories/account/UserAccountRepository'; +import {isJsonRecord, parseJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {seconds} from 'itty-time'; -import type {UserID} from '../../BrandedTypes'; -import {upsertOne} from '../../database/CassandraQueryExecution'; -import {Db} from '../../database/CassandraTypes'; -import {Logger} from '../../Logger'; -import {AuthSessions} from '../../Tables'; -import {isJsonRecord, parseJsonRecord} from '../../utils/JsonBoundaryUtils'; -import {UserAccountRepository} from '../repositories/account/UserAccountRepository'; const PENDING_HASH_KEY = 'user_activity:pending'; const PENDING_AUTH_SESSION_HASH_KEY = 'auth_session_activity:pending'; diff --git a/fluxer_api/src/api/user/services/UserAuth.ts b/fluxer_api/src/api/user/services/UserAuth.ts index 63b927dbd..f8e3885c0 100644 --- a/fluxer_api/src/api/user/services/UserAuth.ts +++ b/fluxer_api/src/api/user/services/UserAuth.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthMfa from '@app/api/auth/AuthMfa'; +import * as AuthUtility from '@app/api/auth/AuthUtility'; +import {deriveSudoMethods, userHasMfa} from '@app/api/auth/services/SudoMethods'; +import type {SudoVerificationResult} from '@app/api/auth/services/SudoVerificationService'; +import type {MfaBackupCode} from '@app/api/models/MfaBackupCode'; +import type {User} from '@app/api/models/User'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; import {UserAuthenticatorTypes} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {MfaNotDisabledError} from '@fluxer/errors/src/domains/auth/MfaNotDisabledError'; import {MfaNotEnabledError} from '@fluxer/errors/src/domains/auth/MfaNotEnabledError'; import {SudoModeRequiredError} from '@fluxer/errors/src/domains/auth/SudoModeRequiredError'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; -import type {ApiContext} from '../../ApiContext'; -import * as AuthMfa from '../../auth/AuthMfa'; -import * as AuthUtility from '../../auth/AuthUtility'; -import {deriveSudoMethods, userHasMfa} from '../../auth/services/SudoMethods'; -import type {SudoVerificationResult} from '../../auth/services/SudoVerificationService'; -import type {MfaBackupCode} from '../../models/MfaBackupCode'; -import type {User} from '../../models/User'; -import {mapUserToPrivateResponse} from '../UserMappers'; const LEGACY_PHONE_AUTHENTICATOR_TYPE = 1; diff --git a/fluxer_api/src/api/user/services/UserAuthRequestService.ts b/fluxer_api/src/api/user/services/UserAuthRequestService.ts index e9c560ee2..0bca35634 100644 --- a/fluxer_api/src/api/user/services/UserAuthRequestService.ts +++ b/fluxer_api/src/api/user/services/UserAuthRequestService.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import * as AuthMfa from '@app/api/auth/AuthMfa'; +import * as AuthPhone from '@app/api/auth/AuthPhone'; +import {requireEmailVerified} from '@app/api/auth/EmailVerificationUtils'; +import type {SudoVerificationResult} from '@app/api/auth/services/SudoVerificationService'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {User} from '@app/api/models/User'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import * as UserAuth from '@app/api/user/services/UserAuth'; import {GuildVerificationLevel} from '@fluxer/constants/src/GuildConstants'; import {UserAuthenticatorTypes} from '@fluxer/constants/src/UserConstants'; import {PhoneAddNotEligibleError} from '@fluxer/errors/src/domains/auth/PhoneAddNotEligibleError'; @@ -18,15 +27,6 @@ import type { WebAuthnCredentialUpdateRequest, WebAuthnRegisterRequest, } from '@fluxer/schema/src/domains/auth/AuthSchemas'; -import type {ApiContext} from '../../ApiContext'; -import * as AuthMfa from '../../auth/AuthMfa'; -import * as AuthPhone from '../../auth/AuthPhone'; -import {requireEmailVerified} from '../../auth/EmailVerificationUtils'; -import type {SudoVerificationResult} from '../../auth/services/SudoVerificationService'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../IUserRepository'; -import * as UserAuth from './UserAuth'; interface UserAuthWithSudoRequest { user: User; diff --git a/fluxer_api/src/api/user/services/UserChannelRequestService.ts b/fluxer_api/src/api/user/services/UserChannelRequestService.ts index db18bea00..6969348bf 100644 --- a/fluxer_api/src/api/user/services/UserChannelRequestService.ts +++ b/fluxer_api/src/api/user/services/UserChannelRequestService.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, UserID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {UserChannelService} from '@app/api/user/services/UserChannelService'; +import {getCachedUserPartialResponses} from '@app/api/user/UserCacheHelpers'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import type {CreatePrivateChannelRequest} from '@fluxer/schema/src/domains/user/UserRequestSchemas'; -import type {ChannelID, UserID} from '../../BrandedTypes'; -import {mapChannelToResponse} from '../../channel/ChannelMappers'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../models/Channel'; -import {getCachedUserPartialResponses} from '../UserCacheHelpers'; -import type {UserChannelService} from './UserChannelService'; interface UserChannelListParams { userId: UserID; diff --git a/fluxer_api/src/api/user/services/UserChannelService.ts b/fluxer_api/src/api/user/services/UserChannelService.ts index d9d52cdc8..c3841c84d 100644 --- a/fluxer_api/src/api/user/services/UserChannelService.ts +++ b/fluxer_api/src/api/user/services/UserChannelService.ts @@ -1,5 +1,33 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {requireEmailVerified} from '@app/api/auth/EmailVerificationUtils'; +import type {ChannelID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import {dispatchMessageCreateBroadcast} from '@app/api/channel/services/message/MessageGatewayDispatch'; +import { + createMessageResponseDataService, + messageResponseAccessForGuild, +} from '@app/api/channel/services/message/MessageResponseDataService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {User} from '@app/api/models/User'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import type {IUserChannelRepository} from '@app/api/user/repositories/IUserChannelRepository'; +import type {IUserRelationshipRepository} from '@app/api/user/repositories/IUserRelationshipRepository'; +import type {DirectMessageSpamMitigationService} from '@app/api/user/services/DirectMessageSpamMitigationService'; +import {createDirectMessageSpamMitigationService} from '@app/api/user/services/DirectMessageSpamMitigationService'; +import type {UserPermissionUtils} from '@app/api/utils/UserPermissionUtils'; import {ChannelTypes, MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; import {MAX_GROUP_DM_RECIPIENTS, MAX_GROUP_DMS_PER_USER} from '@fluxer/constants/src/LimitConstants'; @@ -17,34 +45,6 @@ import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import type {CreatePrivateChannelRequest} from '@fluxer/schema/src/domains/user/UserRequestSchemas'; import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; -import type {ApiContext} from '../../ApiContext'; -import {requireEmailVerified} from '../../auth/EmailVerificationUtils'; -import type {ChannelID, UserID} from '../../BrandedTypes'; -import {createChannelID, createMessageID, createUserID} from '../../BrandedTypes'; -import {mapChannelToResponse} from '../../channel/ChannelMappers'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {ChannelService} from '../../channel/services/ChannelService'; -import {dispatchMessageCreateBroadcast} from '../../channel/services/message/MessageGatewayDispatch'; -import { - createMessageResponseDataService, - messageResponseAccessForGuild, -} from '../../channel/services/message/MessageResponseDataService'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Channel} from '../../models/Channel'; -import type {Message} from '../../models/Message'; -import type {User} from '../../models/User'; -import type {UserPermissionUtils} from '../../utils/UserPermissionUtils'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import type {IUserChannelRepository} from '../repositories/IUserChannelRepository'; -import type {IUserRelationshipRepository} from '../repositories/IUserRelationshipRepository'; -import type {DirectMessageSpamMitigationService} from './DirectMessageSpamMitigationService'; -import {createDirectMessageSpamMitigationService} from './DirectMessageSpamMitigationService'; interface UserChannelRepository extends IUserAccountRepository, IUserChannelRepository, IUserRelationshipRepository {} diff --git a/fluxer_api/src/api/user/services/UserContactChangeLogService.ts b/fluxer_api/src/api/user/services/UserContactChangeLogService.ts index 188d56074..48073e140 100644 --- a/fluxer_api/src/api/user/services/UserContactChangeLogService.ts +++ b/fluxer_api/src/api/user/services/UserContactChangeLogService.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {UserID} from '../../BrandedTypes'; -import type {UserContactChangeLogRow} from '../../database/types/UserTypes'; -import type {User} from '../../models/User'; -import {awaitAll} from '../../utils/ConcurrencyUtils'; -import type {UserContactChangeLogRepository} from '../repositories/UserContactChangeLogRepository'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {UserContactChangeLogRow} from '@app/api/database/types/UserTypes'; +import type {User} from '@app/api/models/User'; +import type {UserContactChangeLogRepository} from '@app/api/user/repositories/UserContactChangeLogRepository'; +import {awaitAll} from '@app/api/utils/ConcurrencyUtils'; type ContactChangeReason = 'user_requested' | 'admin_action'; diff --git a/fluxer_api/src/api/user/services/UserContentRequestService.ts b/fluxer_api/src/api/user/services/UserContentRequestService.ts index e0064cfd3..f0f5ebbbe 100644 --- a/fluxer_api/src/api/user/services/UserContentRequestService.ts +++ b/fluxer_api/src/api/user/services/UserContentRequestService.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Message} from '@app/api/models/Message'; +import type {SavedMessageEntry, UserContentService} from '@app/api/user/services/UserContentService'; import type {MessageListResponse, MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import type { HarvestCreationResponse, @@ -11,12 +17,6 @@ import type { SavedMessageEntryListResponse, SavedMessageEntryResponse, } from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import type {ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Message} from '../../models/Message'; -import type {SavedMessageEntry, UserContentService} from './UserContentService'; type HarvestLatestResponse = HarvestStatusResponse | null; diff --git a/fluxer_api/src/api/user/services/UserContentService.test.ts b/fluxer_api/src/api/user/services/UserContentService.test.ts index 60a3e61f6..2314bc022 100644 --- a/fluxer_api/src/api/user/services/UserContentService.test.ts +++ b/fluxer_api/src/api/user/services/UserContentService.test.ts @@ -1,5 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import type {ChannelID, MessageID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {KVBulkMessageDeletionQueueService} from '@app/api/infrastructure/KVBulkMessageDeletionQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {Message} from '@app/api/models/Message'; +import {UserContentService, UserContentServiceTestHooks} from '@app/api/user/services/UserContentService'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import {UnknownChannelError} from '@fluxer/errors/src/domains/channel/UnknownChannelError'; @@ -12,17 +23,6 @@ import {UnknownGuildError} from '@fluxer/errors/src/domains/guild/UnknownGuildEr import {NsfwContentRequiresAgeVerificationError} from '@fluxer/errors/src/domains/moderation/NsfwContentRequiresAgeVerificationError'; import type {LimitConfigSnapshot} from '@fluxer/limits/src/LimitTypes'; import {describe, expect, it, vi} from 'vitest'; -import type {ApiContext} from '../../ApiContext'; -import type {ChannelID, MessageID, UserID} from '../../BrandedTypes'; -import {createChannelID, createMessageID, createUserID} from '../../BrandedTypes'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {ChannelService} from '../../channel/services/ChannelService'; -import type {KVBulkMessageDeletionQueueService} from '../../infrastructure/KVBulkMessageDeletionQueueService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import {Message} from '../../models/Message'; -import {UserContentService, UserContentServiceTestHooks} from './UserContentService'; const {isUnreachableEntityError} = UserContentServiceTestHooks; diff --git a/fluxer_api/src/api/user/services/UserContentService.ts b/fluxer_api/src/api/user/services/UserContentService.ts index 2d076dcb9..66665395f 100644 --- a/fluxer_api/src/api/user/services/UserContentService.ts +++ b/fluxer_api/src/api/user/services/UserContentService.ts @@ -2,6 +2,34 @@ import crypto from 'node:crypto'; import type {Readable} from 'node:stream'; +import type {ApiContext} from '@app/api/ApiContext'; +import {type ChannelID, createChannelID, createUserID, type MessageID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import {createMessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; +import type {PushSubscriptionRow} from '@app/api/database/types/UserTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {KVBulkMessageDeletionQueueService} from '@app/api/infrastructure/KVBulkMessageDeletionQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Message} from '@app/api/models/Message'; +import type {PushSubscription} from '@app/api/models/PushSubscription'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import type {IUserContentRepository} from '@app/api/user/repositories/IUserContentRepository'; +import {BaseUserUpdatePropagator} from '@app/api/user/services/BaseUserUpdatePropagator'; +import {verifyHarvestDownloadToken} from '@app/api/user/services/HarvestDownloadToken'; +import {buildHarvestDownloadUrl} from '@app/api/user/services/HarvestDownloadUrl'; +import {UserHarvest} from '@app/api/user/UserHarvestModel'; +import {UserHarvestRepository} from '@app/api/user/UserHarvestRepository'; +import {serializeSelfMessageFilter} from '@app/api/worker/utils/SelfMessageFilterPayload'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import {MAX_BOOKMARKS_NON_PREMIUM} from '@fluxer/constants/src/LimitConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {UnknownChannelError} from '@fluxer/errors/src/domains/channel/UnknownChannelError'; @@ -30,34 +58,6 @@ import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import {isPubliclyRoutableUrlShape} from '@pkgs/http_client/src/PublicInternetRequestUrlPolicy'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import {ms} from 'itty-time'; -import type {ApiContext} from '../../ApiContext'; -import {type ChannelID, createChannelID, createUserID, type MessageID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {ChannelService} from '../../channel/services/ChannelService'; -import {createMessageResponseDataService} from '../../channel/services/message/MessageResponseDataService'; -import type {PushSubscriptionRow} from '../../database/types/UserTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import type {KVBulkMessageDeletionQueueService} from '../../infrastructure/KVBulkMessageDeletionQueueService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {Logger} from '../../Logger'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Message} from '../../models/Message'; -import type {PushSubscription} from '../../models/PushSubscription'; -import {serializeSelfMessageFilter} from '../../worker/utils/SelfMessageFilterPayload'; -import type {WorkerTaskName} from '../../worker/WorkerLaneConfig'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import type {IUserContentRepository} from '../repositories/IUserContentRepository'; -import {UserHarvest} from '../UserHarvestModel'; -import {UserHarvestRepository} from '../UserHarvestRepository'; -import {BaseUserUpdatePropagator} from './BaseUserUpdatePropagator'; -import {verifyHarvestDownloadToken} from './HarvestDownloadToken'; -import {buildHarvestDownloadUrl} from './HarvestDownloadUrl'; export interface SavedMessageEntry { channelId: ChannelID; diff --git a/fluxer_api/src/api/user/services/UserDeletionEligibilityService.ts b/fluxer_api/src/api/user/services/UserDeletionEligibilityService.ts index 23c59dfb7..e1d659db0 100644 --- a/fluxer_api/src/api/user/services/UserDeletionEligibilityService.ts +++ b/fluxer_api/src/api/user/services/UserDeletionEligibilityService.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {User} from '@app/api/models/User'; +import {getValidTimestamp, parseStoredTimestamp} from '@app/api/utils/TimestampUtils'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {ms, seconds} from 'itty-time'; -import type {UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {User} from '../../models/User'; -import {getValidTimestamp, parseStoredTimestamp} from '../../utils/TimestampUtils'; const INACTIVITY_WARNING_TTL_DAYS = 30; const INACTIVITY_WARNING_PREFIX = 'inactivity_warning_sent'; diff --git a/fluxer_api/src/api/user/services/UserDeletionService.ts b/fluxer_api/src/api/user/services/UserDeletionService.ts index e41c0721d..38ec74e7f 100644 --- a/fluxer_api/src/api/user/services/UserDeletionService.ts +++ b/fluxer_api/src/api/user/services/UserDeletionService.ts @@ -1,6 +1,27 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomInt} from 'node:crypto'; +import {createMessageID, createUserID, type MessageID, type UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {mapChannelToResponse} from '@app/api/channel/ChannelMappers'; +import type {ChannelRepository} from '@app/api/channel/ChannelRepository'; +import type {IConnectionRepository} from '@app/api/connection/IConnectionRepository'; +import type {FavoriteMemeRepository} from '@app/api/favorite_meme/FavoriteMemeRepository'; +import type {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {DiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import type {ApplicationRepository} from '@app/api/oauth/repositories/ApplicationRepository'; +import type {OAuth2TokenRepository} from '@app/api/oauth/repositories/OAuth2TokenRepository'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {isPendingDeletionBlocked} from '@app/api/user/services/PendingDeletionCoordinator'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import {ChannelTypes, MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import { DELETED_USER_DISCRIMINATOR, @@ -13,27 +34,6 @@ import * as BucketUtils from '@fluxer/snowflake/src/SnowflakeBuckets'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import {ms} from 'itty-time'; import type Stripe from 'stripe'; -import {createMessageID, createUserID, type MessageID, type UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {mapChannelToResponse} from '../../channel/ChannelMappers'; -import type {ChannelRepository} from '../../channel/ChannelRepository'; -import type {IConnectionRepository} from '../../connection/IConnectionRepository'; -import type {FavoriteMemeRepository} from '../../favorite_meme/FavoriteMemeRepository'; -import type {GuildRepository} from '../../guild/repositories/GuildRepository'; -import type {IPurgeQueue} from '../../infrastructure/BunnyPurgeQueue'; -import type {DiscriminatorService} from '../../infrastructure/DiscriminatorService'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {Logger} from '../../Logger'; -import {createRequestCache} from '../../middleware/RequestCacheMiddleware'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import type {ApplicationRepository} from '../../oauth/repositories/ApplicationRepository'; -import type {OAuth2TokenRepository} from '../../oauth/repositories/OAuth2TokenRepository'; -import type {WorkerTaskName} from '../../worker/WorkerLaneConfig'; -import type {UserRepository} from '../repositories/UserRepository'; -import {isPendingDeletionBlocked} from './PendingDeletionCoordinator'; const CHUNK_SIZE = 100; diff --git a/fluxer_api/src/api/user/services/UserRelationshipRequestService.ts b/fluxer_api/src/api/user/services/UserRelationshipRequestService.ts index 9a0364017..e018b8de2 100644 --- a/fluxer_api/src/api/user/services/UserRelationshipRequestService.ts +++ b/fluxer_api/src/api/user/services/UserRelationshipRequestService.ts @@ -1,5 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Relationship} from '@app/api/models/Relationship'; +import type {UserChannelService} from '@app/api/user/services/UserChannelService'; +import type {UserRelationshipService} from '@app/api/user/services/UserRelationshipService'; +import {getCachedUserPartialResponse, getCachedUserPartialResponses} from '@app/api/user/UserCacheHelpers'; +import {mapRelationshipToResponse} from '@app/api/user/UserMappers'; import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; import type { BulkIgnoreFriendRequestsRequest, @@ -12,14 +20,6 @@ import type { BulkIgnoreFriendRequestsResponse, RelationshipResponse, } from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import type {UserID} from '../../BrandedTypes'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {Relationship} from '../../models/Relationship'; -import {getCachedUserPartialResponse, getCachedUserPartialResponses} from '../UserCacheHelpers'; -import {mapRelationshipToResponse} from '../UserMappers'; -import type {UserChannelService} from './UserChannelService'; -import type {UserRelationshipService} from './UserRelationshipService'; interface RelationshipListParams { userId: UserID; diff --git a/fluxer_api/src/api/user/services/UserRelationshipService.ts b/fluxer_api/src/api/user/services/UserRelationshipService.ts index 7b2166dc0..324a9eff2 100644 --- a/fluxer_api/src/api/user/services/UserRelationshipService.ts +++ b/fluxer_api/src/api/user/services/UserRelationshipService.ts @@ -1,5 +1,25 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiContext} from '@app/api/ApiContext'; +import {requireEmailVerified} from '@app/api/auth/EmailVerificationUtils'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {getInstanceConfigRepository} from '@app/api/middleware/ServiceSingletons'; +import type {Relationship} from '@app/api/models/Relationship'; +import type {User} from '@app/api/models/User'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; +import type {IUserRelationshipRepository} from '@app/api/user/repositories/IUserRelationshipRepository'; +import type {IUserSettingsRepository} from '@app/api/user/repositories/IUserSettingsRepository'; +import type {DirectMessageSpamMitigationService} from '@app/api/user/services/DirectMessageSpamMitigationService'; +import {createDirectMessageSpamMitigationService} from '@app/api/user/services/DirectMessageSpamMitigationService'; +import {getCachedUserPartialResponse} from '@app/api/user/UserCacheHelpers'; +import {mapRelationshipToResponse} from '@app/api/user/UserMappers'; +import type {UserPermissionUtils} from '@app/api/utils/UserPermissionUtils'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; import {MAX_RELATIONSHIPS} from '@fluxer/constants/src/LimitConstants'; import {RelationshipTypes, UserFlags} from '@fluxer/constants/src/UserConstants'; @@ -21,26 +41,6 @@ import type { FriendRequestByTagRequest, } from '@fluxer/schema/src/domains/user/UserRequestSchemas'; import {extractTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; -import type {ApiContext} from '../../ApiContext'; -import {requireEmailVerified} from '../../auth/EmailVerificationUtils'; -import type {UserID} from '../../BrandedTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import {resolveLimitSafe} from '../../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../../middleware/RequestCacheMiddleware'; -import {getInstanceConfigRepository} from '../../middleware/ServiceSingletons'; -import type {Relationship} from '../../models/Relationship'; -import type {User} from '../../models/User'; -import type {UserPermissionUtils} from '../../utils/UserPermissionUtils'; -import type {IUserAccountRepository} from '../repositories/IUserAccountRepository'; -import type {IUserRelationshipRepository} from '../repositories/IUserRelationshipRepository'; -import type {IUserSettingsRepository} from '../repositories/IUserSettingsRepository'; -import {getCachedUserPartialResponse} from '../UserCacheHelpers'; -import {mapRelationshipToResponse} from '../UserMappers'; -import type {DirectMessageSpamMitigationService} from './DirectMessageSpamMitigationService'; -import {createDirectMessageSpamMitigationService} from './DirectMessageSpamMitigationService'; interface UserRelationshipRepository extends IUserAccountRepository, diff --git a/fluxer_api/src/api/user/services/UserService.ts b/fluxer_api/src/api/user/services/UserService.ts index f23ce161f..65d17b1f1 100644 --- a/fluxer_api/src/api/user/services/UserService.ts +++ b/fluxer_api/src/api/user/services/UserService.ts @@ -1,23 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ApiContext} from '../../ApiContext'; -import type {IChannelRepository} from '../../channel/IChannelRepository'; -import type {ChannelService} from '../../channel/services/ChannelService'; -import type {IConnectionRepository} from '../../connection/IConnectionRepository'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {GuildService} from '../../guild/services/GuildService'; -import type {IDiscriminatorService} from '../../infrastructure/DiscriminatorService'; -import type {EntityAssetService} from '../../infrastructure/EntityAssetService'; -import type {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import type {KVBulkMessageDeletionQueueService} from '../../infrastructure/KVBulkMessageDeletionQueueService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {LimitConfigService} from '../../limits/LimitConfigService'; -import type {UserPermissionUtils} from '../../utils/UserPermissionUtils'; -import {UserAccountService} from './UserAccountService'; -import {UserChannelService} from './UserChannelService'; -import type {UserContactChangeLogService} from './UserContactChangeLogService'; -import {UserContentService} from './UserContentService'; -import {UserRelationshipService} from './UserRelationshipService'; +import type {ApiContext} from '@app/api/ApiContext'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {IConnectionRepository} from '@app/api/connection/IConnectionRepository'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {IDiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {EntityAssetService} from '@app/api/infrastructure/EntityAssetService'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import type {KVBulkMessageDeletionQueueService} from '@app/api/infrastructure/KVBulkMessageDeletionQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {UserAccountService} from '@app/api/user/services/UserAccountService'; +import {UserChannelService} from '@app/api/user/services/UserChannelService'; +import type {UserContactChangeLogService} from '@app/api/user/services/UserContactChangeLogService'; +import {UserContentService} from '@app/api/user/services/UserContentService'; +import {UserRelationshipService} from '@app/api/user/services/UserRelationshipService'; +import type {UserPermissionUtils} from '@app/api/utils/UserPermissionUtils'; export class UserService { public readonly accountService: UserAccountService; diff --git a/fluxer_api/src/api/user/services/__tests__/HarvestDownloadToken.test.ts b/fluxer_api/src/api/user/services/__tests__/HarvestDownloadToken.test.ts index a4e190221..96d4aee7f 100644 --- a/fluxer_api/src/api/user/services/__tests__/HarvestDownloadToken.test.ts +++ b/fluxer_api/src/api/user/services/__tests__/HarvestDownloadToken.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {signHarvestDownloadToken, verifyHarvestDownloadToken} from '@app/api/user/services/HarvestDownloadToken'; import {describe, expect, test} from 'vitest'; -import {signHarvestDownloadToken, verifyHarvestDownloadToken} from '../HarvestDownloadToken'; const SECRET = 'test-connection-secret'; diff --git a/fluxer_api/src/api/user/tests/AccountDeleteAutoCancelOnLogin.test.ts b/fluxer_api/src/api/user/tests/AccountDeleteAutoCancelOnLogin.test.ts index 9861f5743..0930c47b4 100644 --- a/fluxer_api/src/api/user/tests/AccountDeleteAutoCancelOnLogin.test.ts +++ b/fluxer_api/src/api/user/tests/AccountDeleteAutoCancelOnLogin.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, loginAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {deleteAccount, expectDataExists} from '@app/api/user/tests/UserTestUtils'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, loginAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {deleteAccount, expectDataExists} from './UserTestUtils'; describe('Account Delete Auto Cancel on Login', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/AccountDeleteGracePeriod.test.ts b/fluxer_api/src/api/user/tests/AccountDeleteGracePeriod.test.ts index 49311310d..64c95211c 100644 --- a/fluxer_api/src/api/user/tests/AccountDeleteGracePeriod.test.ts +++ b/fluxer_api/src/api/user/tests/AccountDeleteGracePeriod.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, loginAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {deleteAccount, expectDataExists, fetchUser} from '@app/api/user/tests/UserTestUtils'; import {DELETED_USER_USERNAME} from '@fluxer/constants/src/UserConstants'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, loginAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../channel/tests/ChannelTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {deleteAccount, expectDataExists, fetchUser} from './UserTestUtils'; describe('Account Deletion Grace Period', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/AccountDeleteMentionResolution.test.ts b/fluxer_api/src/api/user/tests/AccountDeleteMentionResolution.test.ts index 055a08d78..e4db52bdd 100644 --- a/fluxer_api/src/api/user/tests/AccountDeleteMentionResolution.test.ts +++ b/fluxer_api/src/api/user/tests/AccountDeleteMentionResolution.test.ts @@ -1,15 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {acceptInvite, createChannel, createChannelInvite, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {ensureSessionStarted, sendMessage} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import { + deleteAccount, + setPendingDeletionAt, + triggerDeletionWorker, + waitForDeletionCompletion, +} from '@app/api/user/tests/UserTestUtils'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {acceptInvite, createChannel, createChannelInvite, createGuild} from '../../guild/tests/GuildTestUtils'; -import {ensureSessionStarted, sendMessage} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {deleteAccount, setPendingDeletionAt, triggerDeletionWorker, waitForDeletionCompletion} from './UserTestUtils'; describe('Account Delete Mention Resolution', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/AccountDeleteMessagePagination.test.ts b/fluxer_api/src/api/user/tests/AccountDeleteMessagePagination.test.ts index e8975e02a..9d8c39bb8 100644 --- a/fluxer_api/src/api/user/tests/AccountDeleteMessagePagination.test.ts +++ b/fluxer_api/src/api/user/tests/AccountDeleteMessagePagination.test.ts @@ -1,14 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {acceptInvite, createChannel, createChannelInvite, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {ensureSessionStarted, sendMessage} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import { + deleteAccount, + setPendingDeletionAt, + triggerDeletionWorker, + waitForDeletionCompletion, +} from '@app/api/user/tests/UserTestUtils'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {acceptInvite, createChannel, createChannelInvite, createGuild} from '../../guild/tests/GuildTestUtils'; -import {ensureSessionStarted, sendMessage} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {deleteAccount, setPendingDeletionAt, triggerDeletionWorker, waitForDeletionCompletion} from './UserTestUtils'; describe('Account Delete Message Pagination', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/AccountDeletePermanent.test.ts b/fluxer_api/src/api/user/tests/AccountDeletePermanent.test.ts index c0c222b84..3b671e9fd 100644 --- a/fluxer_api/src/api/user/tests/AccountDeletePermanent.test.ts +++ b/fluxer_api/src/api/user/tests/AccountDeletePermanent.test.ts @@ -1,18 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {fetchMany} from '@app/api/database/CassandraQueryExecution'; +import type {RelationshipRow} from '@app/api/database/types/UserTypes'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {RelationshipsByTarget} from '@app/api/Tables'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {createFriendship} from '@app/api/user/tests/RelationshipTestUtils'; +import { + deleteAccount, + setPendingDeletionAt, + triggerDeletionWorker, + waitForDeletionCompletion, +} from '@app/api/user/tests/UserTestUtils'; import type {GuildBanResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {fetchMany} from '../../database/CassandraQueryExecution'; -import type {RelationshipRow} from '../../database/types/UserTypes'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {RelationshipsByTarget} from '../../Tables'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createFriendship} from './RelationshipTestUtils'; -import {deleteAccount, setPendingDeletionAt, triggerDeletionWorker, waitForDeletionCompletion} from './UserTestUtils'; describe('Account Delete Permanent', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/AccountDisable.test.ts b/fluxer_api/src/api/user/tests/AccountDisable.test.ts index 92260c0a8..73be09710 100644 --- a/fluxer_api/src/api/user/tests/AccountDisable.test.ts +++ b/fluxer_api/src/api/user/tests/AccountDisable.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, loginAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {disableAccount, expectDataExists} from '@app/api/user/tests/UserTestUtils'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, loginAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {disableAccount, expectDataExists} from './UserTestUtils'; describe('Account Disable', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/BearerTokenScopeFiltering.test.ts b/fluxer_api/src/api/user/tests/BearerTokenScopeFiltering.test.ts index 29f1b2036..5723b9d71 100644 --- a/fluxer_api/src/api/user/tests/BearerTokenScopeFiltering.test.ts +++ b/fluxer_api/src/api/user/tests/BearerTokenScopeFiltering.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {UserPrivateResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, type TestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface OAuth2TokenResponse { token: string; diff --git a/fluxer_api/src/api/user/tests/BulkDeleteSelfMessages.test.ts b/fluxer_api/src/api/user/tests/BulkDeleteSelfMessages.test.ts index ef8886ce3..45aa860fd 100644 --- a/fluxer_api/src/api/user/tests/BulkDeleteSelfMessages.test.ts +++ b/fluxer_api/src/api/user/tests/BulkDeleteSelfMessages.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; const DEFAULT_BODY = { scope: 'selected' as const, diff --git a/fluxer_api/src/api/user/tests/DirectMessageSpamShadow.test.ts b/fluxer_api/src/api/user/tests/DirectMessageSpamShadow.test.ts index f0bb9f9f3..6c9def93a 100644 --- a/fluxer_api/src/api/user/tests/DirectMessageSpamShadow.test.ts +++ b/fluxer_api/src/api/user/tests/DirectMessageSpamShadow.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createDmChannel, sendChannelMessage} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {listRelationships, sendFriendRequest} from '@app/api/user/tests/RelationshipTestUtils'; import {RelationshipTypes, UserFlags} from '@fluxer/constants/src/UserConstants'; import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createDmChannel, sendChannelMessage} from '../../channel/tests/ChannelTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {listRelationships, sendFriendRequest} from './RelationshipTestUtils'; async function setUserFlags(harness: ApiTestHarness, userId: string, flags: bigint): Promise { await createBuilder(harness, '') diff --git a/fluxer_api/src/api/user/tests/FavoriteMemeLimits.test.ts b/fluxer_api/src/api/user/tests/FavoriteMemeLimits.test.ts index 0c5074d6d..1bd4a7a5b 100644 --- a/fluxer_api/src/api/user/tests/FavoriteMemeLimits.test.ts +++ b/fluxer_api/src/api/user/tests/FavoriteMemeLimits.test.ts @@ -1,17 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {MAX_FAVORITE_MEME_TAGS, MAX_FAVORITE_MEMES_NON_PREMIUM} from '@fluxer/constants/src/LimitConstants'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccountForAttachmentTests, setupTestGuildAndChannel} from '../../channel/tests/AttachmentTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import { + createTestAccountForAttachmentTests, + setupTestGuildAndChannel, +} from '@app/api/channel/tests/AttachmentTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { createFavoriteMemeFromMessage, createFavoriteMemeFromUrl, createMessageWithImageAttachment, listFavoriteMemes, -} from './FavoriteMemeTestUtils'; +} from '@app/api/user/tests/FavoriteMemeTestUtils'; +import {MAX_FAVORITE_MEME_TAGS, MAX_FAVORITE_MEMES_NON_PREMIUM} from '@fluxer/constants/src/LimitConstants'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('Favorite Meme Limits', () => { let harness: ApiTestHarness; @@ -147,7 +150,7 @@ describe('Favorite Meme Limits', () => { test('should return error for message without media', async () => { const account = await createTestAccountForAttachmentTests(harness); const {channel} = await setupTestGuildAndChannel(harness, account); - const {sendMessage} = await import('../../message/tests/MessageTestUtils'); + const {sendMessage} = await import('@app/api/message/tests/MessageTestUtils'); const textMessage = await sendMessage(harness, account.token, channel.id, 'No media here'); await createBuilder(harness, account.token) .post(`/channels/${channel.id}/messages/${textMessage.id}/memes`) diff --git a/fluxer_api/src/api/user/tests/FavoriteMemeOperations.test.ts b/fluxer_api/src/api/user/tests/FavoriteMemeOperations.test.ts index 64b27228d..9ac33f3ad 100644 --- a/fluxer_api/src/api/user/tests/FavoriteMemeOperations.test.ts +++ b/fluxer_api/src/api/user/tests/FavoriteMemeOperations.test.ts @@ -1,21 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {MessageAttachmentFlags} from '@fluxer/constants/src/ChannelConstants'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {AttachmentDecayRepository} from '../../attachment/AttachmentDecayRepository'; -import {createAttachmentID, createMemeID, createUserID} from '../../BrandedTypes'; +import {AttachmentDecayRepository} from '@app/api/attachment/AttachmentDecayRepository'; +import {createAttachmentID, createMemeID, createUserID} from '@app/api/BrandedTypes'; import { createTestAccountForAttachmentTests, sendMessageWithAttachments, setupTestGuildAndChannel, -} from '../../channel/tests/AttachmentTestUtils'; -import {fetchOne} from '../../database/CassandraQueryExecution'; -import {Db} from '../../database/CassandraTypes'; -import {FavoriteMemes} from '../../Tables'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {getExpiryBucket} from '../../utils/AttachmentDecay'; +} from '@app/api/channel/tests/AttachmentTestUtils'; +import {fetchOne} from '@app/api/database/CassandraQueryExecution'; +import {Db} from '@app/api/database/CassandraTypes'; +import {FavoriteMemes} from '@app/api/Tables'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { createFavoriteMemeFromMessage, createMessageWithImageAttachment, @@ -23,7 +20,10 @@ import { getFavoriteMeme, listFavoriteMemes, updateFavoriteMeme, -} from './FavoriteMemeTestUtils'; +} from '@app/api/user/tests/FavoriteMemeTestUtils'; +import {getExpiryBucket} from '@app/api/utils/AttachmentDecay'; +import {MessageAttachmentFlags} from '@fluxer/constants/src/ChannelConstants'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; function animatedWebpProbeFixture(): Buffer { const buffer = Buffer.alloc(48); diff --git a/fluxer_api/src/api/user/tests/FavoriteMemeTestUtils.ts b/fluxer_api/src/api/user/tests/FavoriteMemeTestUtils.ts index eb4c041f2..ac59d1fba 100644 --- a/fluxer_api/src/api/user/tests/FavoriteMemeTestUtils.ts +++ b/fluxer_api/src/api/user/tests/FavoriteMemeTestUtils.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {loadFixture, sendMessageWithAttachments} from '@app/api/channel/tests/AttachmentTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {FavoriteMemeResponse} from '@fluxer/schema/src/domains/meme/MemeSchemas'; -import {loadFixture, sendMessageWithAttachments} from '../../channel/tests/AttachmentTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface MessageWithAttachment { id: string; diff --git a/fluxer_api/src/api/user/tests/FriendRequestSourceFlags.test.ts b/fluxer_api/src/api/user/tests/FriendRequestSourceFlags.test.ts index aa222b767..c127918af 100644 --- a/fluxer_api/src/api/user/tests/FriendRequestSourceFlags.test.ts +++ b/fluxer_api/src/api/user/tests/FriendRequestSourceFlags.test.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {FriendSourceFlags, RelationshipTypes} from '@fluxer/constants/src/UserConstants'; -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { assertRelationshipId, assertRelationshipType, createFriendship, sendFriendRequest, -} from './RelationshipTestUtils'; +} from '@app/api/user/tests/RelationshipTestUtils'; +import {FriendSourceFlags, RelationshipTypes} from '@fluxer/constants/src/UserConstants'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; describe('FriendRequestSourceFlags', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/HarvestDownloadExpired.test.ts b/fluxer_api/src/api/user/tests/HarvestDownloadExpired.test.ts index e56aa5c4f..b457fe16d 100644 --- a/fluxer_api/src/api/user/tests/HarvestDownloadExpired.test.ts +++ b/fluxer_api/src/api/user/tests/HarvestDownloadExpired.test.ts @@ -1,9 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import { + expectHarvestDownloadFailsWithError, + markHarvestCompleted, + requestHarvest, +} from '@app/api/user/tests/HarvestTestUtils'; import {beforeEach, describe, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {expectHarvestDownloadFailsWithError, markHarvestCompleted, requestHarvest} from './HarvestTestUtils'; describe('Harvest Download Expired', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/HarvestDownloadNotExpired.test.ts b/fluxer_api/src/api/user/tests/HarvestDownloadNotExpired.test.ts index 844e6c677..d9d3b1705 100644 --- a/fluxer_api/src/api/user/tests/HarvestDownloadNotExpired.test.ts +++ b/fluxer_api/src/api/user/tests/HarvestDownloadNotExpired.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {fetchHarvestDownload, markHarvestCompleted, requestHarvest} from '@app/api/user/tests/HarvestTestUtils'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {fetchHarvestDownload, markHarvestCompleted, requestHarvest} from './HarvestTestUtils'; describe('Harvest Download Not Expired', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/HarvestDownloadStreaming.test.ts b/fluxer_api/src/api/user/tests/HarvestDownloadStreaming.test.ts index 40e624554..d2e67638c 100644 --- a/fluxer_api/src/api/user/tests/HarvestDownloadStreaming.test.ts +++ b/fluxer_api/src/api/user/tests/HarvestDownloadStreaming.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {getConfig} from '@app/api/Config'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {signHarvestDownloadToken} from '@app/api/user/services/HarvestDownloadToken'; +import {fetchHarvestDownload, markHarvestCompleted, requestHarvest} from '@app/api/user/tests/HarvestTestUtils'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {getConfig} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {signHarvestDownloadToken} from '../services/HarvestDownloadToken'; -import {fetchHarvestDownload, markHarvestCompleted, requestHarvest} from './HarvestTestUtils'; const ZIP_BYTES = new TextEncoder().encode('PK pretend zip'); diff --git a/fluxer_api/src/api/user/tests/HarvestRetryClearsFailure.test.ts b/fluxer_api/src/api/user/tests/HarvestRetryClearsFailure.test.ts index e7a0ee96a..5f3b5a12c 100644 --- a/fluxer_api/src/api/user/tests/HarvestRetryClearsFailure.test.ts +++ b/fluxer_api/src/api/user/tests/HarvestRetryClearsFailure.test.ts @@ -1,8 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import { expectHarvestDownloadFailsWithError, fetchHarvestDownload, @@ -11,7 +10,8 @@ import { markHarvestFailed, markHarvestStarted, requestHarvest, -} from './HarvestTestUtils'; +} from '@app/api/user/tests/HarvestTestUtils'; +import {beforeEach, describe, expect, test} from 'vitest'; describe('Harvest Retry Clears Failure', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/HarvestTestUtils.ts b/fluxer_api/src/api/user/tests/HarvestTestUtils.ts index a34d16486..8cb334ecf 100644 --- a/fluxer_api/src/api/user/tests/HarvestTestUtils.ts +++ b/fluxer_api/src/api/user/tests/HarvestTestUtils.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import type {UserHarvest} from '@app/api/user/UserHarvestModel'; +import {UserHarvestRepository} from '@app/api/user/UserHarvestRepository'; import type {HarvestDownloadUrlResponse} from '@fluxer/schema/src/domains/user/UserHarvestSchemas'; import {expect} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import type {UserHarvest} from '../UserHarvestModel'; -import {UserHarvestRepository} from '../UserHarvestRepository'; interface HarvestRequestResponse { harvest_id: string; diff --git a/fluxer_api/src/api/user/tests/InactivityDeletion.test.ts b/fluxer_api/src/api/user/tests/InactivityDeletion.test.ts index e3ab08160..ebe38f153 100644 --- a/fluxer_api/src/api/user/tests/InactivityDeletion.test.ts +++ b/fluxer_api/src/api/user/tests/InactivityDeletion.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import type {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {expectDataExists} from '@app/api/user/tests/UserTestUtils'; import {DeletionReasons} from '@fluxer/constants/src/Core'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import type {MockKVProvider} from '../../test/mocks/MockKVProvider'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../repositories/UserRepository'; -import {expectDataExists} from './UserTestUtils'; interface InactivityCheckResult { warnings_sent: number; diff --git a/fluxer_api/src/api/user/tests/ListEndpointUserPartialPrefetch.test.ts b/fluxer_api/src/api/user/tests/ListEndpointUserPartialPrefetch.test.ts index 1511a9d5e..acfd27ce7 100644 --- a/fluxer_api/src/api/user/tests/ListEndpointUserPartialPrefetch.test.ts +++ b/fluxer_api/src/api/user/tests/ListEndpointUserPartialPrefetch.test.ts @@ -1,21 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createChannelID, createUserID, type UserID} from '@app/api/BrandedTypes'; +import type {ChannelRow} from '@app/api/database/types/ChannelTypes'; +import type {RelationshipRow} from '@app/api/database/types/UserTypes'; +import {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {IUsersServiceClient} from '@app/api/infrastructure/UsersServiceClient'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {Channel} from '@app/api/models/Channel'; +import {Relationship} from '@app/api/models/Relationship'; +import {UserChannelRequestService} from '@app/api/user/services/UserChannelRequestService'; +import type {UserChannelService} from '@app/api/user/services/UserChannelService'; +import {UserRelationshipRequestService} from '@app/api/user/services/UserRelationshipRequestService'; +import type {UserRelationshipService} from '@app/api/user/services/UserRelationshipService'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {DELETED_USER_GLOBAL_NAME, DELETED_USER_USERNAME, RelationshipTypes} from '@fluxer/constants/src/UserConstants'; import type {UserPartialResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {describe, expect, test} from 'vitest'; -import {type ChannelID, createChannelID, createUserID, type UserID} from '../../BrandedTypes'; -import type {ChannelRow} from '../../database/types/ChannelTypes'; -import type {RelationshipRow} from '../../database/types/UserTypes'; -import {UserCacheService} from '../../infrastructure/UserCacheService'; -import type {IUsersServiceClient} from '../../infrastructure/UsersServiceClient'; -import {createRequestCache} from '../../middleware/RequestCacheMiddleware'; -import {Channel} from '../../models/Channel'; -import {Relationship} from '../../models/Relationship'; -import {UserChannelRequestService} from '../services/UserChannelRequestService'; -import type {UserChannelService} from '../services/UserChannelService'; -import {UserRelationshipRequestService} from '../services/UserRelationshipRequestService'; -import type {UserRelationshipService} from '../services/UserRelationshipService'; class RecordingUsersServiceClient implements IUsersServiceClient { readonly requests: Array> = []; diff --git a/fluxer_api/src/api/user/tests/MfaBackupCodesChallengeFlow.test.ts b/fluxer_api/src/api/user/tests/MfaBackupCodesChallengeFlow.test.ts index 3f9802f78..6c5b222bd 100644 --- a/fluxer_api/src/api/user/tests/MfaBackupCodesChallengeFlow.test.ts +++ b/fluxer_api/src/api/user/tests/MfaBackupCodesChallengeFlow.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; import { type BackupCodesResponse, createTestAccount, @@ -9,10 +8,11 @@ import { listTestEmails, type TestAccount, totpCodeNow, -} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; +} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; interface ChallengeStartResult { ticket: string; diff --git a/fluxer_api/src/api/user/tests/PasswordChangeFlow.test.ts b/fluxer_api/src/api/user/tests/PasswordChangeFlow.test.ts index 1e32de4c8..b4f3488ee 100644 --- a/fluxer_api/src/api/user/tests/PasswordChangeFlow.test.ts +++ b/fluxer_api/src/api/user/tests/PasswordChangeFlow.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; import { createTestAccount, findLastTestEmail, listTestEmails, loginUser, type TestAccount, -} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_CREDENTIALS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; +} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_CREDENTIALS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; interface PasswordChangeStartResult { ticket: string; diff --git a/fluxer_api/src/api/user/tests/ProfileCustomizationEmailVerificationRequired.test.ts b/fluxer_api/src/api/user/tests/ProfileCustomizationEmailVerificationRequired.test.ts index ed9685773..67d89c5b7 100644 --- a/fluxer_api/src/api/user/tests/ProfileCustomizationEmailVerificationRequired.test.ts +++ b/fluxer_api/src/api/user/tests/ProfileCustomizationEmailVerificationRequired.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAuthHarness, createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {acceptInvite, createChannelInvite, createGuild, getChannel} from '@app/api/channel/tests/ChannelTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createAuthHarness, createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {acceptInvite, createChannelInvite, createGuild, getChannel} from '../../channel/tests/ChannelTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface ErrorResponse { code: string; diff --git a/fluxer_api/src/api/user/tests/ProfileImageUpload.test.ts b/fluxer_api/src/api/user/tests/ProfileImageUpload.test.ts index dc6e06762..17af3c0e3 100644 --- a/fluxer_api/src/api/user/tests/ProfileImageUpload.test.ts +++ b/fluxer_api/src/api/user/tests/ProfileImageUpload.test.ts @@ -1,13 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {getGifDataUrl, getPngDataUrl} from '@app/api/emoji/tests/EmojiTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import { + grantPremium, + type UserProfileUpdateResult, + updateAvatar, + updateBanner, +} from '@app/api/user/tests/UserTestUtils'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {getGifDataUrl, getPngDataUrl} from '../../emoji/tests/EmojiTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {grantPremium, type UserProfileUpdateResult, updateAvatar, updateBanner} from './UserTestUtils'; const PREMIUM_TYPE_SUBSCRIPTION = 2; const AVATAR_MAX_SIZE = 10 * 1024 * 1024; diff --git a/fluxer_api/src/api/user/tests/PushSubscriptionLifecycle.test.ts b/fluxer_api/src/api/user/tests/PushSubscriptionLifecycle.test.ts index 8a2db0712..91a784d7f 100644 --- a/fluxer_api/src/api/user/tests/PushSubscriptionLifecycle.test.ts +++ b/fluxer_api/src/api/user/tests/PushSubscriptionLifecycle.test.ts @@ -1,16 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; -import {beforeEach, describe, expect, test} from 'vitest'; import { createSessionFromLogin, createTestAccount, loginAccount, logoutSpecificSessions, -} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { deleteMobileDevice, deletePushSubscription, @@ -19,7 +17,9 @@ import { registerMobileDevice, subscribePush, unregisterMobileDevice, -} from './UserTestUtils'; +} from '@app/api/user/tests/UserTestUtils'; +import type {AuthSessionResponse} from '@fluxer/schema/src/domains/auth/AuthSchemas'; +import {beforeEach, describe, expect, test} from 'vitest'; describe('Push Subscription Lifecycle', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/RelationshipAcceptAfterPrivacyChangeAllowsExistingRequest.test.ts b/fluxer_api/src/api/user/tests/RelationshipAcceptAfterPrivacyChangeAllowsExistingRequest.test.ts index 3fc778920..9571ba0e2 100644 --- a/fluxer_api/src/api/user/tests/RelationshipAcceptAfterPrivacyChangeAllowsExistingRequest.test.ts +++ b/fluxer_api/src/api/user/tests/RelationshipAcceptAfterPrivacyChangeAllowsExistingRequest.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; -import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { acceptFriendRequest, assertRelationshipId, assertRelationshipType, listRelationships, sendFriendRequest, -} from './RelationshipTestUtils'; +} from '@app/api/user/tests/RelationshipTestUtils'; +import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; +import {beforeEach, describe, expect, test} from 'vitest'; describe('RelationshipAcceptAfterPrivacyChangeAllowsExistingRequest', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/RelationshipBlocking.test.ts b/fluxer_api/src/api/user/tests/RelationshipBlocking.test.ts index 4f868f3f9..65660236a 100644 --- a/fluxer_api/src/api/user/tests/RelationshipBlocking.test.ts +++ b/fluxer_api/src/api/user/tests/RelationshipBlocking.test.ts @@ -1,13 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createDmChannel, createFriendship} from '../../channel/tests/ChannelTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createDmChannel, createFriendship} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { acceptFriendRequest, assertRelationshipId, @@ -16,7 +14,9 @@ import { listRelationships, removeRelationship, sendFriendRequest, -} from './RelationshipTestUtils'; +} from '@app/api/user/tests/RelationshipTestUtils'; +import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; describe('RelationshipBlocking', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/RelationshipBlockingBehaviors.test.ts b/fluxer_api/src/api/user/tests/RelationshipBlockingBehaviors.test.ts index 37b707314..4a1c82bf5 100644 --- a/fluxer_api/src/api/user/tests/RelationshipBlockingBehaviors.test.ts +++ b/fluxer_api/src/api/user/tests/RelationshipBlockingBehaviors.test.ts @@ -1,11 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; -import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { assertRelationshipId, assertRelationshipType, @@ -13,7 +11,9 @@ import { listRelationships, removeRelationship, sendFriendRequest, -} from './RelationshipTestUtils'; +} from '@app/api/user/tests/RelationshipTestUtils'; +import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; +import {beforeEach, describe, expect, test} from 'vitest'; describe('RelationshipBlockingBehaviors', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/RelationshipNicknameUpdate.test.ts b/fluxer_api/src/api/user/tests/RelationshipNicknameUpdate.test.ts index d8e7125f5..81ced8fcd 100644 --- a/fluxer_api/src/api/user/tests/RelationshipNicknameUpdate.test.ts +++ b/fluxer_api/src/api/user/tests/RelationshipNicknameUpdate.test.ts @@ -1,12 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import { + acceptFriendRequest, + listRelationships, + sendFriendRequest, + updateFriendNickname, +} from '@app/api/user/tests/RelationshipTestUtils'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {profileSubstringBlocklistCache} from '../../middleware/ProfileSubstringBlocklistCache'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {acceptFriendRequest, listRelationships, sendFriendRequest, updateFriendNickname} from './RelationshipTestUtils'; describe('RelationshipNicknameUpdate', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/RelationshipTestUtils.ts b/fluxer_api/src/api/user/tests/RelationshipTestUtils.ts index 31e113617..cae7b21b4 100644 --- a/fluxer_api/src/api/user/tests/RelationshipTestUtils.ts +++ b/fluxer_api/src/api/user/tests/RelationshipTestUtils.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createFriendship as channelCreateFriendship} from '@app/api/channel/tests/ChannelTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {RelationshipTypes} from '@fluxer/constants/src/UserConstants'; import type {RelationshipResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {expect} from 'vitest'; -import {createFriendship as channelCreateFriendship} from '../../channel/tests/ChannelTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; export async function sendFriendRequest( harness: ApiTestHarness, diff --git a/fluxer_api/src/api/user/tests/UnclaimedAccountRestrictions.test.ts b/fluxer_api/src/api/user/tests/UnclaimedAccountRestrictions.test.ts index a2401b8ee..63bf3acb1 100644 --- a/fluxer_api/src/api/user/tests/UnclaimedAccountRestrictions.test.ts +++ b/fluxer_api/src/api/user/tests/UnclaimedAccountRestrictions.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, unclaimAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount, unclaimAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannelInvite, createGuild, getChannel, sendChannelMessage, -} from '../../channel/tests/ChannelTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {fetchUserNote, setUserNote} from './UserTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {fetchUserNote, setUserNote} from '@app/api/user/tests/UserTestUtils'; +import {beforeEach, describe, expect, test} from 'vitest'; describe('Unclaimed Account Restrictions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserAccountAndSettings.test.ts b/fluxer_api/src/api/user/tests/UserAccountAndSettings.test.ts index 4ed0b106d..545854a20 100644 --- a/fluxer_api/src/api/user/tests/UserAccountAndSettings.test.ts +++ b/fluxer_api/src/api/user/tests/UserAccountAndSettings.test.ts @@ -1,11 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_IDS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {sendFriendRequest} from './RelationshipTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_IDS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {sendFriendRequest} from '@app/api/user/tests/RelationshipTestUtils'; import { checkUsernameDiscriminatorAvailability, fetchUser, @@ -14,7 +13,8 @@ import { setUserNote, updateGuildSettings, updateUserProfile, -} from './UserTestUtils'; +} from '@app/api/user/tests/UserTestUtils'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('User Account And Settings', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserActivityFlush.test.ts b/fluxer_api/src/api/user/tests/UserActivityFlush.test.ts index 0660068ae..cf7e0c6e2 100644 --- a/fluxer_api/src/api/user/tests/UserActivityFlush.test.ts +++ b/fluxer_api/src/api/user/tests/UserActivityFlush.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {getUserActivityBuffer, getUserRepository} from '@app/api/middleware/ServiceSingletons'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {getUserActivityBuffer, getUserRepository} from '../../middleware/ServiceSingletons'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; const REGISTRATION_IP = '198.51.100.7'; const REQUEST_IP = '203.0.113.7'; diff --git a/fluxer_api/src/api/user/tests/UserAuthorizedIps.test.ts b/fluxer_api/src/api/user/tests/UserAuthorizedIps.test.ts index 59f0fd0d5..4cdccce3f 100644 --- a/fluxer_api/src/api/user/tests/UserAuthorizedIps.test.ts +++ b/fluxer_api/src/api/user/tests/UserAuthorizedIps.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {clearTestEmails, createTestAccount, findLastTestEmail, listTestEmails} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {deleteOneOrMany, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {getInstanceConfigRepository, getUserRepository} from '@app/api/middleware/ServiceSingletons'; +import {AuthorizedIps} from '@app/api/Tables'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {clearTestEmails, createTestAccount, findLastTestEmail, listTestEmails} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {deleteOneOrMany, upsertOne} from '../../database/CassandraQueryExecution'; -import {getInstanceConfigRepository, getUserRepository} from '../../middleware/ServiceSingletons'; -import {AuthorizedIps} from '../../Tables'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; interface LoginResponse { user_id: string; diff --git a/fluxer_api/src/api/user/tests/UserChannelService.test.ts b/fluxer_api/src/api/user/tests/UserChannelService.test.ts index 566014e7c..5f94794a8 100644 --- a/fluxer_api/src/api/user/tests/UserChannelService.test.ts +++ b/fluxer_api/src/api/user/tests/UserChannelService.test.ts @@ -1,12 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {FLUXERBOT_ID} from '@fluxer/constants/src/AppConstants'; -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import {UserFlags} from '@fluxer/constants/src/UserConstants'; -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, unclaimAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannelID, createUserID} from '../../BrandedTypes'; -import {authorizeBot, createTestBotAccount} from '../../bot/tests/BotTestUtils'; +import {createTestAccount, unclaimAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannelID, createUserID} from '@app/api/BrandedTypes'; +import {authorizeBot, createTestBotAccount} from '@app/api/bot/tests/BotTestUtils'; import { acceptInvite, blockUser, @@ -19,13 +15,17 @@ import { getChannel, type MinimalChannelResponse, sendChannelMessage, -} from '../../channel/tests/ChannelTestUtils'; -import {SYSTEM_USER_ID} from '../../constants/Core'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../../user/repositories/UserRepository'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {SYSTEM_USER_ID} from '@app/api/constants/Core'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {FLUXERBOT_ID} from '@fluxer/constants/src/AppConstants'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; +import {UserFlags} from '@fluxer/constants/src/UserConstants'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; interface PrivateChannelsResponse extends Array {} diff --git a/fluxer_api/src/api/user/tests/UserContactChangeLogService.test.ts b/fluxer_api/src/api/user/tests/UserContactChangeLogService.test.ts index 6a4169739..961459aa3 100644 --- a/fluxer_api/src/api/user/tests/UserContactChangeLogService.test.ts +++ b/fluxer_api/src/api/user/tests/UserContactChangeLogService.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_CREDENTIALS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {fetchUserMe} from '@app/api/user/tests/UserTestUtils'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_CREDENTIALS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {fetchUserMe} from './UserTestUtils'; interface UserMeResponse { id: string; diff --git a/fluxer_api/src/api/user/tests/UserCustomStatusEmojiPremium.test.ts b/fluxer_api/src/api/user/tests/UserCustomStatusEmojiPremium.test.ts index 19c700438..177e50f89 100644 --- a/fluxer_api/src/api/user/tests/UserCustomStatusEmojiPremium.test.ts +++ b/fluxer_api/src/api/user/tests/UserCustomStatusEmojiPremium.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createTestBotAccount} from '@app/api/bot/tests/BotTestUtils'; +import {getPngDataUrl} from '@app/api/emoji/tests/EmojiTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {grantPremium} from '@app/api/user/tests/UserTestUtils'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import type {UserSettingsResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createTestBotAccount} from '../../bot/tests/BotTestUtils'; -import {getPngDataUrl} from '../../emoji/tests/EmojiTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {grantPremium} from './UserTestUtils'; interface EmojiResponse { id: string; diff --git a/fluxer_api/src/api/user/tests/UserDeletionEligibilityService.test.ts b/fluxer_api/src/api/user/tests/UserDeletionEligibilityService.test.ts index 89af98986..82addda8c 100644 --- a/fluxer_api/src/api/user/tests/UserDeletionEligibilityService.test.ts +++ b/fluxer_api/src/api/user/tests/UserDeletionEligibilityService.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {expectDataExists} from '@app/api/user/tests/UserTestUtils'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {expectDataExists} from './UserTestUtils'; interface InactivityCheckResult { warnings_sent: number; diff --git a/fluxer_api/src/api/user/tests/UserDisableAndDeleteEndpoints.test.ts b/fluxer_api/src/api/user/tests/UserDisableAndDeleteEndpoints.test.ts index e5edeef9c..bab639d70 100644 --- a/fluxer_api/src/api/user/tests/UserDisableAndDeleteEndpoints.test.ts +++ b/fluxer_api/src/api/user/tests/UserDisableAndDeleteEndpoints.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, loginAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {deleteAccount, disableAccount} from '@app/api/user/tests/UserTestUtils'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, loginAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {deleteAccount, disableAccount} from './UserTestUtils'; describe('User Disable And Delete Endpoints', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserDiscriminator0000.test.ts b/fluxer_api/src/api/user/tests/UserDiscriminator0000.test.ts index d37b07123..39cbc9285 100644 --- a/fluxer_api/src/api/user/tests/UserDiscriminator0000.test.ts +++ b/fluxer_api/src/api/user/tests/UserDiscriminator0000.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {getConfig} from '@app/api/Config'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {grantPremium, updateUserProfile} from '@app/api/user/tests/UserTestUtils'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {getConfig} from '../../Config'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {grantPremium, updateUserProfile} from './UserTestUtils'; async function withSelfHostedInstance(callback: () => Promise): Promise { const config = getConfig(); diff --git a/fluxer_api/src/api/user/tests/UserFindUniqueAssert.test.ts b/fluxer_api/src/api/user/tests/UserFindUniqueAssert.test.ts index 2815ef00c..1f45fd626 100644 --- a/fluxer_api/src/api/user/tests/UserFindUniqueAssert.test.ts +++ b/fluxer_api/src/api/user/tests/UserFindUniqueAssert.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID} from '@app/api/BrandedTypes'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID} from '../../BrandedTypes'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {UserRepository} from '../repositories/UserRepository'; const MISSING_USER_ID = createUserID(999999999999999999n); const SYSTEM_USER_ID = createUserID(0n); diff --git a/fluxer_api/src/api/user/tests/UserFlagsResponse.test.ts b/fluxer_api/src/api/user/tests/UserFlagsResponse.test.ts index bdf490ec5..f258bb6d5 100644 --- a/fluxer_api/src/api/user/tests/UserFlagsResponse.test.ts +++ b/fluxer_api/src/api/user/tests/UserFlagsResponse.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {fetchUser, fetchUserMe, updateUserProfile} from '@app/api/user/tests/UserTestUtils'; import {PublicUserFlags, UserFlags} from '@fluxer/constants/src/UserConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {fetchUser, fetchUserMe, updateUserProfile} from './UserTestUtils'; async function setUserFlags(harness: ApiTestHarness, userId: string, flags: bigint): Promise { await createBuilder(harness, '') diff --git a/fluxer_api/src/api/user/tests/UserFluxerTagRateLimit.test.ts b/fluxer_api/src/api/user/tests/UserFluxerTagRateLimit.test.ts index 4da3a3551..bafad8838 100644 --- a/fluxer_api/src/api/user/tests/UserFluxerTagRateLimit.test.ts +++ b/fluxer_api/src/api/user/tests/UserFluxerTagRateLimit.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {fetchUserMe, grantPremium, updateUserProfile} from '@app/api/user/tests/UserTestUtils'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {fetchUserMe, grantPremium, updateUserProfile} from './UserTestUtils'; describe('User FluxerTag rate limit', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserNoteLifecycle.test.ts b/fluxer_api/src/api/user/tests/UserNoteLifecycle.test.ts index 6b1c9d728..c8e69a3fe 100644 --- a/fluxer_api/src/api/user/tests/UserNoteLifecycle.test.ts +++ b/fluxer_api/src/api/user/tests/UserNoteLifecycle.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {fetchUserNote, setUserNote} from '@app/api/user/tests/UserTestUtils'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {fetchUserNote, setUserNote} from './UserTestUtils'; describe('User Note Lifecycle', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserPremiumOnboardingDismissal.test.ts b/fluxer_api/src/api/user/tests/UserPremiumOnboardingDismissal.test.ts index c54e0c574..e7ff89d8d 100644 --- a/fluxer_api/src/api/user/tests/UserPremiumOnboardingDismissal.test.ts +++ b/fluxer_api/src/api/user/tests/UserPremiumOnboardingDismissal.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {fetchUserMe, grantPremium} from '@app/api/user/tests/UserTestUtils'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import type {UserPrivateResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {fetchUserMe, grantPremium} from './UserTestUtils'; describe('User Premium Onboarding Dismissal', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserPremiumReset.test.ts b/fluxer_api/src/api/user/tests/UserPremiumReset.test.ts index 2fcf0bc12..66f6f5b09 100644 --- a/fluxer_api/src/api/user/tests/UserPremiumReset.test.ts +++ b/fluxer_api/src/api/user/tests/UserPremiumReset.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface CurrentUserPremiumState { premium_type: number | null; diff --git a/fluxer_api/src/api/user/tests/UserProfileCacheInvalidation.test.ts b/fluxer_api/src/api/user/tests/UserProfileCacheInvalidation.test.ts index 2410b9f7d..bbe403340 100644 --- a/fluxer_api/src/api/user/tests/UserProfileCacheInvalidation.test.ts +++ b/fluxer_api/src/api/user/tests/UserProfileCacheInvalidation.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createFriendship} from '@app/api/channel/tests/ChannelTestUtils'; +import {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import type {UserProfileFullResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it, vi} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createFriendship} from '../../channel/tests/ChannelTestUtils'; -import {UserCacheService} from '../../infrastructure/UserCacheService'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('User Profile Cache Invalidation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserProfileImageValidation.test.ts b/fluxer_api/src/api/user/tests/UserProfileImageValidation.test.ts index 2db6db6c1..eeaedc14f 100644 --- a/fluxer_api/src/api/user/tests/UserProfileImageValidation.test.ts +++ b/fluxer_api/src/api/user/tests/UserProfileImageValidation.test.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { createTestGuild, getGifDataUrl, getPngDataUrl, VALID_GIF_BASE64, VALID_PNG_BASE64, -} from '../../emoji/tests/EmojiTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {grantPremium, updateAvatar, updateBanner} from './UserTestUtils'; +} from '@app/api/emoji/tests/EmojiTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {grantPremium, updateAvatar, updateBanner} from '@app/api/user/tests/UserTestUtils'; +import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; const PREMIUM_TYPE_SUBSCRIPTION = 2; const AVATAR_MAX_SIZE = 10 * 1024 * 1024; diff --git a/fluxer_api/src/api/user/tests/UserProfileTextValidation.test.ts b/fluxer_api/src/api/user/tests/UserProfileTextValidation.test.ts index e1dc79819..62106cbb3 100644 --- a/fluxer_api/src/api/user/tests/UserProfileTextValidation.test.ts +++ b/fluxer_api/src/api/user/tests/UserProfileTextValidation.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount, createUniqueEmail} from '@app/api/auth/tests/AuthTestUtils'; +import {sendMessageWithAttachments, setupTestGuildAndChannel} from '@app/api/channel/tests/AttachmentTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {phraseBlocklistCache} from '@app/api/middleware/PhraseBlocklistCache'; +import {profileSubstringBlocklistCache} from '@app/api/middleware/ProfileSubstringBlocklistCache'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_CREDENTIALS, TEST_USER_DATA} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount, createUniqueEmail} from '../../auth/tests/AuthTestUtils'; -import {sendMessageWithAttachments, setupTestGuildAndChannel} from '../../channel/tests/AttachmentTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {phraseBlocklistCache} from '../../middleware/PhraseBlocklistCache'; -import {profileSubstringBlocklistCache} from '../../middleware/ProfileSubstringBlocklistCache'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_CREDENTIALS, TEST_USER_DATA} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; interface ValidationErrorResponse { code: string; diff --git a/fluxer_api/src/api/user/tests/UserProfileTimezoneVisibility.test.ts b/fluxer_api/src/api/user/tests/UserProfileTimezoneVisibility.test.ts index 6197b7cf8..ab88fee41 100644 --- a/fluxer_api/src/api/user/tests/UserProfileTimezoneVisibility.test.ts +++ b/fluxer_api/src/api/user/tests/UserProfileTimezoneVisibility.test.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createFriendship} from '@app/api/channel/tests/ChannelTestUtils'; +import {acceptInvite, createChannelInvite, createGuild, getChannel} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { ProfileFieldPrivacyFlags, type ProfilePrivacyLevel, @@ -9,12 +15,6 @@ import { import {getCurrentTimeZoneOffsetMinutes} from '@fluxer/date_utils/src/TimeZoneUtils'; import type {UserPrivateResponse, UserProfileFullResponse} from '@fluxer/schema/src/domains/user/UserResponseSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createFriendship} from '../../channel/tests/ChannelTestUtils'; -import {acceptInvite, createChannelInvite, createGuild, getChannel} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; const TEST_TIMEZONE = 'America/New_York'; const TEST_TIMEZONE_OFFSET = getCurrentTimeZoneOffsetMinutes(TEST_TIMEZONE); diff --git a/fluxer_api/src/api/user/tests/UserRecentMentions.test.ts b/fluxer_api/src/api/user/tests/UserRecentMentions.test.ts index eaf748339..852f32652 100644 --- a/fluxer_api/src/api/user/tests/UserRecentMentions.test.ts +++ b/fluxer_api/src/api/user/tests/UserRecentMentions.test.ts @@ -1,22 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import type {MessageListResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannelID, createGuildID, createMessageID, createUserID} from '../../BrandedTypes'; -import {addMemberRole, createRole, removeMemberRole} from '../../guild/tests/GuildTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannelID, createGuildID, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import {addMemberRole, createRole, removeMemberRole} from '@app/api/guild/tests/GuildTestUtils'; import { acceptInvite, createChannelInvite, createGuild, sendMessage, updateChannelPermissions, -} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {UserRepository} from '../repositories/UserRepository'; +} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; +import type {MessageListResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; +import {afterEach, beforeEach, describe, expect, test} from 'vitest'; describe('User recent mentions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserRelationshipEndpoints.test.ts b/fluxer_api/src/api/user/tests/UserRelationshipEndpoints.test.ts index be1c0c4bb..6a9c8153a 100644 --- a/fluxer_api/src/api/user/tests/UserRelationshipEndpoints.test.ts +++ b/fluxer_api/src/api/user/tests/UserRelationshipEndpoints.test.ts @@ -1,10 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {RelationshipTypes, UserFlags} from '@fluxer/constants/src/UserConstants'; -import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { acceptFriendRequest, assertRelationshipId, @@ -13,8 +11,10 @@ import { listRelationships, removeRelationship, sendFriendRequest, -} from './RelationshipTestUtils'; -import {updateUserSettings} from './UserTestUtils'; +} from '@app/api/user/tests/RelationshipTestUtils'; +import {updateUserSettings} from '@app/api/user/tests/UserTestUtils'; +import {RelationshipTypes, UserFlags} from '@fluxer/constants/src/UserConstants'; +import {beforeEach, describe, expect, test} from 'vitest'; async function setUserFlags(harness: ApiTestHarness, userId: string, flags: bigint): Promise { await createBuilder(harness, '') diff --git a/fluxer_api/src/api/user/tests/UserRelationshipStateTransitions.test.ts b/fluxer_api/src/api/user/tests/UserRelationshipStateTransitions.test.ts index e15bbce1f..378a312d2 100644 --- a/fluxer_api/src/api/user/tests/UserRelationshipStateTransitions.test.ts +++ b/fluxer_api/src/api/user/tests/UserRelationshipStateTransitions.test.ts @@ -1,11 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {RelationshipTypes, UserFlags} from '@fluxer/constants/src/UserConstants'; -import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount, unclaimAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +import {createTestAccount, unclaimAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { acceptFriendRequest, assertRelationshipId, @@ -16,8 +14,10 @@ import { removeRelationship, sendFriendRequest, sendFriendRequestByTag, -} from './RelationshipTestUtils'; -import {fetchUserMe} from './UserTestUtils'; +} from '@app/api/user/tests/RelationshipTestUtils'; +import {fetchUserMe} from '@app/api/user/tests/UserTestUtils'; +import {RelationshipTypes, UserFlags} from '@fluxer/constants/src/UserConstants'; +import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; async function markUserScheduledForDeletion(harness: ApiTestHarness, userId: string): Promise { const pendingDeletionAt = new Date(Date.now() + 14 * 24 * 60 * 60 * 1000).toISOString(); diff --git a/fluxer_api/src/api/user/tests/UserSettingsGuildFolders.test.ts b/fluxer_api/src/api/user/tests/UserSettingsGuildFolders.test.ts index e056f79d8..99d12c0a4 100644 --- a/fluxer_api/src/api/user/tests/UserSettingsGuildFolders.test.ts +++ b/fluxer_api/src/api/user/tests/UserSettingsGuildFolders.test.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import { DEFAULT_GUILD_FOLDER_ICON, GuildFolderFlags, @@ -9,11 +14,6 @@ import { } from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('UserSettings guild_folders validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserSettingsSensitiveContentFilter.test.ts b/fluxer_api/src/api/user/tests/UserSettingsSensitiveContentFilter.test.ts index bf577e9de..617913e6c 100644 --- a/fluxer_api/src/api/user/tests/UserSettingsSensitiveContentFilter.test.ts +++ b/fluxer_api/src/api/user/tests/UserSettingsSensitiveContentFilter.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {fetchUserSettings, updateUserSettings} from '@app/api/user/tests/UserTestUtils'; import {SensitiveMediaFilterLevel} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {fetchUserSettings, updateUserSettings} from './UserTestUtils'; describe('User Settings - Sensitive Content Filters', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserSettingsSyncedPreferences.test.ts b/fluxer_api/src/api/user/tests/UserSettingsSyncedPreferences.test.ts index 7b8d765ee..cecf1090e 100644 --- a/fluxer_api/src/api/user/tests/UserSettingsSyncedPreferences.test.ts +++ b/fluxer_api/src/api/user/tests/UserSettingsSyncedPreferences.test.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {updateUserSettings} from '@app/api/user/tests/UserTestUtils'; import {create, equals} from '@bufbuild/protobuf'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import { @@ -16,11 +21,6 @@ import { SearchEngineSettingsSchema, } from '@fluxer/schema/src/gen/fluxer/user/preferences/v1/preferences_pb'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {updateUserSettings} from './UserTestUtils'; describe('User Settings synced_preferences', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/user/tests/UserSettingsValidation.test.ts b/fluxer_api/src/api/user/tests/UserSettingsValidation.test.ts index efdbec407..d008e04f2 100644 --- a/fluxer_api/src/api/user/tests/UserSettingsValidation.test.ts +++ b/fluxer_api/src/api/user/tests/UserSettingsValidation.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {updateUserSettings} from '@app/api/user/tests/UserTestUtils'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {updateUserSettings} from './UserTestUtils'; async function setUserFlags(harness: ApiTestHarness, userId: string, flags: bigint): Promise { await createBuilder(harness, '') diff --git a/fluxer_api/src/api/user/tests/UserSyntheticWriteGuard.test.ts b/fluxer_api/src/api/user/tests/UserSyntheticWriteGuard.test.ts index a3d6eb7b0..144bf1926 100644 --- a/fluxer_api/src/api/user/tests/UserSyntheticWriteGuard.test.ts +++ b/fluxer_api/src/api/user/tests/UserSyntheticWriteGuard.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {UserRepository} from '@app/api/user/repositories/UserRepository'; import {DELETED_USER_ID} from '@fluxer/constants/src/UserConstants'; import {afterAll, beforeAll, beforeEach, describe, expect, test} from 'vitest'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {UserRepository} from '../repositories/UserRepository'; const SYNTHETIC_USER_IDS: Array<[string, UserID]> = [ ['0', createUserID(0n)], diff --git a/fluxer_api/src/api/user/tests/UserTestUtils.ts b/fluxer_api/src/api/user/tests/UserTestUtils.ts index 30d72f36e..5824695c8 100644 --- a/fluxer_api/src/api/user/tests/UserTestUtils.ts +++ b/fluxer_api/src/api/user/tests/UserTestUtils.ts @@ -1,5 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import type { MobileDevicesListResponse, PushSubscribeResponse, @@ -11,8 +13,6 @@ import type { UserSettingsResponse, UserTagCheckResponse, } from '@fluxer/schema/src/domains/user/UserResponseSchemas'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; export async function fetchUserMe( harness: ApiTestHarness, diff --git a/fluxer_api/src/api/user/tests/UserUsernameCaseUpdate.test.ts b/fluxer_api/src/api/user/tests/UserUsernameCaseUpdate.test.ts index 713bce62c..925284060 100644 --- a/fluxer_api/src/api/user/tests/UserUsernameCaseUpdate.test.ts +++ b/fluxer_api/src/api/user/tests/UserUsernameCaseUpdate.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {fetchUserMe, updateUserProfile} from '@app/api/user/tests/UserTestUtils'; import {afterEach, beforeEach, describe, expect, test} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {fetchUserMe, updateUserProfile} from './UserTestUtils'; async function runCaseUpdateTest( harness: ApiTestHarness, diff --git a/fluxer_api/src/api/user/utils/GuildFolderUtils.ts b/fluxer_api/src/api/user/utils/GuildFolderUtils.ts index 4fb2b4598..bb017c414 100644 --- a/fluxer_api/src/api/user/utils/GuildFolderUtils.ts +++ b/fluxer_api/src/api/user/utils/GuildFolderUtils.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {GuildFolder} from '@app/api/database/types/UserTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {mapUserSettingsToResponse} from '@app/api/user/UserMappers'; import {type GuildFolderIcon, UNCATEGORIZED_FOLDER_ID} from '@fluxer/constants/src/UserConstants'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {GuildFolder} from '../../database/types/UserTypes'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {IUserRepository} from '../IUserRepository'; -import {mapUserSettingsToResponse} from '../UserMappers'; export function dedupeGuildFolders(folders: ReadonlyArray): { folders: Array; diff --git a/fluxer_api/src/api/utils/AgeUtils.test.ts b/fluxer_api/src/api/utils/AgeUtils.test.ts index db6dd8c39..843d8276a 100644 --- a/fluxer_api/src/api/utils/AgeUtils.test.ts +++ b/fluxer_api/src/api/utils/AgeUtils.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {setCachedDateOfBirthCollection} from '@app/api/instance/DateOfBirthCollectionCache'; +import {canUserAccessNsfwContent} from '@app/api/utils/AgeUtils'; import {afterEach, describe, expect, it} from 'vitest'; -import {setCachedDateOfBirthCollection} from '../instance/DateOfBirthCollectionCache'; -import {canUserAccessNsfwContent} from './AgeUtils'; const ADULT_DATE_OF_BIRTH = '1990-01-01'; const MINOR_DATE_OF_BIRTH = '2020-01-01'; diff --git a/fluxer_api/src/api/utils/AgeUtils.ts b/fluxer_api/src/api/utils/AgeUtils.ts index ecf68989c..41353f4d1 100644 --- a/fluxer_api/src/api/utils/AgeUtils.ts +++ b/fluxer_api/src/api/utils/AgeUtils.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {instanceCollectsDateOfBirth} from '../instance/DateOfBirthCollectionCache'; +import {instanceCollectsDateOfBirth} from '@app/api/instance/DateOfBirthCollectionCache'; export function calculateAge( dateOfBirth: diff --git a/fluxer_api/src/api/utils/AttachmentDecay.ts b/fluxer_api/src/api/utils/AttachmentDecay.ts index 4d198523b..c0153aadb 100644 --- a/fluxer_api/src/api/utils/AttachmentDecay.ts +++ b/fluxer_api/src/api/utils/AttachmentDecay.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {requireIntegerInRange} from '@app/api/utils/IntegerOptions'; +import {getValidTimestamp} from '@app/api/utils/TimestampUtils'; import {ms} from 'itty-time'; -import {requireIntegerInRange} from './IntegerOptions'; -import {getValidTimestamp} from './TimestampUtils'; export interface AttachmentDecayRules { minMb: number; diff --git a/fluxer_api/src/api/utils/AuditSerializationUtils.ts b/fluxer_api/src/api/utils/AuditSerializationUtils.ts index e1fdd8437..5e9d8363c 100644 --- a/fluxer_api/src/api/utils/AuditSerializationUtils.ts +++ b/fluxer_api/src/api/utils/AuditSerializationUtils.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {Channel} from '../models/Channel'; -import type {Guild} from '../models/Guild'; -import type {GuildEmoji} from '../models/GuildEmoji'; -import type {GuildSticker} from '../models/GuildSticker'; -import {toIdString, toSortedIdArray} from './IdUtils'; +import type {Channel} from '@app/api/models/Channel'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildEmoji} from '@app/api/models/GuildEmoji'; +import type {GuildSticker} from '@app/api/models/GuildSticker'; +import {toIdString, toSortedIdArray} from '@app/api/utils/IdUtils'; export function serializeGuildForAudit(guild: Guild): Record { return { diff --git a/fluxer_api/src/api/utils/EmojiUtils.ts b/fluxer_api/src/api/utils/EmojiUtils.ts index bcded86e8..446a817ee 100644 --- a/fluxer_api/src/api/utils/EmojiUtils.ts +++ b/fluxer_api/src/api/utils/EmojiUtils.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {EmojiID, GuildID, UserID, WebhookID} from '@app/api/BrandedTypes'; +import {createEmojiID} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {GuildEmoji} from '@app/api/models/GuildEmoji'; +import type {IUserAccountRepository} from '@app/api/user/repositories/IUserAccountRepository'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; -import type {EmojiID, GuildID, UserID, WebhookID} from '../BrandedTypes'; -import {createEmojiID} from '../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../guild/repositories/IGuildRepositoryAggregate'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import {resolveLimitSafe} from '../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; -import type {GuildEmoji} from '../models/GuildEmoji'; -import type {IUserAccountRepository} from '../user/repositories/IUserAccountRepository'; type EmojiGuildRepository = Pick; type EmojiUserRepository = Pick; diff --git a/fluxer_api/src/api/utils/FetchUtils.ts b/fluxer_api/src/api/utils/FetchUtils.ts index 862896271..63245b880 100644 --- a/fluxer_api/src/api/utils/FetchUtils.ts +++ b/fluxer_api/src/api/utils/FetchUtils.ts @@ -1,5 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Logger} from '@app/api/Logger'; import {createHttpClient} from '@pkgs/http_client/src/HttpClient'; import {formatUrlForDiagnostics} from '@pkgs/http_client/src/HttpClientDiagnostics'; import {DEFAULT_MAX_REDIRECTS, normalizeMaxRedirects} from '@pkgs/http_client/src/HttpClientRequestInternals'; @@ -11,7 +12,6 @@ import type { StreamResponse, } from '@pkgs/http_client/src/HttpClientTypes'; import {createPublicInternetRequestUrlPolicy} from '@pkgs/http_client/src/PublicInternetRequestUrlPolicy'; -import {Logger} from '../Logger'; const requestUrlPolicy = createPublicInternetRequestUrlPolicy(); const client: HttpClient = createHttpClient({ diff --git a/fluxer_api/src/api/utils/GuildCommunicationUtils.ts b/fluxer_api/src/api/utils/GuildCommunicationUtils.ts index f568b6e46..e8ba8d11d 100644 --- a/fluxer_api/src/api/utils/GuildCommunicationUtils.ts +++ b/fluxer_api/src/api/utils/GuildCommunicationUtils.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isGuildMemberTimedOut} from '@app/api/guild/GuildModel'; import {CommunicationDisabledError} from '@fluxer/errors/src/domains/moderation/CommunicationDisabledError'; import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; -import {isGuildMemberTimedOut} from '../guild/GuildModel'; export function assertGuildMemberCanCommunicate(member?: GuildMemberResponse | null): void { if (isGuildMemberTimedOut(member)) { diff --git a/fluxer_api/src/api/utils/GuildVerificationUtils.test.ts b/fluxer_api/src/api/utils/GuildVerificationUtils.test.ts index 6463084fd..a47ccaff3 100644 --- a/fluxer_api/src/api/utils/GuildVerificationUtils.test.ts +++ b/fluxer_api/src/api/utils/GuildVerificationUtils.test.ts @@ -1,5 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {User} from '@app/api/models/User'; +import {checkGuildVerificationWithResponse} from '@app/api/utils/GuildVerificationUtils'; import {GuildFeatures, GuildVerificationLevel} from '@fluxer/constants/src/GuildConstants'; import {ProfileFieldPrivacyFlags} from '@fluxer/constants/src/UserConstants'; import {GuildEmailVerificationRequiredError} from '@fluxer/errors/src/domains/auth/EmailVerificationRequiredError'; @@ -7,9 +10,6 @@ import {GuildPhoneVerificationRequiredError} from '@fluxer/errors/src/domains/au import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMemberSchemas'; import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {describe, expect, it} from 'vitest'; -import {createUserID} from '../BrandedTypes'; -import {User} from '../models/User'; -import {checkGuildVerificationWithResponse} from './GuildVerificationUtils'; const TEST_USER_ID = createUserID(175928847299117063n); const TEST_OWNER_ID = createUserID(275928847299117063n); diff --git a/fluxer_api/src/api/utils/GuildVerificationUtils.ts b/fluxer_api/src/api/utils/GuildVerificationUtils.ts index 3d9424a07..99f64333f 100644 --- a/fluxer_api/src/api/utils/GuildVerificationUtils.ts +++ b/fluxer_api/src/api/utils/GuildVerificationUtils.ts @@ -1,5 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createRoleIDSet, createUserID, type RoleID, type UserID} from '@app/api/BrandedTypes'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {User} from '@app/api/models/User'; import { GuildFeatures, GuildVerificationLevel, @@ -13,10 +17,6 @@ import type {GuildMemberResponse} from '@fluxer/schema/src/domains/guild/GuildMe import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas'; import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; import {ms} from 'itty-time'; -import {createRoleIDSet, createUserID, type RoleID, type UserID} from '../BrandedTypes'; -import type {Guild} from '../models/Guild'; -import type {GuildMember} from '../models/GuildMember'; -import type {User} from '../models/User'; interface VerificationParams { user: User; diff --git a/fluxer_api/src/api/utils/IdUtils.ts b/fluxer_api/src/api/utils/IdUtils.ts index c9bef00bf..753dc13cd 100644 --- a/fluxer_api/src/api/utils/IdUtils.ts +++ b/fluxer_api/src/api/utils/IdUtils.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, EmojiID, GuildID, RoleID, StickerID, UserID} from '../BrandedTypes'; +import type {ChannelID, EmojiID, GuildID, RoleID, StickerID, UserID} from '@app/api/BrandedTypes'; export function toIdString( value: GuildID | ChannelID | RoleID | UserID | EmojiID | StickerID | bigint | string | null | undefined, diff --git a/fluxer_api/src/api/utils/InviteUtils.ts b/fluxer_api/src/api/utils/InviteUtils.ts index 33592157f..af6239bdb 100644 --- a/fluxer_api/src/api/utils/InviteUtils.ts +++ b/fluxer_api/src/api/utils/InviteUtils.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Config} from '../Config'; -import * as RegexUtils from './RegexUtils'; +import {Config} from '@app/api/Config'; +import * as RegexUtils from '@app/api/utils/RegexUtils'; let _invitePattern: RegExp | null = null; diff --git a/fluxer_api/src/api/utils/IpUtils.ts b/fluxer_api/src/api/utils/IpUtils.ts index 7f9ad7118..68efdb8d9 100644 --- a/fluxer_api/src/api/utils/IpUtils.ts +++ b/fluxer_api/src/api/utils/IpUtils.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import dns from 'node:dns'; +import {Config} from '@app/api/Config'; import {extractClientIp} from '@fluxer/ip_utils/src/ClientIp'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {GeoipResult} from '@pkgs/geoip/src/GeoipLookup'; import {formatGeoipLocation, lookupGeoipByIp} from '@pkgs/geoip/src/GeoipLookup'; import {seconds} from 'itty-time'; -import {Config} from '../Config'; const REVERSE_DNS_CACHE_TTL_SECONDS = seconds('1 day'); const REVERSE_DNS_CACHE_PREFIX = 'reverse-dns:'; diff --git a/fluxer_api/src/api/utils/MutualGuildDmAccess.ts b/fluxer_api/src/api/utils/MutualGuildDmAccess.ts index c1c60778f..4f67e2454 100644 --- a/fluxer_api/src/api/utils/MutualGuildDmAccess.ts +++ b/fluxer_api/src/api/utils/MutualGuildDmAccess.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {Guild} from '../models/Guild'; +import type {Guild} from '@app/api/models/Guild'; export const DISQUALIFIED_MUTUAL_GUILD_DM_ACCESS_GUILD_IDS = [ 1427764882469228556n, diff --git a/fluxer_api/src/api/utils/PasswordUtils.ts b/fluxer_api/src/api/utils/PasswordUtils.ts index 36921f572..8a6455a11 100644 --- a/fluxer_api/src/api/utils/PasswordUtils.ts +++ b/fluxer_api/src/api/utils/PasswordUtils.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; import argon2 from 'argon2'; -import {Config} from '../Config'; const TEST_ARGON2_OPTIONS: argon2.Options = { memoryCost: 1024, diff --git a/fluxer_api/src/api/utils/PermissionUtils.ts b/fluxer_api/src/api/utils/PermissionUtils.ts index c4216f654..333a3a971 100644 --- a/fluxer_api/src/api/utils/PermissionUtils.ts +++ b/fluxer_api/src/api/utils/PermissionUtils.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {MissingPermissionsError} from '@fluxer/errors/src/domains/core/MissingPermissionsError'; -import type {ChannelID, GuildID, UserID} from '../BrandedTypes'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; interface PermissionsDiff { added: Array; diff --git a/fluxer_api/src/api/utils/RequestClientIp.ts b/fluxer_api/src/api/utils/RequestClientIp.ts index 0fa871cdc..d7e965108 100644 --- a/fluxer_api/src/api/utils/RequestClientIp.ts +++ b/fluxer_api/src/api/utils/RequestClientIp.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {HonoEnv} from '@app/api/types/HonoEnv'; import {extractClientIp, MissingClientIpError, resolveClientIpHeaderName} from '@fluxer/ip_utils/src/ClientIp'; import type {Context} from 'hono'; -import {Config} from '../Config'; -import type {HonoEnv} from '../types/HonoEnv'; export interface ClientIpResolution { trustClientIpHeader: boolean; diff --git a/fluxer_api/src/api/utils/RequestJsonBody.ts b/fluxer_api/src/api/utils/RequestJsonBody.ts index 6096b15c3..dd45b544b 100644 --- a/fluxer_api/src/api/utils/RequestJsonBody.ts +++ b/fluxer_api/src/api/utils/RequestJsonBody.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {parseJsonPreservingLargeIntegers} from '@app/api/utils/LosslessJsonParser'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; import type {HonoRequest} from 'hono'; -import {parseJsonPreservingLargeIntegers} from './LosslessJsonParser'; interface RequestJsonBody { parsed: boolean; diff --git a/fluxer_api/src/api/utils/SessionClientIdentity.ts b/fluxer_api/src/api/utils/SessionClientIdentity.ts index 95725161a..5ed9c8ad1 100644 --- a/fluxer_api/src/api/utils/SessionClientIdentity.ts +++ b/fluxer_api/src/api/utils/SessionClientIdentity.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Logger} from '@app/api/Logger'; +import {parseJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; import Bowser from 'bowser'; -import {Logger} from '../Logger'; -import {parseJsonRecord} from './JsonBoundaryUtils'; export type SessionDeviceClass = 'mobile' | 'desktop'; diff --git a/fluxer_api/src/api/utils/UnfurlerUtils.ts b/fluxer_api/src/api/utils/UnfurlerUtils.ts index baa89a527..89d865aea 100644 --- a/fluxer_api/src/api/utils/UnfurlerUtils.ts +++ b/fluxer_api/src/api/utils/UnfurlerUtils.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; +import * as InviteUtils from '@app/api/utils/InviteUtils'; import {URL_REGEX} from '@fluxer/constants/src/Core'; import * as idna from 'idna-uts46-hx'; -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import * as InviteUtils from './InviteUtils'; const MARKETING_PATH_PREFIXES = ['/channels/', '/theme/']; diff --git a/fluxer_api/src/api/utils/UserPermissionUtils.ts b/fluxer_api/src/api/utils/UserPermissionUtils.ts index 73e8431b3..59a61daea 100644 --- a/fluxer_api/src/api/utils/UserPermissionUtils.ts +++ b/fluxer_api/src/api/utils/UserPermissionUtils.ts @@ -1,5 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {Guild} from '@app/api/models/Guild'; +import type {Relationship} from '@app/api/models/Relationship'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {hasMutualGuildForDmAccess} from '@app/api/utils/MutualGuildDmAccess'; import { FriendSourceFlags, GroupDmAddPermissionFlags, @@ -8,12 +14,6 @@ import { } from '@fluxer/constants/src/UserConstants'; import {MissingAccessError} from '@fluxer/errors/src/domains/core/MissingAccessError'; import {FriendRequestBlockedError} from '@fluxer/errors/src/domains/user/FriendRequestBlockedError'; -import type {GuildID, UserID} from '../BrandedTypes'; -import type {IGuildRepositoryAggregate} from '../guild/repositories/IGuildRepositoryAggregate'; -import type {Guild} from '../models/Guild'; -import type {Relationship} from '../models/Relationship'; -import type {IUserRepository} from '../user/IUserRepository'; -import {hasMutualGuildForDmAccess} from './MutualGuildDmAccess'; type UserPermissionRepository = Pick; type GuildPermissionRepository = Pick; diff --git a/fluxer_api/src/api/utils/UsernameGenerator.ts b/fluxer_api/src/api/utils/UsernameGenerator.ts index f96900daf..4e1a1120d 100644 --- a/fluxer_api/src/api/utils/UsernameGenerator.ts +++ b/fluxer_api/src/api/utils/UsernameGenerator.ts @@ -2,8 +2,8 @@ import {randomInt} from 'node:crypto'; import {readFileSync} from 'node:fs'; +import {resolveAssetPath} from '@app/api/utils/AssetPaths'; import {UsernameType} from '@fluxer/schema/src/primitives/UserValidators'; -import {resolveAssetPath} from './AssetPaths'; const scales = readFileSync(resolveAssetPath('words', 'scales.txt'), 'utf-8').trim().split('\n').filter(Boolean); const tails = readFileSync(resolveAssetPath('words', 'tails.txt'), 'utf-8').trim().split('\n').filter(Boolean); diff --git a/fluxer_api/src/api/utils/tests/ArrayUtils.test.ts b/fluxer_api/src/api/utils/tests/ArrayUtils.test.ts index 617639421..fd624b923 100644 --- a/fluxer_api/src/api/utils/tests/ArrayUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/ArrayUtils.test.ts @@ -1,5 +1,5 @@ +import {chunkArray} from '@app/api/utils/ArrayUtils'; import {describe, expect, it} from 'vitest'; -import {chunkArray} from '../ArrayUtils'; describe('chunkArray', () => { it.each([ diff --git a/fluxer_api/src/api/utils/tests/ConcurrencyUtils.test.ts b/fluxer_api/src/api/utils/tests/ConcurrencyUtils.test.ts index 7028d1442..1e43521d5 100644 --- a/fluxer_api/src/api/utils/tests/ConcurrencyUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/ConcurrencyUtils.test.ts @@ -1,5 +1,5 @@ +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; import {describe, expect, it} from 'vitest'; -import {mapWithConcurrency} from '../ConcurrencyUtils'; describe('mapWithConcurrency', () => { it('limits in-flight work and preserves input order when later items finish first', async () => { diff --git a/fluxer_api/src/api/utils/tests/CurrencyUtils.test.ts b/fluxer_api/src/api/utils/tests/CurrencyUtils.test.ts index 9a980c19e..547541e95 100644 --- a/fluxer_api/src/api/utils/tests/CurrencyUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/CurrencyUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getCurrency, getCurrencyPreferences, getGiftCurrencyPreferences} from '@app/api/utils/CurrencyUtils'; import {describe, expect, it} from 'vitest'; -import {getCurrency, getCurrencyPreferences, getGiftCurrencyPreferences} from '../CurrencyUtils'; describe('getCurrency', () => { describe('returns USD for non-EEA countries', () => { diff --git a/fluxer_api/src/api/utils/tests/DOMUtils.test.ts b/fluxer_api/src/api/utils/tests/DOMUtils.test.ts index 9d85ee7da..e15731218 100644 --- a/fluxer_api/src/api/utils/tests/DOMUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/DOMUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {decodeHTMLEntities, htmlToMarkdown, stripHtmlTags} from '@app/api/utils/DOMUtils'; import {describe, expect, it} from 'vitest'; -import {decodeHTMLEntities, htmlToMarkdown, stripHtmlTags} from '../DOMUtils'; describe('decodeHTMLEntities', () => { it('returns empty string for null input', () => { diff --git a/fluxer_api/src/api/utils/tests/FetchUtils.test.ts b/fluxer_api/src/api/utils/tests/FetchUtils.test.ts index f2d8f702c..488b85551 100644 --- a/fluxer_api/src/api/utils/tests/FetchUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/FetchUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import * as FetchUtils from '@app/api/utils/FetchUtils'; import {describe, expect, it, vi} from 'vitest'; -import * as FetchUtils from '../FetchUtils'; function createStream(chunks: Array): ReadableStream { const encoder = new TextEncoder(); diff --git a/fluxer_api/src/api/utils/tests/GeoUtils.test.ts b/fluxer_api/src/api/utils/tests/GeoUtils.test.ts index 232092499..da4f6bafa 100644 --- a/fluxer_api/src/api/utils/tests/GeoUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/GeoUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {calculateDistance, parseCoordinate} from '@app/api/utils/GeoUtils'; import {describe, expect, it} from 'vitest'; -import {calculateDistance, parseCoordinate} from '../GeoUtils'; describe('calculateDistance', () => { it('returns 0 for identical coordinates', () => { diff --git a/fluxer_api/src/api/utils/tests/IdUtils.test.ts b/fluxer_api/src/api/utils/tests/IdUtils.test.ts index fa3981710..955e68bb5 100644 --- a/fluxer_api/src/api/utils/tests/IdUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/IdUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {toIdString, toSortedIdArray} from '@app/api/utils/IdUtils'; import {describe, expect, it} from 'vitest'; -import {toIdString, toSortedIdArray} from '../IdUtils'; describe('toIdString', () => { it.each([ diff --git a/fluxer_api/src/api/utils/tests/IpRangeUtils.test.ts b/fluxer_api/src/api/utils/tests/IpRangeUtils.test.ts index 588b6a9ed..f0a9a7aea 100644 --- a/fluxer_api/src/api/utils/tests/IpRangeUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/IpRangeUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isValidIpOrRange, parseIpBanEntry, tryParseSingleIp} from '@app/api/utils/IpRangeUtils'; import {describe, expect, it} from 'vitest'; -import {isValidIpOrRange, parseIpBanEntry, tryParseSingleIp} from '../IpRangeUtils'; describe('parseIpBanEntry', () => { describe('single IPv4 addresses', () => { diff --git a/fluxer_api/src/api/utils/tests/LosslessJsonParser.test.ts b/fluxer_api/src/api/utils/tests/LosslessJsonParser.test.ts index 845fd0071..846e9c2e3 100644 --- a/fluxer_api/src/api/utils/tests/LosslessJsonParser.test.ts +++ b/fluxer_api/src/api/utils/tests/LosslessJsonParser.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {coerceUnsafeIntegersToStrings, parseJsonPreservingLargeIntegers} from '@app/api/utils/LosslessJsonParser'; import {describe, expect, it} from 'vitest'; -import {coerceUnsafeIntegersToStrings, parseJsonPreservingLargeIntegers} from '../LosslessJsonParser'; describe('parseJsonPreservingLargeIntegers', () => { it('keeps safe integers as numbers', () => { diff --git a/fluxer_api/src/api/utils/tests/MutualGuildDmAccess.test.ts b/fluxer_api/src/api/utils/tests/MutualGuildDmAccess.test.ts index 17c9f2638..591cb2fed 100644 --- a/fluxer_api/src/api/utils/tests/MutualGuildDmAccess.test.ts +++ b/fluxer_api/src/api/utils/tests/MutualGuildDmAccess.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; -import {describe, expect, it} from 'vitest'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import type {GuildRow} from '../../database/types/GuildTypes'; -import {Guild} from '../../models/Guild'; +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import type {GuildRow} from '@app/api/database/types/GuildTypes'; +import {Guild} from '@app/api/models/Guild'; import { DISQUALIFIED_MUTUAL_GUILD_DM_ACCESS_GUILD_IDS, getMutualGuildsForDmAccess, guildQualifiesForMutualGuildDmAccess, -} from '../MutualGuildDmAccess'; +} from '@app/api/utils/MutualGuildDmAccess'; +import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; +import {describe, expect, it} from 'vitest'; function createGuild(overrides: Partial = {}): Guild { return new Guild({ diff --git a/fluxer_api/src/api/utils/tests/RegexUtils.test.ts b/fluxer_api/src/api/utils/tests/RegexUtils.test.ts index 0c16ec253..ffdadecf3 100644 --- a/fluxer_api/src/api/utils/tests/RegexUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/RegexUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {escapeRegex} from '@app/api/utils/RegexUtils'; import {describe, expect, it} from 'vitest'; -import {escapeRegex} from '../RegexUtils'; describe('escapeRegex', () => { it('escapes hyphen', () => { diff --git a/fluxer_api/src/api/utils/tests/RequestClientIp.test.ts b/fluxer_api/src/api/utils/tests/RequestClientIp.test.ts index 985d566b4..1ae59dfe2 100644 --- a/fluxer_api/src/api/utils/tests/RequestClientIp.test.ts +++ b/fluxer_api/src/api/utils/tests/RequestClientIp.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {HonoEnv} from '@app/api/types/HonoEnv'; +import {getRequestClientIp, requireRequestClientIp, resolveClientIpWithOptions} from '@app/api/utils/RequestClientIp'; import {AppErrorHandler} from '@fluxer/errors/src/domains/core/ErrorHandlers'; import {MissingClientIpError} from '@fluxer/ip_utils/src/ClientIp'; import {Hono} from 'hono'; import {describe, expect, it} from 'vitest'; -import type {HonoEnv} from '../../types/HonoEnv'; -import {getRequestClientIp, requireRequestClientIp, resolveClientIpWithOptions} from '../RequestClientIp'; interface CountingRequest { request: Request; diff --git a/fluxer_api/src/api/utils/tests/SessionClientIdentity.test.ts b/fluxer_api/src/api/utils/tests/SessionClientIdentity.test.ts index 93a8cf31a..25dc525c7 100644 --- a/fluxer_api/src/api/utils/tests/SessionClientIdentity.test.ts +++ b/fluxer_api/src/api/utils/tests/SessionClientIdentity.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { isFluxerNativeUserAgent, parseReportedClientOs, resolveSessionClientInfo, type SessionClientInfo, -} from '../SessionClientIdentity'; +} from '@app/api/utils/SessionClientIdentity'; +import {describe, expect, it} from 'vitest'; const ELECTRON_MAC_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) FluxerStable/2026.614.83512 Chrome/126.0.0.0 Electron/31.0.0 Safari/537.36'; diff --git a/fluxer_api/src/api/utils/tests/StringUtils.test.ts b/fluxer_api/src/api/utils/tests/StringUtils.test.ts index 4c9b39ecc..760720271 100644 --- a/fluxer_api/src/api/utils/tests/StringUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/StringUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {hasVisibleContent, parseString} from '@app/api/utils/StringUtils'; import {describe, expect, it} from 'vitest'; -import {hasVisibleContent, parseString} from '../StringUtils'; describe('parseString', () => { it.each([ diff --git a/fluxer_api/src/api/utils/tests/UrlNormalizer.test.ts b/fluxer_api/src/api/utils/tests/UrlNormalizer.test.ts index d68f82b0e..446154f37 100644 --- a/fluxer_api/src/api/utils/tests/UrlNormalizer.test.ts +++ b/fluxer_api/src/api/utils/tests/UrlNormalizer.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {canonicalizeUrl, extractUrlCandidates} from '@app/api/utils/UrlNormalizer'; import {describe, expect, it} from 'vitest'; -import {canonicalizeUrl, extractUrlCandidates} from '../UrlNormalizer'; describe('canonicalizeUrl', () => { it('lowercases scheme and host', () => { diff --git a/fluxer_api/src/api/utils/tests/UrlSanitizer.test.ts b/fluxer_api/src/api/utils/tests/UrlSanitizer.test.ts index 608ad21ca..eff2a62e2 100644 --- a/fluxer_api/src/api/utils/tests/UrlSanitizer.test.ts +++ b/fluxer_api/src/api/utils/tests/UrlSanitizer.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {sanitizeOptionalAbsoluteUrl, sanitizeOptionalAbsoluteUrlOrNull} from '@app/api/utils/UrlSanitizer'; import {describe, expect, it} from 'vitest'; -import {sanitizeOptionalAbsoluteUrl, sanitizeOptionalAbsoluteUrlOrNull} from '../UrlSanitizer'; describe('sanitizeOptionalAbsoluteUrl', () => { it('returns undefined for nullish values', () => { diff --git a/fluxer_api/src/api/utils/tests/featureUtils.test.ts b/fluxer_api/src/api/utils/tests/featureUtils.test.ts index 27451bfa5..835f2b0ee 100644 --- a/fluxer_api/src/api/utils/tests/featureUtils.test.ts +++ b/fluxer_api/src/api/utils/tests/featureUtils.test.ts @@ -1,8 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + applyProtectedOverwriteBits, + applyProtectedRolePermissions, + parseClientFeaturesHeader, +} from '@app/api/utils/featureUtils'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {describe, expect, it} from 'vitest'; -import {applyProtectedOverwriteBits, applyProtectedRolePermissions, parseClientFeaturesHeader} from '../featureUtils'; const VCM = Permissions.VIEW_CHANNEL_MEMBERS; const FEATURE = 'view_channel_members_permission'; diff --git a/fluxer_api/src/api/voice/IVoiceRepository.ts b/fluxer_api/src/api/voice/IVoiceRepository.ts index f7c5ee28a..e0512c4d8 100644 --- a/fluxer_api/src/api/voice/IVoiceRepository.ts +++ b/fluxer_api/src/api/voice/IVoiceRepository.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceRegionRecord, VoiceRegionWithServers, VoiceServerRecord} from './VoiceModel'; +import type {VoiceRegionRecord, VoiceRegionWithServers, VoiceServerRecord} from '@app/api/voice/VoiceModel'; export interface IVoiceRepository { listRegions(): Promise>; diff --git a/fluxer_api/src/api/voice/VoiceAvailabilityService.ts b/fluxer_api/src/api/voice/VoiceAvailabilityService.ts index 0e61c94fa..2fe05497f 100644 --- a/fluxer_api/src/api/voice/VoiceAvailabilityService.ts +++ b/fluxer_api/src/api/voice/VoiceAvailabilityService.ts @@ -1,11 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type { + VoiceRegionAvailability, + VoiceRegionMetadata, + VoiceRegionRecord, + VoiceServerRecord, +} from '@app/api/voice/VoiceModel'; +import {preferServersUnderSoftLimit} from '@app/api/voice/VoiceRegionSelection'; +import type {VoiceServerLoadSource} from '@app/api/voice/VoiceServerLoad'; +import type {VoiceTopology} from '@app/api/voice/VoiceTopology'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; -import type {GuildID, UserID} from '../BrandedTypes'; -import type {VoiceRegionAvailability, VoiceRegionMetadata, VoiceRegionRecord, VoiceServerRecord} from './VoiceModel'; -import {preferServersUnderSoftLimit} from './VoiceRegionSelection'; -import type {VoiceServerLoadSource} from './VoiceServerLoad'; -import type {VoiceTopology} from './VoiceTopology'; export interface VoiceAccessContext { requestingUserId: UserID; diff --git a/fluxer_api/src/api/voice/VoiceDataInitializer.ts b/fluxer_api/src/api/voice/VoiceDataInitializer.ts index 393ba4964..b5a3630b7 100644 --- a/fluxer_api/src/api/voice/VoiceDataInitializer.ts +++ b/fluxer_api/src/api/voice/VoiceDataInitializer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {Config} from '../Config'; -import {Logger} from '../Logger'; -import {VoiceRepository} from './VoiceRepository'; +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; +import {VoiceRepository} from '@app/api/voice/VoiceRepository'; export function resolveLivekitEndpoint(configuredUrl: string | undefined, apiPublicUrl: string): string { if (configuredUrl) { diff --git a/fluxer_api/src/api/voice/VoiceModel.ts b/fluxer_api/src/api/voice/VoiceModel.ts index 454daca6d..052398856 100644 --- a/fluxer_api/src/api/voice/VoiceModel.ts +++ b/fluxer_api/src/api/voice/VoiceModel.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildID, UserID} from '../BrandedTypes'; +import type {GuildID, UserID} from '@app/api/BrandedTypes'; interface VoiceRestriction { vipOnly: boolean; diff --git a/fluxer_api/src/api/voice/VoiceRegionSelection.ts b/fluxer_api/src/api/voice/VoiceRegionSelection.ts index ba9a0c920..cdb14af02 100644 --- a/fluxer_api/src/api/voice/VoiceRegionSelection.ts +++ b/fluxer_api/src/api/voice/VoiceRegionSelection.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {calculateDistance, parseCoordinate} from '../utils/GeoUtils'; -import type {VoiceRegionAvailability, VoiceServerRecord} from './VoiceModel'; +import {calculateDistance, parseCoordinate} from '@app/api/utils/GeoUtils'; +import type {VoiceRegionAvailability, VoiceServerRecord} from '@app/api/voice/VoiceModel'; interface VoiceRegionPreference { regionId: string | null; diff --git a/fluxer_api/src/api/voice/VoiceRepository.ts b/fluxer_api/src/api/voice/VoiceRepository.ts index f81496c58..fca8613fd 100644 --- a/fluxer_api/src/api/voice/VoiceRepository.ts +++ b/fluxer_api/src/api/voice/VoiceRepository.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {createGuildIDSet, createUserIDSet} from '../BrandedTypes'; -import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '../database/CassandraQueryExecution'; -import {defineTable} from '../database/CassandraTableDsl'; +import {createGuildIDSet, createUserIDSet} from '@app/api/BrandedTypes'; +import {BatchBuilder, deleteOneOrMany, fetchMany, fetchOne, upsertOne} from '@app/api/database/CassandraQueryExecution'; +import {defineTable} from '@app/api/database/CassandraTableDsl'; import { VOICE_REGION_COLUMNS, VOICE_SERVER_COLUMNS, type VoiceRegionRow, type VoiceServerRow, -} from '../database/types/VoiceTypes'; -import type {IVoiceRepository} from './IVoiceRepository'; -import type {VoiceRegionRecord, VoiceRegionWithServers, VoiceServerRecord} from './VoiceModel'; +} from '@app/api/database/types/VoiceTypes'; +import type {IVoiceRepository} from '@app/api/voice/IVoiceRepository'; +import type {VoiceRegionRecord, VoiceRegionWithServers, VoiceServerRecord} from '@app/api/voice/VoiceModel'; function toIterable(value: unknown): Array { if (value === null || value === undefined) return []; diff --git a/fluxer_api/src/api/voice/VoiceServerLoad.ts b/fluxer_api/src/api/voice/VoiceServerLoad.ts index 6b999ee73..83595d849 100644 --- a/fluxer_api/src/api/voice/VoiceServerLoad.ts +++ b/fluxer_api/src/api/voice/VoiceServerLoad.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import {Logger} from '../Logger'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; const DEFAULT_REFRESH_INTERVAL_MS = 15000; const STALE_REFRESH_INTERVALS = 4; diff --git a/fluxer_api/src/api/voice/VoiceService.ts b/fluxer_api/src/api/voice/VoiceService.ts index bbe722291..371f8eec6 100644 --- a/fluxer_api/src/api/voice/VoiceService.ts +++ b/fluxer_api/src/api/voice/VoiceService.ts @@ -1,5 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {ListParticipantsResult} from '@app/api/infrastructure/ILiveKitService'; +import type {LiveKitService} from '@app/api/infrastructure/LiveKitService'; +import type {PinnedRoomServer, VoiceRoomStore} from '@app/api/infrastructure/VoiceRoomStore'; +import {Logger} from '@app/api/Logger'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {getEffectiveSuspiciousFlags} from '@app/api/user/UserHelpers'; +import type {VoiceAccessContext, VoiceAvailabilityService} from '@app/api/voice/VoiceAvailabilityService'; +import type {VoiceRegionAvailability, VoiceServerRecord} from '@app/api/voice/VoiceModel'; +import { + resolveVoiceRegionPreference, + selectClosestPseudoRegionServer, + selectVoiceRegionId, +} from '@app/api/voice/VoiceRegionSelection'; +import {generateConnectionId} from '@app/api/words/Words'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {UnclaimedAccountCannotJoinOneOnOneVoiceCallsError} from '@fluxer/errors/src/domains/channel/UnclaimedAccountCannotJoinOneOnOneVoiceCallsError'; import {UnclaimedAccountCannotJoinVoiceChannelsError} from '@fluxer/errors/src/domains/channel/UnclaimedAccountCannotJoinVoiceChannelsError'; @@ -8,23 +25,6 @@ import {FeatureTemporarilyDisabledError} from '@fluxer/errors/src/domains/core/F import {UnknownGuildMemberError} from '@fluxer/errors/src/domains/guild/UnknownGuildMemberError'; import {AccountSuspiciousActivityError} from '@fluxer/errors/src/domains/user/AccountSuspiciousActivityError'; import {UnknownUserError} from '@fluxer/errors/src/domains/user/UnknownUserError'; -import type {ChannelID, GuildID, UserID} from '../BrandedTypes'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import type {IGuildRepositoryAggregate} from '../guild/repositories/IGuildRepositoryAggregate'; -import type {ListParticipantsResult} from '../infrastructure/ILiveKitService'; -import type {LiveKitService} from '../infrastructure/LiveKitService'; -import type {PinnedRoomServer, VoiceRoomStore} from '../infrastructure/VoiceRoomStore'; -import {Logger} from '../Logger'; -import type {IUserRepository} from '../user/IUserRepository'; -import {getEffectiveSuspiciousFlags} from '../user/UserHelpers'; -import {generateConnectionId} from '../words/Words'; -import type {VoiceAccessContext, VoiceAvailabilityService} from './VoiceAvailabilityService'; -import type {VoiceRegionAvailability, VoiceServerRecord} from './VoiceModel'; -import { - resolveVoiceRegionPreference, - selectClosestPseudoRegionServer, - selectVoiceRegionId, -} from './VoiceRegionSelection'; interface GetVoiceTokenParams { guildId?: GuildID; diff --git a/fluxer_api/src/api/voice/VoiceTopology.ts b/fluxer_api/src/api/voice/VoiceTopology.ts index f404f0cb2..0aa94579a 100644 --- a/fluxer_api/src/api/voice/VoiceTopology.ts +++ b/fluxer_api/src/api/voice/VoiceTopology.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Logger} from '@app/api/Logger'; +import {RefreshSubscription, RefreshSubscriptionUnavailableError} from '@app/api/utils/RefreshSubscription'; +import type {IVoiceRepository} from '@app/api/voice/IVoiceRepository'; +import {VOICE_CONFIGURATION_CHANNEL} from '@app/api/voice/VoiceConstants'; +import type {VoiceRegionMetadata, VoiceRegionRecord, VoiceServerRecord} from '@app/api/voice/VoiceModel'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import {Logger} from '../Logger'; -import {RefreshSubscription, RefreshSubscriptionUnavailableError} from '../utils/RefreshSubscription'; -import type {IVoiceRepository} from './IVoiceRepository'; -import {VOICE_CONFIGURATION_CHANNEL} from './VoiceConstants'; -import type {VoiceRegionMetadata, VoiceRegionRecord, VoiceServerRecord} from './VoiceModel'; type Subscriber = () => void; diff --git a/fluxer_api/src/api/voice/tests/VoiceAvailabilityService.test.ts b/fluxer_api/src/api/voice/tests/VoiceAvailabilityService.test.ts index 4ef905998..b4ee66c25 100644 --- a/fluxer_api/src/api/voice/tests/VoiceAvailabilityService.test.ts +++ b/fluxer_api/src/api/voice/tests/VoiceAvailabilityService.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GuildID, UserID} from '@app/api/BrandedTypes'; +import type {VoiceAccessContext} from '@app/api/voice/VoiceAvailabilityService'; +import {VoiceAvailabilityService} from '@app/api/voice/VoiceAvailabilityService'; +import type {VoiceRegionRecord, VoiceServerRecord} from '@app/api/voice/VoiceModel'; +import type {VoiceTopology} from '@app/api/voice/VoiceTopology'; import {GuildFeatures} from '@fluxer/constants/src/GuildConstants'; import {describe, expect, it} from 'vitest'; -import type {GuildID, UserID} from '../../BrandedTypes'; -import type {VoiceAccessContext} from '../VoiceAvailabilityService'; -import {VoiceAvailabilityService} from '../VoiceAvailabilityService'; -import type {VoiceRegionRecord, VoiceServerRecord} from '../VoiceModel'; -import type {VoiceTopology} from '../VoiceTopology'; function createMockRegion(overrides: Partial = {}): VoiceRegionRecord { return { diff --git a/fluxer_api/src/api/voice/tests/VoiceCallEligibility.test.ts b/fluxer_api/src/api/voice/tests/VoiceCallEligibility.test.ts index 6deec1d79..0e2cdec89 100644 --- a/fluxer_api/src/api/voice/tests/VoiceCallEligibility.test.ts +++ b/fluxer_api/src/api/voice/tests/VoiceCallEligibility.test.ts @@ -1,8 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {IncomingCallFlags} from '@fluxer/constants/src/UserConstants'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount, unclaimAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount, unclaimAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannelInvite, @@ -10,12 +8,14 @@ import { createFriendship, createGuild, getChannel, -} from '../../channel/tests/ChannelTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {updateUserSettings} from '../../user/tests/UserTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {updateUserSettings} from '@app/api/user/tests/UserTestUtils'; +import {IncomingCallFlags} from '@fluxer/constants/src/UserConstants'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Voice Call Eligibility', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/voice/tests/VoiceCallRinging.test.ts b/fluxer_api/src/api/voice/tests/VoiceCallRinging.test.ts index d97c43b8a..3d3faedf2 100644 --- a/fluxer_api/src/api/voice/tests/VoiceCallRinging.test.ts +++ b/fluxer_api/src/api/voice/tests/VoiceCallRinging.test.ts @@ -1,7 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannelInvite, @@ -10,11 +9,12 @@ import { createGroupDmChannel, createGuild, getChannel, -} from '../../channel/tests/ChannelTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; interface ErrorResponse { code: string; diff --git a/fluxer_api/src/api/voice/tests/VoiceCallUpdate.test.ts b/fluxer_api/src/api/voice/tests/VoiceCallUpdate.test.ts index 8e8e210c7..1c44802c3 100644 --- a/fluxer_api/src/api/voice/tests/VoiceCallUpdate.test.ts +++ b/fluxer_api/src/api/voice/tests/VoiceCallUpdate.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannelInvite, createDmChannel, createGuild, getChannel, -} from '../../channel/tests/ChannelTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {afterAll, beforeAll, beforeEach, describe, it} from 'vitest'; describe('Voice Call Update', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/voice/tests/VoiceChannelPermissions.test.ts b/fluxer_api/src/api/voice/tests/VoiceChannelPermissions.test.ts index 028457c4c..9e52584c5 100644 --- a/fluxer_api/src/api/voice/tests/VoiceChannelPermissions.test.ts +++ b/fluxer_api/src/api/voice/tests/VoiceChannelPermissions.test.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; -import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, addMemberRole, @@ -13,11 +10,14 @@ import { createPermissionOverwrite, createRole, getChannel, -} from '../../channel/tests/ChannelTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; +import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Voice Channel Permissions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/voice/tests/VoiceChannelRtcRegion.test.ts b/fluxer_api/src/api/voice/tests/VoiceChannelRtcRegion.test.ts index 0515e409d..84c7989e2 100644 --- a/fluxer_api/src/api/voice/tests/VoiceChannelRtcRegion.test.ts +++ b/fluxer_api/src/api/voice/tests/VoiceChannelRtcRegion.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannel, createGuild, getChannel} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas'; import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannel, createGuild, getChannel} from '../../channel/tests/ChannelTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('Voice Channel RTC Region', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/voice/tests/VoiceLivekitEndpoint.test.ts b/fluxer_api/src/api/voice/tests/VoiceLivekitEndpoint.test.ts index 4a6621227..0d254c337 100644 --- a/fluxer_api/src/api/voice/tests/VoiceLivekitEndpoint.test.ts +++ b/fluxer_api/src/api/voice/tests/VoiceLivekitEndpoint.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {resolveLivekitEndpoint} from '@app/api/voice/VoiceDataInitializer'; import {describe, expect, it} from 'vitest'; -import {resolveLivekitEndpoint} from '../VoiceDataInitializer'; describe('resolveLivekitEndpoint', () => { it('keeps the public port when the instance does not serve on the default port', () => { diff --git a/fluxer_api/src/api/voice/tests/VoiceRegionSelection.test.ts b/fluxer_api/src/api/voice/tests/VoiceRegionSelection.test.ts index 4378ef7bb..fb390e69b 100644 --- a/fluxer_api/src/api/voice/tests/VoiceRegionSelection.test.ts +++ b/fluxer_api/src/api/voice/tests/VoiceRegionSelection.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import type {VoiceRegionAvailability, VoiceServerRecord} from '../VoiceModel'; +import type {VoiceRegionAvailability, VoiceServerRecord} from '@app/api/voice/VoiceModel'; import { preferServersUnderSoftLimit, resolveVoiceRegionPreference, selectClosestPseudoRegionServer, selectVoiceRegionId, -} from '../VoiceRegionSelection'; +} from '@app/api/voice/VoiceRegionSelection'; +import {describe, expect, it} from 'vitest'; function createRegionAvailability({ id, diff --git a/fluxer_api/src/api/voice/tests/VoiceServerLoad.test.ts b/fluxer_api/src/api/voice/tests/VoiceServerLoad.test.ts index d1f43ef75..f250e6e9f 100644 --- a/fluxer_api/src/api/voice/tests/VoiceServerLoad.test.ts +++ b/fluxer_api/src/api/voice/tests/VoiceServerLoad.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {GatewayVoiceStateCounts, IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {VoiceServerLoadTracker} from '@app/api/voice/VoiceServerLoad'; import {describe, expect, it} from 'vitest'; -import type {GatewayVoiceStateCounts, IGatewayService} from '../../infrastructure/IGatewayService'; -import {VoiceServerLoadTracker} from '../VoiceServerLoad'; function createGatewayService(respond: () => Promise): { gatewayService: IGatewayService; diff --git a/fluxer_api/src/api/voice/tests/VoiceUnclaimedAccountRestrictions.test.ts b/fluxer_api/src/api/voice/tests/VoiceUnclaimedAccountRestrictions.test.ts index d9af0c65e..1664ea8dc 100644 --- a/fluxer_api/src/api/voice/tests/VoiceUnclaimedAccountRestrictions.test.ts +++ b/fluxer_api/src/api/voice/tests/VoiceUnclaimedAccountRestrictions.test.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {IncomingCallFlags} from '@fluxer/constants/src/UserConstants'; -import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount, unclaimAccount} from '../../auth/tests/AuthTestUtils'; +import {createTestAccount, unclaimAccount} from '@app/api/auth/tests/AuthTestUtils'; import { acceptInvite, createChannelInvite, createDmChannel, createFriendship, createGuild, -} from '../../channel/tests/ChannelTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {updateUserSettings} from '../../user/tests/UserTestUtils'; +} from '@app/api/channel/tests/ChannelTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {updateUserSettings} from '@app/api/user/tests/UserTestUtils'; +import {IncomingCallFlags} from '@fluxer/constants/src/UserConstants'; +import {afterAll, beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Voice Unclaimed Account Restrictions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/IWebhookRepository.ts b/fluxer_api/src/api/webhook/IWebhookRepository.ts index cb7f4ea02..c7b441bf9 100644 --- a/fluxer_api/src/api/webhook/IWebhookRepository.ts +++ b/fluxer_api/src/api/webhook/IWebhookRepository.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {Webhook} from '../models/Webhook'; +import type {Webhook} from '@app/api/models/Webhook'; export abstract class IWebhookRepository { abstract findUnique(webhookId: bigint): Promise; diff --git a/fluxer_api/src/api/webhook/SweegoWebhookService.ts b/fluxer_api/src/api/webhook/SweegoWebhookService.ts index ab6af66ec..93ca64a99 100644 --- a/fluxer_api/src/api/webhook/SweegoWebhookService.ts +++ b/fluxer_api/src/api/webhook/SweegoWebhookService.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; +import type {UserID} from '@app/api/BrandedTypes'; +import type {GatewayDispatchEvent} from '@app/api/constants/Gateway'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import {isJsonRecord, parseJsonWithGuard} from '@app/api/utils/JsonBoundaryUtils'; import {SuspiciousActivityFlags} from '@fluxer/constants/src/UserConstants'; -import type {UserID} from '../BrandedTypes'; -import type {GatewayDispatchEvent} from '../constants/Gateway'; -import type {UserRow} from '../database/types/UserTypes'; -import {Logger} from '../Logger'; -import type {User} from '../models/User'; -import {mapUserToPrivateResponse} from '../user/UserMappers'; -import {isJsonRecord, parseJsonWithGuard} from '../utils/JsonBoundaryUtils'; interface ISweegoUserRepository { findByEmail(email: string): Promise; diff --git a/fluxer_api/src/api/webhook/WebhookController.ts b/fluxer_api/src/api/webhook/WebhookController.ts index f5f7e1edd..0bd9e94fe 100644 --- a/fluxer_api/src/api/webhook/WebhookController.ts +++ b/fluxer_api/src/api/webhook/WebhookController.ts @@ -1,5 +1,25 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createChannelID, + createGuildID, + createMessageID, + createUserID, + createWebhookID, + createWebhookToken, +} from '@app/api/BrandedTypes'; +import type {MessageRequest} from '@app/api/channel/MessageTypes'; +import {normalizeMessageRequestPayload} from '@app/api/channel/services/message/MessageRequestCompatibility'; +import {parseMultipartMessageData} from '@app/api/channel/services/message/MessageRequestParser'; +import {LoginRequired} from '@app/api/middleware/AuthMiddleware'; +import {BlockAppOriginMiddleware} from '@app/api/middleware/BlockAppOriginMiddleware'; +import {RateLimitMiddleware} from '@app/api/middleware/RateLimitMiddleware'; +import {OpenAPI} from '@app/api/middleware/ResponseTypeMiddleware'; +import {RateLimitConfigs} from '@app/api/RateLimitConfig'; +import type {HonoApp, HonoEnv} from '@app/api/types/HonoEnv'; +import {parseJsonPreservingLargeIntegers} from '@app/api/utils/LosslessJsonParser'; +import {Validator} from '@app/api/Validator'; +import type {WebhookExecuteMessageData} from '@app/api/webhook/WebhookService'; import {DELETED_USER_ID} from '@fluxer/constants/src/UserConstants'; import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; import {InputValidationError} from '@fluxer/errors/src/domains/core/InputValidationError'; @@ -33,27 +53,6 @@ import { } from '@fluxer/schema/src/domains/webhook/WebhookSchemas'; import type {Context} from 'hono'; -import { - createChannelID, - createGuildID, - createMessageID, - createUserID, - createWebhookID, - createWebhookToken, -} from '../BrandedTypes'; -import type {MessageRequest} from '../channel/MessageTypes'; -import {normalizeMessageRequestPayload} from '../channel/services/message/MessageRequestCompatibility'; -import {parseMultipartMessageData} from '../channel/services/message/MessageRequestParser'; -import {LoginRequired} from '../middleware/AuthMiddleware'; -import {BlockAppOriginMiddleware} from '../middleware/BlockAppOriginMiddleware'; -import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware'; -import {OpenAPI} from '../middleware/ResponseTypeMiddleware'; -import {RateLimitConfigs} from '../RateLimitConfig'; -import type {HonoApp, HonoEnv} from '../types/HonoEnv'; -import {parseJsonPreservingLargeIntegers} from '../utils/LosslessJsonParser'; -import {Validator} from '../Validator'; -import type {WebhookExecuteMessageData} from './WebhookService'; - function validateWebhookMessagePayload(data: unknown): WebhookMessageRequest { const validationResult = WebhookMessageRequest.safeParse(normalizeMessageRequestPayload(data)); if (!validationResult.success) { diff --git a/fluxer_api/src/api/webhook/WebhookModel.ts b/fluxer_api/src/api/webhook/WebhookModel.ts index 291d4cc9d..184e91308 100644 --- a/fluxer_api/src/api/webhook/WebhookModel.ts +++ b/fluxer_api/src/api/webhook/WebhookModel.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Webhook} from '@app/api/models/Webhook'; +import {getCachedUserPartialResponse} from '@app/api/user/UserCacheHelpers'; import {DELETED_USER_ID} from '@fluxer/constants/src/UserConstants'; import type {WebhookResponse, WebhookTokenResponse} from '@fluxer/schema/src/domains/webhook/WebhookSchemas'; -import {createUserID} from '../BrandedTypes'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Webhook} from '../models/Webhook'; -import {getCachedUserPartialResponse} from '../user/UserCacheHelpers'; export function mapWebhookToTokenResponse(webhook: Webhook): WebhookTokenResponse { return { diff --git a/fluxer_api/src/api/webhook/WebhookRepository.ts b/fluxer_api/src/api/webhook/WebhookRepository.ts index aad9c9ea7..524d0f263 100644 --- a/fluxer_api/src/api/webhook/WebhookRepository.ts +++ b/fluxer_api/src/api/webhook/WebhookRepository.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ChannelID, GuildID, UserID, WebhookID, WebhookToken} from '../BrandedTypes'; +import type {ChannelID, GuildID, UserID, WebhookID, WebhookToken} from '@app/api/BrandedTypes'; import { BatchBuilder, deleteOneOrMany, fetchMany, fetchManyInChunks, fetchOne, -} from '../database/CassandraQueryExecution'; -import {buildPatchFromData, executeVersionedUpdate} from '../database/CassandraVersionedUpdate'; -import type {WebhookRow} from '../database/types/ChannelTypes'; -import {WEBHOOK_COLUMNS} from '../database/types/ChannelTypes'; -import {Webhook} from '../models/Webhook'; -import {Webhooks, WebhooksByChannel, WebhooksByGuild} from '../Tables'; -import {IWebhookRepository} from './IWebhookRepository'; +} from '@app/api/database/CassandraQueryExecution'; +import {buildPatchFromData, executeVersionedUpdate} from '@app/api/database/CassandraVersionedUpdate'; +import type {WebhookRow} from '@app/api/database/types/ChannelTypes'; +import {WEBHOOK_COLUMNS} from '@app/api/database/types/ChannelTypes'; +import {Webhook} from '@app/api/models/Webhook'; +import {Webhooks, WebhooksByChannel, WebhooksByGuild} from '@app/api/Tables'; +import {IWebhookRepository} from '@app/api/webhook/IWebhookRepository'; const FETCH_WEBHOOK_BY_ID_CQL = Webhooks.selectCql({ where: Webhooks.where.eq('webhook_id'), diff --git a/fluxer_api/src/api/webhook/WebhookRequestService.ts b/fluxer_api/src/api/webhook/WebhookRequestService.ts index 6bebaf848..9460b6c1e 100644 --- a/fluxer_api/src/api/webhook/WebhookRequestService.ts +++ b/fluxer_api/src/api/webhook/WebhookRequestService.ts @@ -1,5 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, MessageID, UserID, WebhookID, WebhookToken} from '@app/api/BrandedTypes'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {MessageUpdateRequest} from '@app/api/channel/MessageTypes'; +import {createMessageResponseDataService} from '@app/api/channel/services/message/MessageResponseDataService'; +import type {LiveKitWebhookService} from '@app/api/infrastructure/LiveKitWebhookService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Message} from '@app/api/models/Message'; +import type {SweegoWebhookService} from '@app/api/webhook/SweegoWebhookService'; +import {transformSlackWebhookRequest} from '@app/api/webhook/transformers/SlackTransformer'; +import { + mapWebhooksToResponse, + mapWebhookToResponseWithCache, + mapWebhookToTokenResponse, +} from '@app/api/webhook/WebhookModel'; +import type {WebhookExecuteMessageData, WebhookService} from '@app/api/webhook/WebhookService'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; import type {InstatusWebhook} from '@fluxer/schema/src/domains/webhook/InstatusWebhookSchemas'; @@ -10,20 +28,6 @@ import type { WebhookUpdateRequest, } from '@fluxer/schema/src/domains/webhook/WebhookRequestSchemas'; import type {WebhookResponse, WebhookTokenResponse} from '@fluxer/schema/src/domains/webhook/WebhookSchemas'; -import type {ChannelID, GuildID, MessageID, UserID, WebhookID, WebhookToken} from '../BrandedTypes'; -import {createUserID} from '../BrandedTypes'; -import {Config} from '../Config'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import type {MessageUpdateRequest} from '../channel/MessageTypes'; -import {createMessageResponseDataService} from '../channel/services/message/MessageResponseDataService'; -import type {LiveKitWebhookService} from '../infrastructure/LiveKitWebhookService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Message} from '../models/Message'; -import type {SweegoWebhookService} from './SweegoWebhookService'; -import {transformSlackWebhookRequest} from './transformers/SlackTransformer'; -import {mapWebhooksToResponse, mapWebhookToResponseWithCache, mapWebhookToTokenResponse} from './WebhookModel'; -import type {WebhookExecuteMessageData, WebhookService} from './WebhookService'; type WebhookExecutionResponse = MessageResponse | null; diff --git a/fluxer_api/src/api/webhook/WebhookService.ts b/fluxer_api/src/api/webhook/WebhookService.ts index 306c66aca..5f79e5f97 100644 --- a/fluxer_api/src/api/webhook/WebhookService.ts +++ b/fluxer_api/src/api/webhook/WebhookService.ts @@ -1,6 +1,31 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import fs from 'node:fs/promises'; +import type {ChannelID, GuildID, MessageID, UserID, WebhookID, WebhookToken} from '@app/api/BrandedTypes'; +import {createChannelID, createGuildID, createWebhookID, createWebhookToken} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {MessageRequest, MessageUpdateRequest} from '@app/api/channel/MessageTypes'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {resolveLimitSafe} from '@app/api/limits/LimitConfigUtils'; +import {createLimitMatchContext} from '@app/api/limits/LimitMatchContextBuilder'; +import type {RequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {Channel} from '@app/api/models/Channel'; +import type {Message} from '@app/api/models/Message'; +import type {Webhook} from '@app/api/models/Webhook'; +import {resolveAssetPath} from '@app/api/utils/AssetPaths'; +import * as RandomUtils from '@app/api/utils/RandomUtils'; +import type {IWebhookRepository} from '@app/api/webhook/IWebhookRepository'; +import {transform as GitHubTransform} from '@app/api/webhook/transformers/GitHubTransformer'; +import {instatusDeliveryKey, transformInstatusWebhook} from '@app/api/webhook/transformers/InstatusTransformer'; import {AuditLogActionType} from '@fluxer/constants/src/AuditLogActionType'; import {GUILD_TEXT_BASED_CHANNEL_TYPES, Permissions} from '@fluxer/constants/src/ChannelConstants'; import type {LimitKey} from '@fluxer/constants/src/LimitConfigMetadata'; @@ -22,31 +47,6 @@ import type { } from '@fluxer/schema/src/domains/webhook/WebhookRequestSchemas'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import {seconds} from 'itty-time'; -import type {ChannelID, GuildID, MessageID, UserID, WebhookID, WebhookToken} from '../BrandedTypes'; -import {createChannelID, createGuildID, createWebhookID, createWebhookToken} from '../BrandedTypes'; -import type {IChannelRepository} from '../channel/IChannelRepository'; -import type {MessageRequest, MessageUpdateRequest} from '../channel/MessageTypes'; -import type {ChannelService} from '../channel/services/ChannelService'; -import type {GuildAuditLogService} from '../guild/GuildAuditLogService'; -import type {GuildService} from '../guild/services/GuildService'; -import type {AvatarService} from '../infrastructure/AvatarService'; -import {contentModerationService} from '../infrastructure/ContentModerationService'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {IMediaService} from '../infrastructure/IMediaService'; -import type {ISnowflakeService} from '../infrastructure/ISnowflakeService'; -import {Logger} from '../Logger'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import {resolveLimitSafe} from '../limits/LimitConfigUtils'; -import {createLimitMatchContext} from '../limits/LimitMatchContextBuilder'; -import type {RequestCache} from '../middleware/RequestCacheMiddleware'; -import type {Channel} from '../models/Channel'; -import type {Message} from '../models/Message'; -import type {Webhook} from '../models/Webhook'; -import {resolveAssetPath} from '../utils/AssetPaths'; -import * as RandomUtils from '../utils/RandomUtils'; -import type {IWebhookRepository} from './IWebhookRepository'; -import {transform as GitHubTransform} from './transformers/GitHubTransformer'; -import {instatusDeliveryKey, transformInstatusWebhook} from './transformers/InstatusTransformer'; export interface WebhookExecuteMessageData extends Omit { attachments?: WebhookMessageRequest['attachments'] | MessageRequest['attachments']; diff --git a/fluxer_api/src/api/webhook/tests/GitHubCheckTransformer.test.ts b/fluxer_api/src/api/webhook/tests/GitHubCheckTransformer.test.ts index 489b32616..8ea0fabd1 100644 --- a/fluxer_api/src/api/webhook/tests/GitHubCheckTransformer.test.ts +++ b/fluxer_api/src/api/webhook/tests/GitHubCheckTransformer.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; -import {describe, expect, it} from 'vitest'; import { transformCheckRun, transformCheckSuite, transformDiscussion, transformDiscussionComment, -} from '../transformers/GitHubCheckTransformer'; +} from '@app/api/webhook/transformers/GitHubCheckTransformer'; +import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; +import {describe, expect, it} from 'vitest'; function createBaseSender() { return { diff --git a/fluxer_api/src/api/webhook/tests/GitHubCommitTransformer.test.ts b/fluxer_api/src/api/webhook/tests/GitHubCommitTransformer.test.ts index cae70441b..1979bda06 100644 --- a/fluxer_api/src/api/webhook/tests/GitHubCommitTransformer.test.ts +++ b/fluxer_api/src/api/webhook/tests/GitHubCommitTransformer.test.ts @@ -1,8 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + transformCommitComment, + transformCreate, + transformDelete, +} from '@app/api/webhook/transformers/GitHubCommitTransformer'; import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; import {describe, expect, it} from 'vitest'; -import {transformCommitComment, transformCreate, transformDelete} from '../transformers/GitHubCommitTransformer'; function createBaseSender() { return { diff --git a/fluxer_api/src/api/webhook/tests/GitHubIssueTransformer.test.ts b/fluxer_api/src/api/webhook/tests/GitHubIssueTransformer.test.ts index 31564a9db..a2b98316b 100644 --- a/fluxer_api/src/api/webhook/tests/GitHubIssueTransformer.test.ts +++ b/fluxer_api/src/api/webhook/tests/GitHubIssueTransformer.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {transformIssue, transformIssueComment} from '@app/api/webhook/transformers/GitHubIssueTransformer'; import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; import {describe, expect, it} from 'vitest'; -import {transformIssue, transformIssueComment} from '../transformers/GitHubIssueTransformer'; function createBaseSender() { return { diff --git a/fluxer_api/src/api/webhook/tests/GitHubPullRequestTransformer.test.ts b/fluxer_api/src/api/webhook/tests/GitHubPullRequestTransformer.test.ts index 5d4b7580e..144ba3767 100644 --- a/fluxer_api/src/api/webhook/tests/GitHubPullRequestTransformer.test.ts +++ b/fluxer_api/src/api/webhook/tests/GitHubPullRequestTransformer.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; -import {describe, expect, it} from 'vitest'; import { transformPullRequest, transformPullRequestReview, transformPullRequestReviewComment, -} from '../transformers/GitHubPullRequestTransformer'; +} from '@app/api/webhook/transformers/GitHubPullRequestTransformer'; +import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; +import {describe, expect, it} from 'vitest'; function createBaseSender() { return { diff --git a/fluxer_api/src/api/webhook/tests/GitHubPushTransformer.test.ts b/fluxer_api/src/api/webhook/tests/GitHubPushTransformer.test.ts index ce536563d..710fcc954 100644 --- a/fluxer_api/src/api/webhook/tests/GitHubPushTransformer.test.ts +++ b/fluxer_api/src/api/webhook/tests/GitHubPushTransformer.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {transformPush} from '@app/api/webhook/transformers/GitHubCommitTransformer'; import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; import {describe, expect, it} from 'vitest'; -import {transformPush} from '../transformers/GitHubCommitTransformer'; function createBaseSender() { return { diff --git a/fluxer_api/src/api/webhook/tests/GitHubRepositoryTransformer.test.ts b/fluxer_api/src/api/webhook/tests/GitHubRepositoryTransformer.test.ts index 0ebc34f4e..26defc807 100644 --- a/fluxer_api/src/api/webhook/tests/GitHubRepositoryTransformer.test.ts +++ b/fluxer_api/src/api/webhook/tests/GitHubRepositoryTransformer.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; -import {describe, expect, it} from 'vitest'; import { transformFork, transformMember, @@ -9,7 +7,9 @@ import { transformRelease, transformRepository, transformWatch, -} from '../transformers/GitHubRepositoryTransformer'; +} from '@app/api/webhook/transformers/GitHubRepositoryTransformer'; +import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; +import {describe, expect, it} from 'vitest'; function createBaseSender() { return { diff --git a/fluxer_api/src/api/webhook/tests/GitHubTransformer.test.ts b/fluxer_api/src/api/webhook/tests/GitHubTransformer.test.ts index 5619f1b34..b26634b30 100644 --- a/fluxer_api/src/api/webhook/tests/GitHubTransformer.test.ts +++ b/fluxer_api/src/api/webhook/tests/GitHubTransformer.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {transform} from '@app/api/webhook/transformers/GitHubTransformer'; import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; import {describe, expect, it} from 'vitest'; -import {transform} from '../transformers/GitHubTransformer'; function createBaseSender() { return { diff --git a/fluxer_api/src/api/webhook/tests/InstatusTransformer.test.ts b/fluxer_api/src/api/webhook/tests/InstatusTransformer.test.ts index a32ed92f2..7546d749c 100644 --- a/fluxer_api/src/api/webhook/tests/InstatusTransformer.test.ts +++ b/fluxer_api/src/api/webhook/tests/InstatusTransformer.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {transformInstatusWebhook} from '@app/api/webhook/transformers/InstatusTransformer'; import {RICH_EMBED_DESCRIPTION_MAX_LENGTH} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import {InstatusWebhook} from '@fluxer/schema/src/domains/webhook/InstatusWebhookSchemas'; import {describe, expect, it} from 'vitest'; -import {transformInstatusWebhook} from '../transformers/InstatusTransformer'; function createMeta(): InstatusWebhook['meta'] { return {unsubscribe: 'https://fluxerstatus.com/unsubscribe?id=1&token=abc', documentation: ''}; diff --git a/fluxer_api/src/api/webhook/tests/SlackTransformer.test.ts b/fluxer_api/src/api/webhook/tests/SlackTransformer.test.ts index ecf70f07f..c088395ff 100644 --- a/fluxer_api/src/api/webhook/tests/SlackTransformer.test.ts +++ b/fluxer_api/src/api/webhook/tests/SlackTransformer.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {transformSlackWebhookRequest} from '@app/api/webhook/transformers/SlackTransformer'; import type {SlackWebhookRequest} from '@fluxer/schema/src/domains/webhook/WebhookRequestSchemas'; import {describe, expect, it} from 'vitest'; -import {transformSlackWebhookRequest} from '../transformers/SlackTransformer'; describe('Slack Transformer', () => { describe('transformSlackWebhookRequest', () => { diff --git a/fluxer_api/src/api/webhook/tests/WebhookChannelValidation.test.ts b/fluxer_api/src/api/webhook/tests/WebhookChannelValidation.test.ts index c73f25a08..533bbfe21 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookChannelValidation.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookChannelValidation.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createFriendship} from '@app/api/channel/tests/ChannelTestUtils'; +import {createChannel, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_IDS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {createWebhook, deleteWebhook} from '@app/api/webhook/tests/WebhookTestUtils'; import {afterEach, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createFriendship} from '../../channel/tests/ChannelTestUtils'; -import {createChannel, createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_IDS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createWebhook, deleteWebhook} from './WebhookTestUtils'; describe('Webhook channel validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookCompareUser.test.ts b/fluxer_api/src/api/webhook/tests/WebhookCompareUser.test.ts index d4e61ba64..ffc0546ed 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookCompareUser.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookCompareUser.test.ts @@ -1,10 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannel, createGuild} from '../../guild/tests/GuildTestUtils'; -import {ensureSessionStarted} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannel, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import { createGuildEmoji, createWebhook, @@ -14,7 +13,8 @@ import { grantCreateExpressionsPermission, grantStaffAccess, sendChannelMessage, -} from './WebhookTestUtils'; +} from '@app/api/webhook/tests/WebhookTestUtils'; +import {afterEach, beforeEach, describe, expect, it} from 'vitest'; describe('Webhook compare to regular user', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookEmojiBypass.test.ts b/fluxer_api/src/api/webhook/tests/WebhookEmojiBypass.test.ts index b0dc2b24b..b0734e29d 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookEmojiBypass.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookEmojiBypass.test.ts @@ -1,9 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; import { createGuildEmoji, createGuildEmojiWithFile, @@ -12,7 +11,8 @@ import { executeWebhook, grantCreateExpressionsPermission, grantStaffAccess, -} from './WebhookTestUtils'; +} from '@app/api/webhook/tests/WebhookTestUtils'; +import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Webhook emoji bypass', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookExecution.test.ts b/fluxer_api/src/api/webhook/tests/WebhookExecution.test.ts index cd2318c59..e8bf8347b 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookExecution.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookExecution.test.ts @@ -1,21 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import {MAX_MESSAGE_LENGTH_PREMIUM} from '@fluxer/constants/src/LimitConstants'; -import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; -import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannel, createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannel, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import { createWebhook, deleteWebhook, deleteWebhookMessageByToken, executeWebhook, sendChannelMessage, -} from './WebhookTestUtils'; +} from '@app/api/webhook/tests/WebhookTestUtils'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; +import {MAX_MESSAGE_LENGTH_PREMIUM} from '@fluxer/constants/src/LimitConstants'; +import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; +import {beforeAll, beforeEach, describe, expect, it} from 'vitest'; describe('Webhook execution', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookExecutionAdvanced.test.ts b/fluxer_api/src/api/webhook/tests/WebhookExecutionAdvanced.test.ts index e9f0c5de3..cb5b913b7 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookExecutionAdvanced.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookExecutionAdvanced.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {createWebhook, deleteWebhook} from '@app/api/webhook/tests/WebhookTestUtils'; import {MessageFlags} from '@fluxer/constants/src/ChannelConstants'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createWebhook, deleteWebhook} from './WebhookTestUtils'; describe('Webhook execution advanced', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookGitHub.test.ts b/fluxer_api/src/api/webhook/tests/WebhookGitHub.test.ts index 1c721fe69..0304499a7 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookGitHub.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookGitHub.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {createWebhook, deleteWebhook} from '@app/api/webhook/tests/WebhookTestUtils'; import {afterEach, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createWebhook, deleteWebhook} from './WebhookTestUtils'; function createGitHubSender() { return { diff --git a/fluxer_api/src/api/webhook/tests/WebhookInstatus.test.ts b/fluxer_api/src/api/webhook/tests/WebhookInstatus.test.ts index c3229b5a5..a5d79a820 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookInstatus.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookInstatus.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {getMessages} from '@app/api/message/tests/MessageTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {createWebhook, deleteWebhook} from '@app/api/webhook/tests/WebhookTestUtils'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {getMessages} from '../../message/tests/MessageTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createWebhook, deleteWebhook} from './WebhookTestUtils'; function createInstatusPage() { return { diff --git a/fluxer_api/src/api/webhook/tests/WebhookLimits.test.ts b/fluxer_api/src/api/webhook/tests/WebhookLimits.test.ts index f564df90b..fb8261f0d 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookLimits.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookLimits.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannel, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {createWebhook, deleteWebhook} from '@app/api/webhook/tests/WebhookTestUtils'; import {MAX_WEBHOOKS_PER_CHANNEL} from '@fluxer/constants/src/LimitConstants'; import type {WebhookResponse} from '@fluxer/schema/src/domains/webhook/WebhookSchemas'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannel, createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createWebhook, deleteWebhook} from './WebhookTestUtils'; describe('Webhook limits', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookMultipartAttachmentUploads.test.ts b/fluxer_api/src/api/webhook/tests/WebhookMultipartAttachmentUploads.test.ts index 9cf7cfa4d..2128145a2 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookMultipartAttachmentUploads.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookMultipartAttachmentUploads.test.ts @@ -1,14 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {loadFixture} from '@app/api/channel/tests/AttachmentTestUtils'; +import {createPermissionOverwrite} from '@app/api/channel/tests/ChannelTestUtils'; +import {acceptInvite, addMemberRole, createGuild, createRole} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import { + createChannelInvite, + createWebhook, + deleteWebhook, + executeWebhookWithAttachments, +} from '@app/api/webhook/tests/WebhookTestUtils'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {loadFixture} from '../../channel/tests/AttachmentTestUtils'; -import {createPermissionOverwrite} from '../../channel/tests/ChannelTestUtils'; -import {acceptInvite, addMemberRole, createGuild, createRole} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createChannelInvite, createWebhook, deleteWebhook, executeWebhookWithAttachments} from './WebhookTestUtils'; describe('Webhook multipart attachment uploads', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookOperations.test.ts b/fluxer_api/src/api/webhook/tests/WebhookOperations.test.ts index ed0cbd6ae..368a389e3 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookOperations.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookOperations.test.ts @@ -1,13 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import type {WebhookResponse} from '@fluxer/schema/src/domains/webhook/WebhookSchemas'; -import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannel, createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannel, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import { createWebhook, deleteWebhook, @@ -18,7 +15,10 @@ import { getWebhookByToken, updateWebhook, updateWebhookByToken, -} from './WebhookTestUtils'; +} from '@app/api/webhook/tests/WebhookTestUtils'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; +import type {WebhookResponse} from '@fluxer/schema/src/domains/webhook/WebhookSchemas'; +import {afterEach, beforeEach, describe, expect, it} from 'vitest'; describe('Webhook Operations', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookOrphanedCreator.test.ts b/fluxer_api/src/api/webhook/tests/WebhookOrphanedCreator.test.ts index e13b85e25..d3f538dca 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookOrphanedCreator.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookOrphanedCreator.test.ts @@ -1,14 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createUserID, createWebhookID} from '@app/api/BrandedTypes'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import { + createWebhook, + executeWebhook, + executeWebhookWithAttachments, + getChannelWebhooks, +} from '@app/api/webhook/tests/WebhookTestUtils'; +import {WebhookRepository} from '@app/api/webhook/WebhookRepository'; import {DELETED_USER_ID, DELETED_USER_USERNAME} from '@fluxer/constants/src/UserConstants'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createUserID, createWebhookID} from '../../BrandedTypes'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {WebhookRepository} from '../WebhookRepository'; -import {createWebhook, executeWebhook, executeWebhookWithAttachments, getChannelWebhooks} from './WebhookTestUtils'; const VANISHED_CREATOR_ID = createUserID(999999999999999997n); diff --git a/fluxer_api/src/api/webhook/tests/WebhookPermissions.test.ts b/fluxer_api/src/api/webhook/tests/WebhookPermissions.test.ts index 351fdf6d5..adefc702c 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookPermissions.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookPermissions.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {acceptInvite, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; +import {createChannelInvite, createWebhook, deleteWebhook} from '@app/api/webhook/tests/WebhookTestUtils'; import {beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {acceptInvite, createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; -import {createChannelInvite, createWebhook, deleteWebhook} from './WebhookTestUtils'; describe('Webhook permissions', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookStickerBypass.test.ts b/fluxer_api/src/api/webhook/tests/WebhookStickerBypass.test.ts index daa1e9aba..c7c27dec3 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookStickerBypass.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookStickerBypass.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {createWebhook, deleteWebhook} from '@app/api/webhook/tests/WebhookTestUtils'; import {beforeAll, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createWebhook, deleteWebhook} from './WebhookTestUtils'; describe('Webhook stickers', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookTestUtils.ts b/fluxer_api/src/api/webhook/tests/WebhookTestUtils.ts index 5e458f41c..0e8aef252 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookTestUtils.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookTestUtils.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createMultipartFormData} from '@app/api/channel/tests/AttachmentTestUtils'; +import {getPngDataUrl, VALID_PNG_BASE64} from '@app/api/emoji/tests/EmojiTestUtils'; +import type {ApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {createBuilder, createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; import type {GuildEmojiWithUserResponse} from '@fluxer/schema/src/domains/guild/GuildEmojiSchemas'; import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import type {WebhookResponse, WebhookTokenResponse} from '@fluxer/schema/src/domains/webhook/WebhookSchemas'; -import {createMultipartFormData} from '../../channel/tests/AttachmentTestUtils'; -import {getPngDataUrl, VALID_PNG_BASE64} from '../../emoji/tests/EmojiTestUtils'; -import type {ApiTestHarness} from '../../test/ApiTestHarness'; -import {createBuilder, createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; export async function createWebhook( harness: ApiTestHarness, diff --git a/fluxer_api/src/api/webhook/tests/WebhookTokenAuth.test.ts b/fluxer_api/src/api/webhook/tests/WebhookTokenAuth.test.ts index cb53cca2b..5bc2ba345 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookTokenAuth.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookTokenAuth.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_IDS} from '@app/api/test/TestConstants'; +import {createBuilderWithoutAuth} from '@app/api/test/TestRequestBuilder'; +import {createWebhook, deleteWebhook} from '@app/api/webhook/tests/WebhookTestUtils'; import type {WebhookTokenResponse} from '@fluxer/schema/src/domains/webhook/WebhookSchemas'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_IDS} from '../../test/TestConstants'; -import {createBuilderWithoutAuth} from '../../test/TestRequestBuilder'; -import {createWebhook, deleteWebhook} from './WebhookTestUtils'; describe('Webhook token authentication', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/tests/WebhookValidation.test.ts b/fluxer_api/src/api/webhook/tests/WebhookValidation.test.ts index e1d111fe0..64c6d64f9 100644 --- a/fluxer_api/src/api/webhook/tests/WebhookValidation.test.ts +++ b/fluxer_api/src/api/webhook/tests/WebhookValidation.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createTestAccount} from '@app/api/auth/tests/AuthTestUtils'; +import {createChannel, createGuild} from '@app/api/guild/tests/GuildTestUtils'; +import {type ApiTestHarness, createApiTestHarness} from '@app/api/test/ApiTestHarness'; +import {HTTP_STATUS, TEST_IDS} from '@app/api/test/TestConstants'; +import {createBuilder} from '@app/api/test/TestRequestBuilder'; import {afterEach, beforeEach, describe, it} from 'vitest'; -import {createTestAccount} from '../../auth/tests/AuthTestUtils'; -import {createChannel, createGuild} from '../../guild/tests/GuildTestUtils'; -import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness'; -import {HTTP_STATUS, TEST_IDS} from '../../test/TestConstants'; -import {createBuilder} from '../../test/TestRequestBuilder'; describe('Webhook validation', () => { let harness: ApiTestHarness; diff --git a/fluxer_api/src/api/webhook/transformers/GitHubCheckTransformer.ts b/fluxer_api/src/api/webhook/transformers/GitHubCheckTransformer.ts index eceeec708..1c876af0b 100644 --- a/fluxer_api/src/api/webhook/transformers/GitHubCheckTransformer.ts +++ b/fluxer_api/src/api/webhook/transformers/GitHubCheckTransformer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {parseString} from '@app/api/utils/StringUtils'; import type {RichEmbedRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; -import {parseString} from '../../utils/StringUtils'; export async function transformCheckRun(body: GitHubWebhook): Promise { if (!body.repository || body.action !== 'completed' || !body.check_run) { diff --git a/fluxer_api/src/api/webhook/transformers/GitHubCommitTransformer.ts b/fluxer_api/src/api/webhook/transformers/GitHubCommitTransformer.ts index 156dfa831..38f08d180 100644 --- a/fluxer_api/src/api/webhook/transformers/GitHubCommitTransformer.ts +++ b/fluxer_api/src/api/webhook/transformers/GitHubCommitTransformer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {parseString} from '@app/api/utils/StringUtils'; import type {RichEmbedRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; -import {parseString} from '../../utils/StringUtils'; export async function transformCommitComment(body: GitHubWebhook): Promise { if (!body.repository || body.action !== 'created' || !body.comment) { diff --git a/fluxer_api/src/api/webhook/transformers/GitHubIssueTransformer.ts b/fluxer_api/src/api/webhook/transformers/GitHubIssueTransformer.ts index cd650fea6..bb0435a8c 100644 --- a/fluxer_api/src/api/webhook/transformers/GitHubIssueTransformer.ts +++ b/fluxer_api/src/api/webhook/transformers/GitHubIssueTransformer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {parseString} from '@app/api/utils/StringUtils'; import type {RichEmbedRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; -import {parseString} from '../../utils/StringUtils'; export async function transformIssue(body: GitHubWebhook): Promise { if (!(body.issue && body.action && body.repository)) { diff --git a/fluxer_api/src/api/webhook/transformers/GitHubPullRequestTransformer.ts b/fluxer_api/src/api/webhook/transformers/GitHubPullRequestTransformer.ts index fbc7601a7..88b217f50 100644 --- a/fluxer_api/src/api/webhook/transformers/GitHubPullRequestTransformer.ts +++ b/fluxer_api/src/api/webhook/transformers/GitHubPullRequestTransformer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {parseString} from '@app/api/utils/StringUtils'; import type {RichEmbedRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; -import {parseString} from '../../utils/StringUtils'; function parseDescription(value: string | null | undefined): string | undefined { if (!value) return undefined; diff --git a/fluxer_api/src/api/webhook/transformers/GitHubRepositoryTransformer.ts b/fluxer_api/src/api/webhook/transformers/GitHubRepositoryTransformer.ts index 73ee6256b..1f4b2c4cc 100644 --- a/fluxer_api/src/api/webhook/transformers/GitHubRepositoryTransformer.ts +++ b/fluxer_api/src/api/webhook/transformers/GitHubRepositoryTransformer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {parseString} from '@app/api/utils/StringUtils'; import type {RichEmbedRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; -import {parseString} from '../../utils/StringUtils'; export async function transformFork(body: GitHubWebhook): Promise { if (!(body.repository && body.forkee && body.sender)) { diff --git a/fluxer_api/src/api/webhook/transformers/GitHubTransformer.ts b/fluxer_api/src/api/webhook/transformers/GitHubTransformer.ts index afe952cdc..6a112e304 100644 --- a/fluxer_api/src/api/webhook/transformers/GitHubTransformer.ts +++ b/fluxer_api/src/api/webhook/transformers/GitHubTransformer.ts @@ -1,20 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {RichEmbedRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; -import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; import { transformCheckRun, transformCheckSuite, transformDiscussion, transformDiscussionComment, -} from './GitHubCheckTransformer'; -import {transformCommitComment, transformCreate, transformDelete, transformPush} from './GitHubCommitTransformer'; -import {transformIssue, transformIssueComment} from './GitHubIssueTransformer'; +} from '@app/api/webhook/transformers/GitHubCheckTransformer'; +import { + transformCommitComment, + transformCreate, + transformDelete, + transformPush, +} from '@app/api/webhook/transformers/GitHubCommitTransformer'; +import {transformIssue, transformIssueComment} from '@app/api/webhook/transformers/GitHubIssueTransformer'; import { transformPullRequest, transformPullRequestReview, transformPullRequestReviewComment, -} from './GitHubPullRequestTransformer'; +} from '@app/api/webhook/transformers/GitHubPullRequestTransformer'; import { transformFork, transformMember, @@ -22,7 +25,9 @@ import { transformRelease, transformRepository, transformWatch, -} from './GitHubRepositoryTransformer'; +} from '@app/api/webhook/transformers/GitHubRepositoryTransformer'; +import type {RichEmbedRequest} from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; +import type {GitHubWebhook} from '@fluxer/schema/src/domains/webhook/GitHubWebhookSchemas'; export async function transform(event: string, body: GitHubWebhook): Promise { switch (event) { diff --git a/fluxer_api/src/api/webhook/transformers/InstatusTransformer.ts b/fluxer_api/src/api/webhook/transformers/InstatusTransformer.ts index 8fff50acf..91b540ec5 100644 --- a/fluxer_api/src/api/webhook/transformers/InstatusTransformer.ts +++ b/fluxer_api/src/api/webhook/transformers/InstatusTransformer.ts @@ -1,5 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {parseString, safeUrl} from '@app/api/utils/StringUtils'; import { RICH_EMBED_DESCRIPTION_MAX_LENGTH, RICH_EMBED_FIELD_VALUE_MAX_LENGTH, @@ -8,7 +9,6 @@ import { type RichEmbedRequest, } from '@fluxer/schema/src/domains/message/MessageRequestSchemas'; import type {InstatusWebhook} from '@fluxer/schema/src/domains/webhook/InstatusWebhookSchemas'; -import {parseString, safeUrl} from '../../utils/StringUtils'; type EmbedField = NonNullable[number]; type UpdateLike = { diff --git a/fluxer_api/src/api/webhook/transformers/SlackTransformer.ts b/fluxer_api/src/api/webhook/transformers/SlackTransformer.ts index bbc8b2bac..a0e7b40c3 100644 --- a/fluxer_api/src/api/webhook/transformers/SlackTransformer.ts +++ b/fluxer_api/src/api/webhook/transformers/SlackTransformer.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {safeUrl} from '@app/api/utils/StringUtils'; import type { SlackWebhookRequest, WebhookMessageRequest, } from '@fluxer/schema/src/domains/webhook/WebhookRequestSchemas'; import {ColorType} from '@fluxer/schema/src/primitives/SchemaPrimitives'; -import {safeUrl} from '../../utils/StringUtils'; type SlackAttachment = NonNullable[number]; type SlackAttachmentField = NonNullable[number]; diff --git a/fluxer_api/src/api/words/Words.ts b/fluxer_api/src/api/words/Words.ts index 6600655f0..50c376c60 100644 --- a/fluxer_api/src/api/words/Words.ts +++ b/fluxer_api/src/api/words/Words.ts @@ -2,7 +2,7 @@ import {randomInt} from 'node:crypto'; import * as fs from 'node:fs'; -import {resolveAssetPath} from '../utils/AssetPaths'; +import {resolveAssetPath} from '@app/api/utils/AssetPaths'; let tails: Array | undefined; let scales: Array | undefined; diff --git a/fluxer_api/src/api/worker/CronScheduler.ts b/fluxer_api/src/api/worker/CronScheduler.ts index eed569faa..587277b94 100644 --- a/fluxer_api/src/api/worker/CronScheduler.ts +++ b/fluxer_api/src/api/worker/CronScheduler.ts @@ -1,11 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + WORKER_CRON_STALE_AFTER_MS, + type WorkerHeartbeat, + type WorkerHeartbeatSignal, +} from '@app/api/worker/WorkerHeartbeat'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; +import type {WorkerService} from '@app/api/worker/WorkerService'; import type {LoggerInterface} from '@fluxer/logger/src/LoggerInterface'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import type {WorkerJobPayload} from '@pkgs/worker/src/contracts/WorkerTypes'; -import {WORKER_CRON_STALE_AFTER_MS, type WorkerHeartbeat, type WorkerHeartbeatSignal} from './WorkerHeartbeat'; -import type {WorkerTaskName} from './WorkerLaneConfig'; -import type {WorkerService} from './WorkerService'; const MAX_CATCHUP_SECONDS = 60; diff --git a/fluxer_api/src/api/worker/JetStreamWorkerQueue.ts b/fluxer_api/src/api/worker/JetStreamWorkerQueue.ts index b483ac438..4b4f1d1f3 100644 --- a/fluxer_api/src/api/worker/JetStreamWorkerQueue.ts +++ b/fluxer_api/src/api/worker/JetStreamWorkerQueue.ts @@ -1,6 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {randomUUID} from 'node:crypto'; +import {Logger} from '@app/api/Logger'; +import type {WorkerLaneDefinition} from '@app/api/worker/WorkerLaneConfig'; +import {WorkerQueueOverflowError} from '@app/api/worker/WorkerQueueOverflowError'; import type {JetStreamConnectionManager} from '@pkgs/nats/src/JetStreamConnectionManager'; import type {WorkerJobPayload} from '@pkgs/worker/src/contracts/WorkerTypes'; import { @@ -17,9 +20,6 @@ import { StorageType, type StreamConfig, } from 'nats'; -import {Logger} from '../Logger'; -import type {WorkerLaneDefinition} from './WorkerLaneConfig'; -import {WorkerQueueOverflowError} from './WorkerQueueOverflowError'; const STREAM_NAME = 'JOBS'; const SUBJECT_PREFIX = 'jobs.'; diff --git a/fluxer_api/src/api/worker/WorkerContext.ts b/fluxer_api/src/api/worker/WorkerContext.ts index 175252381..a847220d5 100644 --- a/fluxer_api/src/api/worker/WorkerContext.ts +++ b/fluxer_api/src/api/worker/WorkerContext.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {WorkerDependencies} from '@app/api/worker/WorkerDependencies'; import { clearWorkerDependencies as clearWorkerDependenciesBase, getWorkerDependencies as getWorkerDependenciesBase, setWorkerDependencies as setWorkerDependenciesBase, } from '@pkgs/worker/src/context/WorkerContext'; -import type {WorkerDependencies} from './WorkerDependencies'; export function setWorkerDependencies(dependencies: WorkerDependencies): void { setWorkerDependenciesBase(dependencies); diff --git a/fluxer_api/src/api/worker/WorkerDependencies.ts b/fluxer_api/src/api/worker/WorkerDependencies.ts index 569eb6917..458afc28e 100644 --- a/fluxer_api/src/api/worker/WorkerDependencies.ts +++ b/fluxer_api/src/api/worker/WorkerDependencies.ts @@ -1,51 +1,44 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ICacheService} from '@pkgs/cache/src/ICacheService'; -import type {IEmailService} from '@pkgs/email/src/IEmailService'; -import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {RateLimitService} from '@pkgs/rate_limit/src/RateLimitService'; -import type {IVirusScanService} from '@pkgs/virus_scan/src/IVirusScanService'; -import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import Stripe from 'stripe'; -import type {AdminRepository} from '../admin/AdminRepository'; -import type {AdminArchiveRepository} from '../admin/repositories/AdminArchiveRepository'; -import {BillingRepository} from '../billing/repositories/BillingRepository'; -import {Config} from '../Config'; -import {createApiContext} from '../CreateApiContext'; -import type {ChannelRepository} from '../channel/ChannelRepository'; -import type {ChannelService} from '../channel/services/ChannelService'; -import type {ConnectionRepository} from '../connection/ConnectionRepository'; -import {ConnectionService} from '../connection/ConnectionService'; -import type {NcmecSubmissionService} from '../csam/NcmecSubmissionService'; -import {DonationRepository} from '../donation/DonationRepository'; -import type {IDonationRepository} from '../donation/IDonationRepository'; -import type {FavoriteMemeRepository} from '../favorite_meme/FavoriteMemeRepository'; -import type {GuildAuditLogService} from '../guild/GuildAuditLogService'; -import type {GuildRepository} from '../guild/repositories/GuildRepository'; -import type {GuildService} from '../guild/services/GuildService'; -import type {AvatarService} from '../infrastructure/AvatarService'; -import type {IPurgeQueue} from '../infrastructure/BunnyPurgeQueue'; -import type {DiscriminatorService} from '../infrastructure/DiscriminatorService'; -import type {EmbedService} from '../infrastructure/EmbedService'; -import type {IAssetDeletionQueue} from '../infrastructure/IAssetDeletionQueue'; -import type {IGatewayService} from '../infrastructure/IGatewayService'; -import type {ILiveKitService} from '../infrastructure/ILiveKitService'; -import type {IMediaService} from '../infrastructure/IMediaService'; -import type {ISnowflakeService} from '../infrastructure/ISnowflakeService'; -import type {IStorageService} from '../infrastructure/IStorageService'; -import type {IUnfurlerService} from '../infrastructure/IUnfurlerService'; -import type {IVoiceRoomStore} from '../infrastructure/IVoiceRoomStore'; -import type {KVAccountDeletionQueueService} from '../infrastructure/KVAccountDeletionQueueService'; -import type {KVActivityTracker} from '../infrastructure/KVActivityTracker'; -import type {KVBulkMessageDeletionQueueService} from '../infrastructure/KVBulkMessageDeletionQueueService'; -import type {PremiumStateReconciliationQueueService} from '../infrastructure/PremiumStateReconciliationQueueService'; -import type {UserCacheService} from '../infrastructure/UserCacheService'; -import type {InstanceConfigRepository} from '../instance/InstanceConfigRepository'; -import type {InviteService} from '../invite/InviteService'; -import {Logger} from '../Logger'; -import type {LimitConfigService} from '../limits/LimitConfigService'; -import {createGuildStackServices} from '../middleware/GuildStackServiceFactory'; -import {getIpInfoService} from '../middleware/ServiceMiddleware'; +import type {AdminRepository} from '@app/api/admin/AdminRepository'; +import type {AdminArchiveRepository} from '@app/api/admin/repositories/AdminArchiveRepository'; +import {BillingRepository} from '@app/api/billing/repositories/BillingRepository'; +import {Config} from '@app/api/Config'; +import {createApiContext} from '@app/api/CreateApiContext'; +import type {ChannelRepository} from '@app/api/channel/ChannelRepository'; +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {ConnectionRepository} from '@app/api/connection/ConnectionRepository'; +import {ConnectionService} from '@app/api/connection/ConnectionService'; +import type {NcmecSubmissionService} from '@app/api/csam/NcmecSubmissionService'; +import {DonationRepository} from '@app/api/donation/DonationRepository'; +import type {IDonationRepository} from '@app/api/donation/IDonationRepository'; +import type {FavoriteMemeRepository} from '@app/api/favorite_meme/FavoriteMemeRepository'; +import type {GuildAuditLogService} from '@app/api/guild/GuildAuditLogService'; +import type {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; +import type {GuildService} from '@app/api/guild/services/GuildService'; +import type {AvatarService} from '@app/api/infrastructure/AvatarService'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {DiscriminatorService} from '@app/api/infrastructure/DiscriminatorService'; +import type {EmbedService} from '@app/api/infrastructure/EmbedService'; +import type {IAssetDeletionQueue} from '@app/api/infrastructure/IAssetDeletionQueue'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {ILiveKitService} from '@app/api/infrastructure/ILiveKitService'; +import type {IMediaService} from '@app/api/infrastructure/IMediaService'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import type {IUnfurlerService} from '@app/api/infrastructure/IUnfurlerService'; +import type {IVoiceRoomStore} from '@app/api/infrastructure/IVoiceRoomStore'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import type {KVActivityTracker} from '@app/api/infrastructure/KVActivityTracker'; +import type {KVBulkMessageDeletionQueueService} from '@app/api/infrastructure/KVBulkMessageDeletionQueueService'; +import type {PremiumStateReconciliationQueueService} from '@app/api/infrastructure/PremiumStateReconciliationQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import type {InstanceConfigRepository} from '@app/api/instance/InstanceConfigRepository'; +import type {InviteService} from '@app/api/invite/InviteService'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; +import {createGuildStackServices} from '@app/api/middleware/GuildStackServiceFactory'; +import {getIpInfoService} from '@app/api/middleware/ServiceMiddleware'; import { ensureVoiceResourcesInitialized, getGatewayService, @@ -56,7 +49,7 @@ import { getVoiceRoomStoreInstance, getVoiceTopology, getWorkerService, -} from '../middleware/ServiceRegistry'; +} from '@app/api/middleware/ServiceRegistry'; import { createUserCacheService, ensureVirusScanInitialized, @@ -98,22 +91,29 @@ import { getVirusScanServiceInstance, getVoiceRepository, getWebhookRepository, -} from '../middleware/ServiceSingletons'; -import type {ApplicationRepository} from '../oauth/repositories/ApplicationRepository'; -import type {OAuth2TokenRepository} from '../oauth/repositories/OAuth2TokenRepository'; -import type {ReadStateRepository} from '../read_state/ReadStateRepository'; -import type {ReadStateService} from '../read_state/ReadStateService'; -import type {ReportRepository} from '../report/ReportRepository'; -import {STRIPE_API_VERSION} from '../stripe/StripeApiVersion'; -import {PaymentRepository} from '../user/repositories/PaymentRepository'; -import type {UserRepository} from '../user/repositories/UserRepository'; -import type {UserContactChangeLogService} from '../user/services/UserContactChangeLogService'; -import {UserDeletionEligibilityService} from '../user/services/UserDeletionEligibilityService'; -import {UserHarvestRepository} from '../user/UserHarvestRepository'; -import type {UserPermissionUtils} from '../utils/UserPermissionUtils'; -import type {VoiceRepository} from '../voice/VoiceRepository'; -import type {VoiceTopology} from '../voice/VoiceTopology'; -import type {WorkerTaskName} from './WorkerLaneConfig'; +} from '@app/api/middleware/ServiceSingletons'; +import type {ApplicationRepository} from '@app/api/oauth/repositories/ApplicationRepository'; +import type {OAuth2TokenRepository} from '@app/api/oauth/repositories/OAuth2TokenRepository'; +import type {ReadStateRepository} from '@app/api/read_state/ReadStateRepository'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import type {ReportRepository} from '@app/api/report/ReportRepository'; +import {STRIPE_API_VERSION} from '@app/api/stripe/StripeApiVersion'; +import {PaymentRepository} from '@app/api/user/repositories/PaymentRepository'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import type {UserContactChangeLogService} from '@app/api/user/services/UserContactChangeLogService'; +import {UserDeletionEligibilityService} from '@app/api/user/services/UserDeletionEligibilityService'; +import {UserHarvestRepository} from '@app/api/user/UserHarvestRepository'; +import type {UserPermissionUtils} from '@app/api/utils/UserPermissionUtils'; +import type {VoiceRepository} from '@app/api/voice/VoiceRepository'; +import type {VoiceTopology} from '@app/api/voice/VoiceTopology'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; +import type {ICacheService} from '@pkgs/cache/src/ICacheService'; +import type {IEmailService} from '@pkgs/email/src/IEmailService'; +import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; +import type {RateLimitService} from '@pkgs/rate_limit/src/RateLimitService'; +import type {IVirusScanService} from '@pkgs/virus_scan/src/IVirusScanService'; +import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; +import Stripe from 'stripe'; export interface WorkerDependencies { kvClient: IKVProvider; diff --git a/fluxer_api/src/api/worker/WorkerHeartbeat.ts b/fluxer_api/src/api/worker/WorkerHeartbeat.ts index b2958da46..db4a7f38c 100644 --- a/fluxer_api/src/api/worker/WorkerHeartbeat.ts +++ b/fluxer_api/src/api/worker/WorkerHeartbeat.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {writeFileSync} from 'node:fs'; -import type {ILogger} from '../ILogger'; +import type {ILogger} from '@app/api/ILogger'; const WORKER_HEARTBEAT_PATH = '/tmp/fluxer-worker-heartbeat'; export const WORKER_HEARTBEAT_WRITE_INTERVAL_MS = 5000; diff --git a/fluxer_api/src/api/worker/WorkerLaneConfig.ts b/fluxer_api/src/api/worker/WorkerLaneConfig.ts index 58505c531..f1fa2c2f9 100644 --- a/fluxer_api/src/api/worker/WorkerLaneConfig.ts +++ b/fluxer_api/src/api/worker/WorkerLaneConfig.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {APIWorkerLaneName, APIWorkerMode} from '../config/APIConfig'; +import type {APIWorkerLaneName, APIWorkerMode} from '@app/api/config/APIConfig'; interface LaneSettings { readonly consumerName: string; diff --git a/fluxer_api/src/api/worker/WorkerMain.ts b/fluxer_api/src/api/worker/WorkerMain.ts index b66da262b..21cc46543 100644 --- a/fluxer_api/src/api/worker/WorkerMain.ts +++ b/fluxer_api/src/api/worker/WorkerMain.ts @@ -1,45 +1,49 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {setupGracefulShutdown} from '@fluxer/hono/src/Server'; -import {BACKGROUND_READ_TIMEOUT_MS, initCassandra, shutdownCassandra} from '@pkgs/cassandra/src/Client'; -import {JetStreamConnectionManager} from '@pkgs/nats/src/JetStreamConnectionManager'; -import {getDefaultPostgresClient, initPostgres, shutdownPostgres} from '@pkgs/postgres/src/Client'; -import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {ms} from 'itty-time'; -import {Config} from '../Config'; -import {setDatabaseQueryExecutor} from '../database/CassandraQueryExecution'; -import {ensurePostgresKvSchema, PostgresKvQueryExecutor} from '../database/PostgresKvQueryExecutor'; -import type {ISnowflakeService} from '../infrastructure/ISnowflakeService'; -import type {InstanceConfigRepository} from '../instance/InstanceConfigRepository'; -import {JobLedgerRepository} from '../jobs/JobLedgerRepository'; -import {Logger} from '../Logger'; -import type {LimitConfigService} from '../limits/LimitConfigService'; +import {Config} from '@app/api/Config'; +import {setDatabaseQueryExecutor} from '@app/api/database/CassandraQueryExecution'; +import {ensurePostgresKvSchema, PostgresKvQueryExecutor} from '@app/api/database/PostgresKvQueryExecutor'; +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {InstanceConfigRepository} from '@app/api/instance/InstanceConfigRepository'; +import {JobLedgerRepository} from '@app/api/jobs/JobLedgerRepository'; +import {Logger} from '@app/api/Logger'; +import type {LimitConfigService} from '@app/api/limits/LimitConfigService'; import { closeOwnedKVClient, createSnowflakeService, setInjectedSnowflakeService, setInjectedWorkerService, shutdownVoiceResources, -} from '../middleware/ServiceRegistry'; -import {getCacheService, getInstanceConfigRepository, getLimitConfigService} from '../middleware/ServiceSingletons'; -import {initializeSearch, shutdownSearch} from '../SearchFactory'; -import {awaitAll} from '../utils/ConcurrencyUtils'; -import {CronScheduler} from './CronScheduler'; -import {JetStreamWorkerQueue} from './JetStreamWorkerQueue'; -import {clearWorkerDependencies, setWorkerDependencies} from './WorkerContext'; -import {initializeWorkerDependencies, type WorkerDependencies} from './WorkerDependencies'; -import {WorkerHeartbeat} from './WorkerHeartbeat'; +} from '@app/api/middleware/ServiceRegistry'; +import { + getCacheService, + getInstanceConfigRepository, + getLimitConfigService, +} from '@app/api/middleware/ServiceSingletons'; +import {initializeSearch, shutdownSearch} from '@app/api/SearchFactory'; +import {awaitAll} from '@app/api/utils/ConcurrencyUtils'; +import {CronScheduler} from '@app/api/worker/CronScheduler'; +import {JetStreamWorkerQueue} from '@app/api/worker/JetStreamWorkerQueue'; +import {clearWorkerDependencies, setWorkerDependencies} from '@app/api/worker/WorkerContext'; +import {initializeWorkerDependencies, type WorkerDependencies} from '@app/api/worker/WorkerDependencies'; +import {WorkerHeartbeat} from '@app/api/worker/WorkerHeartbeat'; import { resolveCronSchedulerEnabled, resolveWorkerLanes, validateLaneCompleteness, type WorkerLaneDefinition, -} from './WorkerLaneConfig'; -import {createWorkerProcessErrorHandler} from './WorkerProcessErrorHandler'; -import {WorkerQueueOverflowError} from './WorkerQueueOverflowError'; -import {WorkerRunner} from './WorkerRunner'; -import {WorkerService} from './WorkerService'; -import {workerTasks} from './WorkerTaskRegistry'; +} from '@app/api/worker/WorkerLaneConfig'; +import {createWorkerProcessErrorHandler} from '@app/api/worker/WorkerProcessErrorHandler'; +import {WorkerQueueOverflowError} from '@app/api/worker/WorkerQueueOverflowError'; +import {WorkerRunner} from '@app/api/worker/WorkerRunner'; +import {WorkerService} from '@app/api/worker/WorkerService'; +import {workerTasks} from '@app/api/worker/WorkerTaskRegistry'; +import {setupGracefulShutdown} from '@fluxer/hono/src/Server'; +import {BACKGROUND_READ_TIMEOUT_MS, initCassandra, shutdownCassandra} from '@pkgs/cassandra/src/Client'; +import {JetStreamConnectionManager} from '@pkgs/nats/src/JetStreamConnectionManager'; +import {getDefaultPostgresClient, initPostgres, shutdownPostgres} from '@pkgs/postgres/src/Client'; +import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; +import {ms} from 'itty-time'; const SEARCH_REQUIRED_TASKS = new Set([ 'indexChannelMessages', diff --git a/fluxer_api/src/api/worker/WorkerProcessErrorHandler.ts b/fluxer_api/src/api/worker/WorkerProcessErrorHandler.ts index 9a660759b..caa83b3d5 100644 --- a/fluxer_api/src/api/worker/WorkerProcessErrorHandler.ts +++ b/fluxer_api/src/api/worker/WorkerProcessErrorHandler.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isTransientDatabaseError} from '@app/api/database/TransientDatabaseError'; +import type {ILogger} from '@app/api/ILogger'; import {ms} from 'itty-time'; -import {isTransientDatabaseError} from '../database/TransientDatabaseError'; -import type {ILogger} from '../ILogger'; export type WorkerProcessErrorSource = 'uncaughtException' | 'unhandledRejection'; diff --git a/fluxer_api/src/api/worker/WorkerRunner.ts b/fluxer_api/src/api/worker/WorkerRunner.ts index e4ac5dd17..23aee7691 100644 --- a/fluxer_api/src/api/worker/WorkerRunner.ts +++ b/fluxer_api/src/api/worker/WorkerRunner.ts @@ -1,22 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash, randomUUID} from 'node:crypto'; -import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; -import {JobCancelledError, type WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import type {ConsumerMessages, FetchOptions, JsMsg} from 'nats'; -import {ArchiveAttemptSupersededError} from '../archive/ArchiveAttemptSupersededError'; -import {ArchiveTaskDeferredError, ArchiveTerminalFailureError, isArchiveTask} from '../archive/ArchiveTask'; -import type {IJobLedgerRepository} from '../jobs/IJobLedgerRepository'; -import {Logger} from '../Logger'; -import {getWorkerService} from '../middleware/ServiceRegistry'; -import {isJsonRecord, parseJsonRecord} from '../utils/JsonBoundaryUtils'; -import type {WorkerDeadLetterMetadata} from './JetStreamWorkerQueue'; +import {ArchiveAttemptSupersededError} from '@app/api/archive/ArchiveAttemptSupersededError'; +import {ArchiveTaskDeferredError, ArchiveTerminalFailureError, isArchiveTask} from '@app/api/archive/ArchiveTask'; +import type {IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; +import {Logger} from '@app/api/Logger'; +import {getWorkerService} from '@app/api/middleware/ServiceRegistry'; +import {isJsonRecord, parseJsonRecord} from '@app/api/utils/JsonBoundaryUtils'; +import type {WorkerDeadLetterMetadata} from '@app/api/worker/JetStreamWorkerQueue'; import { WORKER_LANE_HEARTBEAT_INTERVAL_MS, WORKER_LANE_STALE_AFTER_MS, type WorkerHeartbeat, type WorkerHeartbeatSignal, -} from './WorkerHeartbeat'; +} from '@app/api/worker/WorkerHeartbeat'; +import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; +import {JobCancelledError, type WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; +import type {ConsumerMessages, FetchOptions, JsMsg} from 'nats'; const MAX_DLQ_PUBLISH_ATTEMPTS = 3; const DLQ_RETRY_DELAY_MS = 250; diff --git a/fluxer_api/src/api/worker/WorkerService.ts b/fluxer_api/src/api/worker/WorkerService.ts index 5b0233904..ba046d119 100644 --- a/fluxer_api/src/api/worker/WorkerService.ts +++ b/fluxer_api/src/api/worker/WorkerService.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; +import {Logger} from '@app/api/Logger'; +import type {JetStreamWorkerQueue} from '@app/api/worker/JetStreamWorkerQueue'; +import {findLaneForTask, type WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; +import {WorkerQueueOverflowError} from '@app/api/worker/WorkerQueueOverflowError'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import type {WorkerJobOptions, WorkerJobPayload} from '@pkgs/worker/src/contracts/WorkerTypes'; -import type {ISnowflakeService} from '../infrastructure/ISnowflakeService'; -import type {IJobLedgerRepository} from '../jobs/IJobLedgerRepository'; -import {Logger} from '../Logger'; -import type {JetStreamWorkerQueue} from './JetStreamWorkerQueue'; -import {findLaneForTask, type WorkerTaskName} from './WorkerLaneConfig'; -import {WorkerQueueOverflowError} from './WorkerQueueOverflowError'; export class WorkerService implements IWorkerService { private readonly queue: JetStreamWorkerQueue; diff --git a/fluxer_api/src/api/worker/WorkerTaskRegistry.ts b/fluxer_api/src/api/worker/WorkerTaskRegistry.ts index 3c9fcfa74..6c0a927be 100644 --- a/fluxer_api/src/api/worker/WorkerTaskRegistry.ts +++ b/fluxer_api/src/api/worker/WorkerTaskRegistry.ts @@ -1,48 +1,48 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import applicationProcessDeletion from '@app/api/worker/tasks/ApplicationProcessDeletion'; +import bulkAddGuildMembers from '@app/api/worker/tasks/admin_bulk/BulkAddGuildMembers'; +import bulkBanFileShas from '@app/api/worker/tasks/admin_bulk/BulkBanFileShas'; +import bulkDeleteMessagesForUsers from '@app/api/worker/tasks/admin_bulk/BulkDeleteMessagesForUsers'; +import bulkScheduleUserDeletion from '@app/api/worker/tasks/admin_bulk/BulkScheduleUserDeletion'; +import bulkUpdateGuildFeatures from '@app/api/worker/tasks/admin_bulk/BulkUpdateGuildFeatures'; +import bulkUpdateSuspiciousActivityFlags from '@app/api/worker/tasks/admin_bulk/BulkUpdateSuspiciousActivityFlags'; +import bulkUpdateUserFlags from '@app/api/worker/tasks/admin_bulk/BulkUpdateUserFlags'; +import batchGuildAuditLogMessageDeletes from '@app/api/worker/tasks/BatchGuildAuditLogMessageDeletes'; +import bulkDeleteSelfMessagesImmediate from '@app/api/worker/tasks/BulkDeleteSelfMessagesImmediate'; +import bulkDeleteUserMessages from '@app/api/worker/tasks/BulkDeleteUserMessages'; +import bulkDeleteUserMessagesScoped from '@app/api/worker/tasks/BulkDeleteUserMessagesScoped'; +import deleteUserMessagesInGuildByTime from '@app/api/worker/tasks/DeleteUserMessagesInGuildByTime'; +import expireAttachments from '@app/api/worker/tasks/ExpireAttachments'; +import extractEmbeds from '@app/api/worker/tasks/ExtractEmbeds'; +import finalizeNcmecAttachmentReport from '@app/api/worker/tasks/FinalizeNcmecAttachmentReport'; +import flushUserActivityBuffer from '@app/api/worker/tasks/FlushUserActivityBuffer'; +import handleMentionChunk from '@app/api/worker/tasks/HandleMentionChunk'; +import handleMentions from '@app/api/worker/tasks/HandleMentions'; +import harvestGuildData from '@app/api/worker/tasks/HarvestGuildData'; +import harvestUserData from '@app/api/worker/tasks/HarvestUserData'; +import indexChannelMessages from '@app/api/worker/tasks/IndexChannelMessages'; +import indexGuildMembers from '@app/api/worker/tasks/IndexGuildMembers'; +import messageShred from '@app/api/worker/tasks/MessageShred'; +import processAssetDeletionQueue from '@app/api/worker/tasks/ProcessAssetDeletionQueue'; +import processBunnyPurgeQueue from '@app/api/worker/tasks/ProcessBunnyPurgeQueue'; +import processExpiredPremiumSweep from '@app/api/worker/tasks/ProcessExpiredPremiumSweep'; +import processInactivityDeletions from '@app/api/worker/tasks/ProcessInactivityDeletions'; +import processPendingBulkMessageDeletions from '@app/api/worker/tasks/ProcessPendingBulkMessageDeletions'; +import processPremiumStateReconciliationQueue from '@app/api/worker/tasks/ProcessPremiumStateReconciliationQueue'; +import processStripeWebhook from '@app/api/worker/tasks/ProcessStripeWebhook'; +import prunePostgresKvTtl from '@app/api/worker/tasks/PrunePostgresKvTtl'; +import reconcileUserPayments from '@app/api/worker/tasks/ReconcileUserPayments'; +import refreshSearchIndex from '@app/api/worker/tasks/RefreshSearchIndex'; +import {sendSystemDm} from '@app/api/worker/tasks/SendSystemDm'; +import syncDiscoveryIndex from '@app/api/worker/tasks/SyncDiscoveryIndex'; +import syncDisposableEmailDomains from '@app/api/worker/tasks/SyncDisposableEmailDomains'; +import syncFileShaBlocklists from '@app/api/worker/tasks/SyncFileShaBlocklists'; +import syncUrlBlocklists from '@app/api/worker/tasks/SyncUrlBlocklists'; +import userProcessPendingDeletion from '@app/api/worker/tasks/UserProcessPendingDeletion'; +import userProcessPendingDeletions from '@app/api/worker/tasks/UserProcessPendingDeletions'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import applicationProcessDeletion from './tasks/ApplicationProcessDeletion'; -import bulkAddGuildMembers from './tasks/admin_bulk/BulkAddGuildMembers'; -import bulkBanFileShas from './tasks/admin_bulk/BulkBanFileShas'; -import bulkDeleteMessagesForUsers from './tasks/admin_bulk/BulkDeleteMessagesForUsers'; -import bulkScheduleUserDeletion from './tasks/admin_bulk/BulkScheduleUserDeletion'; -import bulkUpdateGuildFeatures from './tasks/admin_bulk/BulkUpdateGuildFeatures'; -import bulkUpdateSuspiciousActivityFlags from './tasks/admin_bulk/BulkUpdateSuspiciousActivityFlags'; -import bulkUpdateUserFlags from './tasks/admin_bulk/BulkUpdateUserFlags'; -import batchGuildAuditLogMessageDeletes from './tasks/BatchGuildAuditLogMessageDeletes'; -import bulkDeleteSelfMessagesImmediate from './tasks/BulkDeleteSelfMessagesImmediate'; -import bulkDeleteUserMessages from './tasks/BulkDeleteUserMessages'; -import bulkDeleteUserMessagesScoped from './tasks/BulkDeleteUserMessagesScoped'; -import deleteUserMessagesInGuildByTime from './tasks/DeleteUserMessagesInGuildByTime'; -import expireAttachments from './tasks/ExpireAttachments'; -import extractEmbeds from './tasks/ExtractEmbeds'; -import finalizeNcmecAttachmentReport from './tasks/FinalizeNcmecAttachmentReport'; -import flushUserActivityBuffer from './tasks/FlushUserActivityBuffer'; -import handleMentionChunk from './tasks/HandleMentionChunk'; -import handleMentions from './tasks/HandleMentions'; -import harvestGuildData from './tasks/HarvestGuildData'; -import harvestUserData from './tasks/HarvestUserData'; -import indexChannelMessages from './tasks/IndexChannelMessages'; -import indexGuildMembers from './tasks/IndexGuildMembers'; -import messageShred from './tasks/MessageShred'; -import processAssetDeletionQueue from './tasks/ProcessAssetDeletionQueue'; -import processBunnyPurgeQueue from './tasks/ProcessBunnyPurgeQueue'; -import processExpiredPremiumSweep from './tasks/ProcessExpiredPremiumSweep'; -import processInactivityDeletions from './tasks/ProcessInactivityDeletions'; -import processPendingBulkMessageDeletions from './tasks/ProcessPendingBulkMessageDeletions'; -import processPremiumStateReconciliationQueue from './tasks/ProcessPremiumStateReconciliationQueue'; -import processStripeWebhook from './tasks/ProcessStripeWebhook'; -import prunePostgresKvTtl from './tasks/PrunePostgresKvTtl'; -import reconcileUserPayments from './tasks/ReconcileUserPayments'; -import refreshSearchIndex from './tasks/RefreshSearchIndex'; -import {sendSystemDm} from './tasks/SendSystemDm'; -import syncDiscoveryIndex from './tasks/SyncDiscoveryIndex'; -import syncDisposableEmailDomains from './tasks/SyncDisposableEmailDomains'; -import syncFileShaBlocklists from './tasks/SyncFileShaBlocklists'; -import syncUrlBlocklists from './tasks/SyncUrlBlocklists'; -import userProcessPendingDeletion from './tasks/UserProcessPendingDeletion'; -import userProcessPendingDeletions from './tasks/UserProcessPendingDeletions'; -import type {WorkerTaskName} from './WorkerLaneConfig'; export const workerTasks: Record = { applicationProcessDeletion, diff --git a/fluxer_api/src/api/worker/services/ChannelEventDispatcher.ts b/fluxer_api/src/api/worker/services/ChannelEventDispatcher.ts index 698ee0cec..543b3c71e 100644 --- a/fluxer_api/src/api/worker/services/ChannelEventDispatcher.ts +++ b/fluxer_api/src/api/worker/services/ChannelEventDispatcher.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {MessageID} from '../../BrandedTypes'; -import {dispatchChannelEvent} from '../../channel/services/ChannelGatewayDispatch'; -import type {GatewayDispatchEvent} from '../../constants/Gateway'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {Channel} from '../../models/Channel'; +import type {MessageID} from '@app/api/BrandedTypes'; +import {dispatchChannelEvent} from '@app/api/channel/services/ChannelGatewayDispatch'; +import type {GatewayDispatchEvent} from '@app/api/constants/Gateway'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {Channel} from '@app/api/models/Channel'; interface ChannelEventDispatcherDeps { gatewayService: IGatewayService; diff --git a/fluxer_api/src/api/worker/tasks/ApplicationProcessDeletion.ts b/fluxer_api/src/api/worker/tasks/ApplicationProcessDeletion.ts index 2e60a8ca7..181cef893 100644 --- a/fluxer_api/src/api/worker/tasks/ApplicationProcessDeletion.ts +++ b/fluxer_api/src/api/worker/tasks/ApplicationProcessDeletion.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {applicationIdToUserId, createApplicationID, type GuildID} from '@app/api/BrandedTypes'; +import {mapGuildMemberToResponse} from '@app/api/guild/GuildModel'; +import {Logger} from '@app/api/Logger'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {remapAuthorMessagesToDeletedUser} from '@app/api/oauth/ApplicationMessageAuthorAnonymization'; +import {chunkArray} from '@app/api/utils/ArrayUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import { DELETED_USER_DISCRIMINATOR, DELETED_USER_GLOBAL_NAME, @@ -8,13 +15,6 @@ import { } from '@fluxer/constants/src/UserConstants'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {applicationIdToUserId, createApplicationID, type GuildID} from '../../BrandedTypes'; -import {mapGuildMemberToResponse} from '../../guild/GuildModel'; -import {Logger} from '../../Logger'; -import {createRequestCache} from '../../middleware/RequestCacheMiddleware'; -import {remapAuthorMessagesToDeletedUser} from '../../oauth/ApplicationMessageAuthorAnonymization'; -import {chunkArray} from '../../utils/ArrayUtils'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ applicationId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/BatchGuildAuditLogMessageDeletes.ts b/fluxer_api/src/api/worker/tasks/BatchGuildAuditLogMessageDeletes.ts index 8da42b49b..4f965a12c 100644 --- a/fluxer_api/src/api/worker/tasks/BatchGuildAuditLogMessageDeletes.ts +++ b/fluxer_api/src/api/worker/tasks/BatchGuildAuditLogMessageDeletes.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {createGuildID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ guildId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/BulkDeleteSelfMessagesImmediate.ts b/fluxer_api/src/api/worker/tasks/BulkDeleteSelfMessagesImmediate.ts index c491e23f8..d0685e859 100644 --- a/fluxer_api/src/api/worker/tasks/BulkDeleteSelfMessagesImmediate.ts +++ b/fluxer_api/src/api/worker/tasks/BulkDeleteSelfMessagesImmediate.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {UserMessageDeletionService} from '@app/api/channel/services/message/UserMessageDeletionService'; +import {getContentMessage} from '@app/api/content_i18n/ContentI18n'; +import {Logger} from '@app/api/Logger'; +import {deserializeSelfMessageFilter, SelfMessageFilterPayload} from '@app/api/worker/utils/SelfMessageFilterPayload'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {createUserID} from '../../BrandedTypes'; -import {UserMessageDeletionService} from '../../channel/services/message/UserMessageDeletionService'; -import {getContentMessage} from '../../content_i18n/ContentI18n'; -import {Logger} from '../../Logger'; -import {deserializeSelfMessageFilter, SelfMessageFilterPayload} from '../utils/SelfMessageFilterPayload'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ userId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/BulkDeleteUserMessages.ts b/fluxer_api/src/api/worker/tasks/BulkDeleteUserMessages.ts index 9012f069f..f054a5160 100644 --- a/fluxer_api/src/api/worker/tasks/BulkDeleteUserMessages.ts +++ b/fluxer_api/src/api/worker/tasks/BulkDeleteUserMessages.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {UserMessageDeletionService} from '@app/api/channel/services/message/UserMessageDeletionService'; +import {Logger} from '@app/api/Logger'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {createUserID} from '../../BrandedTypes'; -import {UserMessageDeletionService} from '../../channel/services/message/UserMessageDeletionService'; -import {Logger} from '../../Logger'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ userId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/BulkDeleteUserMessagesScoped.ts b/fluxer_api/src/api/worker/tasks/BulkDeleteUserMessagesScoped.ts index f7d082a5f..9476e27cc 100644 --- a/fluxer_api/src/api/worker/tasks/BulkDeleteUserMessagesScoped.ts +++ b/fluxer_api/src/api/worker/tasks/BulkDeleteUserMessagesScoped.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {UserMessageDeletionService} from '@app/api/channel/services/message/UserMessageDeletionService'; +import {Logger} from '@app/api/Logger'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {createChannelID, createGuildID, createUserID} from '../../BrandedTypes'; -import {UserMessageDeletionService} from '../../channel/services/message/UserMessageDeletionService'; -import {Logger} from '../../Logger'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ userId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/DeleteUserMessagesInGuildByTime.ts b/fluxer_api/src/api/worker/tasks/DeleteUserMessagesInGuildByTime.ts index 937450bd7..e60dd1409 100644 --- a/fluxer_api/src/api/worker/tasks/DeleteUserMessagesInGuildByTime.ts +++ b/fluxer_api/src/api/worker/tasks/DeleteUserMessagesInGuildByTime.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ guildId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/ExpireAttachments.ts b/fluxer_api/src/api/worker/tasks/ExpireAttachments.ts index afa63aa1f..32340a7f4 100644 --- a/fluxer_api/src/api/worker/tasks/ExpireAttachments.ts +++ b/fluxer_api/src/api/worker/tasks/ExpireAttachments.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AttachmentDecayRepository} from '@app/api/attachment/AttachmentDecayRepository'; +import {makeAttachmentCdnKey, makeAttachmentCdnUrl} from '@app/api/channel/services/message/MessageHelpers'; +import {Logger} from '@app/api/Logger'; +import {getExpiryBucket} from '@app/api/utils/AttachmentDecay'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {AttachmentDecayRepository} from '../../attachment/AttachmentDecayRepository'; -import {makeAttachmentCdnKey, makeAttachmentCdnUrl} from '../../channel/services/message/MessageHelpers'; -import {Logger} from '../../Logger'; -import {getExpiryBucket} from '../../utils/AttachmentDecay'; -import {getWorkerDependencies} from '../WorkerContext'; const BUCKET_LOOKBACK_DAYS = 3; const FETCH_LIMIT = 200; diff --git a/fluxer_api/src/api/worker/tasks/ExtractEmbeds.ts b/fluxer_api/src/api/worker/tasks/ExtractEmbeds.ts index 34cfb2dee..e6290d817 100644 --- a/fluxer_api/src/api/worker/tasks/ExtractEmbeds.ts +++ b/fluxer_api/src/api/worker/tasks/ExtractEmbeds.ts @@ -1,28 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, GuildID, MessageID} from '@app/api/BrandedTypes'; +import {createChannelID, createGuildID, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import type {ChannelRepository} from '@app/api/channel/ChannelRepository'; +import {buildBroadcastMessageData} from '@app/api/channel/services/message/MessageGatewayDispatch'; +import type {MessageEmbed, MessageEmbedChild} from '@app/api/database/types/MessageTypes'; +import type {ModerationContext} from '@app/api/infrastructure/ContentModerationService'; +import {contentModerationService} from '@app/api/infrastructure/ContentModerationService'; +import type {EmbedService} from '@app/api/infrastructure/EmbedService'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {MediaProxyNsfwMode} from '@app/api/infrastructure/IMediaService'; +import {Logger} from '@app/api/Logger'; +import type {Channel} from '@app/api/models/Channel'; +import {Message} from '@app/api/models/Message'; +import {deleteMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import * as UnfurlerUtils from '@app/api/utils/UnfurlerUtils'; +import {ChannelEventDispatcher} from '@app/api/worker/services/ChannelEventDispatcher'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {MessageFlags} from '@fluxer/constants/src/ChannelConstants'; import {MAX_EMBEDS_PER_MESSAGE} from '@fluxer/constants/src/LimitConstants'; import {ContentBlockedError} from '@fluxer/errors/src/domains/content/ContentBlockedError'; import type {ICacheService} from '@pkgs/cache/src/ICacheService'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import type {ChannelID, GuildID, MessageID} from '../../BrandedTypes'; -import {createChannelID, createGuildID, createMessageID, createUserID} from '../../BrandedTypes'; -import type {ChannelRepository} from '../../channel/ChannelRepository'; -import {buildBroadcastMessageData} from '../../channel/services/message/MessageGatewayDispatch'; -import type {MessageEmbed, MessageEmbedChild} from '../../database/types/MessageTypes'; -import type {ModerationContext} from '../../infrastructure/ContentModerationService'; -import {contentModerationService} from '../../infrastructure/ContentModerationService'; -import type {EmbedService} from '../../infrastructure/EmbedService'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {MediaProxyNsfwMode} from '../../infrastructure/IMediaService'; -import {Logger} from '../../Logger'; -import type {Channel} from '../../models/Channel'; -import {Message} from '../../models/Message'; -import {deleteMessageSearchDocuments} from '../../search/MessageSearchIndexCleanup'; -import * as UnfurlerUtils from '../../utils/UnfurlerUtils'; -import {ChannelEventDispatcher} from '../services/ChannelEventDispatcher'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ channelId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/FinalizeNcmecAttachmentReport.ts b/fluxer_api/src/api/worker/tasks/FinalizeNcmecAttachmentReport.ts index b4a61482f..902d0d16b 100644 --- a/fluxer_api/src/api/worker/tasks/FinalizeNcmecAttachmentReport.ts +++ b/fluxer_api/src/api/worker/tasks/FinalizeNcmecAttachmentReport.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createAttachmentID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {createAttachmentID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ attachmentId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/FlushUserActivityBuffer.ts b/fluxer_api/src/api/worker/tasks/FlushUserActivityBuffer.ts index 996d3cd59..01144e809 100644 --- a/fluxer_api/src/api/worker/tasks/FlushUserActivityBuffer.ts +++ b/fluxer_api/src/api/worker/tasks/FlushUserActivityBuffer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {UserActivityBuffer} from '@app/api/user/services/UserActivityBuffer'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {UserActivityBuffer} from '../../user/services/UserActivityBuffer'; -import {getWorkerDependencies} from '../WorkerContext'; const flushUserActivityBuffer: WorkerTaskHandler = async (_payload, helpers) => { const {kvClient} = getWorkerDependencies(); diff --git a/fluxer_api/src/api/worker/tasks/HandleMentionChunk.ts b/fluxer_api/src/api/worker/tasks/HandleMentionChunk.ts index 25c05872f..c2bb6d4d9 100644 --- a/fluxer_api/src/api/worker/tasks/HandleMentionChunk.ts +++ b/fluxer_api/src/api/worker/tasks/HandleMentionChunk.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createGuildID, createMessageID, createUserID, type UserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {createChannelID, createGuildID, createMessageID, createUserID, type UserID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; -import {mapWithConcurrency} from '../../utils/ConcurrencyUtils'; -import {getWorkerDependencies} from '../WorkerContext'; const MENTION_SETTINGS_FETCH_CONCURRENCY = 16; const MentionChunkEntrySchema = z.object({ diff --git a/fluxer_api/src/api/worker/tasks/HandleMentions.ts b/fluxer_api/src/api/worker/tasks/HandleMentions.ts index 2ea63b30c..b0dd9b1b2 100644 --- a/fluxer_api/src/api/worker/tasks/HandleMentions.ts +++ b/fluxer_api/src/api/worker/tasks/HandleMentions.ts @@ -1,8 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {createHash} from 'node:crypto'; -import type {WorkerTaskHandler, WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; -import {z} from 'zod'; import { type ChannelID, createChannelID, @@ -14,10 +12,12 @@ import { type MessageID, type RoleID, type UserID, -} from '../../BrandedTypes'; -import type {GatewayMentionSourceEntry, IGatewayService} from '../../infrastructure/IGatewayService'; -import {Logger} from '../../Logger'; -import {getWorkerDependencies} from '../WorkerContext'; +} from '@app/api/BrandedTypes'; +import type {GatewayMentionSourceEntry, IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import {Logger} from '@app/api/Logger'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; +import type {WorkerTaskHandler, WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; +import {z} from 'zod'; const MENTION_CHUNK_SIZE = 250; const MENTION_CHUNK_KEY_DIGEST_LENGTH = 32; diff --git a/fluxer_api/src/api/worker/tasks/HarvestGuildData.ts b/fluxer_api/src/api/worker/tasks/HarvestGuildData.ts index 3194b9cf6..52c0f515a 100644 --- a/fluxer_api/src/api/worker/tasks/HarvestGuildData.ts +++ b/fluxer_api/src/api/worker/tasks/HarvestGuildData.ts @@ -4,31 +4,31 @@ import assert from 'node:assert/strict'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import {GUILD_TEXT_BASED_CHANNEL_TYPES} from '@fluxer/constants/src/ChannelConstants'; -import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import {z} from 'zod'; -import {ArchiveAttemptSupersededError} from '../../archive/ArchiveAttemptSupersededError'; +import {ArchiveAttemptSupersededError} from '@app/api/archive/ArchiveAttemptSupersededError'; import { type ArchiveTaskHandler, ArchiveTerminalFailureError, createArchiveTask, throwIfArchiveTerminallyFailed, -} from '../../archive/ArchiveTask'; -import {type AttachmentID, type ChannelID, createGuildID, type MessageID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {makeAttachmentCdnKey, makeAttachmentCdnUrl} from '../../channel/services/message/MessageHelpers'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {Logger} from '../../Logger'; -import {mapWithConcurrency} from '../../utils/ConcurrencyUtils'; -import {writeZipArchive} from '../utils/ArchiveFile'; -import {createArchiveJsonBuffer} from '../utils/ArchiveJson'; +} from '@app/api/archive/ArchiveTask'; +import {type AttachmentID, type ChannelID, createGuildID, type MessageID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {makeAttachmentCdnKey, makeAttachmentCdnUrl} from '@app/api/channel/services/message/MessageHelpers'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; +import {writeZipArchive} from '@app/api/worker/utils/ArchiveFile'; +import {createArchiveJsonBuffer} from '@app/api/worker/utils/ArchiveJson'; import { buildHashedAssetKey, buildSimpleAssetKey, getAnimatedAssetExtension, getEmojiExtension, -} from '../utils/AssetArchiveHelpers'; -import {getWorkerDependencies} from '../WorkerContext'; +} from '@app/api/worker/utils/AssetArchiveHelpers'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; +import {GUILD_TEXT_BASED_CHANNEL_TYPES} from '@fluxer/constants/src/ChannelConstants'; +import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; +import {z} from 'zod'; const CHANNEL_CONCURRENCY = 4; const ASSET_CONCURRENCY = 8; diff --git a/fluxer_api/src/api/worker/tasks/HarvestUserData.test.ts b/fluxer_api/src/api/worker/tasks/HarvestUserData.test.ts index a3e6f8c14..3ef07f799 100644 --- a/fluxer_api/src/api/worker/tasks/HarvestUserData.test.ts +++ b/fluxer_api/src/api/worker/tasks/HarvestUserData.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type ChannelID, createChannelID, createMessageID, createUserID, type MessageID} from '@app/api/BrandedTypes'; +import {harvestMessages} from '@app/api/worker/tasks/HarvestUserData'; import {describe, expect, it} from 'vitest'; -import {type ChannelID, createChannelID, createMessageID, createUserID, type MessageID} from '../../BrandedTypes'; -import {harvestMessages} from './HarvestUserData'; const AUTHOR = createUserID(1000000000000000000n); diff --git a/fluxer_api/src/api/worker/tasks/HarvestUserData.ts b/fluxer_api/src/api/worker/tasks/HarvestUserData.ts index 46531be25..91a54668c 100644 --- a/fluxer_api/src/api/worker/tasks/HarvestUserData.ts +++ b/fluxer_api/src/api/worker/tasks/HarvestUserData.ts @@ -4,21 +4,13 @@ import assert from 'node:assert/strict'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import { - decodeSyncedPreferencesLenient, - syncedPreferencesToJson, -} from '@fluxer/schema/src/domains/user/SyncedPreferencesCodec'; -import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; -import {ms} from 'itty-time'; -import {z} from 'zod'; -import {ArchiveAttemptSupersededError} from '../../archive/ArchiveAttemptSupersededError'; +import {ArchiveAttemptSupersededError} from '@app/api/archive/ArchiveAttemptSupersededError'; import { type ArchiveTaskHandler, ArchiveTerminalFailureError, createArchiveTask, throwIfArchiveTerminallyFailed, -} from '../../archive/ArchiveTask'; +} from '@app/api/archive/ArchiveTask'; import { type ChannelID, createAttachmentID, @@ -27,45 +19,57 @@ import { type GuildID, type MessageID, type UserID, -} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {makeAttachmentCdnUrl} from '../../channel/services/message/MessageHelpers'; +} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {makeAttachmentCdnUrl} from '@app/api/channel/services/message/MessageHelpers'; import { isChannelEligible, isTimestampInWindow, type SelfMessageEligibilityContext, type SelfMessageFilter, -} from '../../channel/services/message/SelfMessageFilter'; -import type {UserConnectionRow} from '../../database/types/ConnectionTypes'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {Logger} from '../../Logger'; -import type {Application} from '../../models/Application'; -import type {Attachment} from '../../models/Attachment'; -import type {AuthSession} from '../../models/AuthSession'; -import type {Channel} from '../../models/Channel'; -import type {FavoriteMeme} from '../../models/FavoriteMeme'; -import type {GiftCode} from '../../models/GiftCode'; -import type {Guild} from '../../models/Guild'; -import type {GuildMember} from '../../models/GuildMember'; -import type {MfaBackupCode} from '../../models/MfaBackupCode'; -import type {Payment} from '../../models/Payment'; -import type {PushSubscription} from '../../models/PushSubscription'; -import type {Relationship} from '../../models/Relationship'; -import type {SavedMessage} from '../../models/SavedMessage'; -import type {User} from '../../models/User'; -import type {UserGuildSettings} from '../../models/UserGuildSettings'; -import type {UserSettings} from '../../models/UserSettings'; -import type {WebAuthnCredential} from '../../models/WebAuthnCredential'; -import {buildHarvestDownloadUrl} from '../../user/services/HarvestDownloadUrl'; -import {mapWithConcurrency} from '../../utils/ConcurrencyUtils'; -import {resolveSessionClientInfo} from '../../utils/SessionClientIdentity'; -import {writeZipArchive} from '../utils/ArchiveFile'; -import {createArchiveJsonBuffer} from '../utils/ArchiveJson'; -import {appendAssetToArchive, buildHashedAssetKey, getAnimatedAssetExtension} from '../utils/AssetArchiveHelpers'; -import {ContentAddressedAttachmentCollector} from '../utils/ContentAddressedAttachmentCollector'; -import {deserializeSelfMessageFilter, SelfMessageFilterPayload} from '../utils/SelfMessageFilterPayload'; -import {getWorkerDependencies} from '../WorkerContext'; -import type {WorkerDependencies} from '../WorkerDependencies'; +} from '@app/api/channel/services/message/SelfMessageFilter'; +import type {UserConnectionRow} from '@app/api/database/types/ConnectionTypes'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import type {Application} from '@app/api/models/Application'; +import type {Attachment} from '@app/api/models/Attachment'; +import type {AuthSession} from '@app/api/models/AuthSession'; +import type {Channel} from '@app/api/models/Channel'; +import type {FavoriteMeme} from '@app/api/models/FavoriteMeme'; +import type {GiftCode} from '@app/api/models/GiftCode'; +import type {Guild} from '@app/api/models/Guild'; +import type {GuildMember} from '@app/api/models/GuildMember'; +import type {MfaBackupCode} from '@app/api/models/MfaBackupCode'; +import type {Payment} from '@app/api/models/Payment'; +import type {PushSubscription} from '@app/api/models/PushSubscription'; +import type {Relationship} from '@app/api/models/Relationship'; +import type {SavedMessage} from '@app/api/models/SavedMessage'; +import type {User} from '@app/api/models/User'; +import type {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import type {UserSettings} from '@app/api/models/UserSettings'; +import type {WebAuthnCredential} from '@app/api/models/WebAuthnCredential'; +import {buildHarvestDownloadUrl} from '@app/api/user/services/HarvestDownloadUrl'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; +import {resolveSessionClientInfo} from '@app/api/utils/SessionClientIdentity'; +import {writeZipArchive} from '@app/api/worker/utils/ArchiveFile'; +import {createArchiveJsonBuffer} from '@app/api/worker/utils/ArchiveJson'; +import { + appendAssetToArchive, + buildHashedAssetKey, + getAnimatedAssetExtension, +} from '@app/api/worker/utils/AssetArchiveHelpers'; +import {ContentAddressedAttachmentCollector} from '@app/api/worker/utils/ContentAddressedAttachmentCollector'; +import {deserializeSelfMessageFilter, SelfMessageFilterPayload} from '@app/api/worker/utils/SelfMessageFilterPayload'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; +import type {WorkerDependencies} from '@app/api/worker/WorkerDependencies'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; +import { + decodeSyncedPreferencesLenient, + syncedPreferencesToJson, +} from '@fluxer/schema/src/domains/user/SyncedPreferencesCodec'; +import {snowflakeToDate} from '@fluxer/snowflake/src/Snowflake'; +import {ms} from 'itty-time'; +import {z} from 'zod'; const PayloadSchema = z.object({ userId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/IndexChannelMessages.ts b/fluxer_api/src/api/worker/tasks/IndexChannelMessages.ts index 335efb975..a56329bab 100644 --- a/fluxer_api/src/api/worker/tasks/IndexChannelMessages.ts +++ b/fluxer_api/src/api/worker/tasks/IndexChannelMessages.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {MessageID, UserID} from '@app/api/BrandedTypes'; +import {createChannelID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import {getMessageSearchService} from '@app/api/SearchFactory'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {seconds} from 'itty-time'; import {z} from 'zod'; -import type {MessageID, UserID} from '../../BrandedTypes'; -import {createChannelID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; -import {getMessageSearchService} from '../../SearchFactory'; -import type {IMessageSearchService} from '../../search/IMessageSearchService'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ channelId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/IndexGuildMembers.ts b/fluxer_api/src/api/worker/tasks/IndexGuildMembers.ts index dc50cbac3..9a3364cbb 100644 --- a/fluxer_api/src/api/worker/tasks/IndexGuildMembers.ts +++ b/fluxer_api/src/api/worker/tasks/IndexGuildMembers.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import {getGuildMemberSearchService} from '@app/api/SearchFactory'; +import {chunkArray} from '@app/api/utils/ArrayUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import type {UserID} from '../../BrandedTypes'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; -import type {User} from '../../models/User'; -import {getGuildMemberSearchService} from '../../SearchFactory'; -import {chunkArray} from '../../utils/ArrayUtils'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ guildId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/MessageShred.ts b/fluxer_api/src/api/worker/tasks/MessageShred.ts index a62b954ba..186e18f6d 100644 --- a/fluxer_api/src/api/worker/tasks/MessageShred.ts +++ b/fluxer_api/src/api/worker/tasks/MessageShred.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelID, MessageID} from '@app/api/BrandedTypes'; +import {createChannelID, createMessageID, createUserID} from '@app/api/BrandedTypes'; +import {purgeMessageAttachments} from '@app/api/channel/services/message/MessageHelpers'; +import type {Message} from '@app/api/models/Message'; +import {deleteMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import {chunkArray} from '@app/api/utils/ArrayUtils'; +import {createBulkDeleteDispatcher} from '@app/api/worker/tasks/utils/MessageDeletion'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {seconds} from 'itty-time'; import {z} from 'zod'; -import type {ChannelID, MessageID} from '../../BrandedTypes'; -import {createChannelID, createMessageID, createUserID} from '../../BrandedTypes'; -import {purgeMessageAttachments} from '../../channel/services/message/MessageHelpers'; -import type {Message} from '../../models/Message'; -import {deleteMessageSearchDocuments} from '../../search/MessageSearchIndexCleanup'; -import {chunkArray} from '../../utils/ArrayUtils'; -import {getWorkerDependencies} from '../WorkerContext'; -import {createBulkDeleteDispatcher} from './utils/MessageDeletion'; const PayloadSchema = z.object({ job_id: z.string().min(1), diff --git a/fluxer_api/src/api/worker/tasks/ProcessAssetDeletionQueue.ts b/fluxer_api/src/api/worker/tasks/ProcessAssetDeletionQueue.ts index 1f3173e49..75c422de6 100644 --- a/fluxer_api/src/api/worker/tasks/ProcessAssetDeletionQueue.ts +++ b/fluxer_api/src/api/worker/tasks/ProcessAssetDeletionQueue.ts @@ -1,22 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {SnowflakeType} from '@fluxer/schema/src/primitives/SchemaPrimitives'; -import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {createGuildID, createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {GuildRepository} from '../../guild/repositories/GuildRepository'; -import type {IPurgeQueue} from '../../infrastructure/BunnyPurgeQueue'; +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {GuildRepository} from '@app/api/guild/repositories/GuildRepository'; +import type {IPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; import type { IAssetDeletionQueue, QueuedAssetDeletion, QueuedAssetEntityType, QueuedAssetReference, QueuedAssetType, -} from '../../infrastructure/IAssetDeletionQueue'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {Logger} from '../../Logger'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import {getWorkerDependencies} from '../WorkerContext'; +} from '@app/api/infrastructure/IAssetDeletionQueue'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; +import {SnowflakeType} from '@fluxer/schema/src/primitives/SchemaPrimitives'; +import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; const BATCH_SIZE = 50; const MAX_ITEMS_PER_RUN = 500; diff --git a/fluxer_api/src/api/worker/tasks/ProcessBunnyPurgeQueue.ts b/fluxer_api/src/api/worker/tasks/ProcessBunnyPurgeQueue.ts index e3a3456bd..a7d69e5da 100644 --- a/fluxer_api/src/api/worker/tasks/ProcessBunnyPurgeQueue.ts +++ b/fluxer_api/src/api/worker/tasks/ProcessBunnyPurgeQueue.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import type {BunnyPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import {Logger} from '@app/api/Logger'; +import {EXTERNAL_RESPONSE_LIMITS} from '@app/api/utils/ExternalResponseLimits'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {formatUrlForDiagnostics} from '@pkgs/http_client/src/HttpClientDiagnostics'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {ms} from 'itty-time'; -import {Config} from '../../Config'; -import type {BunnyPurgeQueue} from '../../infrastructure/BunnyPurgeQueue'; -import {Logger} from '../../Logger'; -import {EXTERNAL_RESPONSE_LIMITS} from '../../utils/ExternalResponseLimits'; -import * as FetchUtils from '../../utils/FetchUtils'; -import {getWorkerDependencies} from '../WorkerContext'; const EXACT_BATCH_SIZE = 120; const PREFIX_BATCH_SIZE = 20; diff --git a/fluxer_api/src/api/worker/tasks/ProcessExpiredPremiumSweep.ts b/fluxer_api/src/api/worker/tasks/ProcessExpiredPremiumSweep.ts index b9db9a3fe..df70575f5 100644 --- a/fluxer_api/src/api/worker/tasks/ProcessExpiredPremiumSweep.ts +++ b/fluxer_api/src/api/worker/tasks/ProcessExpiredPremiumSweep.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {mapGuildMemberToResponse} from '@app/api/guild/GuildModel'; +import type {IGuildRepositoryAggregate} from '@app/api/guild/repositories/IGuildRepositoryAggregate'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; +import type {PremiumStateReconciliationQueueService} from '@app/api/infrastructure/PremiumStateReconciliationQueueService'; +import type {UserCacheService} from '@app/api/infrastructure/UserCacheService'; +import {Logger} from '@app/api/Logger'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import type {User} from '@app/api/models/User'; +import type {IUserRepository} from '@app/api/user/IUserRepository'; +import {checkIsPremium, createPremiumClearPatch, shouldStripExpiredPremium} from '@app/api/user/UserHelpers'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {PremiumFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {Config} from '../../Config'; -import {mapGuildMemberToResponse} from '../../guild/GuildModel'; -import type {IGuildRepositoryAggregate} from '../../guild/repositories/IGuildRepositoryAggregate'; -import type {IGatewayService} from '../../infrastructure/IGatewayService'; -import type {PremiumStateReconciliationQueueService} from '../../infrastructure/PremiumStateReconciliationQueueService'; -import type {UserCacheService} from '../../infrastructure/UserCacheService'; -import {Logger} from '../../Logger'; -import {createRequestCache} from '../../middleware/RequestCacheMiddleware'; -import type {User} from '../../models/User'; -import type {IUserRepository} from '../../user/IUserRepository'; -import {checkIsPremium, createPremiumClearPatch, shouldStripExpiredPremium} from '../../user/UserHelpers'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import {getWorkerDependencies} from '../WorkerContext'; const BATCH_SIZE = 100; diff --git a/fluxer_api/src/api/worker/tasks/ProcessInactivityDeletions.ts b/fluxer_api/src/api/worker/tasks/ProcessInactivityDeletions.ts index 18d758eee..9126235c1 100644 --- a/fluxer_api/src/api/worker/tasks/ProcessInactivityDeletions.ts +++ b/fluxer_api/src/api/worker/tasks/ProcessInactivityDeletions.ts @@ -1,5 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import type {KVActivityTracker} from '@app/api/infrastructure/KVActivityTracker'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {reschedulePendingDeletion} from '@app/api/user/services/PendingDeletionCoordinator'; +import type {UserDeletionEligibilityService} from '@app/api/user/services/UserDeletionEligibilityService'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {DeletionReasons} from '@fluxer/constants/src/Core'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import type {IEmailService} from '@pkgs/email/src/IEmailService'; @@ -7,17 +18,6 @@ import {TestEmailService} from '@pkgs/email/src/TestEmailService'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {ms} from 'itty-time'; -import type {UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import type {KVActivityTracker} from '../../infrastructure/KVActivityTracker'; -import {Logger} from '../../Logger'; -import type {User} from '../../models/User'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import {reschedulePendingDeletion} from '../../user/services/PendingDeletionCoordinator'; -import type {UserDeletionEligibilityService} from '../../user/services/UserDeletionEligibilityService'; -import {mapWithConcurrency} from '../../utils/ConcurrencyUtils'; -import {getWorkerDependencies} from '../WorkerContext'; const BATCH_SIZE = 100; const USER_PROCESSING_CONCURRENCY = 8; diff --git a/fluxer_api/src/api/worker/tasks/ProcessPendingBulkMessageDeletions.ts b/fluxer_api/src/api/worker/tasks/ProcessPendingBulkMessageDeletions.ts index 0983a6802..5426869a2 100644 --- a/fluxer_api/src/api/worker/tasks/ProcessPendingBulkMessageDeletions.ts +++ b/fluxer_api/src/api/worker/tasks/ProcessPendingBulkMessageDeletions.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import {getValidTimestamp} from '@app/api/utils/TimestampUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {createUserID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; -import {getValidTimestamp} from '../../utils/TimestampUtils'; -import {getWorkerDependencies} from '../WorkerContext'; const processPendingBulkMessageDeletions: WorkerTaskHandler = async (_payload, helpers) => { helpers.logger.debug('Processing pending bulk message deletions'); diff --git a/fluxer_api/src/api/worker/tasks/ProcessPremiumStateReconciliationQueue.ts b/fluxer_api/src/api/worker/tasks/ProcessPremiumStateReconciliationQueue.ts index 88e857dc7..f75059f69 100644 --- a/fluxer_api/src/api/worker/tasks/ProcessPremiumStateReconciliationQueue.ts +++ b/fluxer_api/src/api/worker/tasks/ProcessPremiumStateReconciliationQueue.ts @@ -1,23 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {PremiumFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; -import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import type Stripe from 'stripe'; -import type {UserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import type {UserRow} from '../../database/types/UserTypes'; -import {Logger} from '../../Logger'; -import {getBillingRepository} from '../../middleware/ServiceRegistry'; -import type {User} from '../../models/User'; -import {canProvisionPremiumFromSubscriptionStatus} from '../../stripe/StripeSubscriptionAccessPolicy'; +import type {UserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import type {UserRow} from '@app/api/database/types/UserTypes'; +import {Logger} from '@app/api/Logger'; +import {getBillingRepository} from '@app/api/middleware/ServiceRegistry'; +import type {User} from '@app/api/models/User'; +import {canProvisionPremiumFromSubscriptionStatus} from '@app/api/stripe/StripeSubscriptionAccessPolicy'; import { getPrimarySubscriptionItem, getSubscriptionPremiumPeriodEnd, getSubscriptionStartDate, -} from '../../stripe/StripeSubscriptionPeriod'; -import {createPremiumClearPatch, getEffectivePremiumUntil} from '../../user/UserHelpers'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import {getWorkerDependencies} from '../WorkerContext'; +} from '@app/api/stripe/StripeSubscriptionPeriod'; +import {createPremiumClearPatch, getEffectivePremiumUntil} from '@app/api/user/UserHelpers'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; +import {PremiumFlags, UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; +import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; +import type Stripe from 'stripe'; interface ReconcileResult { status: 'patched' | 'no_change' | 'skipped' | 'no_active_subscription' | 'stripped_no_subscription' | 'missing_user'; diff --git a/fluxer_api/src/api/worker/tasks/ProcessStripeWebhook.ts b/fluxer_api/src/api/worker/tasks/ProcessStripeWebhook.ts index 5560dba1c..b56223862 100644 --- a/fluxer_api/src/api/worker/tasks/ProcessStripeWebhook.ts +++ b/fluxer_api/src/api/worker/tasks/ProcessStripeWebhook.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {revokeAllAuthSessions} from '@app/api/auth/AuthSessionRevocation'; +import type {ISessionTerminator} from '@app/api/auth/ISessionTerminator'; +import {ProductRegistry} from '@app/api/stripe/ProductRegistry'; +import {AgeVerificationService} from '@app/api/stripe/services/AgeVerificationService'; +import {StripeCheckoutService} from '@app/api/stripe/services/StripeCheckoutService'; +import {StripeGiftService} from '@app/api/stripe/services/StripeGiftService'; +import {StripePremiumService} from '@app/api/stripe/services/StripePremiumService'; +import {StripeRefundService} from '@app/api/stripe/services/StripeRefundService'; +import {StripeSubscriptionService} from '@app/api/stripe/services/StripeSubscriptionService'; +import {StripeWebhookService} from '@app/api/stripe/services/StripeWebhookService'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {revokeAllAuthSessions} from '../../auth/AuthSessionRevocation'; -import type {ISessionTerminator} from '../../auth/ISessionTerminator'; -import {ProductRegistry} from '../../stripe/ProductRegistry'; -import {AgeVerificationService} from '../../stripe/services/AgeVerificationService'; -import {StripeCheckoutService} from '../../stripe/services/StripeCheckoutService'; -import {StripeGiftService} from '../../stripe/services/StripeGiftService'; -import {StripePremiumService} from '../../stripe/services/StripePremiumService'; -import {StripeRefundService} from '../../stripe/services/StripeRefundService'; -import {StripeSubscriptionService} from '../../stripe/services/StripeSubscriptionService'; -import {StripeWebhookService} from '../../stripe/services/StripeWebhookService'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ body: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/PrunePostgresKvTtl.ts b/fluxer_api/src/api/worker/tasks/PrunePostgresKvTtl.ts index 385473653..90dca2b03 100644 --- a/fluxer_api/src/api/worker/tasks/PrunePostgresKvTtl.ts +++ b/fluxer_api/src/api/worker/tasks/PrunePostgresKvTtl.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Config} from '@app/api/Config'; +import {pruneExpiredPostgresKvRows} from '@app/api/database/PostgresKvQueryExecutor'; import {getDefaultPostgresClient} from '@pkgs/postgres/src/Client'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {Config} from '../../Config'; -import {pruneExpiredPostgresKvRows} from '../../database/PostgresKvQueryExecutor'; const PRUNE_BATCH_SIZE = 5000; const MAX_PRUNE_BATCHES_PER_RUN = 20; diff --git a/fluxer_api/src/api/worker/tasks/ReconcileUserPayments.ts b/fluxer_api/src/api/worker/tasks/ReconcileUserPayments.ts index c0e0be553..acadd061c 100644 --- a/fluxer_api/src/api/worker/tasks/ReconcileUserPayments.ts +++ b/fluxer_api/src/api/worker/tasks/ReconcileUserPayments.ts @@ -1,19 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {Config} from '@app/api/Config'; +import {Logger} from '@app/api/Logger'; +import {mapGiftDurationMonthsToFields} from '@app/api/models/GiftCode'; +import type {Payment} from '@app/api/models/Payment'; +import type {User} from '@app/api/models/User'; +import {ProductRegistry} from '@app/api/stripe/ProductRegistry'; +import {extractId} from '@app/api/stripe/StripeUtils'; +import type {PaymentRepository} from '@app/api/user/repositories/PaymentRepository'; +import {mapUserToPrivateResponse} from '@app/api/user/UserMappers'; +import * as RandomUtils from '@app/api/utils/RandomUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import type Stripe from 'stripe'; -import {createUserID} from '../../BrandedTypes'; -import {Config} from '../../Config'; -import {Logger} from '../../Logger'; -import {mapGiftDurationMonthsToFields} from '../../models/GiftCode'; -import type {Payment} from '../../models/Payment'; -import type {User} from '../../models/User'; -import {ProductRegistry} from '../../stripe/ProductRegistry'; -import {extractId} from '../../stripe/StripeUtils'; -import type {PaymentRepository} from '../../user/repositories/PaymentRepository'; -import {mapUserToPrivateResponse} from '../../user/UserMappers'; -import * as RandomUtils from '../../utils/RandomUtils'; -import {getWorkerDependencies} from '../WorkerContext'; const STALE_PENDING_THRESHOLD_MS = 10 * 60 * 1000; diff --git a/fluxer_api/src/api/worker/tasks/RefreshSearchIndex.ts b/fluxer_api/src/api/worker/tasks/RefreshSearchIndex.ts index e77616d0b..41d7fa677 100644 --- a/fluxer_api/src/api/worker/tasks/RefreshSearchIndex.ts +++ b/fluxer_api/src/api/worker/tasks/RefreshSearchIndex.ts @@ -1,16 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {DiscoveryApplicationStatus} from '@fluxer/constants/src/DiscoveryConstants'; -import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; -import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {WorkerTaskHandler, WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; -import {seconds} from 'itty-time'; -import {z} from 'zod'; -import type {GuildID, ReportID, UserID} from '../../BrandedTypes'; -import {createGuildID} from '../../BrandedTypes'; -import {GuildDiscoveryRepository} from '../../guild/repositories/GuildDiscoveryRepository'; -import {Logger} from '../../Logger'; -import type {User} from '../../models/User'; +import type {GuildID, ReportID, UserID} from '@app/api/BrandedTypes'; +import {createGuildID} from '@app/api/BrandedTypes'; +import {GuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import {Logger} from '@app/api/Logger'; +import type {User} from '@app/api/models/User'; import { getAuditLogSearchService, getGuildMemberSearchService, @@ -18,11 +12,17 @@ import { getMessageSearchService, getReportSearchService, getUserSearchService, -} from '../../SearchFactory'; -import type {IGuildMemberSearchService} from '../../search/IGuildMemberSearchService'; -import type {IMessageSearchService} from '../../search/IMessageSearchService'; -import {deleteChannelMessageSearchDocuments} from '../../search/MessageSearchIndexCleanup'; -import {getWorkerDependencies} from '../WorkerContext'; +} from '@app/api/SearchFactory'; +import type {IGuildMemberSearchService} from '@app/api/search/IGuildMemberSearchService'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import {deleteChannelMessageSearchDocuments} from '@app/api/search/MessageSearchIndexCleanup'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; +import {DiscoveryApplicationStatus} from '@fluxer/constants/src/DiscoveryConstants'; +import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes'; +import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; +import type {WorkerTaskHandler, WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; +import {seconds} from 'itty-time'; +import {z} from 'zod'; const INDEX_TYPES = [ 'guilds', diff --git a/fluxer_api/src/api/worker/tasks/SendSystemDm.ts b/fluxer_api/src/api/worker/tasks/SendSystemDm.ts index 2e4f987c8..85370a295 100644 --- a/fluxer_api/src/api/worker/tasks/SendSystemDm.ts +++ b/fluxer_api/src/api/worker/tasks/SendSystemDm.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {UserChannelService} from '@app/api/user/services/UserChannelService'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {JobCancelledError, type WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {createRequestCache} from '../../middleware/RequestCacheMiddleware'; -import {UserChannelService} from '../../user/services/UserChannelService'; -import {getWorkerDependencies} from '../WorkerContext'; const SYSTEM_USER_ID: UserID = createUserID(0n); const PayloadSchema = z.object({ diff --git a/fluxer_api/src/api/worker/tasks/SyncDiscoveryIndex.ts b/fluxer_api/src/api/worker/tasks/SyncDiscoveryIndex.ts index 27d71e60b..1d638ebe9 100644 --- a/fluxer_api/src/api/worker/tasks/SyncDiscoveryIndex.ts +++ b/fluxer_api/src/api/worker/tasks/SyncDiscoveryIndex.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GuildDiscoveryRepository} from '@app/api/guild/repositories/GuildDiscoveryRepository'; +import {getGuildSearchService} from '@app/api/SearchFactory'; +import {mapWithConcurrency} from '@app/api/utils/ConcurrencyUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {DiscoveryApplicationStatus} from '@fluxer/constants/src/DiscoveryConstants'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {GuildDiscoveryRepository} from '../../guild/repositories/GuildDiscoveryRepository'; -import {getGuildSearchService} from '../../SearchFactory'; -import {mapWithConcurrency} from '../../utils/ConcurrencyUtils'; -import {getWorkerDependencies} from '../WorkerContext'; const BATCH_SIZE = 200; const UPDATE_CONCURRENCY = 25; diff --git a/fluxer_api/src/api/worker/tasks/SyncDisposableEmailDomains.ts b/fluxer_api/src/api/worker/tasks/SyncDisposableEmailDomains.ts index cd86efc06..a456b0669 100644 --- a/fluxer_api/src/api/worker/tasks/SyncDisposableEmailDomains.ts +++ b/fluxer_api/src/api/worker/tasks/SyncDisposableEmailDomains.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {domainToASCII} from 'node:url'; +import {isAccountPolicyContactDomainReputationExempt} from '@app/api/risk/AccountPolicyService'; +import {EXTERNAL_RESPONSE_LIMITS} from '@app/api/utils/ExternalResponseLimits'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {JobCancelledError, type WorkerTaskHandler, type WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; -import {isAccountPolicyContactDomainReputationExempt} from '../../risk/AccountPolicyService'; -import {EXTERNAL_RESPONSE_LIMITS} from '../../utils/ExternalResponseLimits'; -import * as FetchUtils from '../../utils/FetchUtils'; -import {getWorkerDependencies} from '../WorkerContext'; const SOURCES = [ 'https://raw.githubusercontent.com/doodad-labs/disposable-email-domains/main/data/domains.txt', diff --git a/fluxer_api/src/api/worker/tasks/SyncFileShaBlocklists.ts b/fluxer_api/src/api/worker/tasks/SyncFileShaBlocklists.ts index 107225644..d44e55589 100644 --- a/fluxer_api/src/api/worker/tasks/SyncFileShaBlocklists.ts +++ b/fluxer_api/src/api/worker/tasks/SyncFileShaBlocklists.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {BANNED_FILE_SHAS_REFRESH_CHANNEL} from '@app/api/constants/ContentModeration'; +import {EXTERNAL_RESPONSE_LIMITS} from '@app/api/utils/ExternalResponseLimits'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {BANNED_FILE_SHAS_REFRESH_CHANNEL} from '../../constants/ContentModeration'; -import {EXTERNAL_RESPONSE_LIMITS} from '../../utils/ExternalResponseLimits'; -import * as FetchUtils from '../../utils/FetchUtils'; -import {getWorkerDependencies} from '../WorkerContext'; const MALWARE_BAZAAR_SHA256_URL = 'https://bazaar.abuse.ch/export/txt/sha256/recent/'; const SHA256_RE = /^[0-9a-fA-F]{64}$/; diff --git a/fluxer_api/src/api/worker/tasks/SyncUrlBlocklists.ts b/fluxer_api/src/api/worker/tasks/SyncUrlBlocklists.ts index 751f02808..ba1eeb509 100644 --- a/fluxer_api/src/api/worker/tasks/SyncUrlBlocklists.ts +++ b/fluxer_api/src/api/worker/tasks/SyncUrlBlocklists.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {BANNED_URLS_REFRESH_CHANNEL} from '@app/api/constants/ContentModeration'; +import {RISK_S3_KEYS, writeLinesToS3} from '@app/api/risk/RiskBlocklistS3'; +import {EXTERNAL_RESPONSE_LIMITS} from '@app/api/utils/ExternalResponseLimits'; +import * as FetchUtils from '@app/api/utils/FetchUtils'; +import {canonicalizeUrl} from '@app/api/utils/UrlNormalizer'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {BANNED_URLS_REFRESH_CHANNEL} from '../../constants/ContentModeration'; -import {RISK_S3_KEYS, writeLinesToS3} from '../../risk/RiskBlocklistS3'; -import {EXTERNAL_RESPONSE_LIMITS} from '../../utils/ExternalResponseLimits'; -import * as FetchUtils from '../../utils/FetchUtils'; -import {canonicalizeUrl} from '../../utils/UrlNormalizer'; -import {getWorkerDependencies} from '../WorkerContext'; interface FeedSource { url: string; diff --git a/fluxer_api/src/api/worker/tasks/UserProcessPendingDeletion.ts b/fluxer_api/src/api/worker/tasks/UserProcessPendingDeletion.ts index ef1556899..e57636d69 100644 --- a/fluxer_api/src/api/worker/tasks/UserProcessPendingDeletion.ts +++ b/fluxer_api/src/api/worker/tasks/UserProcessPendingDeletion.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; +import {processUserDeletion} from '@app/api/user/services/UserDeletionService'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {z} from 'zod'; -import {createUserID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; -import {processUserDeletion} from '../../user/services/UserDeletionService'; -import {getWorkerDependencies} from '../WorkerContext'; const PayloadSchema = z.object({ userId: z.string(), diff --git a/fluxer_api/src/api/worker/tasks/UserProcessPendingDeletions.ts b/fluxer_api/src/api/worker/tasks/UserProcessPendingDeletions.ts index 13b21bda4..746b44c53 100644 --- a/fluxer_api/src/api/worker/tasks/UserProcessPendingDeletions.ts +++ b/fluxer_api/src/api/worker/tasks/UserProcessPendingDeletions.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; -import {createUserID} from '../../BrandedTypes'; -import {Logger} from '../../Logger'; +import {createUserID} from '@app/api/BrandedTypes'; +import {Logger} from '@app/api/Logger'; import { isPendingDeletionBlocked, resolvePendingDeletionReasonCode, -} from '../../user/services/PendingDeletionCoordinator'; -import {getValidTimestamp} from '../../utils/TimestampUtils'; -import {getWorkerDependencies} from '../WorkerContext'; +} from '@app/api/user/services/PendingDeletionCoordinator'; +import {getValidTimestamp} from '@app/api/utils/TimestampUtils'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; +import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; const userProcessPendingDeletions: WorkerTaskHandler = async (_payload, helpers) => { helpers.logger.debug('Processing userProcessPendingDeletions task'); diff --git a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkAddGuildMembers.ts b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkAddGuildMembers.ts index 9211dc5f1..000c9e8ef 100644 --- a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkAddGuildMembers.ts +++ b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkAddGuildMembers.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {createRequestCache} from '@app/api/middleware/RequestCacheMiddleware'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {JoinSourceTypes} from '@fluxer/constants/src/GuildConstants'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {JobCancelledError} from '@pkgs/worker/src/contracts/WorkerTask'; -import {AdminAuditService} from '../../../admin/services/AdminAuditService'; -import {createGuildID, createUserID} from '../../../BrandedTypes'; -import {createRequestCache} from '../../../middleware/RequestCacheMiddleware'; -import {getWorkerDependencies} from '../../WorkerContext'; interface Payload { guild_id: string; diff --git a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkBanFileShas.ts b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkBanFileShas.ts index 36db2e247..28d7cc69f 100644 --- a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkBanFileShas.ts +++ b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkBanFileShas.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {createUserID} from '@app/api/BrandedTypes'; +import {ContentBlocklistCategory, ContentBlocklistSeverity} from '@app/api/constants/ContentModeration'; +import {fileShaCache} from '@app/api/middleware/FileShaCache'; +import {getCacheService} from '@app/api/middleware/ServiceSingletons'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {JobCancelledError} from '@pkgs/worker/src/contracts/WorkerTask'; -import {AdminAuditService} from '../../../admin/services/AdminAuditService'; -import {createUserID} from '../../../BrandedTypes'; -import {ContentBlocklistCategory, ContentBlocklistSeverity} from '../../../constants/ContentModeration'; -import {fileShaCache} from '../../../middleware/FileShaCache'; -import {getCacheService} from '../../../middleware/ServiceSingletons'; -import {getWorkerDependencies} from '../../WorkerContext'; const BANNED_FILE_SHAS_REFRESH_CHANNEL = 'banned_file_shas:refresh'; const SHA256_RE = /^[0-9a-fA-F]{64}$/; diff --git a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkDeleteMessagesForUsers.ts b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkDeleteMessagesForUsers.ts index e78711d6c..af3098b6a 100644 --- a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkDeleteMessagesForUsers.ts +++ b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkDeleteMessagesForUsers.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {createUserID} from '@app/api/BrandedTypes'; +import {UserMessageDeletionService} from '@app/api/channel/services/message/UserMessageDeletionService'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {JobCancelledError} from '@pkgs/worker/src/contracts/WorkerTask'; -import {AdminAuditService} from '../../../admin/services/AdminAuditService'; -import {createUserID} from '../../../BrandedTypes'; -import {UserMessageDeletionService} from '../../../channel/services/message/UserMessageDeletionService'; -import {getWorkerDependencies} from '../../WorkerContext'; interface Payload { user_ids: Array; diff --git a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkScheduleUserDeletion.ts b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkScheduleUserDeletion.ts index ec0661024..f4f37233b 100644 --- a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkScheduleUserDeletion.ts +++ b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkScheduleUserDeletion.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {AdminUserUpdatePropagator} from '@app/api/admin/services/AdminUserUpdatePropagator'; +import {createUserID} from '@app/api/BrandedTypes'; +import {reschedulePendingDeletion} from '@app/api/user/services/PendingDeletionCoordinator'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {DeletionReasons} from '@fluxer/constants/src/Core'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {JobCancelledError} from '@pkgs/worker/src/contracts/WorkerTask'; -import {AdminAuditService} from '../../../admin/services/AdminAuditService'; -import {AdminUserUpdatePropagator} from '../../../admin/services/AdminUserUpdatePropagator'; -import {createUserID} from '../../../BrandedTypes'; -import {reschedulePendingDeletion} from '../../../user/services/PendingDeletionCoordinator'; -import {getWorkerDependencies} from '../../WorkerContext'; interface Payload { user_ids: Array; diff --git a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateGuildFeatures.ts b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateGuildFeatures.ts index 13926d04a..ef58a74e9 100644 --- a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateGuildFeatures.ts +++ b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateGuildFeatures.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {AdminGuildUpdatePropagator} from '@app/api/admin/services/guild/AdminGuildUpdatePropagator'; +import {createGuildID, createUserID} from '@app/api/BrandedTypes'; +import {getGuildDiscoveryRepository} from '@app/api/middleware/ServiceSingletons'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {JobCancelledError} from '@pkgs/worker/src/contracts/WorkerTask'; -import {AdminAuditService} from '../../../admin/services/AdminAuditService'; -import {AdminGuildUpdatePropagator} from '../../../admin/services/guild/AdminGuildUpdatePropagator'; -import {createGuildID, createUserID} from '../../../BrandedTypes'; -import {getGuildDiscoveryRepository} from '../../../middleware/ServiceSingletons'; -import {getWorkerDependencies} from '../../WorkerContext'; interface Payload { guild_ids: Array; diff --git a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateSuspiciousActivityFlags.ts b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateSuspiciousActivityFlags.ts index 63fd396b4..6c61c88c9 100644 --- a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateSuspiciousActivityFlags.ts +++ b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateSuspiciousActivityFlags.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {AdminUserUpdatePropagator} from '@app/api/admin/services/AdminUserUpdatePropagator'; +import {createUserID} from '@app/api/BrandedTypes'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import {imposePhoneRequirements, SuspiciousActivityFlags} from '@fluxer/constants/src/UserConstants'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {JobCancelledError} from '@pkgs/worker/src/contracts/WorkerTask'; -import {AdminAuditService} from '../../../admin/services/AdminAuditService'; -import {AdminUserUpdatePropagator} from '../../../admin/services/AdminUserUpdatePropagator'; -import {createUserID} from '../../../BrandedTypes'; -import {getWorkerDependencies} from '../../WorkerContext'; interface Payload { user_ids: Array; diff --git a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateUserFlags.ts b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateUserFlags.ts index 2df11e798..e818c5820 100644 --- a/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateUserFlags.ts +++ b/fluxer_api/src/api/worker/tasks/admin_bulk/BulkUpdateUserFlags.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AdminAuditService} from '@app/api/admin/services/AdminAuditService'; +import {AdminUserUpdatePropagator} from '@app/api/admin/services/AdminUserUpdatePropagator'; +import {createUserID} from '@app/api/BrandedTypes'; +import {getWorkerDependencies} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask'; import {JobCancelledError} from '@pkgs/worker/src/contracts/WorkerTask'; -import {AdminAuditService} from '../../../admin/services/AdminAuditService'; -import {AdminUserUpdatePropagator} from '../../../admin/services/AdminUserUpdatePropagator'; -import {createUserID} from '../../../BrandedTypes'; -import {getWorkerDependencies} from '../../WorkerContext'; interface BulkUpdateUserFlagsPayload { user_ids: Array; diff --git a/fluxer_api/src/api/worker/tasks/utils/MessageDeletion.ts b/fluxer_api/src/api/worker/tasks/utils/MessageDeletion.ts index ae15a6c29..4274c7777 100644 --- a/fluxer_api/src/api/worker/tasks/utils/MessageDeletion.ts +++ b/fluxer_api/src/api/worker/tasks/utils/MessageDeletion.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {type ChannelID, createChannelID, type MessageID} from '../../../BrandedTypes'; -import type {IChannelRepository} from '../../../channel/IChannelRepository'; -import type {IGatewayService} from '../../../infrastructure/IGatewayService'; +import {type ChannelID, createChannelID, type MessageID} from '@app/api/BrandedTypes'; +import type {IChannelRepository} from '@app/api/channel/IChannelRepository'; +import type {IGatewayService} from '@app/api/infrastructure/IGatewayService'; interface BulkDeleteDispatcherDeps { channelRepository: IChannelRepository; diff --git a/fluxer_api/src/api/worker/tests/ArchiveJson.test.ts b/fluxer_api/src/api/worker/tests/ArchiveJson.test.ts index 1bf1c21fa..8cba1b220 100644 --- a/fluxer_api/src/api/worker/tests/ArchiveJson.test.ts +++ b/fluxer_api/src/api/worker/tests/ArchiveJson.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createArchiveJsonBuffer, stringifyArchiveJson} from '@app/api/worker/utils/ArchiveJson'; import {describe, expect, test} from 'vitest'; -import {createArchiveJsonBuffer, stringifyArchiveJson} from '../utils/ArchiveJson'; describe('ArchiveJson', () => { test('serializes non-ASCII text as JSON escapes while preserving parsed values', () => { diff --git a/fluxer_api/src/api/worker/tests/CronScheduler.test.ts b/fluxer_api/src/api/worker/tests/CronScheduler.test.ts index b5f55a780..8ff8afbf4 100644 --- a/fluxer_api/src/api/worker/tests/CronScheduler.test.ts +++ b/fluxer_api/src/api/worker/tests/CronScheduler.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {CronScheduler} from '@app/api/worker/CronScheduler'; +import type {WorkerService} from '@app/api/worker/WorkerService'; import type {LoggerInterface} from '@fluxer/logger/src/LoggerInterface'; import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; import {afterEach, describe, expect, it, vi} from 'vitest'; -import {CronScheduler} from '../CronScheduler'; -import type {WorkerService} from '../WorkerService'; function createLogger(): LoggerInterface { const logger = { diff --git a/fluxer_api/src/api/worker/tests/ExpireAttachments.test.ts b/fluxer_api/src/api/worker/tests/ExpireAttachments.test.ts index eb04ca8c7..2b2f7ae22 100644 --- a/fluxer_api/src/api/worker/tests/ExpireAttachments.test.ts +++ b/fluxer_api/src/api/worker/tests/ExpireAttachments.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AttachmentDecayRepository} from '@app/api/attachment/AttachmentDecayRepository'; +import {createAttachmentID, createChannelID, createMessageID} from '@app/api/BrandedTypes'; +import type {IAssetDeletionQueue, QueuedAssetDeletion} from '@app/api/infrastructure/IAssetDeletionQueue'; +import type {InstanceConfigRepository} from '@app/api/instance/InstanceConfigRepository'; +import {getExpiryBucket} from '@app/api/utils/AttachmentDecay'; +import {processExpiredAttachments} from '@app/api/worker/tasks/ExpireAttachments'; +import {clearWorkerDependencies, setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; import {ms} from 'itty-time'; import {afterEach, describe, expect, it} from 'vitest'; -import {AttachmentDecayRepository} from '../../attachment/AttachmentDecayRepository'; -import {createAttachmentID, createChannelID, createMessageID} from '../../BrandedTypes'; -import type {IAssetDeletionQueue, QueuedAssetDeletion} from '../../infrastructure/IAssetDeletionQueue'; -import type {InstanceConfigRepository} from '../../instance/InstanceConfigRepository'; -import {getExpiryBucket} from '../../utils/AttachmentDecay'; -import {processExpiredAttachments} from '../tasks/ExpireAttachments'; -import {clearWorkerDependencies, setWorkerDependenciesForTest} from '../WorkerContext'; const ATTACHMENT_ID = createAttachmentID(9001n); const CHANNEL_ID = createChannelID(9002n); diff --git a/fluxer_api/src/api/worker/tests/HandleMentionChunk.test.ts b/fluxer_api/src/api/worker/tests/HandleMentionChunk.test.ts index b5e18a351..005a05dcc 100644 --- a/fluxer_api/src/api/worker/tests/HandleMentionChunk.test.ts +++ b/fluxer_api/src/api/worker/tests/HandleMentionChunk.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; -import {afterEach, describe, expect, test} from 'vitest'; import { type ChannelID, createChannelID, @@ -11,14 +9,16 @@ import { type GuildID, type MessageID, type UserID, -} from '../../BrandedTypes'; -import type {RecentMentionRow} from '../../database/types/UserTypes'; -import {UserGuildSettings} from '../../models/UserGuildSettings'; -import type {ReadStateService} from '../../read_state/ReadStateService'; -import {NoopLogger} from '../../test/mocks/NoopLogger'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import handleMentionChunk from '../tasks/HandleMentionChunk'; -import {clearWorkerDependencies, setWorkerDependenciesForTest} from '../WorkerContext'; +} from '@app/api/BrandedTypes'; +import type {RecentMentionRow} from '@app/api/database/types/UserTypes'; +import {UserGuildSettings} from '@app/api/models/UserGuildSettings'; +import type {ReadStateService} from '@app/api/read_state/ReadStateService'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import handleMentionChunk from '@app/api/worker/tasks/HandleMentionChunk'; +import {clearWorkerDependencies, setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; +import type {WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; +import {afterEach, describe, expect, test} from 'vitest'; const CHANNEL_ID = '2000'; const MESSAGE_ID = '3000'; diff --git a/fluxer_api/src/api/worker/tests/IndexChannelMessages.test.ts b/fluxer_api/src/api/worker/tests/IndexChannelMessages.test.ts index cd88e5987..abb5ae35d 100644 --- a/fluxer_api/src/api/worker/tests/IndexChannelMessages.test.ts +++ b/fluxer_api/src/api/worker/tests/IndexChannelMessages.test.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelRepository} from '@app/api/channel/ChannelRepository'; +import {setInjectedSearchProvider} from '@app/api/SearchFactory'; +import type {IMessageSearchService} from '@app/api/search/IMessageSearchService'; +import type {ISearchProvider} from '@app/api/search/ISearchProvider'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import indexChannelMessages from '@app/api/worker/tasks/IndexChannelMessages'; +import {clearWorkerDependencies, setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; import {afterEach, describe, expect, it, vi} from 'vitest'; -import type {ChannelRepository} from '../../channel/ChannelRepository'; -import {setInjectedSearchProvider} from '../../SearchFactory'; -import type {IMessageSearchService} from '../../search/IMessageSearchService'; -import type {ISearchProvider} from '../../search/ISearchProvider'; -import {MockKVProvider} from '../../test/mocks/MockKVProvider'; -import {NoopLogger} from '../../test/mocks/NoopLogger'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import indexChannelMessages from '../tasks/IndexChannelMessages'; -import {clearWorkerDependencies, setWorkerDependenciesForTest} from '../WorkerContext'; const COMPLETION_KEY = 'bulk_reindex:7000:remaining'; const HELPERS = {logger: new NoopLogger()} as unknown as WorkerTaskHelpers; diff --git a/fluxer_api/src/api/worker/tests/JetStreamWorkerQueue.test.ts b/fluxer_api/src/api/worker/tests/JetStreamWorkerQueue.test.ts index 93f77b3d8..a5ce087bf 100644 --- a/fluxer_api/src/api/worker/tests/JetStreamWorkerQueue.test.ts +++ b/fluxer_api/src/api/worker/tests/JetStreamWorkerQueue.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {JetStreamWorkerQueue} from '@app/api/worker/JetStreamWorkerQueue'; +import {WORKER_LANES} from '@app/api/worker/WorkerLaneConfig'; +import {WorkerQueueOverflowError} from '@app/api/worker/WorkerQueueOverflowError'; import type {JetStreamConnectionManager} from '@pkgs/nats/src/JetStreamConnectionManager'; import {DiscardPolicy, NatsError, RetentionPolicy, StorageType, type StreamConfig} from 'nats'; import {describe, expect, it} from 'vitest'; -import {JetStreamWorkerQueue} from '../JetStreamWorkerQueue'; -import {WORKER_LANES} from '../WorkerLaneConfig'; -import {WorkerQueueOverflowError} from '../WorkerQueueOverflowError'; const GIB = 1024 * 1024 * 1024; const MIB = 1024 * 1024; diff --git a/fluxer_api/src/api/worker/tests/PerMessageJobLedger.test.ts b/fluxer_api/src/api/worker/tests/PerMessageJobLedger.test.ts index f59e81ca4..403919c48 100644 --- a/fluxer_api/src/api/worker/tests/PerMessageJobLedger.test.ts +++ b/fluxer_api/src/api/worker/tests/PerMessageJobLedger.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createChannelID, createMessageID, createRoleID, createUserID} from '@app/api/BrandedTypes'; +import {MessageMentionService} from '@app/api/channel/services/message/MessageMentionService'; +import {EmbedService} from '@app/api/infrastructure/EmbedService'; +import type {Message} from '@app/api/models/Message'; +import type {WorkerTaskName} from '@app/api/worker/WorkerLaneConfig'; +import {WorkerQueueOverflowError} from '@app/api/worker/WorkerQueueOverflowError'; import {MessageTypes} from '@fluxer/constants/src/ChannelConstants'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import type {WorkerJobOptions, WorkerJobPayload} from '@pkgs/worker/src/contracts/WorkerTypes'; import {describe, expect, it} from 'vitest'; -import {createChannelID, createMessageID, createRoleID, createUserID} from '../../BrandedTypes'; -import {MessageMentionService} from '../../channel/services/message/MessageMentionService'; -import {EmbedService} from '../../infrastructure/EmbedService'; -import type {Message} from '../../models/Message'; -import type {WorkerTaskName} from '../WorkerLaneConfig'; -import {WorkerQueueOverflowError} from '../WorkerQueueOverflowError'; class RecordingWorkerService implements IWorkerService { readonly jobs: Array<{taskType: WorkerTaskName; options: WorkerJobOptions | undefined}> = []; diff --git a/fluxer_api/src/api/worker/tests/ProcessAssetDeletionQueue.test.ts b/fluxer_api/src/api/worker/tests/ProcessAssetDeletionQueue.test.ts index 20f972017..ecb27459b 100644 --- a/fluxer_api/src/api/worker/tests/ProcessAssetDeletionQueue.test.ts +++ b/fluxer_api/src/api/worker/tests/ProcessAssetDeletionQueue.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {AssetDeletionQueue} from '@app/api/infrastructure/AssetDeletionQueue'; +import {NoopPurgeQueue} from '@app/api/infrastructure/BunnyPurgeQueue'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import processAssetDeletionQueue from '@app/api/worker/tasks/ProcessAssetDeletionQueue'; +import {clearWorkerDependencies, setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; import {afterEach, describe, expect, it, vi} from 'vitest'; -import {AssetDeletionQueue} from '../../infrastructure/AssetDeletionQueue'; -import {NoopPurgeQueue} from '../../infrastructure/BunnyPurgeQueue'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {MockKVProvider} from '../../test/mocks/MockKVProvider'; -import {NoopLogger} from '../../test/mocks/NoopLogger'; -import processAssetDeletionQueue from '../tasks/ProcessAssetDeletionQueue'; -import {clearWorkerDependencies, setWorkerDependenciesForTest} from '../WorkerContext'; const HELPERS = {logger: new NoopLogger()} as unknown as WorkerTaskHelpers; diff --git a/fluxer_api/src/api/worker/tests/ProcessExpiredPremiumSweep.test.ts b/fluxer_api/src/api/worker/tests/ProcessExpiredPremiumSweep.test.ts index 3947a63cd..0f1c82421 100644 --- a/fluxer_api/src/api/worker/tests/ProcessExpiredPremiumSweep.test.ts +++ b/fluxer_api/src/api/worker/tests/ProcessExpiredPremiumSweep.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getConfig} from '@app/api/Config'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import processExpiredPremiumSweep from '@app/api/worker/tasks/ProcessExpiredPremiumSweep'; +import {clearWorkerDependencies, setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; import {afterEach, describe, expect, test} from 'vitest'; -import {getConfig} from '../../Config'; -import {NoopLogger} from '../../test/mocks/NoopLogger'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import processExpiredPremiumSweep from '../tasks/ProcessExpiredPremiumSweep'; -import {clearWorkerDependencies, setWorkerDependenciesForTest} from '../WorkerContext'; function createHarness() { const scanLimits: Array = []; diff --git a/fluxer_api/src/api/worker/tests/ProcessPremiumStateReconciliationQueue.test.ts b/fluxer_api/src/api/worker/tests/ProcessPremiumStateReconciliationQueue.test.ts index c69f0c07b..4b2dd4837 100644 --- a/fluxer_api/src/api/worker/tests/ProcessPremiumStateReconciliationQueue.test.ts +++ b/fluxer_api/src/api/worker/tests/ProcessPremiumStateReconciliationQueue.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID} from '@app/api/BrandedTypes'; +import {PremiumStateReconciliationQueueService} from '@app/api/infrastructure/PremiumStateReconciliationQueueService'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import processPremiumStateReconciliationQueue from '@app/api/worker/tasks/ProcessPremiumStateReconciliationQueue'; +import {clearWorkerDependencies, setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; import type {WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; import type Stripe from 'stripe'; import {afterEach, describe, expect, test} from 'vitest'; -import {createUserID} from '../../BrandedTypes'; -import {PremiumStateReconciliationQueueService} from '../../infrastructure/PremiumStateReconciliationQueueService'; -import {MockKVProvider} from '../../test/mocks/MockKVProvider'; -import {NoopLogger} from '../../test/mocks/NoopLogger'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import processPremiumStateReconciliationQueue from '../tasks/ProcessPremiumStateReconciliationQueue'; -import {clearWorkerDependencies, setWorkerDependenciesForTest} from '../WorkerContext'; const USER_ID = createUserID(834271905123471361n); const ONE_HOUR_MS = 60 * 60 * 1000; diff --git a/fluxer_api/src/api/worker/tests/SendSystemDmCancel.test.ts b/fluxer_api/src/api/worker/tests/SendSystemDmCancel.test.ts index 3d680bfa5..317e3e05c 100644 --- a/fluxer_api/src/api/worker/tests/SendSystemDmCancel.test.ts +++ b/fluxer_api/src/api/worker/tests/SendSystemDmCancel.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ChannelService} from '@app/api/channel/services/ChannelService'; +import type {IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; +import {setInjectedWorkerService} from '@app/api/middleware/ServiceRegistry'; +import {NoopWorkerService} from '@app/api/test/NoopWorkerService'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import {sendSystemDm} from '@app/api/worker/tasks/SendSystemDm'; +import {clearWorkerDependencies, setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; +import {WorkerRunner} from '@app/api/worker/WorkerRunner'; import type {JsMsg} from 'nats'; import {afterEach, beforeAll, describe, expect, it, vi} from 'vitest'; -import type {ChannelService} from '../../channel/services/ChannelService'; -import type {IJobLedgerRepository} from '../../jobs/IJobLedgerRepository'; -import {setInjectedWorkerService} from '../../middleware/ServiceRegistry'; -import {NoopWorkerService} from '../../test/NoopWorkerService'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import {sendSystemDm} from '../tasks/SendSystemDm'; -import {clearWorkerDependencies, setWorkerDependenciesForTest} from '../WorkerContext'; -import {WorkerRunner} from '../WorkerRunner'; const TASK_TYPE = 'sendSystemDm'; const LEDGER_JOB_ID = 88n; diff --git a/fluxer_api/src/api/worker/tests/UserProcessPendingDeletions.test.ts b/fluxer_api/src/api/worker/tests/UserProcessPendingDeletions.test.ts index f2dbd88f7..7517dce4d 100644 --- a/fluxer_api/src/api/worker/tests/UserProcessPendingDeletions.test.ts +++ b/fluxer_api/src/api/worker/tests/UserProcessPendingDeletions.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createUserID, type UserID} from '@app/api/BrandedTypes'; +import {EMPTY_USER_ROW, type UserRow} from '@app/api/database/types/UserTypes'; +import {KVAccountDeletionQueueService} from '@app/api/infrastructure/KVAccountDeletionQueueService'; +import {User} from '@app/api/models/User'; +import {MockKVProvider} from '@app/api/test/mocks/MockKVProvider'; +import {NoopLogger} from '@app/api/test/mocks/NoopLogger'; +import type {UserRepository} from '@app/api/user/repositories/UserRepository'; +import userProcessPendingDeletions from '@app/api/worker/tasks/UserProcessPendingDeletions'; +import {clearWorkerDependencies, setWorkerDependenciesForTest} from '@app/api/worker/WorkerContext'; import {UserFlags} from '@fluxer/constants/src/UserConstants'; import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService'; import type {WorkerTaskHelpers} from '@pkgs/worker/src/contracts/WorkerTask'; import {afterEach, describe, expect, test} from 'vitest'; -import {createUserID, type UserID} from '../../BrandedTypes'; -import {EMPTY_USER_ROW, type UserRow} from '../../database/types/UserTypes'; -import {KVAccountDeletionQueueService} from '../../infrastructure/KVAccountDeletionQueueService'; -import {User} from '../../models/User'; -import {MockKVProvider} from '../../test/mocks/MockKVProvider'; -import {NoopLogger} from '../../test/mocks/NoopLogger'; -import type {UserRepository} from '../../user/repositories/UserRepository'; -import userProcessPendingDeletions from '../tasks/UserProcessPendingDeletions'; -import {clearWorkerDependencies, setWorkerDependenciesForTest} from '../WorkerContext'; function createFakeUser( userId: UserID, diff --git a/fluxer_api/src/api/worker/tests/WorkerAckHeartbeat.test.ts b/fluxer_api/src/api/worker/tests/WorkerAckHeartbeat.test.ts index 92427456a..c3e058c97 100644 --- a/fluxer_api/src/api/worker/tests/WorkerAckHeartbeat.test.ts +++ b/fluxer_api/src/api/worker/tests/WorkerAckHeartbeat.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; +import {setInjectedWorkerService} from '@app/api/middleware/ServiceRegistry'; +import {NoopWorkerService} from '@app/api/test/NoopWorkerService'; +import {WorkerRunner} from '@app/api/worker/WorkerRunner'; import {JobCancelledError} from '@pkgs/worker/src/contracts/WorkerTask'; import type {JsMsg} from 'nats'; import {afterEach, beforeAll, describe, expect, it, vi} from 'vitest'; -import type {IJobLedgerRepository} from '../../jobs/IJobLedgerRepository'; -import {setInjectedWorkerService} from '../../middleware/ServiceRegistry'; -import {NoopWorkerService} from '../../test/NoopWorkerService'; -import {WorkerRunner} from '../WorkerRunner'; const LANE_ACK_WAIT_MS = 120000; const LANE_MAX_DELIVER = 25; diff --git a/fluxer_api/src/api/worker/tests/WorkerHeartbeat.test.ts b/fluxer_api/src/api/worker/tests/WorkerHeartbeat.test.ts index d2c009741..76f76b0a5 100644 --- a/fluxer_api/src/api/worker/tests/WorkerHeartbeat.test.ts +++ b/fluxer_api/src/api/worker/tests/WorkerHeartbeat.test.ts @@ -1,21 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {LoggerInterface} from '@fluxer/logger/src/LoggerInterface'; -import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; -import type {ConsumerMessages, JsMsg} from 'nats'; -import {afterEach, beforeAll, describe, expect, it, vi} from 'vitest'; -import type {IJobLedgerRepository} from '../../jobs/IJobLedgerRepository'; -import {setInjectedWorkerService} from '../../middleware/ServiceRegistry'; -import {NoopWorkerService} from '../../test/NoopWorkerService'; -import {CronScheduler} from '../CronScheduler'; +import type {IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; +import {setInjectedWorkerService} from '@app/api/middleware/ServiceRegistry'; +import {NoopWorkerService} from '@app/api/test/NoopWorkerService'; +import {CronScheduler} from '@app/api/worker/CronScheduler'; import { WORKER_CRON_STALE_AFTER_MS, WORKER_HEARTBEAT_WRITE_INTERVAL_MS, WORKER_LANE_STALE_AFTER_MS, WorkerHeartbeat, -} from '../WorkerHeartbeat'; -import {WorkerRunner} from '../WorkerRunner'; -import type {WorkerService} from '../WorkerService'; +} from '@app/api/worker/WorkerHeartbeat'; +import {WorkerRunner} from '@app/api/worker/WorkerRunner'; +import type {WorkerService} from '@app/api/worker/WorkerService'; +import type {LoggerInterface} from '@fluxer/logger/src/LoggerInterface'; +import type {IKVProvider} from '@pkgs/kv_client/src/IKVProvider'; +import type {ConsumerMessages, JsMsg} from 'nats'; +import {afterEach, beforeAll, describe, expect, it, vi} from 'vitest'; const HEARTBEAT_PATH = '/tmp/fluxer-worker-heartbeat-test'; const TASK_TYPE = 'processInactivityDeletions'; diff --git a/fluxer_api/src/api/worker/tests/WorkerLaneConfig.test.ts b/fluxer_api/src/api/worker/tests/WorkerLaneConfig.test.ts index b11d2be4c..986ca1324 100644 --- a/fluxer_api/src/api/worker/tests/WorkerLaneConfig.test.ts +++ b/fluxer_api/src/api/worker/tests/WorkerLaneConfig.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { resolveCronSchedulerEnabled, resolveWorkerLanes, validateLaneCompleteness, WORKER_LANES, -} from '../WorkerLaneConfig'; +} from '@app/api/worker/WorkerLaneConfig'; +import {describe, expect, it} from 'vitest'; describe('WorkerLaneConfig', () => { it('returns all lanes in all_lanes mode', () => { diff --git a/fluxer_api/src/api/worker/tests/WorkerProcessErrorHandler.test.ts b/fluxer_api/src/api/worker/tests/WorkerProcessErrorHandler.test.ts index 48f2eb159..8359a783b 100644 --- a/fluxer_api/src/api/worker/tests/WorkerProcessErrorHandler.test.ts +++ b/fluxer_api/src/api/worker/tests/WorkerProcessErrorHandler.test.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createWorkerProcessErrorHandler, + type WorkerProcessErrorSource, +} from '@app/api/worker/WorkerProcessErrorHandler'; import {describe, expect, it, vi} from 'vitest'; -import {createWorkerProcessErrorHandler, type WorkerProcessErrorSource} from '../WorkerProcessErrorHandler'; function createHarness(overrides: {shutdown?: () => Promise; forceExitDelayMs?: number} = {}) { const logger = {error: vi.fn(), warn: vi.fn()}; diff --git a/fluxer_api/src/api/worker/tests/WorkerRetiredTask.test.ts b/fluxer_api/src/api/worker/tests/WorkerRetiredTask.test.ts index 80c228ce9..b5bd606a0 100644 --- a/fluxer_api/src/api/worker/tests/WorkerRetiredTask.test.ts +++ b/fluxer_api/src/api/worker/tests/WorkerRetiredTask.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; +import {setInjectedWorkerService} from '@app/api/middleware/ServiceRegistry'; +import {NoopWorkerService} from '@app/api/test/NoopWorkerService'; +import {WorkerRunner} from '@app/api/worker/WorkerRunner'; import type {JsMsg} from 'nats'; import {afterEach, beforeAll, describe, expect, it, vi} from 'vitest'; -import type {IJobLedgerRepository} from '../../jobs/IJobLedgerRepository'; -import {setInjectedWorkerService} from '../../middleware/ServiceRegistry'; -import {NoopWorkerService} from '../../test/NoopWorkerService'; -import {WorkerRunner} from '../WorkerRunner'; const RETIRED_TASK_TYPE = 'sendScheduledMessage'; const RETIRED_REASON = 'task type retired'; diff --git a/fluxer_api/src/api/worker/tests/WorkerRunnerResubscribe.test.ts b/fluxer_api/src/api/worker/tests/WorkerRunnerResubscribe.test.ts index 721328ab3..8466bb91b 100644 --- a/fluxer_api/src/api/worker/tests/WorkerRunnerResubscribe.test.ts +++ b/fluxer_api/src/api/worker/tests/WorkerRunnerResubscribe.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; +import {setInjectedWorkerService} from '@app/api/middleware/ServiceRegistry'; +import {NoopWorkerService} from '@app/api/test/NoopWorkerService'; +import {WorkerRunner} from '@app/api/worker/WorkerRunner'; import type {ConsumerMessages, JsMsg} from 'nats'; import {afterEach, beforeAll, describe, expect, it, vi} from 'vitest'; -import type {IJobLedgerRepository} from '../../jobs/IJobLedgerRepository'; -import {setInjectedWorkerService} from '../../middleware/ServiceRegistry'; -import {NoopWorkerService} from '../../test/NoopWorkerService'; -import {WorkerRunner} from '../WorkerRunner'; const TASK_TYPE = 'processInactivityDeletions'; const RESUBSCRIBE_WINDOW_MS = 30000; diff --git a/fluxer_api/src/api/worker/tests/WorkerRunnerShutdown.test.ts b/fluxer_api/src/api/worker/tests/WorkerRunnerShutdown.test.ts index fe7e4bc3b..a44b5bc39 100644 --- a/fluxer_api/src/api/worker/tests/WorkerRunnerShutdown.test.ts +++ b/fluxer_api/src/api/worker/tests/WorkerRunnerShutdown.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; +import {setInjectedWorkerService} from '@app/api/middleware/ServiceRegistry'; +import {NoopWorkerService} from '@app/api/test/NoopWorkerService'; +import {WorkerRunner} from '@app/api/worker/WorkerRunner'; import type {ConsumerMessages, JsMsg} from 'nats'; import {beforeAll, describe, expect, it, vi} from 'vitest'; -import type {IJobLedgerRepository} from '../../jobs/IJobLedgerRepository'; -import {setInjectedWorkerService} from '../../middleware/ServiceRegistry'; -import {NoopWorkerService} from '../../test/NoopWorkerService'; -import {WorkerRunner} from '../WorkerRunner'; const TASK_TYPE = 'processInactivityDeletions'; diff --git a/fluxer_api/src/api/worker/tests/WorkerServiceLedger.test.ts b/fluxer_api/src/api/worker/tests/WorkerServiceLedger.test.ts index 14c39d8f5..a21787d1b 100644 --- a/fluxer_api/src/api/worker/tests/WorkerServiceLedger.test.ts +++ b/fluxer_api/src/api/worker/tests/WorkerServiceLedger.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {ISnowflakeService} from '@app/api/infrastructure/ISnowflakeService'; +import type {CreateJobInput, IJobLedgerRepository} from '@app/api/jobs/IJobLedgerRepository'; +import type {JetStreamWorkerQueue} from '@app/api/worker/JetStreamWorkerQueue'; +import {WorkerService} from '@app/api/worker/WorkerService'; import {describe, expect, test} from 'vitest'; -import type {ISnowflakeService} from '../../infrastructure/ISnowflakeService'; -import type {CreateJobInput, IJobLedgerRepository} from '../../jobs/IJobLedgerRepository'; -import type {JetStreamWorkerQueue} from '../JetStreamWorkerQueue'; -import {WorkerService} from '../WorkerService'; const JOB_ID = 4242n; diff --git a/fluxer_api/src/api/worker/utils/AssetArchiveHelpers.ts b/fluxer_api/src/api/worker/utils/AssetArchiveHelpers.ts index b1dd986ea..1609fd512 100644 --- a/fluxer_api/src/api/worker/utils/AssetArchiveHelpers.ts +++ b/fluxer_api/src/api/worker/utils/AssetArchiveHelpers.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {Readable} from 'node:stream'; +import {Config} from '@app/api/Config'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import type {ArchiveEntryWriter} from '@app/api/worker/utils/ArchiveFile'; import {S3ServiceException} from '@aws-sdk/client-s3'; -import {Config} from '../../Config'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {Logger} from '../../Logger'; -import type {ArchiveEntryWriter} from './ArchiveFile'; let _cdnBucket: string | null = null; diff --git a/fluxer_api/src/api/worker/utils/ContentAddressedAttachmentCollector.ts b/fluxer_api/src/api/worker/utils/ContentAddressedAttachmentCollector.ts index 1324d7e76..7ebacfa39 100644 --- a/fluxer_api/src/api/worker/utils/ContentAddressedAttachmentCollector.ts +++ b/fluxer_api/src/api/worker/utils/ContentAddressedAttachmentCollector.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import crypto from 'node:crypto'; -import type {AttachmentID, ChannelID} from '../../BrandedTypes'; -import {makeAttachmentCdnKey} from '../../channel/services/message/MessageHelpers'; -import type {IStorageService} from '../../infrastructure/IStorageService'; -import {Logger} from '../../Logger'; -import type {ArchiveEntryWriter} from './ArchiveFile'; -import {streamCdnAssetIfExists} from './AssetArchiveHelpers'; +import type {AttachmentID, ChannelID} from '@app/api/BrandedTypes'; +import {makeAttachmentCdnKey} from '@app/api/channel/services/message/MessageHelpers'; +import type {IStorageService} from '@app/api/infrastructure/IStorageService'; +import {Logger} from '@app/api/Logger'; +import type {ArchiveEntryWriter} from '@app/api/worker/utils/ArchiveFile'; +import {streamCdnAssetIfExists} from '@app/api/worker/utils/AssetArchiveHelpers'; interface CollectedAttachment { archivePath: string; diff --git a/fluxer_api/src/api/worker/utils/SelfMessageFilterPayload.ts b/fluxer_api/src/api/worker/utils/SelfMessageFilterPayload.ts index 7f88ea98b..3cb713340 100644 --- a/fluxer_api/src/api/worker/utils/SelfMessageFilterPayload.ts +++ b/fluxer_api/src/api/worker/utils/SelfMessageFilterPayload.ts @@ -1,10 +1,10 @@ +import type {SelfMessageFilter} from '@app/api/channel/services/message/SelfMessageFilter'; import { type BulkDeleteSelfMessagesFilter, BulkDeleteSelfMessagesGuildFilterMode, BulkDeleteSelfMessagesScope, } from '@fluxer/schema/src/domains/user/UserRequestSchemas'; import {z} from 'zod'; -import type {SelfMessageFilter} from '../../channel/services/message/SelfMessageFilter'; export const SelfMessageFilterPayload = z.object({ scope: BulkDeleteSelfMessagesScope, diff --git a/fluxer_app/scripts/GenerateAvatarMasks.ts b/fluxer_app/scripts/GenerateAvatarMasks.ts index 44512f6f5..7ebc73694 100644 --- a/fluxer_app/scripts/GenerateAvatarMasks.ts +++ b/fluxer_app/scripts/GenerateAvatarMasks.ts @@ -3,7 +3,7 @@ import fs from 'node:fs'; import path from 'node:path'; import {fileURLToPath} from 'node:url'; -import {TYPING_BRIDGE_RIGHT_SHIFT_RATIO, TYPING_WIDTH_MULTIPLIER} from '../src/features/ui/constants/TypingConstants'; +import {TYPING_BRIDGE_RIGHT_SHIFT_RATIO, TYPING_WIDTH_MULTIPLIER} from '@app/features/ui/constants/TypingConstants'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); diff --git a/fluxer_app/scripts/GenerateEmojiSprites.ts b/fluxer_app/scripts/GenerateEmojiSprites.ts index 4b055f817..81d2cea7a 100644 --- a/fluxer_app/scripts/GenerateEmojiSprites.ts +++ b/fluxer_app/scripts/GenerateEmojiSprites.ts @@ -2,8 +2,8 @@ import {mkdirSync, readFileSync, writeFileSync} from 'node:fs'; import {join} from 'node:path'; +import {convertToCodePoints} from '@app/features/expressions/utils/EmojiCodepointUtils'; import sharp, {type OverlayOptions} from 'sharp'; -import {convertToCodePoints} from '../src/features/expressions/utils/EmojiCodepointUtils'; const EMOJI_SPRITES = { basePerRow: 42, diff --git a/fluxer_app/scripts/GenerateMessageLayoutCss.ts b/fluxer_app/scripts/GenerateMessageLayoutCss.ts index 6060921fc..f6c38f290 100644 --- a/fluxer_app/scripts/GenerateMessageLayoutCss.ts +++ b/fluxer_app/scripts/GenerateMessageLayoutCss.ts @@ -2,7 +2,7 @@ import {existsSync, mkdirSync, readFileSync, writeFileSync} from 'node:fs'; import {dirname, join, relative} from 'node:path'; -import {renderMessageLayoutCss} from '../src/features/theme/layout/MessageLayoutCss'; +import {renderMessageLayoutCss} from '@app/features/theme/layout/MessageLayoutCss'; function main(): void { const scriptDir = import.meta.dirname; diff --git a/fluxer_app/src/features/accessibility/state/MessageGroupSpacing.test.ts b/fluxer_app/src/features/accessibility/state/MessageGroupSpacing.test.ts index f7e974053..f3dae7385 100644 --- a/fluxer_app/src/features/accessibility/state/MessageGroupSpacing.test.ts +++ b/fluxer_app/src/features/accessibility/state/MessageGroupSpacing.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { COMFY_MESSAGE_GROUP_SPACING_DEFAULT, COMPACT_MESSAGE_GROUP_SPACING_DEFAULT, @@ -8,7 +7,8 @@ import { getMessageGroupSpacingForDisplayMode, getMessageGroupSpacingPatch, migrateLegacyMessageGroupSpacing, -} from './MessageGroupSpacing'; +} from '@app/features/accessibility/state/MessageGroupSpacing'; +import {describe, expect, it} from 'vitest'; describe('MessageGroupSpacing', () => { it('keeps explicit defaults per display mode', () => { diff --git a/fluxer_app/src/features/accessibility/state/MotionPreferencesMachine.test.ts b/fluxer_app/src/features/accessibility/state/MotionPreferencesMachine.test.ts index 9cf941803..124ed9deb 100644 --- a/fluxer_app/src/features/accessibility/state/MotionPreferencesMachine.test.ts +++ b/fluxer_app/src/features/accessibility/state/MotionPreferencesMachine.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {StickerAnimationOptions} from '@fluxer/constants/src/UserConstants'; -import {describe, expect, it} from 'vitest'; import { createMotionPreferencesContext, createMotionPreferencesSnapshot, @@ -22,7 +20,9 @@ import { selectReducedMotionSource, selectSmoothScrollingEnabled, transitionMotionPreferencesSnapshot, -} from './MotionPreferencesMachine'; +} from '@app/features/accessibility/state/MotionPreferencesMachine'; +import {StickerAnimationOptions} from '@fluxer/constants/src/UserConstants'; +import {describe, expect, it} from 'vitest'; const {ALWAYS_ANIMATE, ANIMATE_ON_INTERACTION, NEVER_ANIMATE} = StickerAnimationOptions; diff --git a/fluxer_app/src/features/app/components/alerts/FeatureTemporarilyDisabledModal.tsx b/fluxer_app/src/features/app/components/alerts/FeatureTemporarilyDisabledModal.tsx index c0c76f44f..643865fb6 100644 --- a/fluxer_app/src/features/app/components/alerts/FeatureTemporarilyDisabledModal.tsx +++ b/fluxer_app/src/features/app/components/alerts/FeatureTemporarilyDisabledModal.tsx @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GenericErrorModal} from '@app/features/app/components/alerts/GenericErrorModal'; import {msg} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; import {observer} from 'mobx-react-lite'; -import {GenericErrorModal} from './GenericErrorModal'; const FEATURE_TEMPORARILY_DISABLED_DESCRIPTOR = msg({ message: 'Feature temporarily disabled', diff --git a/fluxer_app/src/features/app/components/alerts/MaxBookmarksModal.tsx b/fluxer_app/src/features/app/components/alerts/MaxBookmarksModal.tsx index 41218b3f4..b06d7ad29 100644 --- a/fluxer_app/src/features/app/components/alerts/MaxBookmarksModal.tsx +++ b/fluxer_app/src/features/app/components/alerts/MaxBookmarksModal.tsx @@ -1,5 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GenericErrorModal} from '@app/features/app/components/alerts/GenericErrorModal'; import {ConfirmModal} from '@app/features/app/components/dialogs/ConfirmModal'; import {PREMIUM_PRODUCT_NAME} from '@app/features/app/config/I18nDisplayConstants'; import {Limits} from '@app/features/app/utils/UserLimits'; @@ -11,7 +12,6 @@ import {MAX_BOOKMARKS_PREMIUM} from '@fluxer/constants/src/LimitConstants'; import {msg, plural} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; import {observer} from 'mobx-react-lite'; -import {GenericErrorModal} from './GenericErrorModal'; const BOOKMARK_LIMIT_REACHED_DESCRIPTOR = msg({ message: 'Bookmark limit reached', diff --git a/fluxer_app/src/features/app/components/alerts/MaxFavoriteMemesModal.tsx b/fluxer_app/src/features/app/components/alerts/MaxFavoriteMemesModal.tsx index 30ea552e0..7c0657813 100644 --- a/fluxer_app/src/features/app/components/alerts/MaxFavoriteMemesModal.tsx +++ b/fluxer_app/src/features/app/components/alerts/MaxFavoriteMemesModal.tsx @@ -1,5 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GenericErrorModal} from '@app/features/app/components/alerts/GenericErrorModal'; import {ConfirmModal} from '@app/features/app/components/dialogs/ConfirmModal'; import {PREMIUM_PRODUCT_NAME} from '@app/features/app/config/I18nDisplayConstants'; import {Limits} from '@app/features/app/utils/UserLimits'; @@ -11,7 +12,6 @@ import {MAX_FAVORITE_MEMES_PREMIUM} from '@fluxer/constants/src/LimitConstants'; import {msg, plural} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; import {observer} from 'mobx-react-lite'; -import {GenericErrorModal} from './GenericErrorModal'; const SAVED_MEDIA_LIMIT_REACHED_DESCRIPTOR = msg({ message: 'Saved media limit reached', diff --git a/fluxer_app/src/features/app/components/alerts/RoleNameBlankModal.tsx b/fluxer_app/src/features/app/components/alerts/RoleNameBlankModal.tsx index 707f61d53..c63cd9c8b 100644 --- a/fluxer_app/src/features/app/components/alerts/RoleNameBlankModal.tsx +++ b/fluxer_app/src/features/app/components/alerts/RoleNameBlankModal.tsx @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GenericErrorModal} from '@app/features/app/components/alerts/GenericErrorModal'; import {msg} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; import {observer} from 'mobx-react-lite'; -import {GenericErrorModal} from './GenericErrorModal'; const ROLE_NAME_CANNOT_BE_BLANK_DESCRIPTOR = msg({ message: 'Role name is required', diff --git a/fluxer_app/src/features/app/components/alerts/TemporaryInviteRequiresPresenceModal.tsx b/fluxer_app/src/features/app/components/alerts/TemporaryInviteRequiresPresenceModal.tsx index b595ccbdf..256c3fccc 100644 --- a/fluxer_app/src/features/app/components/alerts/TemporaryInviteRequiresPresenceModal.tsx +++ b/fluxer_app/src/features/app/components/alerts/TemporaryInviteRequiresPresenceModal.tsx @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {GenericErrorModal} from '@app/features/app/components/alerts/GenericErrorModal'; import {msg} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; import {observer} from 'mobx-react-lite'; -import {GenericErrorModal} from './GenericErrorModal'; const GATEWAY_CONNECTION_REQUIRED_DESCRIPTOR = msg({ message: 'Gateway connection required', diff --git a/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelEligibility.test.ts b/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelEligibility.test.ts index 5f6430900..6446cb388 100644 --- a/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelEligibility.test.ts +++ b/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelEligibility.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isForwardableChannelType} from '@app/features/app/components/dialogs/shared/ForwardChannelEligibility'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {describe, expect, it} from 'vitest'; -import {isForwardableChannelType} from './ForwardChannelEligibility'; describe('forward channel eligibility', () => { it('allows every text-based message destination, including text-in-voice channels', () => { diff --git a/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelIndex.ts b/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelIndex.ts index 823eff90c..1e05a4b9d 100644 --- a/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelIndex.ts +++ b/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelIndex.ts @@ -1,5 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isForwardableChannelType} from '@app/features/app/components/dialogs/shared/ForwardChannelEligibility'; +import {matchesForwardChannelSearch} from '@app/features/app/components/dialogs/shared/ForwardChannelSearchMatch'; import {formatSlowmodeTime} from '@app/features/channel/components/SlowmodeIndicator'; import type {Channel} from '@app/features/channel/models/Channel'; import {PERSONAL_NOTES_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; @@ -8,8 +10,6 @@ import {formatPermissionLabel} from '@app/features/permissions/utils/PermissionU import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'; import type {I18n} from '@lingui/core'; import {msg} from '@lingui/core/macro'; -import {isForwardableChannelType} from './ForwardChannelEligibility'; -import {matchesForwardChannelSearch} from './ForwardChannelSearchMatch'; const GUILD_MESSAGES_DISABLED_DESCRIPTOR = msg({ message: 'Sending messages is disabled in this community', diff --git a/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelSearch.test.ts b/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelSearch.test.ts index 96504366e..3f0e80f1a 100644 --- a/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelSearch.test.ts +++ b/fluxer_app/src/features/app/components/dialogs/shared/ForwardChannelSearch.test.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + type ForwardChannelSearchValues, + matchesForwardChannelSearch, +} from '@app/features/app/components/dialogs/shared/ForwardChannelSearchMatch'; import {describe, expect, it} from 'vitest'; -import {type ForwardChannelSearchValues, matchesForwardChannelSearch} from './ForwardChannelSearchMatch'; const PERSONAL_NOTES = 'personal notes'; diff --git a/fluxer_app/src/features/app/components/floating/UnreadChannelOrder.test.ts b/fluxer_app/src/features/app/components/floating/UnreadChannelOrder.test.ts index bfd808eed..57c31152d 100644 --- a/fluxer_app/src/features/app/components/floating/UnreadChannelOrder.test.ts +++ b/fluxer_app/src/features/app/components/floating/UnreadChannelOrder.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {selectFrozenUnreadChannels} from '@app/features/app/components/floating/UnreadChannelOrder'; import {describe, expect, it} from 'vitest'; -import {selectFrozenUnreadChannels} from './UnreadChannelOrder'; function ids(channels: ReadonlyArray<{id: string}>): Array { return channels.map((channel) => channel.id); diff --git a/fluxer_app/src/features/app/components/layout/ChannelListContent.tsx b/fluxer_app/src/features/app/components/layout/ChannelListContent.tsx index 7ad2a7fb5..f7ff9158c 100644 --- a/fluxer_app/src/features/app/components/layout/ChannelListContent.tsx +++ b/fluxer_app/src/features/app/components/layout/ChannelListContent.tsx @@ -2,6 +2,7 @@ import {Routes} from '@app/app/Routes'; import Accessibility from '@app/features/accessibility/state/Accessibility'; +import {GenericErrorModal} from '@app/features/app/components/alerts/GenericErrorModal'; import {ChannelItem} from '@app/features/app/components/layout/ChannelItem'; import channelItemStyles from '@app/features/app/components/layout/ChannelItem.module.css'; import {ChannelItemContent} from '@app/features/app/components/layout/ChannelItemContent'; @@ -70,7 +71,6 @@ import {observer} from 'mobx-react-lite'; import type {MotionValue} from 'motion'; import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {useDragLayer} from 'react-dnd'; -import {GenericErrorModal} from '../alerts/GenericErrorModal'; const CATEGORY_FULL_DESCRIPTOR = msg({ message: 'Category full', diff --git a/fluxer_app/src/features/app/components/layout/NativeTitlebar.tsx b/fluxer_app/src/features/app/components/layout/NativeTitlebar.tsx index ab50f2f5d..81202aa1c 100644 --- a/fluxer_app/src/features/app/components/layout/NativeTitlebar.tsx +++ b/fluxer_app/src/features/app/components/layout/NativeTitlebar.tsx @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import styles from '@app/features/app/components/layout/NativeTitlebar.module.css'; +import {NativeWindowControls} from '@app/features/app/components/layout/NativeWindowControls'; import {FluxerWordmark} from '@app/features/ui/components/icons/FluxerWordmark'; import {getElectronAPI, type NativePlatform} from '@app/features/ui/utils/NativeUtils'; import type React from 'react'; import {useLayoutEffect} from 'react'; -import {NativeWindowControls} from './NativeWindowControls'; const STARTUP_NATIVE_TITLEBAR_ID = 'fluxer-startup-native-titlebar'; diff --git a/fluxer_app/src/features/app/components/layout/ScrollIndicatorStateMachine.test.ts b/fluxer_app/src/features/app/components/layout/ScrollIndicatorStateMachine.test.ts index 76f391db1..4a32fa96a 100644 --- a/fluxer_app/src/features/app/components/layout/ScrollIndicatorStateMachine.test.ts +++ b/fluxer_app/src/features/app/components/layout/ScrollIndicatorStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createScrollIndicatorSnapshot, getScrollIndicatorStateValue, @@ -10,7 +9,8 @@ import { type ScrollIndicatorTargetMeasurement, selectActiveScrollIndicator, transitionScrollIndicatorSnapshot, -} from './ScrollIndicatorStateMachine'; +} from '@app/features/app/components/layout/ScrollIndicatorStateMachine'; +import {describe, expect, it} from 'vitest'; function target( id: string, diff --git a/fluxer_app/src/features/app/components/layout/UserAreaState.test.ts b/fluxer_app/src/features/app/components/layout/UserAreaState.test.ts index 27f3eddae..26cd92c48 100644 --- a/fluxer_app/src/features/app/components/layout/UserAreaState.test.ts +++ b/fluxer_app/src/features/app/components/layout/UserAreaState.test.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + selectUserAreaMicrophoneState, + type UserAreaMicrophoneSignals, +} from '@app/features/app/components/layout/UserAreaState'; import {describe, expect, it} from 'vitest'; -import {selectUserAreaMicrophoneState, type UserAreaMicrophoneSignals} from './UserAreaState'; const baseSignals: UserAreaMicrophoneSignals = { effectiveAudioMuted: false, diff --git a/fluxer_app/src/features/app/components/layout/dnd/ChannelReorderIntegration.test.ts b/fluxer_app/src/features/app/components/layout/dnd/ChannelReorderIntegration.test.ts index 4cb7eca42..0e43c34e0 100644 --- a/fluxer_app/src/features/app/components/layout/dnd/ChannelReorderIntegration.test.ts +++ b/fluxer_app/src/features/app/components/layout/dnd/ChannelReorderIntegration.test.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + type ChannelReorderRect, + type ChannelReorderTarget, + selectChannelReorderIntent, +} from '@app/features/app/components/layout/dnd/ChannelReorderStateMachine'; import {type DragItem, DragItemType, type DropResult} from '@app/features/app/components/layout/types/DndTypes'; import { type ChannelMoveOperation, @@ -9,11 +14,6 @@ import type {Channel} from '@app/features/channel/models/Channel'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {computeGuildChannelReorderPlan} from '@fluxer/schema/src/domains/channel/GuildChannelOrdering'; import {describe, expect, it} from 'vitest'; -import { - type ChannelReorderRect, - type ChannelReorderTarget, - selectChannelReorderIntent, -} from './ChannelReorderStateMachine'; const rect: ChannelReorderRect = { top: 100, diff --git a/fluxer_app/src/features/app/components/layout/dnd/ChannelReorderStateMachine.test.ts b/fluxer_app/src/features/app/components/layout/dnd/ChannelReorderStateMachine.test.ts index 7333e27fa..85ca6bf2d 100644 --- a/fluxer_app/src/features/app/components/layout/dnd/ChannelReorderStateMachine.test.ts +++ b/fluxer_app/src/features/app/components/layout/dnd/ChannelReorderStateMachine.test.ts @@ -1,8 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {type DragItem, DragItemType} from '@app/features/app/components/layout/types/DndTypes'; -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import {describe, expect, it} from 'vitest'; import { type ChannelReorderRect, type ChannelReorderTarget, @@ -13,7 +10,10 @@ import { selectChannelReorderIntent, selectChannelReorderResolution, transitionChannelReorderSnapshot, -} from './ChannelReorderStateMachine'; +} from '@app/features/app/components/layout/dnd/ChannelReorderStateMachine'; +import {type DragItem, DragItemType} from '@app/features/app/components/layout/types/DndTypes'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; +import {describe, expect, it} from 'vitest'; const rect: ChannelReorderRect = { top: 40, diff --git a/fluxer_app/src/features/app/components/layout/utils/ChannelListVisibility.test.ts b/fluxer_app/src/features/app/components/layout/utils/ChannelListVisibility.test.ts index 2bfa7dffc..8a321ff0f 100644 --- a/fluxer_app/src/features/app/components/layout/utils/ChannelListVisibility.test.ts +++ b/fluxer_app/src/features/app/components/layout/utils/ChannelListVisibility.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { shouldShowCategoryWhenHidingMutedChannels, shouldShowChannelInCollapsedCategory, shouldShowChannelWhenHidingMutedChannels, -} from './ChannelListVisibility'; +} from '@app/features/app/components/layout/utils/ChannelListVisibility'; +import {describe, expect, it} from 'vitest'; describe('shouldShowChannelWhenHidingMutedChannels', () => { it('keeps muted channels with visible unread state so mentions are findable', () => { diff --git a/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadState.test.ts b/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadState.test.ts index 8e4d7ec1a..39f686ce7 100644 --- a/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadState.test.ts +++ b/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadState.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getChannelUnreadState} from '@app/features/app/components/layout/utils/ChannelUnreadState'; import {MessageNotifications} from '@fluxer/constants/src/NotificationConstants'; import {describe, expect, it} from 'vitest'; -import {getChannelUnreadState} from './ChannelUnreadState'; describe('getChannelUnreadState', () => { it('shows a normal unread indicator for all-messages unread badges', () => { diff --git a/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadState.ts b/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadState.ts index e11d62082..cea6945a4 100644 --- a/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadState.ts +++ b/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadState.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {resolveChannelUnreadState} from './ChannelUnreadStateMachine'; +import {resolveChannelUnreadState} from '@app/features/app/components/layout/utils/ChannelUnreadStateMachine'; export interface ChannelUnreadStateInput { hasUnread: boolean; diff --git a/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadStateMachine.test.ts b/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadStateMachine.test.ts index 52d52b2a0..6053059b2 100644 --- a/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadStateMachine.test.ts +++ b/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadStateMachine.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {MessageNotifications} from '@fluxer/constants/src/NotificationConstants'; -import {describe, expect, it} from 'vitest'; -import type {ChannelUnreadStateInput} from './ChannelUnreadState'; +import type {ChannelUnreadStateInput} from '@app/features/app/components/layout/utils/ChannelUnreadState'; import { type ChannelUnreadStateValue, createChannelUnreadSnapshot, selectChannelUnreadState, transitionChannelUnreadSnapshot, -} from './ChannelUnreadStateMachine'; +} from '@app/features/app/components/layout/utils/ChannelUnreadStateMachine'; +import {MessageNotifications} from '@fluxer/constants/src/NotificationConstants'; +import {describe, expect, it} from 'vitest'; function input(overrides: Partial = {}): ChannelUnreadStateInput { return { diff --git a/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadStateMachine.ts b/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadStateMachine.ts index 6c2adf059..d5ca09cbc 100644 --- a/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadStateMachine.ts +++ b/fluxer_app/src/features/app/components/layout/utils/ChannelUnreadStateMachine.ts @@ -1,8 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type { + ChannelUnreadState, + ChannelUnreadStateInput, +} from '@app/features/app/components/layout/utils/ChannelUnreadState'; import {MessageNotifications} from '@fluxer/constants/src/NotificationConstants'; import {assign, initialTransition, type SnapshotFrom, setup, transition} from 'xstate'; -import type {ChannelUnreadState, ChannelUnreadStateInput} from './ChannelUnreadState'; interface ChannelUnreadMachineContext extends ChannelUnreadStateInput {} diff --git a/fluxer_app/src/features/app/components/setup/SetupWizardStateMachine.test.ts b/fluxer_app/src/features/app/components/setup/SetupWizardStateMachine.test.ts index 6606ed8df..8965e6711 100644 --- a/fluxer_app/src/features/app/components/setup/SetupWizardStateMachine.test.ts +++ b/fluxer_app/src/features/app/components/setup/SetupWizardStateMachine.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createSetupWizardSnapshot, type SetupWizardMachineEvent, type SetupWizardSnapshot, selectSetupWizardModel, transitionSetupWizardSnapshot, -} from './SetupWizardStateMachine'; +} from '@app/features/app/components/setup/SetupWizardStateMachine'; +import {describe, expect, it} from 'vitest'; function transition(snapshot: SetupWizardSnapshot, event: SetupWizardMachineEvent): SetupWizardSnapshot { return transitionSetupWizardSnapshot(snapshot, event); diff --git a/fluxer_app/src/features/app/components/setup/SetupWizardWelcomeRotation.test.ts b/fluxer_app/src/features/app/components/setup/SetupWizardWelcomeRotation.test.ts index 173e8985e..2b36ed509 100644 --- a/fluxer_app/src/features/app/components/setup/SetupWizardWelcomeRotation.test.ts +++ b/fluxer_app/src/features/app/components/setup/SetupWizardWelcomeRotation.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createRandomWelcomeRotationState, createWelcomeRotationState, WELCOME_ROTATION, type WelcomeRotationState, -} from './SetupWizardWelcomeRotation'; +} from '@app/features/app/components/setup/SetupWizardWelcomeRotation'; +import {describe, expect, it} from 'vitest'; function constantRandom(value: number): () => number { return () => value; diff --git a/fluxer_app/src/features/app/config/I18nDisplayConstants.ts b/fluxer_app/src/features/app/config/I18nDisplayConstants.ts index 0f915fda9..a2a99d9db 100644 --- a/fluxer_app/src/features/app/config/I18nDisplayConstants.ts +++ b/fluxer_app/src/features/app/config/I18nDisplayConstants.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import Config from '@app/features/app/config/Config'; +import {PREMIUM_PRODUCT_FULL_NAME, PREMIUM_PRODUCT_NAME, PRODUCT_NAME} from '@app/features/app/config/ProductConstants'; import {formatAssetUploadExtensions, formatKnownAnimatedAssetExtensions} from '@fluxer/constants/src/AssetFormatPolicy'; import {THE_OTHER_PLATFORM} from '@fluxer/constants/src/ExternalPlatformConstants'; -import {PREMIUM_PRODUCT_FULL_NAME, PREMIUM_PRODUCT_NAME, PRODUCT_NAME} from './ProductConstants'; export {PREMIUM_PRODUCT_FULL_NAME, PREMIUM_PRODUCT_NAME, PRODUCT_NAME}; export const PRODUCT_API_NAME = `${PRODUCT_NAME} API`; diff --git a/fluxer_app/src/features/app/hooks/useHover.ts b/fluxer_app/src/features/app/hooks/useHover.ts index 7f8a03f76..bba48cf00 100644 --- a/fluxer_app/src/features/app/hooks/useHover.ts +++ b/fluxer_app/src/features/app/hooks/useHover.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import { - canUseWindowFocusedHoverControls, - subscribeWindowHoverControlsChange, -} from '@app/features/ui/utils/WindowFocusInteractionGuard'; -import type React from 'react'; -import {useCallback, useEffect, useRef, useState} from 'react'; import { createHoverStateSnapshot, type HoverStateEvent, type HoverStateSnapshot, selectIsHovering, transitionHoverStateSnapshot, -} from './HoverStateMachine'; +} from '@app/features/app/hooks/HoverStateMachine'; +import { + canUseWindowFocusedHoverControls, + subscribeWindowHoverControlsChange, +} from '@app/features/ui/utils/WindowFocusInteractionGuard'; +import type React from 'react'; +import {useCallback, useEffect, useRef, useState} from 'react'; type HoverHook = [React.RefCallback, boolean]; diff --git a/fluxer_app/src/features/app/keybindings/KeybindManager.test.ts b/fluxer_app/src/features/app/keybindings/KeybindManager.test.ts index 6e6c3cf13..172688b07 100644 --- a/fluxer_app/src/features/app/keybindings/KeybindManager.test.ts +++ b/fluxer_app/src/features/app/keybindings/KeybindManager.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import {describe, expect, it} from 'vitest'; import { keyboardEventCanRecoverStaleMacMetaPress, keyboardEventMatchesCombo, @@ -9,11 +7,16 @@ import { keyboardEventStartsComboPress, keyboardEventTriggerMatchesCombo, shouldAllowLocalShortcutForChannelTextarea, -} from './KeybindEventUtils'; -import {isKeybindAllowedDuringVoiceCallFullscreen, isKeybindBlockedByCompactVoiceCallView} from './KeybindScopeUtils'; -import {comboToCombokeysStrings} from './utils/ComboShortcutStrings'; -import {keyNameForGlobalHook, physicalKeyNameForGlobalHook} from './utils/GlobalHookKeys'; -import {hookShortcutIdForKeybind} from './utils/HookShortcutIds'; +} from '@app/features/app/keybindings/KeybindEventUtils'; +import { + isKeybindAllowedDuringVoiceCallFullscreen, + isKeybindBlockedByCompactVoiceCallView, +} from '@app/features/app/keybindings/KeybindScopeUtils'; +import {comboToCombokeysStrings} from '@app/features/app/keybindings/utils/ComboShortcutStrings'; +import {keyNameForGlobalHook, physicalKeyNameForGlobalHook} from '@app/features/app/keybindings/utils/GlobalHookKeys'; +import {hookShortcutIdForKeybind} from '@app/features/app/keybindings/utils/HookShortcutIds'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; +import {describe, expect, it} from 'vitest'; const keyEvent = ( overrides: Partial<{ diff --git a/fluxer_app/src/features/app/keybindings/utils/RuntimeKeybinds.test.ts b/fluxer_app/src/features/app/keybindings/utils/RuntimeKeybinds.test.ts index 62c15949b..2a62f461d 100644 --- a/fluxer_app/src/features/app/keybindings/utils/RuntimeKeybinds.test.ts +++ b/fluxer_app/src/features/app/keybindings/utils/RuntimeKeybinds.test.ts @@ -1,8 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + buildCustomRuntimeKeybinds, + buildDefaultRuntimeKeybinds, + getCustomActionOverrides, +} from '@app/features/app/keybindings/utils/RuntimeKeybinds'; import type {CustomKeybindEntry, KeybindCommand, KeybindConfig, KeyCombo} from '@app/features/input/state/InputKeybind'; import {describe, expect, it} from 'vitest'; -import {buildCustomRuntimeKeybinds, buildDefaultRuntimeKeybinds, getCustomActionOverrides} from './RuntimeKeybinds'; const action: KeybindCommand = 'voice_toggle_deafen'; const keybind = (combo: KeyCombo): KeybindConfig => ({ diff --git a/fluxer_app/src/features/app/keybindings/utils/RuntimeKeybinds.ts b/fluxer_app/src/features/app/keybindings/utils/RuntimeKeybinds.ts index 44f8f600c..26177c0aa 100644 --- a/fluxer_app/src/features/app/keybindings/utils/RuntimeKeybinds.ts +++ b/fluxer_app/src/features/app/keybindings/utils/RuntimeKeybinds.ts @@ -3,7 +3,11 @@ import type {CustomKeybindEntry, KeybindCommand, KeybindConfig, KeyCombo} from '@app/features/input/state/InputKeybind'; import {keyComboHasTriggerInput} from '@app/features/input/state/KeybindResolution'; -export {comboModifierSignature, hookShortcutIdForAction, hookShortcutIdForKeybind} from './HookShortcutIds'; +export { + comboModifierSignature, + hookShortcutIdForAction, + hookShortcutIdForKeybind, +} from '@app/features/app/keybindings/utils/HookShortcutIds'; export type RuntimeKeybind = KeybindConfig & { combo: KeyCombo; diff --git a/fluxer_app/src/features/app/state/GifProviderConfig.test.ts b/fluxer_app/src/features/app/state/GifProviderConfig.test.ts index e671533be..782be6768 100644 --- a/fluxer_app/src/features/app/state/GifProviderConfig.test.ts +++ b/fluxer_app/src/features/app/state/GifProviderConfig.test.ts @@ -1,9 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {normalizeGifProviderInfo} from '@app/features/app/state/GifProviderConfig'; import {describe, expect, it} from 'vitest'; -import {normalizeGifProviderInfo} from './GifProviderConfig'; - describe('normalizeGifProviderInfo', () => { it('uses Klipy as the default GIF provider display name', () => { expect(normalizeGifProviderInfo()).toEqual({ diff --git a/fluxer_app/src/features/app/utils/UpdaterPlatformUtils.test.ts b/fluxer_app/src/features/app/utils/UpdaterPlatformUtils.test.ts index 5571c86ad..5376d1b9a 100644 --- a/fluxer_app/src/features/app/utils/UpdaterPlatformUtils.test.ts +++ b/fluxer_app/src/features/app/utils/UpdaterPlatformUtils.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { shouldShowNativeDesktopUpdateDownloadProgress, shouldShowNativeDesktopUpdateInApp, -} from './UpdaterPlatformUtils'; +} from '@app/features/app/utils/UpdaterPlatformUtils'; +import {describe, expect, it} from 'vitest'; describe('UpdaterPlatformUtils', () => { it('surfaces native desktop update availability in-app on Linux, macOS, and Windows', () => { diff --git a/fluxer_app/src/features/auth/components/modals/required_action/RequiredActionErrorMessages.test.ts b/fluxer_app/src/features/auth/components/modals/required_action/RequiredActionErrorMessages.test.ts index ad4475235..e40c83786 100644 --- a/fluxer_app/src/features/auth/components/modals/required_action/RequiredActionErrorMessages.test.ts +++ b/fluxer_app/src/features/auth/components/modals/required_action/RequiredActionErrorMessages.test.ts @@ -32,7 +32,9 @@ vi.mock('@app/features/auth/state/SudoPrompt', () => ({isAbortError: () => false const {APIErrorCodes} = await import('@fluxer/constants/src/ApiErrorCodes'); const {HttpError} = await import('@app/features/platform/types/EndpointError'); -const {resolveRequiredActionErrorMessage} = await import('./RequiredActionShared'); +const {resolveRequiredActionErrorMessage} = await import( + '@app/features/auth/components/modals/required_action/RequiredActionShared' +); const { ENTER_VALID_PHONE_DESCRIPTOR, PHONE_CANNOT_BE_USED_DESCRIPTOR, @@ -44,7 +46,7 @@ const { PHONE_NOT_MOBILE_DESCRIPTOR, SOMETHING_WENT_WRONG_TRY_AGAIN_DESCRIPTOR, TOO_MANY_ATTEMPTS_DESCRIPTOR, -} = await import('./RequiredActionDescriptors'); +} = await import('@app/features/auth/components/modals/required_action/RequiredActionDescriptors'); const i18n = setupI18n({locale: 'en', messages: {en: {}}}); diff --git a/fluxer_app/src/features/auth/components/modals/required_action/RequiredActionEscapeCopy.test.ts b/fluxer_app/src/features/auth/components/modals/required_action/RequiredActionEscapeCopy.test.ts index c293f7c26..afb5d94a0 100644 --- a/fluxer_app/src/features/auth/components/modals/required_action/RequiredActionEscapeCopy.test.ts +++ b/fluxer_app/src/features/auth/components/modals/required_action/RequiredActionEscapeCopy.test.ts @@ -17,7 +17,9 @@ vi.mock('@app/features/app/config/Config', () => ({ }, })); -const {buildPhoneGateEscapeConfirmCopy, buildPhoneGateEscapeHint} = await import('./RequiredActionEscapeCopy'); +const {buildPhoneGateEscapeConfirmCopy, buildPhoneGateEscapeHint} = await import( + '@app/features/auth/components/modals/required_action/RequiredActionEscapeCopy' +); const i18n = setupI18n({locale: 'en', messages: {en: {}}}); diff --git a/fluxer_app/src/features/auth/components/pages/oauth_authorize_page/state/authorizeMachine.test.ts b/fluxer_app/src/features/auth/components/pages/oauth_authorize_page/state/authorizeMachine.test.ts index 1129f24ab..9dc920ef3 100644 --- a/fluxer_app/src/features/auth/components/pages/oauth_authorize_page/state/authorizeMachine.test.ts +++ b/fluxer_app/src/features/auth/components/pages/oauth_authorize_page/state/authorizeMachine.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createAuthorizeSnapshot, getAuthorizeStateValue, selectAuthorizePhase, transitionAuthorizeSnapshot, -} from './authorizeMachine'; +} from '@app/features/auth/components/pages/oauth_authorize_page/state/authorizeMachine'; +import {describe, expect, it} from 'vitest'; describe('authorizeMachine', () => { it('moves from loading into review and through bot invite success', () => { diff --git a/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.bench.ts b/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.bench.ts index e4da68b4f..c259800b5 100644 --- a/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.bench.ts +++ b/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.bench.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getUnreadDividerBeforeMessageId} from '@app/features/channel/components/ChannelMessageStreamUtils'; import type {Message} from '@app/features/messaging/models/MessagingMessage'; import type {ChannelStreamItem} from '@app/features/messaging/utils/MessageGroupingUtils'; import {bench, describe} from 'vitest'; -import {getUnreadDividerBeforeMessageId} from './ChannelMessageStreamUtils'; const GROUP_ITEMS = Array.from( {length: 100}, diff --git a/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.test.ts b/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.test.ts index 322ee93b1..0fd5a2f64 100644 --- a/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.test.ts +++ b/fluxer_app/src/features/channel/components/ChannelMessageStreamUtils.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getUnreadDividerBeforeMessageId} from '@app/features/channel/components/ChannelMessageStreamUtils'; import type {Message} from '@app/features/messaging/models/MessagingMessage'; import type {ChannelStreamItem} from '@app/features/messaging/utils/MessageGroupingUtils'; import {describe, expect, it} from 'vitest'; -import {getUnreadDividerBeforeMessageId} from './ChannelMessageStreamUtils'; function item(messageId: string, showUnreadDividerBefore = false): ChannelStreamItem { return { diff --git a/fluxer_app/src/features/channel/components/MessageAttachmentUtils.bench.ts b/fluxer_app/src/features/channel/components/MessageAttachmentUtils.bench.ts index 7c1cb34da..203102f4c 100644 --- a/fluxer_app/src/features/channel/components/MessageAttachmentUtils.bench.ts +++ b/fluxer_app/src/features/channel/components/MessageAttachmentUtils.bench.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {splitMediaAndFileAttachments} from '@app/features/channel/components/MessageAttachmentUtils'; import type {MessageAttachment} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import {bench, describe} from 'vitest'; -import {splitMediaAndFileAttachments} from './MessageAttachmentUtils'; const CONTENT_TYPES = [ 'image/png', diff --git a/fluxer_app/src/features/channel/components/MessageAttachmentUtils.test.ts b/fluxer_app/src/features/channel/components/MessageAttachmentUtils.test.ts index 90c03ed95..e0bb8a887 100644 --- a/fluxer_app/src/features/channel/components/MessageAttachmentUtils.test.ts +++ b/fluxer_app/src/features/channel/components/MessageAttachmentUtils.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {splitMediaAndFileAttachments} from '@app/features/channel/components/MessageAttachmentUtils'; import type {MessageAttachment} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import {describe, expect, it} from 'vitest'; -import {splitMediaAndFileAttachments} from './MessageAttachmentUtils'; const baseAttachment = { id: 'attachment-1', diff --git a/fluxer_app/src/features/channel/components/SearchResultGrouping.test.ts b/fluxer_app/src/features/channel/components/SearchResultGrouping.test.ts index e47c556cf..d59ceb9f0 100644 --- a/fluxer_app/src/features/channel/components/SearchResultGrouping.test.ts +++ b/fluxer_app/src/features/channel/components/SearchResultGrouping.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {Message} from '@app/features/messaging/models/MessagingMessage'; -import {describe, expect, it} from 'vitest'; import { buildSearchResultGroups, buildSearchResultGroupsByMessageId, countSearchResultChannels, -} from './SearchResultGrouping'; +} from '@app/features/channel/components/SearchResultGrouping'; +import type {Message} from '@app/features/messaging/models/MessagingMessage'; +import {describe, expect, it} from 'vitest'; const message = (id: string, channelId: string): Message => ({id, channelId}) as Message; diff --git a/fluxer_app/src/features/channel/components/SearchResultsUtils.ts b/fluxer_app/src/features/channel/components/SearchResultsUtils.ts index ec42b9fc8..6ebd1ed40 100644 --- a/fluxer_app/src/features/channel/components/SearchResultsUtils.ts +++ b/fluxer_app/src/features/channel/components/SearchResultsUtils.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {SearchMachineState} from '@app/features/channel/components/SearchStateMachine'; import {Channel} from '@app/features/channel/models/Channel'; import {Message} from '@app/features/messaging/models/MessagingMessage'; import type {SearchSegment} from '@app/features/search/utils/SearchSegmentManager'; -import type {SearchMachineState} from './SearchStateMachine'; export type { SearchMachineEvent, @@ -14,7 +14,7 @@ export type { SearchMachineStateIndexing, SearchMachineStateLoading, SearchMachineStateSuccess, -} from './SearchStateMachine'; +} from '@app/features/channel/components/SearchStateMachine'; export const cloneMessageRecord = (message: Message): Message => { return new Message(message.toJSON(), {skipUserCache: true}); diff --git a/fluxer_app/src/features/channel/components/SearchScopeResolution.test.ts b/fluxer_app/src/features/channel/components/SearchScopeResolution.test.ts index 0c6d263eb..2308f5594 100644 --- a/fluxer_app/src/features/channel/components/SearchScopeResolution.test.ts +++ b/fluxer_app/src/features/channel/components/SearchScopeResolution.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {resolveSearchScope} from '@app/features/channel/components/SearchScopeResolution'; import type {MessageSearchScope} from '@app/features/search/utils/SearchUtils'; import {describe, expect, it} from 'vitest'; -import {resolveSearchScope} from './SearchScopeResolution'; const GUILD_SCOPE_OPTIONS = new Set([ 'current', diff --git a/fluxer_app/src/features/channel/components/SearchStateMachine.test.ts b/fluxer_app/src/features/channel/components/SearchStateMachine.test.ts index c624d9d1a..1c0d39e68 100644 --- a/fluxer_app/src/features/channel/components/SearchStateMachine.test.ts +++ b/fluxer_app/src/features/channel/components/SearchStateMachine.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createSearchMachineSnapshot, selectSearchMachineState, transitionSearchMachineSnapshot, -} from './SearchStateMachine'; +} from '@app/features/channel/components/SearchStateMachine'; +import {describe, expect, it} from 'vitest'; describe('SearchStateMachine', () => { it('starts idle and transitions through loading to success', () => { diff --git a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/AccountPremiumMenu.tsx b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/AccountPremiumMenu.tsx index d89516f13..9496bb870 100644 --- a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/AccountPremiumMenu.tsx +++ b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/AccountPremiumMenu.tsx @@ -1,6 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {showChannelErrorModal} from '@app/features/channel/components/alerts/ChannelErrorModalUtils'; +import { + PREMIUM_TYPE_DESCRIPTOR, + UNREAD_GIFT_COUNT_DESCRIPTOR, +} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperOptionLabels'; import { DeveloperOptionCheckbox, DeveloperOptionRadioItems, @@ -9,6 +13,8 @@ import { translateDescriptor, USE_ACTUAL_VALUE_DESCRIPTOR, } from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared'; +import {getPremiumTypeOptions} from '@app/features/channel/components/channel_header_components/developer_tools/OptionPresets'; +import {updateOption} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions'; import { applyPremiumScenarioOption, PREMIUM_SCENARIO_OPTIONS, @@ -28,9 +34,6 @@ import {msg, plural} from '@lingui/core/macro'; import {Trans, useLingui} from '@lingui/react/macro'; import {observer} from 'mobx-react-lite'; import type React from 'react'; -import {PREMIUM_TYPE_DESCRIPTOR, UNREAD_GIFT_COUNT_DESCRIPTOR} from './DeveloperOptionLabels'; -import {getPremiumTypeOptions} from './OptionPresets'; -import {updateOption} from './ResetOptions'; const logger = new Logger('DeveloperToolsContextMenu/AccountPremiumMenu'); const ACCOUNT_STATE_DESCRIPTOR = msg({ diff --git a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/DeveloperOptionLabels.ts b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/DeveloperOptionLabels.ts index 09141f4d4..827d95f90 100644 --- a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/DeveloperOptionLabels.ts +++ b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/DeveloperOptionLabels.ts @@ -13,13 +13,20 @@ import { USE_ACTUAL_VALUE_DESCRIPTOR, USE_DEFAULT_DESCRIPTOR, } from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared'; +import {formatDurationMs} from '@app/features/channel/components/channel_header_components/developer_tools/FormatHelpers'; +import { + getPremiumTypeLabel, + LIFETIME_DESCRIPTOR, +} from '@app/features/channel/components/channel_header_components/developer_tools/OptionPresets'; +import { + DEVELOPER_OPTION_KEYS, + isDeveloperOptionAtDefault, + resetDeveloperOption, +} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions'; import type {DeveloperOptionsState} from '@app/features/devtools/state/DeveloperOptions'; import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions'; import type {I18n, MessageDescriptor} from '@lingui/core'; import {msg} from '@lingui/core/macro'; -import {formatDurationMs} from './FormatHelpers'; -import {getPremiumTypeLabel, LIFETIME_DESCRIPTOR} from './OptionPresets'; -import {DEVELOPER_OPTION_KEYS, isDeveloperOptionAtDefault, resetDeveloperOption} from './ResetOptions'; const ACTIVE_DEVELOPER_OPTION_KEYS = DEVELOPER_OPTION_KEYS.filter((key) => key !== 'premiumScenarioOverride'); export const ATTACHMENT_MOCKS_DESCRIPTOR = msg({ diff --git a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/DeveloperToolsMenuComponents.tsx b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/DeveloperToolsMenuComponents.tsx index eb7fd8231..e6c75841a 100644 --- a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/DeveloperToolsMenuComponents.tsx +++ b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/DeveloperToolsMenuComponents.tsx @@ -7,6 +7,7 @@ import { type RadioMenuOption, translateDescriptor, } from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared'; +import {updateOption} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions'; import type {DeveloperOptionsState} from '@app/features/devtools/state/DeveloperOptions'; import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions'; import * as PremiumCommands from '@app/features/premium/commands/PremiumCommands'; @@ -22,7 +23,6 @@ import {useLingui} from '@lingui/react/macro'; import {CrownIcon} from '@phosphor-icons/react'; import {observer} from 'mobx-react-lite'; import type React from 'react'; -import {updateOption} from './ResetOptions'; interface DeveloperOptionCheckboxProps { optionKey: K; diff --git a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/GeneralOptionsMenu.tsx b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/GeneralOptionsMenu.tsx index 5d1665028..b326b3f9f 100644 --- a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/GeneralOptionsMenu.tsx +++ b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/GeneralOptionsMenu.tsx @@ -1,6 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {translateDescriptor} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared'; +import {updateOption} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions'; import {getToggleGroups, type ToggleGroup} from '@app/features/devtools/components/DeveloperOptionsToggleGroups'; import type {DeveloperOptionsState} from '@app/features/devtools/state/DeveloperOptions'; import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions'; @@ -13,7 +14,6 @@ import {msg} from '@lingui/core/macro'; import {Trans, useLingui} from '@lingui/react/macro'; import {observer} from 'mobx-react-lite'; import type React from 'react'; -import {updateOption} from './ResetOptions'; const MENTION_CONTROLS_DESCRIPTOR = msg({ message: 'Mention controls', diff --git a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/MockingMenu.tsx b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/MockingMenu.tsx index 3a2defa4a..0a28448e4 100644 --- a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/MockingMenu.tsx +++ b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/MockingMenu.tsx @@ -7,6 +7,18 @@ import { DeveloperOptionRadioItems, DeveloperOptionRadioSubmenu, } from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsMenuComponents'; +import { + getCountdownTimerOptions, + getGiftDurationOptions, + getMatureContentChannelGateOptions, + getMatureContentMediaGateOptions, + getRequiredActionModeOptions, + getRequiredActionPhoneStepOptions, + getRequiredActionResendOutcomeOptions, + getRequiredActionTabOptions, + getVerificationBarrierOptions, +} from '@app/features/channel/components/channel_header_components/developer_tools/OptionPresets'; +import {updateOption} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions'; import * as DeveloperOptionsCommands from '@app/features/devtools/commands/DeveloperOptionsCommands'; import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions'; import {remFromPx} from '@app/features/theme/layout/RemFromPx'; @@ -20,18 +32,6 @@ import {Trans, useLingui} from '@lingui/react/macro'; import {PhoneIcon, TrashIcon, UsersIcon} from '@phosphor-icons/react'; import {observer} from 'mobx-react-lite'; import type React from 'react'; -import { - getCountdownTimerOptions, - getGiftDurationOptions, - getMatureContentChannelGateOptions, - getMatureContentMediaGateOptions, - getRequiredActionModeOptions, - getRequiredActionPhoneStepOptions, - getRequiredActionResendOutcomeOptions, - getRequiredActionTabOptions, - getVerificationBarrierOptions, -} from './OptionPresets'; -import {updateOption} from './ResetOptions'; const VERIFICATION_MEMBERSHIP_BARRIERS_DESCRIPTOR = msg({ message: 'Verification & membership barriers', diff --git a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/NagbarsMenu.tsx b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/NagbarsMenu.tsx index 4bdce8397..727dd63f1 100644 --- a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/NagbarsMenu.tsx +++ b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/NagbarsMenu.tsx @@ -1,5 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + getNagbarActionItems, + NAGBAR_OVERRIDES_DESCRIPTOR, +} from '@app/features/channel/components/channel_header_components/developer_tools/NagbarControls'; import {getNagbarControls, type NagbarControlDefinition} from '@app/features/devtools/components/NagbarControls'; import {remFromPx} from '@app/features/theme/layout/RemFromPx'; import {MenuItem} from '@app/features/ui/action_menu/MenuItem'; @@ -10,7 +14,6 @@ import {Trans, useLingui} from '@lingui/react/macro'; import {TrashIcon} from '@phosphor-icons/react'; import {observer} from 'mobx-react-lite'; import type React from 'react'; -import {getNagbarActionItems, NAGBAR_OVERRIDES_DESCRIPTOR} from './NagbarControls'; const NagbarOverrideSubmenu: React.FC<{control: NagbarControlDefinition}> = observer(({control}) => { const {i18n} = useLingui(); diff --git a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/OptionPresets.ts b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/OptionPresets.ts index 0bd3a0efc..75c3b6a78 100644 --- a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/OptionPresets.ts +++ b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/OptionPresets.ts @@ -5,12 +5,15 @@ import { type RadioMenuOption, USE_ACTUAL_VALUE_DESCRIPTOR, } from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared'; +import { + formatDurationMs, + NO_TIMER_DESCRIPTOR, +} from '@app/features/channel/components/channel_header_components/developer_tools/FormatHelpers'; import type {DeveloperOptionsState} from '@app/features/devtools/state/DeveloperOptions'; import {EMAIL_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; import {UserPremiumTypes} from '@fluxer/constants/src/UserConstants'; import type {I18n} from '@lingui/core'; import {msg} from '@lingui/core/macro'; -import {formatDurationMs, NO_TIMER_DESCRIPTOR} from './FormatHelpers'; export const SUBSCRIPTION_DESCRIPTOR = msg({ message: 'Subscription', diff --git a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/StateSummaryMenu.tsx b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/StateSummaryMenu.tsx index af91bc79d..8326c38a0 100644 --- a/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/StateSummaryMenu.tsx +++ b/fluxer_app/src/features/channel/components/channel_header_components/developer_tools/StateSummaryMenu.tsx @@ -1,5 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getActiveDeveloperOptionEntries} from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperOptionLabels'; import { ActiveOverrideMenuGroup, BackendPremiumOverrideMenuGroup, @@ -10,6 +11,8 @@ import { humanizeDeveloperStateKey, nonEmptyText, } from '@app/features/channel/components/channel_header_components/developer_tools/DeveloperToolsShared'; +import {setNagbarUseActual} from '@app/features/channel/components/channel_header_components/developer_tools/NagbarControls'; +import {resetAllDeveloperOptions} from '@app/features/channel/components/channel_header_components/developer_tools/ResetOptions'; import {getNagbarControls} from '@app/features/devtools/components/NagbarControls'; import * as PremiumCommands from '@app/features/premium/commands/PremiumCommands'; import {remFromPx} from '@app/features/theme/layout/RemFromPx'; @@ -24,9 +27,6 @@ import {Trans, useLingui} from '@lingui/react/macro'; import {BellRingingIcon, TrashIcon, WarningCircleIcon} from '@phosphor-icons/react'; import {observer} from 'mobx-react-lite'; import type React from 'react'; -import {getActiveDeveloperOptionEntries} from './DeveloperOptionLabels'; -import {setNagbarUseActual} from './NagbarControls'; -import {resetAllDeveloperOptions} from './ResetOptions'; const NO_ACTIVE_OVERRIDES_DESCRIPTOR = msg({ message: 'No active overrides', diff --git a/fluxer_app/src/features/channel/components/embeds/attachments/CsvAttachmentPreviewUtils.test.ts b/fluxer_app/src/features/channel/components/embeds/attachments/CsvAttachmentPreviewUtils.test.ts index 78bfbf2f1..d422b1a57 100644 --- a/fluxer_app/src/features/channel/components/embeds/attachments/CsvAttachmentPreviewUtils.test.ts +++ b/fluxer_app/src/features/channel/components/embeds/attachments/CsvAttachmentPreviewUtils.test.ts @@ -1,9 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + buildCsvTableNode, + isCsvAttachment, + parseCsvRows, +} from '@app/features/channel/components/embeds/attachments/CsvAttachmentPreviewUtils'; import {TableAlignment} from '@app/features/messaging/utils/markdown/parser/Enums'; import type {MessageAttachment} from '@fluxer/schema/src/domains/message/MessageResponseSchemas'; import {describe, expect, it} from 'vitest'; -import {buildCsvTableNode, isCsvAttachment, parseCsvRows} from './CsvAttachmentPreviewUtils'; function attachmentFixture(fields: Partial): MessageAttachment { return fields as MessageAttachment; diff --git a/fluxer_app/src/features/channel/components/embeds/media/VideoDimensionUtils.test.ts b/fluxer_app/src/features/channel/components/embeds/media/VideoDimensionUtils.test.ts index 06e0c6d5e..63bc5cda3 100644 --- a/fluxer_app/src/features/channel/components/embeds/media/VideoDimensionUtils.test.ts +++ b/fluxer_app/src/features/channel/components/embeds/media/VideoDimensionUtils.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { getEffectiveVideoLayoutDimensions, hasDifferentAspectRatio, isInlinePlayableVideoSize, resolveVideoLayout, -} from './VideoDimensionUtils'; +} from '@app/features/channel/components/embeds/media/VideoDimensionUtils'; +import {describe, expect, it} from 'vitest'; describe('getEffectiveVideoLayoutDimensions', () => { it('prefers decoded dimensions over declared upload dimensions', () => { diff --git a/fluxer_app/src/features/channel/components/pickers/gif/FavoriteGifSlimming.test.ts b/fluxer_app/src/features/channel/components/pickers/gif/FavoriteGifSlimming.test.ts index 5dc551237..4fd3fe6d6 100644 --- a/fluxer_app/src/features/channel/components/pickers/gif/FavoriteGifSlimming.test.ts +++ b/fluxer_app/src/features/channel/components/pickers/gif/FavoriteGifSlimming.test.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + type FavoriteGifEntry, + slimFavoriteGifEntry, +} from '@app/features/channel/components/pickers/gif/FavoriteGifTypes'; import {describe, expect, it} from 'vitest'; -import {type FavoriteGifEntry, slimFavoriteGifEntry} from './FavoriteGifTypes'; function format(src: string, width: number) { return {src, proxy_src: `https://media.test/external/sig/${src}`, width, height: Math.round(width * 0.84)}; diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.bench.ts b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.bench.ts index 2076b6638..cb6a9eea4 100644 --- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.bench.ts +++ b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.bench.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {buildGifPickerGridData} from '@app/features/channel/components/pickers/gif/GifPickerGridData'; import {bench, describe} from 'vitest'; -import {buildGifPickerGridData} from './GifPickerGridData'; function gif(index: number, width = 200 + (index % 80), height = 120 + (index % 160)) { return { diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.test.ts b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.test.ts index 42f1f550c..4654388f9 100644 --- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.test.ts +++ b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerGridData.test.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {FavoriteGifEntry} from '@app/features/channel/components/pickers/gif/FavoriteGifTypes'; +import {buildGifPickerGridData} from '@app/features/channel/components/pickers/gif/GifPickerGridData'; +import type {FavoriteAwareGif} from '@app/features/channel/components/pickers/gif/GifPickerTypes'; import {describe, expect, it} from 'vitest'; -import type {FavoriteGifEntry} from './FavoriteGifTypes'; -import {buildGifPickerGridData} from './GifPickerGridData'; -import type {FavoriteAwareGif} from './GifPickerTypes'; function gif(id: string, width = 200, height = 120): FavoriteAwareGif { return { diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGrid.tsx b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGrid.tsx index 186db1be1..c765bb5a5 100644 --- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGrid.tsx +++ b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGrid.tsx @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import styles from '@app/features/channel/components/GifPicker.module.css'; +import {buildGifPickerLoadingSkeletonLayout} from '@app/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout'; import {motion, useReducedMotion} from 'framer-motion'; import {useLayoutEffect, useMemo, useRef, useState} from 'react'; -import {buildGifPickerLoadingSkeletonLayout} from './GifPickerLoadingSkeletonGridLayout'; interface SkeletonViewportSize { width: number; diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.bench.ts b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.bench.ts index 6caa1e58f..a310b0421 100644 --- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.bench.ts +++ b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.bench.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {buildGifPickerLoadingSkeletonLayout} from '@app/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout'; import {bench, describe} from 'vitest'; -import {buildGifPickerLoadingSkeletonLayout} from './GifPickerLoadingSkeletonGridLayout'; const VIEWPORTS = [ {viewportWidth: 360, viewportHeight: 480}, diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.test.ts b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.test.ts index 266e93ba6..5d168d581 100644 --- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.test.ts +++ b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {buildGifPickerLoadingSkeletonLayout} from '@app/features/channel/components/pickers/gif/GifPickerLoadingSkeletonGridLayout'; import {describe, expect, it} from 'vitest'; -import {buildGifPickerLoadingSkeletonLayout} from './GifPickerLoadingSkeletonGridLayout'; describe('buildGifPickerLoadingSkeletonLayout', () => { it('lays out GIF-like placeholders with the same masonry constraints as the real grid', () => { diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerMediaKind.test.ts b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerMediaKind.test.ts index f68507860..492e7e177 100644 --- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerMediaKind.test.ts +++ b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerMediaKind.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {resolvesToVideo} from '@app/features/channel/components/pickers/gif/GifPickerMediaKind'; import {describe, expect, it} from 'vitest'; -import {resolvesToVideo} from './GifPickerMediaKind'; const OPAQUE_PROXY_SRC = 'https://media.test/external/sig/v2/aHR0cHM6Ly9zdGF0aWMua2xpcHkuY29tL2lpLzhjLzZhL2E4LzVsU2U1SFBCLndlYm0'; diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.bench.ts b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.bench.ts index d7cfaf34c..b1e561a9b 100644 --- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.bench.ts +++ b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.bench.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {bench, describe} from 'vitest'; import { createGifPickerRequestId, createGifPickerSnapshot, selectGifPickerModel, transitionGifPickerSnapshot, -} from './GifPickerStateMachine'; +} from '@app/features/channel/components/pickers/gif/GifPickerStateMachine'; +import {bench, describe} from 'vitest'; const SEARCH_TERMS = Array.from({length: 1_000}, (_, index) => `query-${index}`); diff --git a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.test.ts b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.test.ts index 9b5652ab0..ec9e1b74a 100644 --- a/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.test.ts +++ b/fluxer_app/src/features/channel/components/pickers/gif/GifPickerStateMachine.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createGifPickerRequestId, createGifPickerSnapshot, selectGifPickerModel, transitionGifPickerSnapshot, -} from './GifPickerStateMachine'; +} from '@app/features/channel/components/pickers/gif/GifPickerStateMachine'; +import {describe, expect, it} from 'vitest'; describe('GifPickerStateMachine', () => { it('starts on the featured surface without showing a loading state', () => { diff --git a/fluxer_app/src/features/channel/utils/ChannelSearchPolling.test.ts b/fluxer_app/src/features/channel/utils/ChannelSearchPolling.test.ts index fd7e9ba84..ede42ae13 100644 --- a/fluxer_app/src/features/channel/utils/ChannelSearchPolling.test.ts +++ b/fluxer_app/src/features/channel/utils/ChannelSearchPolling.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { CHANNEL_SEARCH_INDEXING_INITIAL_POLL_INTERVAL_MS, CHANNEL_SEARCH_INDEXING_MAX_POLL_INTERVAL_MS, getChannelSearchIndexingPollInterval, -} from './ChannelSearchPolling'; +} from '@app/features/channel/utils/ChannelSearchPolling'; +import {describe, expect, it} from 'vitest'; describe('getChannelSearchIndexingPollInterval', () => { it('starts with a short retry interval for newly indexing channels', () => { diff --git a/fluxer_app/src/features/discovery/state/Discovery.test.ts b/fluxer_app/src/features/discovery/state/Discovery.test.ts index 40c3cb728..33ed6b121 100644 --- a/fluxer_app/src/features/discovery/state/Discovery.test.ts +++ b/fluxer_app/src/features/discovery/state/Discovery.test.ts @@ -2,10 +2,9 @@ import type {DiscoveryGuild, DiscoverySearchResponse} from '@app/features/discovery/commands/DiscoveryCommands'; import * as DiscoveryCommands from '@app/features/discovery/commands/DiscoveryCommands'; +import Discovery from '@app/features/discovery/state/Discovery'; import {beforeEach, describe, expect, test, vi} from 'vitest'; -import Discovery from './Discovery'; - vi.mock('@app/features/discovery/commands/DiscoveryCommands', () => ({ searchGuilds: vi.fn(), getCategories: vi.fn(), diff --git a/fluxer_app/src/features/emoji/state/EmojiSearchIndex.bench.ts b/fluxer_app/src/features/emoji/state/EmojiSearchIndex.bench.ts index 9bae1217c..8381a63eb 100644 --- a/fluxer_app/src/features/emoji/state/EmojiSearchIndex.bench.ts +++ b/fluxer_app/src/features/emoji/state/EmojiSearchIndex.bench.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createEmojiSearchIndex} from '@app/features/emoji/state/EmojiSearchIndex'; import type {FlatEmoji} from '@app/features/emoji/types/EmojiTypes'; import {bench, describe} from 'vitest'; -import {createEmojiSearchIndex} from './EmojiSearchIndex'; const EMOJI_COUNT = 20_000; const QUERY_COUNT = 1_000; diff --git a/fluxer_app/src/features/emoji/state/EmojiSearchIndex.test.ts b/fluxer_app/src/features/emoji/state/EmojiSearchIndex.test.ts index e3c217277..6e0006d32 100644 --- a/fluxer_app/src/features/emoji/state/EmojiSearchIndex.test.ts +++ b/fluxer_app/src/features/emoji/state/EmojiSearchIndex.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createEmojiSearchIndex} from '@app/features/emoji/state/EmojiSearchIndex'; import type {FlatEmoji} from '@app/features/emoji/types/EmojiTypes'; import {describe, expect, test} from 'vitest'; -import {createEmojiSearchIndex} from './EmojiSearchIndex'; function emoji(name: string, options: Partial = {}): FlatEmoji { return { diff --git a/fluxer_app/src/features/expressions/utils/AssetImageGeometry.test.ts b/fluxer_app/src/features/expressions/utils/AssetImageGeometry.test.ts index ba72f81e2..64b4f4026 100644 --- a/fluxer_app/src/features/expressions/utils/AssetImageGeometry.test.ts +++ b/fluxer_app/src/features/expressions/utils/AssetImageGeometry.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { clampWideAssetAspectRatio, getAspectRatioRange, isAspectRatioInRange, isOriginalImageWithinAssetBounds, WIDE_ASSET_ASPECT_RATIO_RANGE, -} from './AssetImageGeometry'; +} from '@app/features/expressions/utils/AssetImageGeometry'; +import {describe, expect, it} from 'vitest'; describe('AssetImageGeometry', () => { it('builds the flexible wide asset range from the crop height limits', () => { diff --git a/fluxer_app/src/features/expressions/utils/ImageCropUtils.ts b/fluxer_app/src/features/expressions/utils/ImageCropUtils.ts index 103d5b6b2..65cc44d96 100644 --- a/fluxer_app/src/features/expressions/utils/ImageCropUtils.ts +++ b/fluxer_app/src/features/expressions/utils/ImageCropUtils.ts @@ -1,8 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isAnimatedFile} from '@app/features/expressions/utils/AnimatedImageUtils'; +import { + isSvgFile, + readBlobAsBase64NoPrefix, + readImageFileAsUploadDataUrl, +} from '@app/features/expressions/utils/ImageUploadFileUtils'; import {EMOJI_MAX_SIZE, STICKER_MAX_SIZE} from '@fluxer/constants/src/LimitConstants'; -import {isAnimatedFile} from './AnimatedImageUtils'; -import {isSvgFile, readBlobAsBase64NoPrefix, readImageFileAsUploadDataUrl} from './ImageUploadFileUtils'; const EMOJI_MAX_SIZE_FALLBACK = EMOJI_MAX_SIZE; const STICKER_MAX_SIZE_FALLBACK = STICKER_MAX_SIZE; diff --git a/fluxer_app/src/features/expressions/utils/ImageUploadFileUtils.test.ts b/fluxer_app/src/features/expressions/utils/ImageUploadFileUtils.test.ts index 1c88d63dc..593ac9c25 100644 --- a/fluxer_app/src/features/expressions/utils/ImageUploadFileUtils.test.ts +++ b/fluxer_app/src/features/expressions/utils/ImageUploadFileUtils.test.ts @@ -1,7 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + getImageUploadMimeType, + isSvgFile, + isSvgMimeType, + normalizeImageMimeType, +} from '@app/features/expressions/utils/ImageUploadFileUtils'; import {describe, expect, it} from 'vitest'; -import {getImageUploadMimeType, isSvgFile, isSvgMimeType, normalizeImageMimeType} from './ImageUploadFileUtils'; describe('ImageUploadFileUtils', () => { it('normalizes image MIME type parameters', () => { diff --git a/fluxer_app/src/features/gateway/transport/GuildActivationTarget.test.ts b/fluxer_app/src/features/gateway/transport/GuildActivationTarget.test.ts index b6bbe3263..fa257a27c 100644 --- a/fluxer_app/src/features/gateway/transport/GuildActivationTarget.test.ts +++ b/fluxer_app/src/features/gateway/transport/GuildActivationTarget.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {selectGuildActivationTarget} from '@app/features/gateway/transport/GuildActivationTarget'; import {FAVORITES_GUILD_ID} from '@fluxer/constants/src/AppConstants'; import {describe, expect, it} from 'vitest'; -import {selectGuildActivationTarget} from './GuildActivationTarget'; describe('selectGuildActivationTarget', () => { it('returns the selected guild on a guild route', () => { diff --git a/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleMoveOperation.test.ts b/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleMoveOperation.test.ts index 97e733b2c..823d53447 100644 --- a/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleMoveOperation.test.ts +++ b/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleMoveOperation.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createRoleMovePreview} from '@app/features/guild/components/modals/guild_tabs/RoleMoveOperation'; import type {GuildRole} from '@app/features/guild/models/GuildRole'; import {describe, expect, it} from 'vitest'; -import {createRoleMovePreview} from './RoleMoveOperation'; const guildId = 'guild-1'; diff --git a/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleReorderIntegration.test.ts b/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleReorderIntegration.test.ts index 9ace37788..546cb5318 100644 --- a/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleReorderIntegration.test.ts +++ b/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleReorderIntegration.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GuildRole} from '@app/features/guild/models/GuildRole'; -import {describe, expect, it} from 'vitest'; -import {createRoleMovePreview} from './RoleMoveOperation'; +import {createRoleMovePreview} from '@app/features/guild/components/modals/guild_tabs/RoleMoveOperation'; import { type RoleReorderAccess, type RoleReorderDragItem, type RoleReorderRect, type RoleReorderTarget, selectRoleReorderResolution, -} from './RoleReorderStateMachine'; +} from '@app/features/guild/components/modals/guild_tabs/RoleReorderStateMachine'; +import type {GuildRole} from '@app/features/guild/models/GuildRole'; +import {describe, expect, it} from 'vitest'; const guildId = 'guild-1'; const rect: RoleReorderRect = { diff --git a/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleReorderStateMachine.test.ts b/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleReorderStateMachine.test.ts index 62c939765..e854c26d4 100644 --- a/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleReorderStateMachine.test.ts +++ b/fluxer_app/src/features/guild/components/modals/guild_tabs/RoleReorderStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { canRoleDropOnTarget, createRoleReorderSnapshot, @@ -12,7 +11,8 @@ import { resolveRoleReorderHover, selectRoleReorderIntent, transitionRoleReorderSnapshot, -} from './RoleReorderStateMachine'; +} from '@app/features/guild/components/modals/guild_tabs/RoleReorderStateMachine'; +import {describe, expect, it} from 'vitest'; const rect: RoleReorderRect = { top: 20, diff --git a/fluxer_app/src/features/guild/state/GuildReadStateContributionMachine.test.ts b/fluxer_app/src/features/guild/state/GuildReadStateContributionMachine.test.ts index ee72e98f3..4b74fe8f5 100644 --- a/fluxer_app/src/features/guild/state/GuildReadStateContributionMachine.test.ts +++ b/fluxer_app/src/features/guild/state/GuildReadStateContributionMachine.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {MessageNotifications} from '@fluxer/constants/src/NotificationConstants'; -import {describe, expect, it} from 'vitest'; import { createGuildReadStateContributionSnapshot, type GuildReadStateContributionInput, resolveGuildReadStateContribution, selectGuildReadStateContribution, transitionGuildReadStateContributionSnapshot, -} from './GuildReadStateContributionMachine'; +} from '@app/features/guild/state/GuildReadStateContributionMachine'; +import {MessageNotifications} from '@fluxer/constants/src/NotificationConstants'; +import {describe, expect, it} from 'vitest'; function input(overrides: Partial = {}): GuildReadStateContributionInput { return { diff --git a/fluxer_app/src/features/guild/utils/GuildModerationCapabilityUtils.test.ts b/fluxer_app/src/features/guild/utils/GuildModerationCapabilityUtils.test.ts index 633616e1f..a07d42fb8 100644 --- a/fluxer_app/src/features/guild/utils/GuildModerationCapabilityUtils.test.ts +++ b/fluxer_app/src/features/guild/utils/GuildModerationCapabilityUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {resolveGuildModerationCapabilities} from '@app/features/guild/utils/GuildModerationCapabilityUtils'; import {describe, expect, it} from 'vitest'; -import {resolveGuildModerationCapabilities} from './GuildModerationCapabilityUtils'; describe('resolveGuildModerationCapabilities', () => { const baseOptions = { diff --git a/fluxer_app/src/features/input/components/KeybindRecorderCapture.test.ts b/fluxer_app/src/features/input/components/KeybindRecorderCapture.test.ts index bf9c57105..33499c0c5 100644 --- a/fluxer_app/src/features/input/components/KeybindRecorderCapture.test.ts +++ b/fluxer_app/src/features/input/components/KeybindRecorderCapture.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {GlobalKeyEvent} from '@app/features/platform/types/Electron'; -import {describe, expect, it} from 'vitest'; import { beginGlobalKeyCapture, type GlobalKeyCaptureApi, globalKeyEventToCombo, isGlobalKeyEventModifierKey, -} from './KeybindRecorderCapture'; +} from '@app/features/input/components/KeybindRecorderCapture'; +import type {GlobalKeyEvent} from '@app/features/platform/types/Electron'; +import {describe, expect, it} from 'vitest'; const keyEvent = (event: Partial): GlobalKeyEvent => ({ type: 'keydown', diff --git a/fluxer_app/src/features/input/state/InputKeybind.ts b/fluxer_app/src/features/input/state/InputKeybind.ts index e68670d2b..e1f43a318 100644 --- a/fluxer_app/src/features/input/state/InputKeybind.ts +++ b/fluxer_app/src/features/input/state/InputKeybind.ts @@ -82,6 +82,16 @@ import { ZOOM_IN_DESCRIPTOR, ZOOM_OUT_DESCRIPTOR, } from '@app/features/input/state/input_keybind/shared'; +import { + getActiveCombosForResolvedAction, + getDisplayKeybindForResolvedAction, +} from '@app/features/input/state/KeybindResolution'; +import { + DEFAULT_KEYBOARD_SHORTCUTS_OVERLAY_COMBO, + getKeyboardShortcutsOverlayComboForCurrentLayout, + keyCombosEqual, + SHIFTED_SLASH_FALLBACK_KEYBOARD_SHORTCUTS_OVERLAY_COMBO, +} from '@app/features/input/utils/KeyboardShortcutLayoutUtils'; import AppStorage from '@app/features/platform/state/PersistentStorage'; import {awaitHydration, makePersistent} from '@app/features/platform/utils/MobXPersistence'; import {makeSyncedField} from '@app/features/user/state/SyncedField'; @@ -97,13 +107,6 @@ import { } from '@fluxer/schema/src/gen/fluxer/user/preferences/v1/preferences_pb'; import type {I18n} from '@lingui/core'; import {makeAutoObservable, runInAction} from 'mobx'; -import { - DEFAULT_KEYBOARD_SHORTCUTS_OVERLAY_COMBO, - getKeyboardShortcutsOverlayComboForCurrentLayout, - keyCombosEqual, - SHIFTED_SLASH_FALLBACK_KEYBOARD_SHORTCUTS_OVERLAY_COMBO, -} from '../utils/KeyboardShortcutLayoutUtils'; -import {getActiveCombosForResolvedAction, getDisplayKeybindForResolvedAction} from './KeybindResolution'; const KEYBIND_STORE_NAME = 'Keybind'; const KEYBIND_COMMAND_VALUES = [ diff --git a/fluxer_app/src/features/input/state/KeybindResolution.test.ts b/fluxer_app/src/features/input/state/KeybindResolution.test.ts index 8d71223d3..e31066f1a 100644 --- a/fluxer_app/src/features/input/state/KeybindResolution.test.ts +++ b/fluxer_app/src/features/input/state/KeybindResolution.test.ts @@ -1,8 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {CustomKeybindEntry, KeybindCommand, KeybindConfig, KeyCombo} from '@app/features/input/state/InputKeybind'; +import { + getActiveCombosForResolvedAction, + getDisplayKeybindForResolvedAction, +} from '@app/features/input/state/KeybindResolution'; import {describe, expect, it} from 'vitest'; -import type {CustomKeybindEntry, KeybindCommand, KeybindConfig, KeyCombo} from './InputKeybind'; -import {getActiveCombosForResolvedAction, getDisplayKeybindForResolvedAction} from './KeybindResolution'; const action: KeybindCommand = 'voice_toggle_deafen'; const keybind = (combo: KeyCombo, overrides: Partial = {}): KeybindConfig => ({ diff --git a/fluxer_app/src/features/input/state/KeybindResolution.ts b/fluxer_app/src/features/input/state/KeybindResolution.ts index 2755e1ff0..4361256e2 100644 --- a/fluxer_app/src/features/input/state/KeybindResolution.ts +++ b/fluxer_app/src/features/input/state/KeybindResolution.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {CustomKeybindEntry, KeybindConfig, KeyCombo} from './InputKeybind'; +import type {CustomKeybindEntry, KeybindConfig, KeyCombo} from '@app/features/input/state/InputKeybind'; export const keyComboHasTriggerInput = (combo: KeyCombo): boolean => (combo.key ?? '') !== '' || (combo.code ?? '') !== '' || combo.mouseButton != null || combo.gamepadButton != null; diff --git a/fluxer_app/src/features/lexical/composer/LexicalRichInput.tsx b/fluxer_app/src/features/lexical/composer/LexicalRichInput.tsx index 06b3a00c6..ba8d75800 100644 --- a/fluxer_app/src/features/lexical/composer/LexicalRichInput.tsx +++ b/fluxer_app/src/features/lexical/composer/LexicalRichInput.tsx @@ -12,7 +12,6 @@ import type {MentionSegment} from '@app/features/messaging/utils/TextareaSegment import {resolveTypedEmojiToken} from '@app/features/messaging/utils/TypedEmojiShortcodeUtils'; import {flxElementClassName} from '@app/lib/react'; import type {I18n} from '@lingui/core'; - import type React from 'react'; import {useCallback, useId, useImperativeHandle, useRef, useState} from 'react'; diff --git a/fluxer_app/src/features/member/state/MemberListViewportStateMachine.test.ts b/fluxer_app/src/features/member/state/MemberListViewportStateMachine.test.ts index 76df6492d..d60ca847f 100644 --- a/fluxer_app/src/features/member/state/MemberListViewportStateMachine.test.ts +++ b/fluxer_app/src/features/member/state/MemberListViewportStateMachine.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {MEMBER_LIST_RANGE_MAX_END} from '@fluxer/constants/src/GatewayConstants'; -import {describe, expect, it} from 'vitest'; import { createMemberListViewportSnapshot, getMemberListViewportStateValue, resolveMemberListViewportModel, selectMemberListViewportModel, transitionMemberListViewportSnapshot, -} from './MemberListViewportStateMachine'; +} from '@app/features/member/state/MemberListViewportStateMachine'; +import {MEMBER_LIST_RANGE_MAX_END} from '@fluxer/constants/src/GatewayConstants'; +import {describe, expect, it} from 'vitest'; const INITIAL_RANGE: Array<[number, number]> = [[0, 99]]; diff --git a/fluxer_app/src/features/member/utils/MemberListRangeUtils.bench.ts b/fluxer_app/src/features/member/utils/MemberListRangeUtils.bench.ts index ee4a6faa1..3867f1fad 100644 --- a/fluxer_app/src/features/member/utils/MemberListRangeUtils.bench.ts +++ b/fluxer_app/src/features/member/utils/MemberListRangeUtils.bench.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {bench, describe} from 'vitest'; import { areMemberListRangesCovered, areMemberListRangesEqual, @@ -9,7 +8,8 @@ import { buildMemberListRangeWindow, buildMemberListRenderWindow, normalizeMemberListRanges, -} from './MemberListRangeUtils'; +} from '@app/features/member/utils/MemberListRangeUtils'; +import {bench, describe} from 'vitest'; const ROW_HEIGHT = 44; const VIEWPORT_HEIGHT = ROW_HEIGHT * 18; diff --git a/fluxer_app/src/features/member/utils/MemberListRangeUtils.test.ts b/fluxer_app/src/features/member/utils/MemberListRangeUtils.test.ts index b5c03dd91..25c6a9d54 100644 --- a/fluxer_app/src/features/member/utils/MemberListRangeUtils.test.ts +++ b/fluxer_app/src/features/member/utils/MemberListRangeUtils.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {MEMBER_LIST_RANGE_MAX_SPAN} from '@fluxer/constants/src/GatewayConstants'; -import {describe, expect, it} from 'vitest'; import { areMemberListRangesCovered, areMemberListRangesEqual, @@ -10,7 +8,9 @@ import { buildMemberListRangeWindow, buildMemberListRenderWindow, normalizeMemberListRanges, -} from './MemberListRangeUtils'; +} from '@app/features/member/utils/MemberListRangeUtils'; +import {MEMBER_LIST_RANGE_MAX_SPAN} from '@fluxer/constants/src/GatewayConstants'; +import {describe, expect, it} from 'vitest'; describe('MemberListRangeUtils', () => { it('compares ranges after normalization and page splitting', () => { diff --git a/fluxer_app/src/features/messaging/commands/MessageFetchStateMachine.test.ts b/fluxer_app/src/features/messaging/commands/MessageFetchStateMachine.test.ts index 313917791..8fdc2d09c 100644 --- a/fluxer_app/src/features/messaging/commands/MessageFetchStateMachine.test.ts +++ b/fluxer_app/src/features/messaging/commands/MessageFetchStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createMessageFetchExecutionSnapshot, createMessageFetchPreflightSnapshot, @@ -13,7 +12,8 @@ import { selectMessageFetchPreflightDecision, transitionMessageFetchExecutionSnapshot, transitionMessageFetchPreflightSnapshot, -} from './MessageFetchStateMachine'; +} from '@app/features/messaging/commands/MessageFetchStateMachine'; +import {describe, expect, it} from 'vitest'; function preflight(overrides: Partial = {}): MessageFetchPreflightInput { return { diff --git a/fluxer_app/src/features/messaging/commands/MessagePageStateMachine.test.ts b/fluxer_app/src/features/messaging/commands/MessagePageStateMachine.test.ts index 4fe5b9c46..11341142e 100644 --- a/fluxer_app/src/features/messaging/commands/MessagePageStateMachine.test.ts +++ b/fluxer_app/src/features/messaging/commands/MessagePageStateMachine.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createMessagePageStateSnapshot, type MessagePageStateInput, resolveMessagePageState, selectMessagePageState, transitionMessagePageStateSnapshot, -} from './MessagePageStateMachine'; +} from '@app/features/messaging/commands/MessagePageStateMachine'; +import {describe, expect, it} from 'vitest'; function input(overrides: Partial = {}): MessagePageStateInput { return { diff --git a/fluxer_app/src/features/messaging/components/markdown/MarkdownRendering.bench.ts b/fluxer_app/src/features/messaging/components/markdown/MarkdownRendering.bench.ts index a904edad3..57f9ef7a1 100644 --- a/fluxer_app/src/features/messaging/components/markdown/MarkdownRendering.bench.ts +++ b/fluxer_app/src/features/messaging/components/markdown/MarkdownRendering.bench.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {MarkdownParseOptions} from '@app/features/messaging/components/markdown/renderers/RendererTypes'; +import {MarkdownContext} from '@app/features/messaging/components/markdown/renderers/RendererTypes'; import {parseMarkdownContent as parse} from '@app/features/messaging/utils/markdown/MarkdownParseCache'; import type {Node} from '@app/features/messaging/utils/markdown/parser/Nodes'; import {bench, describe} from 'vitest'; -import {MarkdownContext} from './renderers/RendererTypes'; const SIMPLE_CONTENT = 'hello **world** with <@1234567890> and https://fluxer.app'; const RICH_CONTENT = [ diff --git a/fluxer_app/src/features/messaging/components/modals/ForwardModal.test.ts b/fluxer_app/src/features/messaging/components/modals/ForwardModal.test.ts index 7f4b5d05d..65d14546a 100644 --- a/fluxer_app/src/features/messaging/components/modals/ForwardModal.test.ts +++ b/fluxer_app/src/features/messaging/components/modals/ForwardModal.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {shouldNavigateAfterForward} from '@app/features/messaging/components/modals/ForwardModalUtils'; import {describe, expect, it} from 'vitest'; -import {shouldNavigateAfterForward} from './ForwardModalUtils'; describe('ForwardModal', () => { it('navigates only for an unmodified single-destination forward', () => { diff --git a/fluxer_app/src/features/messaging/components/modals/media_modal/MediaRotationMath.test.ts b/fluxer_app/src/features/messaging/components/modals/media_modal/MediaRotationMath.test.ts index 41f388061..bfe78df2e 100644 --- a/fluxer_app/src/features/messaging/components/modals/media_modal/MediaRotationMath.test.ts +++ b/fluxer_app/src/features/messaging/components/modals/media_modal/MediaRotationMath.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { getNearestDefaultRotationDegrees, isDefaultRotationDegrees, @@ -8,7 +7,8 @@ import { normalizeRotationDegrees, rotateAnticlockwiseDegrees, rotateClockwiseDegrees, -} from './MediaRotationMath'; +} from '@app/features/messaging/components/modals/media_modal/MediaRotationMath'; +import {describe, expect, it} from 'vitest'; describe('MediaRotationMath', () => { it('keeps clockwise animation continuous through a full turn', () => { diff --git a/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/PanZoomMath.test.ts b/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/PanZoomMath.test.ts index b88fe3e3d..6f67efcc2 100644 --- a/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/PanZoomMath.test.ts +++ b/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/PanZoomMath.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { clampPanForScale, clampScale, @@ -12,7 +11,8 @@ import { MIN_ZOOM_SCALE, type PanZoomMetrics, TAP_MOVE_THRESHOLD, -} from './PanZoomMath'; +} from '@app/features/messaging/components/modals/media_modal/pan_zoom/PanZoomMath'; +import {describe, expect, it} from 'vitest'; const METRICS: PanZoomMetrics = { viewportWidth: 800, diff --git a/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/PanZoomSurface.tsx b/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/PanZoomSurface.tsx index 1eda2afad..f42099334 100644 --- a/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/PanZoomSurface.tsx +++ b/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/PanZoomSurface.tsx @@ -1,12 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import styles from '@app/features/messaging/components/modals/media_modal/pan_zoom/PanZoomSurface.module.css'; +import { + type PanZoomTransformSnapshot, + type UsePanZoomSurfaceOptions, + usePanZoomSurface, +} from '@app/features/messaging/components/modals/media_modal/pan_zoom/usePanZoomSurface'; import type {ZoomState} from '@app/features/messaging/components/modals/media_modal/shared'; import {clsx} from 'clsx'; import {motion} from 'framer-motion'; import type {CSSProperties, HTMLAttributes, ReactNode} from 'react'; import {forwardRef, memo, useImperativeHandle} from 'react'; -import styles from './PanZoomSurface.module.css'; -import {type PanZoomTransformSnapshot, type UsePanZoomSurfaceOptions, usePanZoomSurface} from './usePanZoomSurface'; export interface PanZoomSurfaceHandle { reset: () => void; diff --git a/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/usePanZoomSurface.ts b/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/usePanZoomSurface.ts index 58478bf2e..6c8b0584c 100644 --- a/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/usePanZoomSurface.ts +++ b/fluxer_app/src/features/messaging/components/modals/media_modal/pan_zoom/usePanZoomSurface.ts @@ -1,11 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ZoomState} from '@app/features/messaging/components/modals/media_modal/shared'; -import {wasPointerDownInside} from '@app/lib/overlay/DismissGuard'; -import type {AnimationPlaybackControls, MotionValue} from 'framer-motion'; -import {animate, useMotionValue, useReducedMotion} from 'framer-motion'; -import type React from 'react'; -import {useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; import { clampPanForScale, clampScale, @@ -22,8 +16,14 @@ import { TAP_MOVE_THRESHOLD, ZOOM_STATE_EPSILON, ZOOM_STEP, -} from './PanZoomMath'; -import {useLatestRef} from './useLatestRef'; +} from '@app/features/messaging/components/modals/media_modal/pan_zoom/PanZoomMath'; +import {useLatestRef} from '@app/features/messaging/components/modals/media_modal/pan_zoom/useLatestRef'; +import type {ZoomState} from '@app/features/messaging/components/modals/media_modal/shared'; +import {wasPointerDownInside} from '@app/lib/overlay/DismissGuard'; +import type {AnimationPlaybackControls, MotionValue} from 'framer-motion'; +import {animate, useMotionValue, useReducedMotion} from 'framer-motion'; +import type React from 'react'; +import {useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; interface PointerRecord extends Point { pointerId: number; diff --git a/fluxer_app/src/features/messaging/state/ChannelIncomingMessageStateMachine.test.ts b/fluxer_app/src/features/messaging/state/ChannelIncomingMessageStateMachine.test.ts index c6a64f858..ce6bf2a5a 100644 --- a/fluxer_app/src/features/messaging/state/ChannelIncomingMessageStateMachine.test.ts +++ b/fluxer_app/src/features/messaging/state/ChannelIncomingMessageStateMachine.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { type ChannelIncomingMessageInput, createChannelIncomingMessageSnapshot, resolveChannelIncomingMessageDecision, selectChannelIncomingMessageDecision, transitionChannelIncomingMessageSnapshot, -} from './ChannelIncomingMessageStateMachine'; +} from '@app/features/messaging/state/ChannelIncomingMessageStateMachine'; +import {describe, expect, it} from 'vitest'; function input(overrides: Partial = {}): ChannelIncomingMessageInput { return { diff --git a/fluxer_app/src/features/messaging/state/ChannelMessagesLoadStateMachine.test.ts b/fluxer_app/src/features/messaging/state/ChannelMessagesLoadStateMachine.test.ts index a5ce15f9c..9d3fbfbd6 100644 --- a/fluxer_app/src/features/messaging/state/ChannelMessagesLoadStateMachine.test.ts +++ b/fluxer_app/src/features/messaging/state/ChannelMessagesLoadStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { type ChannelMessagesLoadInput, type ChannelMessagesWindowInput, @@ -17,7 +16,8 @@ import { selectChannelMessagesWindowStatus, transitionChannelMessagesLoadSnapshot, transitionChannelMessagesWindowSnapshot, -} from './ChannelMessagesLoadStateMachine'; +} from '@app/features/messaging/state/ChannelMessagesLoadStateMachine'; +import {describe, expect, it} from 'vitest'; function input(overrides: Partial = {}): ChannelMessagesLoadInput { return { diff --git a/fluxer_app/src/features/messaging/state/MessageQueueStateMachine.test.ts b/fluxer_app/src/features/messaging/state/MessageQueueStateMachine.test.ts index 8baec44e3..aff972a34 100644 --- a/fluxer_app/src/features/messaging/state/MessageQueueStateMachine.test.ts +++ b/fluxer_app/src/features/messaging/state/MessageQueueStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createMessageLocalSendRateLimitSnapshot, createMessageQueuePayloadRouteSnapshot, @@ -19,7 +18,8 @@ import { transitionMessageQueuePayloadRouteSnapshot, transitionMessageQueueRequestOutcomeSnapshot, transitionMessageQueueSendExecutionSnapshot, -} from './MessageQueueStateMachine'; +} from '@app/features/messaging/state/MessageQueueStateMachine'; +import {describe, expect, it} from 'vitest'; function localLimiter(overrides: Partial = {}): MessageLocalSendRateLimitInput { return { diff --git a/fluxer_app/src/features/messaging/state/ReactionStateMachine.bench.ts b/fluxer_app/src/features/messaging/state/ReactionStateMachine.bench.ts index 9ce2dd020..a11cb7c62 100644 --- a/fluxer_app/src/features/messaging/state/ReactionStateMachine.bench.ts +++ b/fluxer_app/src/features/messaging/state/ReactionStateMachine.bench.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ReactionEmoji} from '@app/features/messaging/utils/ReactionUtils'; -import {bench, describe} from 'vitest'; import { createReactionMachineSnapshot, emptyMap, mapToReactions, transitionReactionSnapshot, -} from './ReactionStateMachine'; +} from '@app/features/messaging/state/ReactionStateMachine'; +import type {ReactionEmoji} from '@app/features/messaging/utils/ReactionUtils'; +import {bench, describe} from 'vitest'; const EMOJIS: Array = Array.from({length: 32}, (_value, index) => ({ id: index % 3 === 0 ? `emoji-${index}` : undefined, diff --git a/fluxer_app/src/features/messaging/state/ReactionStateMachine.test.ts b/fluxer_app/src/features/messaging/state/ReactionStateMachine.test.ts index c93002c09..cc9a1af37 100644 --- a/fluxer_app/src/features/messaging/state/ReactionStateMachine.test.ts +++ b/fluxer_app/src/features/messaging/state/ReactionStateMachine.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ReactionEmoji} from '@app/features/messaging/utils/ReactionUtils'; -import {describe, expect, it} from 'vitest'; import { applyAdd, applyRemove, @@ -21,7 +19,9 @@ import { transitionReactionMap, transitionReactionSnapshot, untrackReactor, -} from './ReactionStateMachine'; +} from '@app/features/messaging/state/ReactionStateMachine'; +import type {ReactionEmoji} from '@app/features/messaging/utils/ReactionUtils'; +import {describe, expect, it} from 'vitest'; const ME = 'me-user-id'; const ALICE = 'alice-id'; diff --git a/fluxer_app/src/features/messaging/utils/ChannelShared.test.ts b/fluxer_app/src/features/messaging/utils/ChannelShared.test.ts index 7b6125a3f..0180c6c77 100644 --- a/fluxer_app/src/features/messaging/utils/ChannelShared.test.ts +++ b/fluxer_app/src/features/messaging/utils/ChannelShared.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {filterViewableChannels, pickDefaultGuildChannelId} from '@app/features/messaging/utils/ChannelShared'; import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; import {describe, expect, it} from 'vitest'; -import {filterViewableChannels, pickDefaultGuildChannelId} from './ChannelShared'; describe('filterViewableChannels', () => { it('excludes link channels from default navigation fallbacks', () => { diff --git a/fluxer_app/src/features/messaging/utils/EmbeddableCodeLinkContent.test.ts b/fluxer_app/src/features/messaging/utils/EmbeddableCodeLinkContent.test.ts index 25ee4bc3c..7e1011751 100644 --- a/fluxer_app/src/features/messaging/utils/EmbeddableCodeLinkContent.test.ts +++ b/fluxer_app/src/features/messaging/utils/EmbeddableCodeLinkContent.test.ts @@ -1,10 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import * as CodeLinkUtils from '@app/features/messaging/utils/CodeLinkUtils'; +import {extractEmbeddableCodeLinkContent} from '@app/features/messaging/utils/EmbeddableCodeLinkContent'; import {describe, expect, it} from 'vitest'; -import {extractEmbeddableCodeLinkContent} from './EmbeddableCodeLinkContent'; - const TEST_LINK_CONFIG: CodeLinkUtils.CodeLinkConfig = { path: 'invite', urlBases: ['https://fluxer.app/invite'], diff --git a/fluxer_app/src/features/messaging/utils/EmbeddableImageTypes.test.ts b/fluxer_app/src/features/messaging/utils/EmbeddableImageTypes.test.ts index 6d64f51c1..32c58ba13 100644 --- a/fluxer_app/src/features/messaging/utils/EmbeddableImageTypes.test.ts +++ b/fluxer_app/src/features/messaging/utils/EmbeddableImageTypes.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isEmbeddableImageFile} from '@app/features/messaging/utils/EmbeddableImageTypes'; import {describe, expect, it} from 'vitest'; -import {isEmbeddableImageFile} from './EmbeddableImageTypes'; describe('isEmbeddableImageFile', () => { it('embeds common raster image mime types', () => { diff --git a/fluxer_app/src/features/messaging/utils/LocalAttachmentPreviewUtils.test.ts b/fluxer_app/src/features/messaging/utils/LocalAttachmentPreviewUtils.test.ts index bad62f5c3..9ee717972 100644 --- a/fluxer_app/src/features/messaging/utils/LocalAttachmentPreviewUtils.test.ts +++ b/fluxer_app/src/features/messaging/utils/LocalAttachmentPreviewUtils.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { getScaledMediaDimensions, hasRenderableLocalPreview, LOCAL_MEDIA_PREVIEW_MAX_BYTES, shouldEagerlyPreviewLocalImage, shouldEagerlyPreviewLocalVideo, -} from './LocalAttachmentPreviewUtils'; +} from '@app/features/messaging/utils/LocalAttachmentPreviewUtils'; +import {describe, expect, it} from 'vitest'; describe('Local attachment preview utils', () => { it('allows eager image previews at or below the local preview size cap', () => { diff --git a/fluxer_app/src/features/messaging/utils/MessageEditContentUtils.test.ts b/fluxer_app/src/features/messaging/utils/MessageEditContentUtils.test.ts index 1e5d4b7f7..69cbe8dd9 100644 --- a/fluxer_app/src/features/messaging/utils/MessageEditContentUtils.test.ts +++ b/fluxer_app/src/features/messaging/utils/MessageEditContentUtils.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import AdvancedSettings from '@app/features/user/state/AdvancedSettings'; -import {afterEach, describe, expect, it} from 'vitest'; import { buildExistingAttachmentEditReferences, canSubmitEmptyMessageEdit, isAttachmentOnlyMessage, -} from './MessageEditContentUtils'; +} from '@app/features/messaging/utils/MessageEditContentUtils'; +import AdvancedSettings from '@app/features/user/state/AdvancedSettings'; +import {afterEach, describe, expect, it} from 'vitest'; describe('Message edit content utils', () => { afterEach(() => { diff --git a/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.bench.ts b/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.bench.ts index a17dc03a8..98863f443 100644 --- a/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.bench.ts +++ b/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.bench.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + calculateAroundPaginationState, + getAroundWindowCounts, +} from '@app/features/messaging/utils/MessagePaginationUtils'; import {bench, describe} from 'vitest'; -import {calculateAroundPaginationState, getAroundWindowCounts} from './MessagePaginationUtils'; const PAGINATION_INPUTS = Array.from({length: 100_000}, (_value, index) => ({ limit: 50 + (index % 25), diff --git a/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.test.ts b/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.test.ts index 416ae455a..3c236fe61 100644 --- a/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.test.ts +++ b/fluxer_app/src/features/messaging/utils/MessagePaginationUtils.test.ts @@ -1,7 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + calculateAroundPaginationState, + getAroundWindowCounts, + mergeAscendingById, +} from '@app/features/messaging/utils/MessagePaginationUtils'; import {describe, expect, it} from 'vitest'; -import {calculateAroundPaginationState, getAroundWindowCounts, mergeAscendingById} from './MessagePaginationUtils'; describe('MessagePaginationUtils', () => { it('splits around windows with the newer side receiving the extra item for even limits', () => { diff --git a/fluxer_app/src/features/messaging/utils/MessageSelectionCopyUtils.test.ts b/fluxer_app/src/features/messaging/utils/MessageSelectionCopyUtils.test.ts index 36ec538d5..d92bef4b1 100644 --- a/fluxer_app/src/features/messaging/utils/MessageSelectionCopyUtils.test.ts +++ b/fluxer_app/src/features/messaging/utils/MessageSelectionCopyUtils.test.ts @@ -1,8 +1,8 @@ // @vitest-environment happy-dom // SPDX-License-Identifier: AGPL-3.0-or-later +import {buildMessageSelectionCopyTextForRange} from '@app/features/messaging/utils/MessageSelectionCopyUtils'; import {afterEach, describe, expect, it} from 'vitest'; -import {buildMessageSelectionCopyTextForRange} from './MessageSelectionCopyUtils'; describe('Message selection copy utils', () => { afterEach(() => { diff --git a/fluxer_app/src/features/messaging/utils/TextareaKeyboardNavigationUtils.test.ts b/fluxer_app/src/features/messaging/utils/TextareaKeyboardNavigationUtils.test.ts index 1dff27fcf..0bc6efbf7 100644 --- a/fluxer_app/src/features/messaging/utils/TextareaKeyboardNavigationUtils.test.ts +++ b/fluxer_app/src/features/messaging/utils/TextareaKeyboardNavigationUtils.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { getPreviousVisualLineCaretPositionFromPoints, getPreviousWordBoundaryAcrossLineStart, -} from './TextareaKeyboardNavigationUtils'; +} from '@app/features/messaging/utils/TextareaKeyboardNavigationUtils'; +import {describe, expect, it} from 'vitest'; describe('TextareaKeyboardNavigationUtils', () => { it('moves a stuck Shift+ArrowUp focus edge to the previous visual row', () => { diff --git a/fluxer_app/src/features/messaging/utils/TextareaSegmentManager.test.ts b/fluxer_app/src/features/messaging/utils/TextareaSegmentManager.test.ts index cc82144d4..803f3871e 100644 --- a/fluxer_app/src/features/messaging/utils/TextareaSegmentManager.test.ts +++ b/fluxer_app/src/features/messaging/utils/TextareaSegmentManager.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {type MentionSegment, TextareaSegmentManager} from '@app/features/messaging/utils/TextareaSegmentManager'; import {describe, expect, it} from 'vitest'; -import {type MentionSegment, TextareaSegmentManager} from './TextareaSegmentManager'; function userSegment(overrides: Partial = {}): MentionSegment { return { diff --git a/fluxer_app/src/features/messaging/utils/markdown/parser/AstUtils.ts b/fluxer_app/src/features/messaging/utils/markdown/parser/AstUtils.ts index 63b962e66..d7cc1e394 100644 --- a/fluxer_app/src/features/messaging/utils/markdown/parser/AstUtils.ts +++ b/fluxer_app/src/features/messaging/utils/markdown/parser/AstUtils.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {NodeType} from './Enums'; +import {NodeType} from '@app/features/messaging/utils/markdown/parser/Enums'; import type { AlertNode, BlockquoteNode, @@ -15,7 +15,7 @@ import type { TableNode, TableRowNode, TextNode, -} from './Nodes'; +} from '@app/features/messaging/utils/markdown/parser/Nodes'; const NT_TEXT = NodeType.Text; const NT_STRONG = NodeType.Strong; diff --git a/fluxer_app/src/features/messaging/utils/markdown/parser/MarkdownParserWasm.ts b/fluxer_app/src/features/messaging/utils/markdown/parser/MarkdownParserWasm.ts index fa3ef1147..a455117a9 100644 --- a/fluxer_app/src/features/messaging/utils/markdown/parser/MarkdownParserWasm.ts +++ b/fluxer_app/src/features/messaging/utils/markdown/parser/MarkdownParserWasm.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {flattenAST} from './AstUtils'; -import {getEmojiParserConfig} from './EmojiParsers'; -import {MARKDOWN_PARSER_WASM_BASE64} from './MarkdownParserWasmBytes'; -import type {Node} from './Nodes'; -import * as StringUtils from './StringUtils'; -import * as URLUtils from './UrlUtils'; +import {flattenAST} from '@app/features/messaging/utils/markdown/parser/AstUtils'; +import {getEmojiParserConfig} from '@app/features/messaging/utils/markdown/parser/EmojiParsers'; +import {MARKDOWN_PARSER_WASM_BASE64} from '@app/features/messaging/utils/markdown/parser/MarkdownParserWasmBytes'; +import type {Node} from '@app/features/messaging/utils/markdown/parser/Nodes'; +import * as StringUtils from '@app/features/messaging/utils/markdown/parser/StringUtils'; +import * as URLUtils from '@app/features/messaging/utils/markdown/parser/UrlUtils'; interface WasmExports { memory: {buffer: ArrayBuffer}; diff --git a/fluxer_app/src/features/messaging/utils/markdown/parser/Nodes.ts b/fluxer_app/src/features/messaging/utils/markdown/parser/Nodes.ts index 73a56910e..06c2172dc 100644 --- a/fluxer_app/src/features/messaging/utils/markdown/parser/Nodes.ts +++ b/fluxer_app/src/features/messaging/utils/markdown/parser/Nodes.ts @@ -1,6 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {AlertType, NodeType, TableAlignment, TimestampStyle} from './Enums'; +import type { + AlertType, + NodeType, + TableAlignment, + TimestampStyle, +} from '@app/features/messaging/utils/markdown/parser/Enums'; interface BaseNode { type: NodeType; diff --git a/fluxer_app/src/features/messaging/utils/markdown/parser/WasmParser.ts b/fluxer_app/src/features/messaging/utils/markdown/parser/WasmParser.ts index ccabadfe3..03a6eacbb 100644 --- a/fluxer_app/src/features/messaging/utils/markdown/parser/WasmParser.ts +++ b/fluxer_app/src/features/messaging/utils/markdown/parser/WasmParser.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {parseMarkdownAstWithWasm} from './MarkdownParserWasm'; -import type {Node} from './Nodes'; +import {parseMarkdownAstWithWasm} from '@app/features/messaging/utils/markdown/parser/MarkdownParserWasm'; +import type {Node} from '@app/features/messaging/utils/markdown/parser/Nodes'; export class WasmParser { private readonly input: string; diff --git a/fluxer_app/src/features/messaging/utils/markdown/parser/WasmParserCompat.ts b/fluxer_app/src/features/messaging/utils/markdown/parser/WasmParserCompat.ts index 0c040ccee..2fc71253f 100644 --- a/fluxer_app/src/features/messaging/utils/markdown/parser/WasmParserCompat.ts +++ b/fluxer_app/src/features/messaging/utils/markdown/parser/WasmParserCompat.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {parseMarkdownAstWithWasm} from './MarkdownParserWasm'; -import type {Node} from './Nodes'; +import {parseMarkdownAstWithWasm} from '@app/features/messaging/utils/markdown/parser/MarkdownParserWasm'; +import type {Node} from '@app/features/messaging/utils/markdown/parser/Nodes'; export class Parser { private readonly input: string; diff --git a/fluxer_app/src/features/moderation/components/report/ReportState.test.ts b/fluxer_app/src/features/moderation/components/report/ReportState.test.ts index 7a24aa6f4..10cf4c58a 100644 --- a/fluxer_app/src/features/moderation/components/report/ReportState.test.ts +++ b/fluxer_app/src/features/moderation/components/report/ReportState.test.ts @@ -1,7 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createReportSnapshot, + selectReportState, + transitionReportSnapshot, +} from '@app/features/moderation/components/report/ReportState'; import {describe, expect, it} from 'vitest'; -import {createReportSnapshot, selectReportState, transitionReportSnapshot} from './ReportState'; describe('ReportState machine', () => { it('moves through the public report flow while preserving context', () => { diff --git a/fluxer_app/src/features/notification/state/NotificationAutoAckStateMachine.test.ts b/fluxer_app/src/features/notification/state/NotificationAutoAckStateMachine.test.ts index 34f1126b1..05ffa86df 100644 --- a/fluxer_app/src/features/notification/state/NotificationAutoAckStateMachine.test.ts +++ b/fluxer_app/src/features/notification/state/NotificationAutoAckStateMachine.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { type AutoAckWindowConditions, createAutoAckWindowSnapshot, selectAutoAckWindowCommands, transitionAutoAckWindowSnapshot, -} from './NotificationAutoAckStateMachine'; +} from '@app/features/notification/state/NotificationAutoAckStateMachine'; +import {describe, expect, it} from 'vitest'; function conditions(overrides: Partial = {}): AutoAckWindowConditions { return { diff --git a/fluxer_app/src/features/notification/utils/AutoAckVisibility.test.ts b/fluxer_app/src/features/notification/utils/AutoAckVisibility.test.ts index d83827da6..6c93a2e19 100644 --- a/fluxer_app/src/features/notification/utils/AutoAckVisibility.test.ts +++ b/fluxer_app/src/features/notification/utils/AutoAckVisibility.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {getGuildVoiceCallExpansionKey} from '@app/features/voice/state/CompactVoiceCallHeight'; -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import {describe, expect, it} from 'vitest'; import { getDirectCallFullscreenScopeKey, isTextChatVisibleForAutoAck, isVoiceCallFullscreenScopeForChannel, -} from './AutoAckVisibility'; +} from '@app/features/notification/utils/AutoAckVisibility'; +import {getGuildVoiceCallExpansionKey} from '@app/features/voice/state/CompactVoiceCallHeight'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; +import {describe, expect, it} from 'vitest'; describe('isTextChatVisibleForAutoAck', () => { it('allows normal text channels to auto-ack when no fullscreen call view is active', () => { diff --git a/fluxer_app/src/features/notification/utils/MentionFeedFilters.test.ts b/fluxer_app/src/features/notification/utils/MentionFeedFilters.test.ts index 5130aadf3..e2f0fc09f 100644 --- a/fluxer_app/src/features/notification/utils/MentionFeedFilters.test.ts +++ b/fluxer_app/src/features/notification/utils/MentionFeedFilters.test.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + type MentionFilters, + messageMatchesMentionTypeFilters, +} from '@app/features/notification/utils/MentionFeedFilters'; import {describe, expect, it} from 'vitest'; -import {type MentionFilters, messageMatchesMentionTypeFilters} from './MentionFeedFilters'; const DIRECT_ONLY = {mention_everyone: false, mention_roles: []}; const EVERYONE_ONLY = {mention_everyone: true, mention_roles: []}; diff --git a/fluxer_app/src/features/platform/notifications/NotificationAlertOptions.test.ts b/fluxer_app/src/features/platform/notifications/NotificationAlertOptions.test.ts index 19019375d..02545738f 100644 --- a/fluxer_app/src/features/platform/notifications/NotificationAlertOptions.test.ts +++ b/fluxer_app/src/features/platform/notifications/NotificationAlertOptions.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { getNotificationAlertOptions, isIOSMobileOrTabletUserAgent, isMobileOrTabletUserAgent, NOTIFICATION_VIBRATION_PATTERN, -} from './NotificationAlertOptions'; +} from '@app/features/platform/notifications/NotificationAlertOptions'; +import {describe, expect, it} from 'vitest'; describe('NotificationAlertOptions', () => { it('uses vibration instead of silent notifications on mobile devices', () => { diff --git a/fluxer_app/src/features/platform/service_worker/WorkerPushPayload.test.ts b/fluxer_app/src/features/platform/service_worker/WorkerPushPayload.test.ts index a99e40c41..c50d32941 100644 --- a/fluxer_app/src/features/platform/service_worker/WorkerPushPayload.test.ts +++ b/fluxer_app/src/features/platform/service_worker/WorkerPushPayload.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { getBadgeCount, getPushNotificationClientState, @@ -10,7 +9,8 @@ import { resolvePushChannelId, resolvePushNotificationTag, shouldSilenceNonMobilePushNotification, -} from './WorkerPushPayload'; +} from '@app/features/platform/service_worker/WorkerPushPayload'; +import {describe, expect, it} from 'vitest'; describe('WorkerPushPayload', () => { it('normalizes encrypted Web Push payloads without losing navigation data', () => { diff --git a/fluxer_app/src/features/platform/state/auth_session/AuthSessionStateMachine.test.ts b/fluxer_app/src/features/platform/state/auth_session/AuthSessionStateMachine.test.ts index 49950b341..52b19df0e 100644 --- a/fluxer_app/src/features/platform/state/auth_session/AuthSessionStateMachine.test.ts +++ b/fluxer_app/src/features/platform/state/auth_session/AuthSessionStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { type Account, createAuthSessionSnapshot, @@ -9,7 +8,8 @@ import { selectAuthSessionAccounts, selectAuthSessionCanSwitch, transitionAuthSessionSnapshot, -} from './AuthSessionStateMachine'; +} from '@app/features/platform/state/auth_session/AuthSessionStateMachine'; +import {describe, expect, it} from 'vitest'; function account(userId: string, lastActive = 1): Account { return { diff --git a/fluxer_app/src/features/platform/utils/ScrollPosition.bench.ts b/fluxer_app/src/features/platform/utils/ScrollPosition.bench.ts index f82660ce3..7c0b8f051 100644 --- a/fluxer_app/src/features/platform/utils/ScrollPosition.bench.ts +++ b/fluxer_app/src/features/platform/utils/ScrollPosition.bench.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {evaluateScrollPinning} from '@app/features/platform/utils/ScrollPosition'; import {bench, describe} from 'vitest'; -import {evaluateScrollPinning} from './ScrollPosition'; const SCROLL_METRICS = Array.from({length: 100_000}, (_value, index) => ({ scrollTop: (index * 37) % 200_000, diff --git a/fluxer_app/src/features/platform/utils/scroll_manager/shared.test.ts b/fluxer_app/src/features/platform/utils/scroll_manager/shared.test.ts index 95f120e87..29f872192 100644 --- a/fluxer_app/src/features/platform/utils/scroll_manager/shared.test.ts +++ b/fluxer_app/src/features/platform/utils/scroll_manager/shared.test.ts @@ -1,9 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; -import {JumpTypes} from '@fluxer/constants/src/JumpConstants'; -import {NEW_MESSAGES_BAR_BUFFER} from '@fluxer/constants/src/LimitConstants'; -import {describe, expect, it} from 'vitest'; import { CENTRE_ALIGNMENT_LIFT, InitialScrollIntent, @@ -12,7 +8,11 @@ import { resolveInitialScrollIntent, type ScrollerState, shouldAnimateMessageJump, -} from './shared'; +} from '@app/features/platform/utils/scroll_manager/shared'; +import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants'; +import {JumpTypes} from '@fluxer/constants/src/JumpConstants'; +import {NEW_MESSAGES_BAR_BUFFER} from '@fluxer/constants/src/LimitConstants'; +import {describe, expect, it} from 'vitest'; describe('the scroll geometry constants', () => { it('lifts a centred node by exactly eight pixels', () => { diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateAckMachine.test.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateAckMachine.test.ts index f93672884..84ef8cb1d 100644 --- a/fluxer_app/src/features/read_state/state/read_states/ReadStateAckMachine.test.ts +++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateAckMachine.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {fromTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; -import {describe, expect, it} from 'vitest'; import { createReadStateAckSnapshot, type ReadStateAckInput, resolveReadStateAckDecision, selectReadStateAckDecision, transitionReadStateAckSnapshot, -} from './ReadStateAckMachine'; +} from '@app/features/read_state/state/read_states/ReadStateAckMachine'; +import {fromTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; +import {describe, expect, it} from 'vitest'; const BASE_TIMESTAMP = Date.UTC(2024, 0, 1); const OLDER_ID = fromTimestamp(BASE_TIMESTAMP + 1000); diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateAckMachine.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateAckMachine.ts index a745c1629..893a1de65 100644 --- a/fluxer_app/src/features/read_state/state/read_states/ReadStateAckMachine.ts +++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateAckMachine.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {compareMessageIds} from '@app/features/read_state/state/read_states/shared'; import {assign, initialTransition, type SnapshotFrom, setup, transition} from 'xstate'; -import {compareMessageIds} from './shared'; export interface ReadStateAckInput { requestedMessageId?: string | null; diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.bench.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.bench.ts index c0ebfddf2..99b6eb372 100644 --- a/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.bench.ts +++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.bench.ts @@ -1,8 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + type ReadStateEntryStatusInput, + resolveReadStateEntryStatus, +} from '@app/features/read_state/state/read_states/ReadStateEntryStatusMachine'; import {fromTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; import {bench, describe} from 'vitest'; -import {type ReadStateEntryStatusInput, resolveReadStateEntryStatus} from './ReadStateEntryStatusMachine'; const BASE_TIMESTAMP = Date.UTC(2024, 0, 1); const ACK_ID = fromTimestamp(BASE_TIMESTAMP + 1_000); diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.test.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.test.ts index ed3afa3e5..db8f0b344 100644 --- a/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.test.ts +++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {fromTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; -import {describe, expect, it} from 'vitest'; import { createReadStateEntryStatusSnapshot, type ReadStateEntryStatusInput, @@ -9,7 +7,9 @@ import { resolveReadStateEntryStatus, selectReadStateEntryStatusModel, transitionReadStateEntryStatusSnapshot, -} from './ReadStateEntryStatusMachine'; +} from '@app/features/read_state/state/read_states/ReadStateEntryStatusMachine'; +import {fromTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; +import {describe, expect, it} from 'vitest'; const BASE_TIMESTAMP = Date.UTC(2024, 0, 1); const ACK_ID = fromTimestamp(BASE_TIMESTAMP + 1000); diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.ts index de2fc7dda..9dd77a886 100644 --- a/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.ts +++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateEntryStatusMachine.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {compareMessageIds} from '@app/features/read_state/state/read_states/shared'; import {assign, initialTransition, type SnapshotFrom, setup, transition} from 'xstate'; -import {compareMessageIds} from './shared'; export interface ReadStateEntryStatusInput { supportsUnreadTracking: boolean; diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateIncomingMessageMachine.test.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateIncomingMessageMachine.test.ts index d778e70cb..aae1a9cd6 100644 --- a/fluxer_app/src/features/read_state/state/read_states/ReadStateIncomingMessageMachine.test.ts +++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateIncomingMessageMachine.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {fromTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; -import {describe, expect, it} from 'vitest'; import { createReadStateIncomingMessageSnapshot, type ReadStateIncomingMessageInput, resolveReadStateIncomingMessageDecision, selectReadStateIncomingMessageDecision, transitionReadStateIncomingMessageSnapshot, -} from './ReadStateIncomingMessageMachine'; +} from '@app/features/read_state/state/read_states/ReadStateIncomingMessageMachine'; +import {fromTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; +import {describe, expect, it} from 'vitest'; const BASE_TIMESTAMP = Date.UTC(2024, 0, 1); const PREVIOUS_ID = fromTimestamp(BASE_TIMESTAMP + 1000); diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateIncomingMessageMachine.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateIncomingMessageMachine.ts index b61b6eb93..e8e136019 100644 --- a/fluxer_app/src/features/read_state/state/read_states/ReadStateIncomingMessageMachine.ts +++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateIncomingMessageMachine.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {compareMessageIds} from '@app/features/read_state/state/read_states/shared'; import {assign, initialTransition, type SnapshotFrom, setup, transition} from 'xstate'; -import {compareMessageIds} from './shared'; export interface ReadStateIncomingMessageInput { isCurrentUserAuthor: boolean; diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateMentionMachine.test.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateMentionMachine.test.ts index 5a6aa4675..0677935dc 100644 --- a/fluxer_app/src/features/read_state/state/read_states/ReadStateMentionMachine.test.ts +++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateMentionMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createReadStateMentionSnapshot, type ReadStateMentionInput, @@ -8,7 +7,8 @@ import { resolveReadStateMention, selectReadStateMentionModel, transitionReadStateMentionSnapshot, -} from './ReadStateMentionMachine'; +} from '@app/features/read_state/state/read_states/ReadStateMentionMachine'; +import {describe, expect, it} from 'vitest'; function input(overrides: Partial = {}): ReadStateMentionInput { return { diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateServerAckMachine.test.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateServerAckMachine.test.ts index c435d51d6..401511c1f 100644 --- a/fluxer_app/src/features/read_state/state/read_states/ReadStateServerAckMachine.test.ts +++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateServerAckMachine.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {fromTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; -import {describe, expect, it} from 'vitest'; import { createReadStateServerAckSnapshot, type ReadStateServerAckInput, resolveReadStateServerAckDecision, selectReadStateServerAckDecision, transitionReadStateServerAckSnapshot, -} from './ReadStateServerAckMachine'; +} from '@app/features/read_state/state/read_states/ReadStateServerAckMachine'; +import {fromTimestamp} from '@fluxer/snowflake/src/SnowflakeUtils'; +import {describe, expect, it} from 'vitest'; const BASE_TIMESTAMP = Date.UTC(2024, 0, 1); const OLDER_ID = fromTimestamp(BASE_TIMESTAMP + 1000); diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateServerAckMachine.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateServerAckMachine.ts index fd206ff77..e67df20c9 100644 --- a/fluxer_app/src/features/read_state/state/read_states/ReadStateServerAckMachine.ts +++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateServerAckMachine.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {compareMessageIds, compareReadStateVersions} from '@app/features/read_state/state/read_states/shared'; import {assign, initialTransition, type SnapshotFrom, setup, transition} from 'xstate'; -import {compareMessageIds, compareReadStateVersions} from './shared'; export interface ReadStateServerAckInput { messageId: string; diff --git a/fluxer_app/src/features/read_state/utils/AutoAckPredicate.test.ts b/fluxer_app/src/features/read_state/utils/AutoAckPredicate.test.ts index da0d9aede..648b44723 100644 --- a/fluxer_app/src/features/read_state/utils/AutoAckPredicate.test.ts +++ b/fluxer_app/src/features/read_state/utils/AutoAckPredicate.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {shouldAutoAck} from '@app/features/read_state/utils/AutoAckPredicate'; import {describe, expect, it} from 'vitest'; -import {shouldAutoAck} from './AutoAckPredicate'; function conditions(overrides: Partial[0]> = {}): Parameters[0] { return { diff --git a/fluxer_app/src/features/theme/layout/MessageLayoutCss.ts b/fluxer_app/src/features/theme/layout/MessageLayoutCss.ts index d6838f7d6..10359500c 100644 --- a/fluxer_app/src/features/theme/layout/MessageLayoutCss.ts +++ b/fluxer_app/src/features/theme/layout/MessageLayoutCss.ts @@ -4,9 +4,12 @@ import { MARKDOWN_BLOCK_ATTRIBUTE, MarkdownBlock, type MarkdownBlockName, -} from '../../messaging/components/markdown/renderers/common/MarkdownBlockAttributes'; -import {COMPACT_MARKDOWN_ATTRIBUTE, COMPACT_MESSAGE_PREFIX_ATTRIBUTE} from './MessageLayoutAttributes'; -import {getMessageLayoutCssVariables} from './MessageLayoutSpec'; +} from '@app/features/messaging/components/markdown/renderers/common/MarkdownBlockAttributes'; +import { + COMPACT_MARKDOWN_ATTRIBUTE, + COMPACT_MESSAGE_PREFIX_ATTRIBUTE, +} from '@app/features/theme/layout/MessageLayoutAttributes'; +import {getMessageLayoutCssVariables} from '@app/features/theme/layout/MessageLayoutSpec'; function renderRule(selector: string, declarations: ReadonlyArray): string { return `${selector} {\n${declarations.map((declaration) => `\t${declaration}`).join('\n')}\n}`; diff --git a/fluxer_app/src/features/theme/utils/HolidayClassUtils.test.ts b/fluxer_app/src/features/theme/utils/HolidayClassUtils.test.ts index 66b5ff18b..40cbbdeda 100644 --- a/fluxer_app/src/features/theme/utils/HolidayClassUtils.test.ts +++ b/fluxer_app/src/features/theme/utils/HolidayClassUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {getActiveHolidaySlugs, millisecondsUntilNextLocalMidnight} from '@app/features/theme/utils/HolidayClassUtils'; import {describe, expect, it} from 'vitest'; -import {getActiveHolidaySlugs, millisecondsUntilNextLocalMidnight} from './HolidayClassUtils'; describe('getActiveHolidaySlugs', () => { it('fires christmas + christmastide on Dec 25', () => { diff --git a/fluxer_app/src/features/theme_studio/ThemeStudio.tsx b/fluxer_app/src/features/theme_studio/ThemeStudio.tsx index e78d5b8bc..3fdd4f34b 100644 --- a/fluxer_app/src/features/theme_studio/ThemeStudio.tsx +++ b/fluxer_app/src/features/theme_studio/ThemeStudio.tsx @@ -5,6 +5,25 @@ import Accessibility from '@app/features/accessibility/state/Accessibility'; import {SETTINGS_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; import Theme from '@app/features/theme/state/Theme'; import ThemeLibrary from '@app/features/theme/state/ThemeLibrary'; +import {AssetsSection} from '@app/features/theme_studio/sections/AssetsSection'; +import {LibrarySection} from '@app/features/theme_studio/sections/LibrarySection'; +import {QuickCssSection} from '@app/features/theme_studio/sections/QuickCssSection'; +import {SettingsSection} from '@app/features/theme_studio/sections/ThemeStudioSettingsSection'; +import {TokensSection} from '@app/features/theme_studio/sections/TokensSection'; +import { + broadcastThemeStudioMessage, + useThemeStudioBroadcast, +} from '@app/features/theme_studio/state/ThemeStudioBroadcast'; +import ThemeStudioState from '@app/features/theme_studio/state/ThemeStudioState'; +import styles from '@app/features/theme_studio/ThemeStudio.module.css'; +import {StudioSidebar, StudioSidebarFooterText, StudioSidebarItem} from '@app/features/theme_studio/ui/StudioSidebar'; +import {StudioToolbar} from '@app/features/theme_studio/ui/StudioToolbar'; +import { + getThemeStudioBaseTheme, + getThemeStudioFallbackDefaultVariables, + pinThemeStudioDefaultVariables, + type ThemeStudioBaseTheme, +} from '@app/features/theme_studio/utils/ThemeStudioPinnedVariables'; import {extractThemeVariableOverrides} from '@app/features/user/components/modals/tabs/appearance_tab/theme/ThemeUtils'; import {ThemeTypes} from '@fluxer/constants/src/UserConstants'; import {msg} from '@lingui/core/macro'; @@ -21,22 +40,6 @@ import {observer} from 'mobx-react-lite'; import type React from 'react'; import type {ReactNode} from 'react'; import {useCallback, useEffect, useMemo, useRef} from 'react'; -import {AssetsSection} from './sections/AssetsSection'; -import {LibrarySection} from './sections/LibrarySection'; -import {QuickCssSection} from './sections/QuickCssSection'; -import {SettingsSection} from './sections/ThemeStudioSettingsSection'; -import {TokensSection} from './sections/TokensSection'; -import {broadcastThemeStudioMessage, useThemeStudioBroadcast} from './state/ThemeStudioBroadcast'; -import ThemeStudioState from './state/ThemeStudioState'; -import styles from './ThemeStudio.module.css'; -import {StudioSidebar, StudioSidebarFooterText, StudioSidebarItem} from './ui/StudioSidebar'; -import {StudioToolbar} from './ui/StudioToolbar'; -import { - getThemeStudioBaseTheme, - getThemeStudioFallbackDefaultVariables, - pinThemeStudioDefaultVariables, - type ThemeStudioBaseTheme, -} from './utils/ThemeStudioPinnedVariables'; const LIBRARY_DESCRIPTOR = msg({ message: 'Library', diff --git a/fluxer_app/src/features/theme_studio/ThemeStudioStandaloneApp.tsx b/fluxer_app/src/features/theme_studio/ThemeStudioStandaloneApp.tsx index da885cc10..2d97c67c0 100644 --- a/fluxer_app/src/features/theme_studio/ThemeStudioStandaloneApp.tsx +++ b/fluxer_app/src/features/theme_studio/ThemeStudioStandaloneApp.tsx @@ -7,6 +7,14 @@ import {useNativePlatform} from '@app/features/app/hooks/useNativePlatform'; import {usePlatformClasses} from '@app/features/app/hooks/usePlatformClasses'; import {Logger} from '@app/features/platform/utils/AppLogger'; import Theme from '@app/features/theme/state/Theme'; +import {THEME_STUDIO_DESCRIPTOR, ThemeStudio} from '@app/features/theme_studio/ThemeStudio'; +import styles from '@app/features/theme_studio/ThemeStudio.module.css'; +import { + getThemeStudioBaseTheme, + getThemeStudioFallbackDefaultVariables, + pinThemeStudioDefaultVariables, + readThemeStudioComputedDefaultVariables, +} from '@app/features/theme_studio/utils/ThemeStudioPinnedVariables'; import FocusRing from '@app/features/ui/focus_ring/FocusRing'; import {Toasts} from '@app/features/ui/toast/Toasts'; import {getElectronAPI} from '@app/features/ui/utils/NativeUtils'; @@ -19,14 +27,6 @@ import {clsx} from 'clsx'; import {observer} from 'mobx-react-lite'; import type React from 'react'; import {useCallback, useEffect, useMemo, useRef, useState} from 'react'; -import {THEME_STUDIO_DESCRIPTOR, ThemeStudio} from './ThemeStudio'; -import styles from './ThemeStudio.module.css'; -import { - getThemeStudioBaseTheme, - getThemeStudioFallbackDefaultVariables, - pinThemeStudioDefaultVariables, - readThemeStudioComputedDefaultVariables, -} from './utils/ThemeStudioPinnedVariables'; const logger = new Logger('ThemeStudioStandaloneApp'); const THEME_STUDIO_POPOUT_KEY = 'fluxer_theme_studio'; diff --git a/fluxer_app/src/features/theme_studio/commands/ThemeStudioCommands.ts b/fluxer_app/src/features/theme_studio/commands/ThemeStudioCommands.ts index 9a0ee7685..385e868d3 100644 --- a/fluxer_app/src/features/theme_studio/commands/ThemeStudioCommands.ts +++ b/fluxer_app/src/features/theme_studio/commands/ThemeStudioCommands.ts @@ -3,9 +3,9 @@ import {Routes} from '@app/app/Routes'; import {Logger} from '@app/features/platform/utils/AppLogger'; import Theme from '@app/features/theme/state/Theme'; +import {broadcastThemeStudioMessage} from '@app/features/theme_studio/state/ThemeStudioBroadcast'; +import ThemeStudioState from '@app/features/theme_studio/state/ThemeStudioState'; import {getElectronAPI} from '@app/features/ui/utils/NativeUtils'; -import {broadcastThemeStudioMessage} from '../state/ThemeStudioBroadcast'; -import ThemeStudioState from '../state/ThemeStudioState'; const logger = new Logger('ThemeStudioCommands'); const POPOUT_WINDOW_NAME = 'fluxer_theme_studio'; diff --git a/fluxer_app/src/features/theme_studio/sections/AssetsSection.tsx b/fluxer_app/src/features/theme_studio/sections/AssetsSection.tsx index 8325d9040..4a42e697c 100644 --- a/fluxer_app/src/features/theme_studio/sections/AssetsSection.tsx +++ b/fluxer_app/src/features/theme_studio/sections/AssetsSection.tsx @@ -3,6 +3,13 @@ import {remFromPx} from '@app/features/theme/layout/RemFromPx'; import ThemeLibrary from '@app/features/theme/state/ThemeLibrary'; import {createThemeAssetReference, createThemeLocalFileReference} from '@app/features/theme/utils/ThemeCssUtils'; +import styles from '@app/features/theme_studio/sections/AssetsSection.module.css'; +import {broadcastThemeStudioMessage} from '@app/features/theme_studio/state/ThemeStudioBroadcast'; +import {StudioButton} from '@app/features/theme_studio/ui/StudioButton'; +import {StudioEmptyState} from '@app/features/theme_studio/ui/StudioEmptyState'; +import {StudioIconButton} from '@app/features/theme_studio/ui/StudioIconButton'; +import {StudioListItem} from '@app/features/theme_studio/ui/StudioListItem'; +import {StudioPanel} from '@app/features/theme_studio/ui/StudioPanel'; import {showThemeStudioErrorModal} from '@app/features/theme_studio/utils/ThemeStudioErrorModalUtils'; import * as ToastCommands from '@app/features/ui/commands/ToastCommands'; import {getElectronAPI, isDesktop} from '@app/features/ui/utils/NativeUtils'; @@ -13,13 +20,6 @@ import {CopyIcon, FilePlusIcon, ImageIcon, TrashIcon, UploadSimpleIcon} from '@p import {observer} from 'mobx-react-lite'; import type React from 'react'; import {useCallback, useRef} from 'react'; -import {broadcastThemeStudioMessage} from '../state/ThemeStudioBroadcast'; -import {StudioButton} from '../ui/StudioButton'; -import {StudioEmptyState} from '../ui/StudioEmptyState'; -import {StudioIconButton} from '../ui/StudioIconButton'; -import {StudioListItem} from '../ui/StudioListItem'; -import {StudioPanel} from '../ui/StudioPanel'; -import styles from './AssetsSection.module.css'; const UPLOADED_OTHER_DESCRIPTOR = msg({ message: 'Uploaded {length, plural, one {# theme asset} other {# theme assets}}.', diff --git a/fluxer_app/src/features/theme_studio/sections/LibrarySection.tsx b/fluxer_app/src/features/theme_studio/sections/LibrarySection.tsx index 67766a4d1..6fb93bd28 100644 --- a/fluxer_app/src/features/theme_studio/sections/LibrarySection.tsx +++ b/fluxer_app/src/features/theme_studio/sections/LibrarySection.tsx @@ -5,7 +5,16 @@ import {CANCEL_DESCRIPTOR, DESCRIPTION_DESCRIPTOR} from '@app/features/i18n/util import {createDefaultLoadableComponent} from '@app/features/platform/components/loadable/LoadableComponent'; import ThemeLibrary from '@app/features/theme/state/ThemeLibrary'; import {upsertThemeCssHeader} from '@app/features/theme/utils/ThemeCssUtils'; +import styles from '@app/features/theme_studio/sections/LibrarySection.module.css'; +import type {QuickCssEditorProps} from '@app/features/theme_studio/sections/QuickCssEditor'; +import {broadcastThemeStudioMessage} from '@app/features/theme_studio/state/ThemeStudioBroadcast'; +import ThemeStudioState from '@app/features/theme_studio/state/ThemeStudioState'; +import {StudioButton} from '@app/features/theme_studio/ui/StudioButton'; +import {StudioEmptyState} from '@app/features/theme_studio/ui/StudioEmptyState'; +import {StudioSearchInput} from '@app/features/theme_studio/ui/StudioSearchInput'; +import {StudioSplit} from '@app/features/theme_studio/ui/StudioSplit'; import {showThemeStudioErrorModal} from '@app/features/theme_studio/utils/ThemeStudioErrorModalUtils'; +import type {ThemeStudioBaseTheme} from '@app/features/theme_studio/utils/ThemeStudioPinnedVariables'; import * as ModalCommands from '@app/features/ui/commands/ModalCommands'; import {modal} from '@app/features/ui/commands/ModalCommands'; import * as ToastCommands from '@app/features/ui/commands/ToastCommands'; @@ -34,15 +43,6 @@ import {clsx} from 'clsx'; import {observer} from 'mobx-react-lite'; import type React from 'react'; import {useCallback, useEffect, useId, useMemo, useRef, useState} from 'react'; -import {broadcastThemeStudioMessage} from '../state/ThemeStudioBroadcast'; -import ThemeStudioState from '../state/ThemeStudioState'; -import {StudioButton} from '../ui/StudioButton'; -import {StudioEmptyState} from '../ui/StudioEmptyState'; -import {StudioSearchInput} from '../ui/StudioSearchInput'; -import {StudioSplit} from '../ui/StudioSplit'; -import type {ThemeStudioBaseTheme} from '../utils/ThemeStudioPinnedVariables'; -import styles from './LibrarySection.module.css'; -import type {QuickCssEditorProps} from './QuickCssEditor'; const THEME_SAVED_DESCRIPTOR = msg({ message: 'Theme saved.', @@ -148,7 +148,7 @@ function LibraryCssEditorLoading() { const LibraryCssEditor = createDefaultLoadableComponent({ displayName: 'LibraryCssEditor', LoadingComponent: LibraryCssEditorLoading, - load: () => import('./QuickCssEditor'), + load: () => import('@app/features/theme_studio/sections/QuickCssEditor'), }); interface LibrarySectionProps { diff --git a/fluxer_app/src/features/theme_studio/sections/QuickCssEditor.tsx b/fluxer_app/src/features/theme_studio/sections/QuickCssEditor.tsx index bbf597262..50dfdc2a1 100644 --- a/fluxer_app/src/features/theme_studio/sections/QuickCssEditor.tsx +++ b/fluxer_app/src/features/theme_studio/sections/QuickCssEditor.tsx @@ -1,6 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import Accessibility from '@app/features/accessibility/state/Accessibility'; +import {getTokenVariableDefinition, TOKEN_GROUPS} from '@app/features/theme_studio/sections/TokenGroups'; +import type {ThemeStudioBaseTheme} from '@app/features/theme_studio/utils/ThemeStudioPinnedVariables'; import type {CompletionContext, CompletionResult} from '@codemirror/autocomplete'; import {indentWithTab} from '@codemirror/commands'; import {css, cssLanguage} from '@codemirror/lang-css'; @@ -12,8 +14,6 @@ import {basicSetup} from 'codemirror'; import {observer} from 'mobx-react-lite'; import type React from 'react'; import {useEffect, useMemo, useRef} from 'react'; -import type {ThemeStudioBaseTheme} from '../utils/ThemeStudioPinnedVariables'; -import {getTokenVariableDefinition, TOKEN_GROUPS} from './TokenGroups'; const themeTokenCompletions = TOKEN_GROUPS.flatMap((group) => group.variables.map((variable) => ({ diff --git a/fluxer_app/src/features/theme_studio/sections/QuickCssSection.tsx b/fluxer_app/src/features/theme_studio/sections/QuickCssSection.tsx index 2d5713023..bf7a7d4f9 100644 --- a/fluxer_app/src/features/theme_studio/sections/QuickCssSection.tsx +++ b/fluxer_app/src/features/theme_studio/sections/QuickCssSection.tsx @@ -6,7 +6,12 @@ import {ConfirmModal} from '@app/features/app/components/dialogs/ConfirmModal'; import {CANCEL_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; import {createDefaultLoadableComponent} from '@app/features/platform/components/loadable/LoadableComponent'; import {ShareThemeModal} from '@app/features/theme/components/modals/ShareThemeModal'; +import type {QuickCssEditorProps} from '@app/features/theme_studio/sections/QuickCssEditor'; +import styles from '@app/features/theme_studio/sections/QuickCssSection.module.css'; +import {broadcastThemeStudioMessage} from '@app/features/theme_studio/state/ThemeStudioBroadcast'; +import {StudioButton} from '@app/features/theme_studio/ui/StudioButton'; import {showThemeStudioErrorModal} from '@app/features/theme_studio/utils/ThemeStudioErrorModalUtils'; +import type {ThemeStudioBaseTheme} from '@app/features/theme_studio/utils/ThemeStudioPinnedVariables'; import * as ModalCommands from '@app/features/ui/commands/ModalCommands'; import {modal} from '@app/features/ui/commands/ModalCommands'; import * as ToastCommands from '@app/features/ui/commands/ToastCommands'; @@ -27,11 +32,6 @@ import { import {observer} from 'mobx-react-lite'; import type React from 'react'; import {useCallback, useEffect, useRef, useState} from 'react'; -import {broadcastThemeStudioMessage} from '../state/ThemeStudioBroadcast'; -import {StudioButton} from '../ui/StudioButton'; -import type {ThemeStudioBaseTheme} from '../utils/ThemeStudioPinnedVariables'; -import type {QuickCssEditorProps} from './QuickCssEditor'; -import styles from './QuickCssSection.module.css'; const QUICK_CSS_REPLACED_FROM_DESCRIPTOR = msg({ message: 'Quick CSS replaced from {fileName}.', @@ -79,7 +79,7 @@ function QuickCssEditorLoading() { const QuickCssEditor = createDefaultLoadableComponent({ displayName: 'QuickCssEditor', LoadingComponent: QuickCssEditorLoading, - load: () => import('./QuickCssEditor'), + load: () => import('@app/features/theme_studio/sections/QuickCssEditor'), }); interface QuickCssSectionProps { diff --git a/fluxer_app/src/features/theme_studio/sections/ThemeStudioSettingsSection.tsx b/fluxer_app/src/features/theme_studio/sections/ThemeStudioSettingsSection.tsx index bbb0a02cb..3cf8c714c 100644 --- a/fluxer_app/src/features/theme_studio/sections/ThemeStudioSettingsSection.tsx +++ b/fluxer_app/src/features/theme_studio/sections/ThemeStudioSettingsSection.tsx @@ -11,6 +11,8 @@ import {remFromPx} from '@app/features/theme/layout/RemFromPx'; import Theme from '@app/features/theme/state/Theme'; import ThemeLibrary from '@app/features/theme/state/ThemeLibrary'; import styles from '@app/features/theme_studio/sections/ThemeStudioSettingsSection.module.css'; +import {broadcastThemeStudioMessage} from '@app/features/theme_studio/state/ThemeStudioBroadcast'; +import {StudioButton} from '@app/features/theme_studio/ui/StudioButton'; import {showThemeStudioErrorModal} from '@app/features/theme_studio/utils/ThemeStudioErrorModalUtils'; import * as ModalCommands from '@app/features/ui/commands/ModalCommands'; import {modal} from '@app/features/ui/commands/ModalCommands'; @@ -30,8 +32,6 @@ import {ArrowCounterClockwiseIcon, ShareNetworkIcon, TrashIcon} from '@phosphor- import {observer} from 'mobx-react-lite'; import type React from 'react'; import {useCallback, useEffect, useState} from 'react'; -import {broadcastThemeStudioMessage} from '../state/ThemeStudioBroadcast'; -import {StudioButton} from '../ui/StudioButton'; const SYNC_CUSTOM_CSS_DESCRIPTOR = msg({ message: 'Sync custom CSS?', diff --git a/fluxer_app/src/features/theme_studio/sections/TokensSection.tsx b/fluxer_app/src/features/theme_studio/sections/TokensSection.tsx index bc746d421..0e7bddc40 100644 --- a/fluxer_app/src/features/theme_studio/sections/TokensSection.tsx +++ b/fluxer_app/src/features/theme_studio/sections/TokensSection.tsx @@ -5,6 +5,20 @@ import Accessibility from '@app/features/accessibility/state/Accessibility'; import {ShareThemeModal} from '@app/features/theme/components/modals/ShareThemeModal'; import {remFromPx} from '@app/features/theme/layout/RemFromPx'; import ThemeLibrary from '@app/features/theme/state/ThemeLibrary'; +import { + DEFAULT_EXPANDED_GROUP_IDS, + getTokenVariableDefinition, + humanizeVariableName, + TOKEN_GROUPS, +} from '@app/features/theme_studio/sections/TokenGroups'; +import styles from '@app/features/theme_studio/sections/TokensSection.module.css'; +import {broadcastThemeStudioMessage} from '@app/features/theme_studio/state/ThemeStudioBroadcast'; +import ThemeStudioState from '@app/features/theme_studio/state/ThemeStudioState'; +import {StudioButton} from '@app/features/theme_studio/ui/StudioButton'; +import {StudioEmptyState} from '@app/features/theme_studio/ui/StudioEmptyState'; +import {StudioSearchInput} from '@app/features/theme_studio/ui/StudioSearchInput'; +import {StudioSection} from '@app/features/theme_studio/ui/StudioSection'; +import {StudioTokenColor, StudioTokenFont, StudioTokenValue} from '@app/features/theme_studio/ui/StudioToken'; import {showThemeStudioErrorModal} from '@app/features/theme_studio/utils/ThemeStudioErrorModalUtils'; import * as ModalCommands from '@app/features/ui/commands/ModalCommands'; import {modal} from '@app/features/ui/commands/ModalCommands'; @@ -19,20 +33,6 @@ import {ArrowCounterClockwiseIcon, ShareNetworkIcon} from '@phosphor-icons/react import {observer} from 'mobx-react-lite'; import type React from 'react'; import {useEffect, useMemo} from 'react'; -import {broadcastThemeStudioMessage} from '../state/ThemeStudioBroadcast'; -import ThemeStudioState from '../state/ThemeStudioState'; -import {StudioButton} from '../ui/StudioButton'; -import {StudioEmptyState} from '../ui/StudioEmptyState'; -import {StudioSearchInput} from '../ui/StudioSearchInput'; -import {StudioSection} from '../ui/StudioSection'; -import {StudioTokenColor, StudioTokenFont, StudioTokenValue} from '../ui/StudioToken'; -import { - DEFAULT_EXPANDED_GROUP_IDS, - getTokenVariableDefinition, - humanizeVariableName, - TOKEN_GROUPS, -} from './TokenGroups'; -import styles from './TokensSection.module.css'; const TOKEN_OVERRIDES_CLEARED_DESCRIPTOR = msg({ message: 'Token overrides cleared.', diff --git a/fluxer_app/src/features/theme_studio/ui/StudioButton.tsx b/fluxer_app/src/features/theme_studio/ui/StudioButton.tsx index 01e0edbc0..7416b4fef 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioButton.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioButton.tsx @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import styles from '@app/features/theme_studio/ui/StudioButton.module.css'; import FocusRing from '@app/features/ui/focus_ring/FocusRing'; import {clsx} from 'clsx'; import {type ButtonHTMLAttributes, forwardRef, type ReactNode} from 'react'; -import styles from './StudioButton.module.css'; type StudioButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger' | 'dangerSolid' | 'successSolid'; diff --git a/fluxer_app/src/features/theme_studio/ui/StudioDivider.tsx b/fluxer_app/src/features/theme_studio/ui/StudioDivider.tsx index 532b0c37e..2f2eb1e42 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioDivider.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioDivider.tsx @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import styles from '@app/features/theme_studio/ui/StudioDivider.module.css'; import {clsx} from 'clsx'; import type React from 'react'; -import styles from './StudioDivider.module.css'; interface StudioDividerProps { orientation?: 'horizontal' | 'vertical'; diff --git a/fluxer_app/src/features/theme_studio/ui/StudioEmptyState.tsx b/fluxer_app/src/features/theme_studio/ui/StudioEmptyState.tsx index 46fcd8415..5bd04b76e 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioEmptyState.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioEmptyState.tsx @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import styles from '@app/features/theme_studio/ui/StudioEmptyState.module.css'; import type React from 'react'; import type {ReactNode} from 'react'; -import styles from './StudioEmptyState.module.css'; interface StudioEmptyStateProps { icon?: ReactNode; diff --git a/fluxer_app/src/features/theme_studio/ui/StudioIconButton.tsx b/fluxer_app/src/features/theme_studio/ui/StudioIconButton.tsx index e0693fbd6..4a1caf94a 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioIconButton.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioIconButton.tsx @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import styles from '@app/features/theme_studio/ui/StudioIconButton.module.css'; import FocusRing from '@app/features/ui/focus_ring/FocusRing'; import {clsx} from 'clsx'; import {type ButtonHTMLAttributes, forwardRef} from 'react'; -import styles from './StudioIconButton.module.css'; interface StudioIconButtonProps extends ButtonHTMLAttributes { compact?: boolean; diff --git a/fluxer_app/src/features/theme_studio/ui/StudioListItem.tsx b/fluxer_app/src/features/theme_studio/ui/StudioListItem.tsx index 732acbd30..0bb3f5c85 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioListItem.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioListItem.tsx @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import styles from '@app/features/theme_studio/ui/StudioListItem.module.css'; import FocusRing from '@app/features/ui/focus_ring/FocusRing'; import {clsx} from 'clsx'; import type React from 'react'; import type {ReactNode} from 'react'; -import styles from './StudioListItem.module.css'; interface StudioListItemProps { leading?: ReactNode; diff --git a/fluxer_app/src/features/theme_studio/ui/StudioPanel.tsx b/fluxer_app/src/features/theme_studio/ui/StudioPanel.tsx index 72e33f0d7..683db1d65 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioPanel.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioPanel.tsx @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import styles from '@app/features/theme_studio/ui/StudioPanel.module.css'; import {clsx} from 'clsx'; import type React from 'react'; import type {ReactNode} from 'react'; -import styles from './StudioPanel.module.css'; interface StudioPanelProps { title?: ReactNode; diff --git a/fluxer_app/src/features/theme_studio/ui/StudioSearchInput.tsx b/fluxer_app/src/features/theme_studio/ui/StudioSearchInput.tsx index ddab5ea12..546fb2816 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioSearchInput.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioSearchInput.tsx @@ -2,12 +2,12 @@ import {CLEAR_SEARCH_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; import {remFromPx} from '@app/features/theme/layout/RemFromPx'; +import styles from '@app/features/theme_studio/ui/StudioSearchInput.module.css'; import {msg} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; import {MagnifyingGlassIcon, XCircleIcon} from '@phosphor-icons/react'; import {clsx} from 'clsx'; import {forwardRef, type InputHTMLAttributes, useImperativeHandle, useRef} from 'react'; -import styles from './StudioSearchInput.module.css'; const SEARCH_DESCRIPTOR = msg({ message: 'Search…', diff --git a/fluxer_app/src/features/theme_studio/ui/StudioSection.tsx b/fluxer_app/src/features/theme_studio/ui/StudioSection.tsx index cbb9629a3..e37d95f8e 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioSection.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioSection.tsx @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {remFromPx} from '@app/features/theme/layout/RemFromPx'; +import styles from '@app/features/theme_studio/ui/StudioSection.module.css'; import FocusRing from '@app/features/ui/focus_ring/FocusRing'; import {CaretRightIcon} from '@phosphor-icons/react'; import {clsx} from 'clsx'; import type React from 'react'; import type {ReactNode} from 'react'; import {useCallback, useId} from 'react'; -import styles from './StudioSection.module.css'; interface StudioSectionProps { title: ReactNode; diff --git a/fluxer_app/src/features/theme_studio/ui/StudioSidebar.tsx b/fluxer_app/src/features/theme_studio/ui/StudioSidebar.tsx index 99394cb5e..d039767d1 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioSidebar.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioSidebar.tsx @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import styles from '@app/features/theme_studio/ui/StudioSidebar.module.css'; import FocusRing from '@app/features/ui/focus_ring/FocusRing'; import {clsx} from 'clsx'; import type React from 'react'; import type {ReactNode} from 'react'; -import styles from './StudioSidebar.module.css'; interface StudioSidebarProps { ariaLabel: string; diff --git a/fluxer_app/src/features/theme_studio/ui/StudioSplit.tsx b/fluxer_app/src/features/theme_studio/ui/StudioSplit.tsx index 0cadcb632..fa8fa9b35 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioSplit.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioSplit.tsx @@ -1,6 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import AppStorage from '@app/features/platform/state/PersistentStorage'; +import styles from '@app/features/theme_studio/ui/StudioSplit.module.css'; import FocusRing from '@app/features/ui/focus_ring/FocusRing'; import {msg} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; @@ -8,7 +9,6 @@ import {clsx} from 'clsx'; import type React from 'react'; import type {ReactNode} from 'react'; import {useCallback, useEffect, useRef, useState} from 'react'; -import styles from './StudioSplit.module.css'; const RESIZE_PANELS_DESCRIPTOR = msg({ message: 'Resize panels', diff --git a/fluxer_app/src/features/theme_studio/ui/StudioToken.tsx b/fluxer_app/src/features/theme_studio/ui/StudioToken.tsx index b9977282b..665c289c4 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioToken.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioToken.tsx @@ -2,6 +2,7 @@ import {ColorPickerPopover} from '@app/features/app/components/floating/ColorPickerPopover'; import {remFromPx} from '@app/features/theme/layout/RemFromPx'; +import styles from '@app/features/theme_studio/ui/StudioToken.module.css'; import FocusRing from '@app/features/ui/focus_ring/FocusRing'; import type {ThemeVariableKind} from '@app/features/user/components/modals/tabs/appearance_tab/theme/ThemeConstants'; import { @@ -15,7 +16,6 @@ import {clsx} from 'clsx'; import type React from 'react'; import {useCallback, useEffect, useState} from 'react'; import {Button as AriaButton, Dialog, DialogTrigger, Popover} from 'react-aria-components'; -import styles from './StudioToken.module.css'; const EDIT_COLOR_FOR_DESCRIPTOR = msg({ message: 'Edit color for {tokenLabel}', diff --git a/fluxer_app/src/features/theme_studio/ui/StudioToolbar.tsx b/fluxer_app/src/features/theme_studio/ui/StudioToolbar.tsx index 7697198ae..0837b1289 100644 --- a/fluxer_app/src/features/theme_studio/ui/StudioToolbar.tsx +++ b/fluxer_app/src/features/theme_studio/ui/StudioToolbar.tsx @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import styles from '@app/features/theme_studio/ui/StudioToolbar.module.css'; import {clsx} from 'clsx'; import type React from 'react'; import type {ReactNode} from 'react'; -import styles from './StudioToolbar.module.css'; interface StudioToolbarProps { leading?: ReactNode; diff --git a/fluxer_app/src/features/typing/state/LocalTypingStateMachine.test.ts b/fluxer_app/src/features/typing/state/LocalTypingStateMachine.test.ts index 68633d325..55b84d12e 100644 --- a/fluxer_app/src/features/typing/state/LocalTypingStateMachine.test.ts +++ b/fluxer_app/src/features/typing/state/LocalTypingStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createLocalTypingSnapshot, LOCAL_TYPING_REMOTE_REFRESH_MS, @@ -8,7 +7,8 @@ import { type LocalTypingSnapshot, selectLocalTypingModel, transitionLocalTypingSnapshot, -} from './LocalTypingStateMachine'; +} from '@app/features/typing/state/LocalTypingStateMachine'; +import {describe, expect, it} from 'vitest'; function transition(snapshot: LocalTypingSnapshot, event: LocalTypingMachineEvent): LocalTypingSnapshot { return transitionLocalTypingSnapshot(snapshot, event); diff --git a/fluxer_app/src/features/ui/action_menu/ContextMenuIcons.tsx b/fluxer_app/src/features/ui/action_menu/ContextMenuIcons.tsx index b12bd58b6..eb4919b7c 100644 --- a/fluxer_app/src/features/ui/action_menu/ContextMenuIcons.tsx +++ b/fluxer_app/src/features/ui/action_menu/ContextMenuIcons.tsx @@ -1,7 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {remFromPx} from '@app/features/theme/layout/RemFromPx'; - import { ArrowBendUpLeftIcon, ArrowBendUpRightIcon, diff --git a/fluxer_app/src/features/ui/action_menu/items/voice_participant_menu_data/shared.ts b/fluxer_app/src/features/ui/action_menu/items/voice_participant_menu_data/shared.ts index b643df625..b99b97708 100644 --- a/fluxer_app/src/features/ui/action_menu/items/voice_participant_menu_data/shared.ts +++ b/fluxer_app/src/features/ui/action_menu/items/voice_participant_menu_data/shared.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -export {BLOCKED_USER_DM_WARNING_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; - import {msg} from '@lingui/core/macro'; +export {BLOCKED_USER_DM_WARNING_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; + export const COPY_DEVICE_ID_DESCRIPTOR = msg({ message: 'Copy device ID', comment: 'Developer-mode voice menu action that copies the unique identifier of a voice device or connection.', diff --git a/fluxer_app/src/features/ui/components/icons/FluxerIcon.tsx b/fluxer_app/src/features/ui/components/icons/FluxerIcon.tsx index c7806b75e..c49482fe5 100644 --- a/fluxer_app/src/features/ui/components/icons/FluxerIcon.tsx +++ b/fluxer_app/src/features/ui/components/icons/FluxerIcon.tsx @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import RuntimeConfig from '@app/features/app/state/RuntimeConfig'; +import {getDataFlx, getImageSizingProps} from '@app/features/ui/components/icons/BrandImageUtils'; import {msg} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; import {observer} from 'mobx-react-lite'; import type React from 'react'; -import {getDataFlx, getImageSizingProps} from './BrandImageUtils'; const APPLICATION_ICON_DESCRIPTOR = msg({ message: '{productName} application icon', diff --git a/fluxer_app/src/features/ui/components/icons/FluxerLogo.tsx b/fluxer_app/src/features/ui/components/icons/FluxerLogo.tsx index 757d9eebe..b31eed19d 100644 --- a/fluxer_app/src/features/ui/components/icons/FluxerLogo.tsx +++ b/fluxer_app/src/features/ui/components/icons/FluxerLogo.tsx @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import RuntimeConfig from '@app/features/app/state/RuntimeConfig'; +import {type BrandSvgProps, getDataFlx, getImageSizingProps} from '@app/features/ui/components/icons/BrandImageUtils'; import FluxerLogoAsset from '@app/media/images/fluxer-logo-color.svg?react'; import {msg} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; import {observer} from 'mobx-react-lite'; -import {type BrandSvgProps, getDataFlx, getImageSizingProps} from './BrandImageUtils'; const APPLICATION_LOGO_DESCRIPTOR = msg({ message: '{productName} application logo', diff --git a/fluxer_app/src/features/ui/components/icons/FluxerWordmark.tsx b/fluxer_app/src/features/ui/components/icons/FluxerWordmark.tsx index 383e0b1d4..99ba3c29e 100644 --- a/fluxer_app/src/features/ui/components/icons/FluxerWordmark.tsx +++ b/fluxer_app/src/features/ui/components/icons/FluxerWordmark.tsx @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import RuntimeConfig, {DEFAULT_APP_PUBLIC_CONFIG} from '@app/features/app/state/RuntimeConfig'; +import {type BrandSvgProps, getDataFlx, getImageSizingProps} from '@app/features/ui/components/icons/BrandImageUtils'; import FluxerWordmarkMonochromeAsset from '@app/media/images/fluxer-logo-wordmark-monochrome.svg?react'; import FluxerWordmarkAsset from '@app/media/images/fluxer-wordmark.svg?react'; import {msg} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; import {observer} from 'mobx-react-lite'; import type React from 'react'; -import {type BrandSvgProps, getDataFlx, getImageSizingProps} from './BrandImageUtils'; const APPLICATION_WORDMARK_DESCRIPTOR = msg({ message: '{productName} wordmark', diff --git a/fluxer_app/src/features/ui/floating_pane/FloatingPaneMath.test.ts b/fluxer_app/src/features/ui/floating_pane/FloatingPaneMath.test.ts index ef87ddd97..9d75e1381 100644 --- a/fluxer_app/src/features/ui/floating_pane/FloatingPaneMath.test.ts +++ b/fluxer_app/src/features/ui/floating_pane/FloatingPaneMath.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { ALL_CORNERS, ALL_RESIZE_EDGES, @@ -18,7 +17,8 @@ import { type ResizeEdge, reconcileToGeometry, snapPointToCorner, -} from './FloatingPaneMath'; +} from '@app/features/ui/floating_pane/FloatingPaneMath'; +import {describe, expect, it} from 'vitest'; const BASE_GEOMETRY: FloatingPaneGeometry = { viewport: {width: 1000, height: 600}, diff --git a/fluxer_app/src/features/ui/floating_pane/index.ts b/fluxer_app/src/features/ui/floating_pane/index.ts index d5b8bce1d..31b3a667d 100644 --- a/fluxer_app/src/features/ui/floating_pane/index.ts +++ b/fluxer_app/src/features/ui/floating_pane/index.ts @@ -11,7 +11,7 @@ export type { ResizeStart, Size, WidthRange, -} from './FloatingPaneMath'; +} from '@app/features/ui/floating_pane/FloatingPaneMath'; export { ALL_CORNERS, ALL_RESIZE_EDGES, @@ -26,8 +26,12 @@ export { pickCornerForFling, reconcileToGeometry, snapPointToCorner, -} from './FloatingPaneMath'; -export type {FloatingPaneResizeHandlesProps} from './FloatingPaneResizeHandles'; -export {FloatingPaneResizeHandles} from './FloatingPaneResizeHandles'; -export type {FloatingPanePointerHandlers, FloatingPaneResult, UseFloatingPaneOptions} from './useFloatingPane'; -export {useFloatingPane} from './useFloatingPane'; +} from '@app/features/ui/floating_pane/FloatingPaneMath'; +export type {FloatingPaneResizeHandlesProps} from '@app/features/ui/floating_pane/FloatingPaneResizeHandles'; +export {FloatingPaneResizeHandles} from '@app/features/ui/floating_pane/FloatingPaneResizeHandles'; +export type { + FloatingPanePointerHandlers, + FloatingPaneResult, + UseFloatingPaneOptions, +} from '@app/features/ui/floating_pane/useFloatingPane'; +export {useFloatingPane} from '@app/features/ui/floating_pane/useFloatingPane'; diff --git a/fluxer_app/src/features/ui/floating_pane/useFloatingPane.ts b/fluxer_app/src/features/ui/floating_pane/useFloatingPane.ts index 495982930..a5435a9c9 100644 --- a/fluxer_app/src/features/ui/floating_pane/useFloatingPane.ts +++ b/fluxer_app/src/features/ui/floating_pane/useFloatingPane.ts @@ -1,9 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {appZoomLayoutPx} from '@app/features/ui/utils/AppZoomUtils'; -import {canUseWindowFocusedHoverControls} from '@app/features/ui/utils/WindowFocusInteractionGuard'; -import type React from 'react'; -import {useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; import { type Corner, clampPoint, @@ -17,7 +13,11 @@ import { type ResizeEdge, type ResizeStart, reconcileToGeometry, -} from './FloatingPaneMath'; +} from '@app/features/ui/floating_pane/FloatingPaneMath'; +import {appZoomLayoutPx} from '@app/features/ui/utils/AppZoomUtils'; +import {canUseWindowFocusedHoverControls} from '@app/features/ui/utils/WindowFocusInteractionGuard'; +import type React from 'react'; +import {useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; const DRAG_ACTIVATION_DISTANCE_SQ = 9; diff --git a/fluxer_app/src/features/ui/stepped_carousel/SteppedCarouselStateMachine.test.ts b/fluxer_app/src/features/ui/stepped_carousel/SteppedCarouselStateMachine.test.ts index 5380c39bd..2d496a434 100644 --- a/fluxer_app/src/features/ui/stepped_carousel/SteppedCarouselStateMachine.test.ts +++ b/fluxer_app/src/features/ui/stepped_carousel/SteppedCarouselStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createSteppedCarouselSnapshot, getSteppedCarouselStateValue, @@ -9,7 +8,8 @@ import { type SteppedCarouselSnapshot, selectSteppedCarouselModel, transitionSteppedCarouselSnapshot, -} from './SteppedCarouselStateMachine'; +} from '@app/features/ui/stepped_carousel/SteppedCarouselStateMachine'; +import {describe, expect, it} from 'vitest'; const STEPS = ['account', 'credentials', 'mfa'] as const; diff --git a/fluxer_app/src/features/ui/tooltip/Tooltip.tsx b/fluxer_app/src/features/ui/tooltip/Tooltip.tsx index 2aad749e3..f1d04a67b 100644 --- a/fluxer_app/src/features/ui/tooltip/Tooltip.tsx +++ b/fluxer_app/src/features/ui/tooltip/Tooltip.tsx @@ -10,6 +10,12 @@ import ContextMenuState from '@app/features/ui/state/ContextMenu'; import KeyboardMode from '@app/features/ui/state/KeyboardMode'; import MobileLayout from '@app/features/ui/state/MobileLayout'; import styles from '@app/features/ui/tooltip/Tooltip.module.css'; +import {useExclusiveTooltip} from '@app/features/ui/tooltip/TooltipExclusivity'; +import {isTooltipHandoffWarm, markTooltipOpen} from '@app/features/ui/tooltip/TooltipHandoff'; +import { + getTooltipScrollSuppressRemainingMs, + subscribeTooltipScrollHide, +} from '@app/features/ui/tooltip/TooltipScrollCoordinator'; import { createTooltipSnapshot, getTooltipStateValue, @@ -33,9 +39,6 @@ import {clsx} from 'clsx'; import {AnimatePresence, motion} from 'framer-motion'; import {observer} from 'mobx-react-lite'; import React, {useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState} from 'react'; -import {useExclusiveTooltip} from './TooltipExclusivity'; -import {isTooltipHandoffWarm, markTooltipOpen} from './TooltipHandoff'; -import {getTooltipScrollSuppressRemainingMs, subscribeTooltipScrollHide} from './TooltipScrollCoordinator'; const logger = new Logger('Tooltip'); diff --git a/fluxer_app/src/features/ui/tooltip/TooltipStateMachine.test.ts b/fluxer_app/src/features/ui/tooltip/TooltipStateMachine.test.ts index 5f1777e27..3bead0b7c 100644 --- a/fluxer_app/src/features/ui/tooltip/TooltipStateMachine.test.ts +++ b/fluxer_app/src/features/ui/tooltip/TooltipStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createTooltipSnapshot, DEFAULT_TOOLTIP_ENVIRONMENT, @@ -11,7 +10,8 @@ import { type TooltipSnapshot, tooltipSnapshotsAreEquivalent, transitionTooltipSnapshot, -} from './TooltipStateMachine'; +} from '@app/features/ui/tooltip/TooltipStateMachine'; +import {describe, expect, it} from 'vitest'; function environment(overrides: Partial = {}): TooltipEnvironment { return {...DEFAULT_TOOLTIP_ENVIRONMENT, ...overrides}; diff --git a/fluxer_app/src/features/ui/tooltip/useHoverFloatingTooltip.ts b/fluxer_app/src/features/ui/tooltip/useHoverFloatingTooltip.ts index 5b65a66fc..e231e75bf 100644 --- a/fluxer_app/src/features/ui/tooltip/useHoverFloatingTooltip.ts +++ b/fluxer_app/src/features/ui/tooltip/useHoverFloatingTooltip.ts @@ -1,6 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import KeyboardMode from '@app/features/ui/state/KeyboardMode'; +import {useExclusiveTooltip} from '@app/features/ui/tooltip/TooltipExclusivity'; +import {isTooltipHandoffWarm, markTooltipOpen} from '@app/features/ui/tooltip/TooltipHandoff'; +import {subscribeTooltipScrollHide} from '@app/features/ui/tooltip/TooltipScrollCoordinator'; import {appZoomLayoutPx} from '@app/features/ui/utils/AppZoomUtils'; import type {Placement, ReferenceType} from '@floating-ui/react'; import { @@ -16,9 +19,6 @@ import { } from '@floating-ui/react'; import type React from 'react'; import {useCallback, useEffect, useMemo, useState} from 'react'; -import {useExclusiveTooltip} from './TooltipExclusivity'; -import {isTooltipHandoffWarm, markTooltipOpen} from './TooltipHandoff'; -import {subscribeTooltipScrollHide} from './TooltipScrollCoordinator'; export interface HoverFloatingTooltipState { x: number; diff --git a/fluxer_app/src/features/ui/utils/AppZoomKeybindUtils.test.ts b/fluxer_app/src/features/ui/utils/AppZoomKeybindUtils.test.ts index bccb31b79..bd19aa6e5 100644 --- a/fluxer_app/src/features/ui/utils/AppZoomKeybindUtils.test.ts +++ b/fluxer_app/src/features/ui/utils/AppZoomKeybindUtils.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {KeybindCommand, KeyCombo} from '@app/features/input/state/InputKeybind'; +import {isWebReservedZoomShortcut} from '@app/features/ui/utils/AppZoomKeybindUtils'; import {describe, expect, it} from 'vitest'; -import {isWebReservedZoomShortcut} from './AppZoomKeybindUtils'; const zoomShortcut = (action: KeybindCommand, combo: KeyCombo, isDesktop = false): boolean => isWebReservedZoomShortcut(action, combo, {isDesktop}); diff --git a/fluxer_app/src/features/ui/utils/DimensionUtils.test.ts b/fluxer_app/src/features/ui/utils/DimensionUtils.test.ts index 58ef31b56..7ca360a26 100644 --- a/fluxer_app/src/features/ui/utils/DimensionUtils.test.ts +++ b/fluxer_app/src/features/ui/utils/DimensionUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createCalculator, fitMediaWithinBounds, mediaAspectRatioValue} from '@app/features/ui/utils/DimensionUtils'; import {describe, expect, it} from 'vitest'; -import {createCalculator, fitMediaWithinBounds, mediaAspectRatioValue} from './DimensionUtils'; const ATTACHMENT_CAPS = {maxWidth: 550, maxHeight: 350}; diff --git a/fluxer_app/src/features/updater/state/UpdaterStateMachine.test.ts b/fluxer_app/src/features/updater/state/UpdaterStateMachine.test.ts index 42412458a..74c8928a4 100644 --- a/fluxer_app/src/features/updater/state/UpdaterStateMachine.test.ts +++ b/fluxer_app/src/features/updater/state/UpdaterStateMachine.test.ts @@ -1,7 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {UpdaterDownloadOption} from '@app/features/platform/types/Electron'; -import {describe, expect, it} from 'vitest'; import { createUpdaterMachineSnapshot, getUpdaterDisplayVersion, @@ -11,7 +10,8 @@ import { transitionUpdaterMachineSnapshot, type UpdaterMachineEvent, type UpdaterMachineSnapshot, -} from './UpdaterStateMachine'; +} from '@app/features/updater/state/UpdaterStateMachine'; +import {describe, expect, it} from 'vitest'; const NOW = 1_700_000_000_000; diff --git a/fluxer_app/src/features/updater/utils/LinuxManualUpdateOptions.test.ts b/fluxer_app/src/features/updater/utils/LinuxManualUpdateOptions.test.ts index 62ca1ece1..d4d194e69 100644 --- a/fluxer_app/src/features/updater/utils/LinuxManualUpdateOptions.test.ts +++ b/fluxer_app/src/features/updater/utils/LinuxManualUpdateOptions.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {UpdaterDownloadOption} from '@app/features/platform/types/Electron'; +import {buildLinuxManualUpdateOptions} from '@app/features/updater/utils/LinuxManualUpdateOptions'; import {describe, expect, it, vi} from 'vitest'; -import {buildLinuxManualUpdateOptions} from './LinuxManualUpdateOptions'; vi.mock('@app/features/app/config/Config', () => ({ default: { diff --git a/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/ThemeTabContent.tsx b/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/ThemeTabContent.tsx index 36800dfcb..359fe084b 100644 --- a/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/ThemeTabContent.tsx +++ b/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/ThemeTabContent.tsx @@ -9,6 +9,7 @@ import {Button} from '@app/features/ui/button/Button'; import {Switch} from '@app/features/ui/components/form/FormSwitch'; import {Tooltip} from '@app/features/ui/tooltip/Tooltip'; import styles from '@app/features/user/components/modals/tabs/appearance_tab/ThemeTab.module.css'; +import {ThemeButton} from '@app/features/user/components/modals/tabs/appearance_tab/theme/ThemeButton'; import type {ThemeType} from '@fluxer/constants/src/UserConstants'; import {ThemeTypes} from '@fluxer/constants/src/UserConstants'; import {msg} from '@lingui/core/macro'; @@ -17,7 +18,6 @@ import {ArrowsCounterClockwiseIcon, PaintBrushBroadIcon} from '@phosphor-icons/r import {observer} from 'mobx-react-lite'; import type React from 'react'; import {useCallback, useEffect, useMemo, useRef} from 'react'; -import {ThemeButton} from './ThemeButton'; const DARK_THEME_DESCRIPTOR = msg({ message: 'Dark theme', diff --git a/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/ThemeUtils.test.ts b/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/ThemeUtils.test.ts index 3b918d6b7..ce8a6312c 100644 --- a/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/ThemeUtils.test.ts +++ b/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/ThemeUtils.test.ts @@ -1,7 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + cssColorStringToHex, + cssColorStringToNumber, + numberToHex, + updateCssForVariable, +} from '@app/features/user/components/modals/tabs/appearance_tab/theme/ThemeUtils'; import {describe, expect, it} from 'vitest'; -import {cssColorStringToHex, cssColorStringToNumber, numberToHex, updateCssForVariable} from './ThemeUtils'; describe('updateCssForVariable', () => { it('adds a token override when the CSS is empty', () => { diff --git a/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/useThemeHydration.ts b/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/useThemeHydration.ts index e23d38cef..95e87af55 100644 --- a/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/useThemeHydration.ts +++ b/fluxer_app/src/features/user/components/modals/tabs/appearance_tab/theme/useThemeHydration.ts @@ -1,9 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import Theme from '@app/features/theme/state/Theme'; +import { + THEME_STUDIO_DARK_DEFAULT_VARIABLE_VALUES, + THEME_STUDIO_LIGHT_DEFAULT_VARIABLE_VALUES, +} from '@app/features/user/components/modals/tabs/appearance_tab/theme/ThemeConstants'; import type {ThemeType} from '@fluxer/constants/src/UserConstants'; import {ThemeTypes} from '@fluxer/constants/src/UserConstants'; -import {THEME_STUDIO_DARK_DEFAULT_VARIABLE_VALUES, THEME_STUDIO_LIGHT_DEFAULT_VARIABLE_VALUES} from './ThemeConstants'; export interface ThemeHydrationResult { systemPrefersDark: boolean; diff --git a/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/ProfileAssetCustomizationStateMachine.test.ts b/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/ProfileAssetCustomizationStateMachine.test.ts index 361721c02..3bf38b6a9 100644 --- a/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/ProfileAssetCustomizationStateMachine.test.ts +++ b/fluxer_app/src/features/user/components/modals/tabs/my_profile_tab/ProfileAssetCustomizationStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { assignProfileAssetUploadPatch, createGlobalProfileAssetRemoteState, @@ -13,7 +12,8 @@ import { type ProfileAssetRemoteState, selectProfileAssetCustomizationState, transitionProfileAssetCustomizationSnapshot, -} from './ProfileAssetCustomizationStateMachine'; +} from '@app/features/user/components/modals/tabs/my_profile_tab/ProfileAssetCustomizationStateMachine'; +import {describe, expect, it} from 'vitest'; const IDENTITY = 'user-1:guild-1'; const OTHER_IDENTITY = 'user-1:guild-2'; diff --git a/fluxer_app/src/features/user/components/settings_utils/SettingsMetadata.test.ts b/fluxer_app/src/features/user/components/settings_utils/SettingsMetadata.test.ts index 779188d98..27181e578 100644 --- a/fluxer_app/src/features/user/components/settings_utils/SettingsMetadata.test.ts +++ b/fluxer_app/src/features/user/components/settings_utils/SettingsMetadata.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isSettingsItemNew} from '@app/features/user/components/settings_utils/SettingsMetadata'; import {describe, expect, it} from 'vitest'; -import {isSettingsItemNew} from './SettingsMetadata'; const NOW = new Date('2026-06-04T12:00:00.000Z'); diff --git a/fluxer_app/src/features/user/components/settings_utils/section_registry/AccessibilitySections.ts b/fluxer_app/src/features/user/components/settings_utils/section_registry/AccessibilitySections.ts index 9c43c2e18..ad11210c5 100644 --- a/fluxer_app/src/features/user/components/settings_utils/section_registry/AccessibilitySections.ts +++ b/fluxer_app/src/features/user/components/settings_utils/section_registry/AccessibilitySections.ts @@ -1,9 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {STICKERS_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; -import {VOICE_CALL_DESCRIPTOR} from '@app/features/voice/utils/VoiceMessageDescriptors'; -import {msg} from '@lingui/core/macro'; -import type {SectionDefinition} from './SectionRegistryTypes'; +import type {SectionDefinition} from '@app/features/user/components/settings_utils/section_registry/SectionRegistryTypes'; import { ACCESSIBILITY_DESCRIPTOR, CALL_DESCRIPTOR, @@ -26,7 +24,9 @@ import { STRIKETHROUGH_DESCRIPTOR, TEXT_TO_SPEECH_3_DESCRIPTOR, TTS_DESCRIPTOR, -} from './SharedDescriptors'; +} from '@app/features/user/components/settings_utils/section_registry/SharedDescriptors'; +import {VOICE_CALL_DESCRIPTOR} from '@app/features/voice/utils/VoiceMessageDescriptors'; +import {msg} from '@lingui/core/macro'; const CONTRAST_DESCRIPTOR = msg({ message: 'Contrast', diff --git a/fluxer_app/src/features/user/components/settings_utils/section_registry/AccountSecuritySections.ts b/fluxer_app/src/features/user/components/settings_utils/section_registry/AccountSecuritySections.ts index fdcb9db12..b6ad329ff 100644 --- a/fluxer_app/src/features/user/components/settings_utils/section_registry/AccountSecuritySections.ts +++ b/fluxer_app/src/features/user/components/settings_utils/section_registry/AccountSecuritySections.ts @@ -1,10 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {EMAIL_DESCRIPTOR, PASSWORD_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; +import {shouldShowClaimedAccountSections} from '@app/features/user/components/settings_utils/section_registry/SectionRegistryHelpers'; +import type {SectionDefinition} from '@app/features/user/components/settings_utils/section_registry/SectionRegistryTypes'; +import { + DELETE_DESCRIPTOR, + REMOVE_DESCRIPTOR, +} from '@app/features/user/components/settings_utils/section_registry/SharedDescriptors'; import {msg} from '@lingui/core/macro'; -import {shouldShowClaimedAccountSections} from './SectionRegistryHelpers'; -import type {SectionDefinition} from './SectionRegistryTypes'; -import {DELETE_DESCRIPTOR, REMOVE_DESCRIPTOR} from './SharedDescriptors'; const MAIL_DESCRIPTOR = msg({ message: 'Mail', diff --git a/fluxer_app/src/features/user/components/settings_utils/section_registry/AppearanceSections.ts b/fluxer_app/src/features/user/components/settings_utils/section_registry/AppearanceSections.ts index c6e3f6018..4b3e4b427 100644 --- a/fluxer_app/src/features/user/components/settings_utils/section_registry/AppearanceSections.ts +++ b/fluxer_app/src/features/user/components/settings_utils/section_registry/AppearanceSections.ts @@ -7,8 +7,7 @@ import { } from '@app/features/i18n/utils/CommonMessageDescriptors'; import {shouldShowHdrSettings} from '@app/features/user/components/modals/tabs/appearance_tab/AppearanceTabHdrTab'; import {shouldShowAppZoomLevel} from '@app/features/user/components/settings_utils/AppZoomLevelUtils'; -import {msg} from '@lingui/core/macro'; -import type {SectionDefinition} from './SectionRegistryTypes'; +import type {SectionDefinition} from '@app/features/user/components/settings_utils/section_registry/SectionRegistryTypes'; import { CHANNEL_LIST_DESCRIPTOR, CHAT_INPUT_DESCRIPTOR, @@ -29,7 +28,8 @@ import { TYPING_DESCRIPTOR, UNREAD_DESCRIPTOR, VOICE_DESCRIPTOR, -} from './SharedDescriptors'; +} from '@app/features/user/components/settings_utils/section_registry/SharedDescriptors'; +import {msg} from '@lingui/core/macro'; const CHOOSE_A_BASE_APPEARANCE_MANAGE_QUICK_CSS_ORGANIZE_DESCRIPTOR = msg({ message: 'Choose a base appearance, manage quick CSS, organize saved theme files, and tune theme tokens.', diff --git a/fluxer_app/src/features/user/components/settings_utils/section_registry/ChatSettingsSections.ts b/fluxer_app/src/features/user/components/settings_utils/section_registry/ChatSettingsSections.ts index aea712d07..9fd14d009 100644 --- a/fluxer_app/src/features/user/components/settings_utils/section_registry/ChatSettingsSections.ts +++ b/fluxer_app/src/features/user/components/settings_utils/section_registry/ChatSettingsSections.ts @@ -2,10 +2,13 @@ import {STICKERS_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; import {getPermissionTitleDescriptor} from '@app/features/permissions/utils/PermissionLabelDescriptors'; +import type {SectionDefinition} from '@app/features/user/components/settings_utils/section_registry/SectionRegistryTypes'; +import { + EMOJI_DESCRIPTOR, + MENTIONS_DESCRIPTOR, +} from '@app/features/user/components/settings_utils/section_registry/SharedDescriptors'; import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {msg} from '@lingui/core/macro'; -import type {SectionDefinition} from './SectionRegistryTypes'; -import {EMOJI_DESCRIPTOR, MENTIONS_DESCRIPTOR} from './SharedDescriptors'; const REACTIONS_DESCRIPTOR = msg({ message: 'Reactions', diff --git a/fluxer_app/src/features/user/components/settings_utils/section_registry/GeneralSettingsSections.ts b/fluxer_app/src/features/user/components/settings_utils/section_registry/GeneralSettingsSections.ts index d8e3db8a0..e5852ea80 100644 --- a/fluxer_app/src/features/user/components/settings_utils/section_registry/GeneralSettingsSections.ts +++ b/fluxer_app/src/features/user/components/settings_utils/section_registry/GeneralSettingsSections.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {SectionDefinition} from '@app/features/user/components/settings_utils/section_registry/SectionRegistryTypes'; import {msg} from '@lingui/core/macro'; -import type {SectionDefinition} from './SectionRegistryTypes'; const PROFILE_CUSTOMIZATION_DESCRIPTOR = msg({ message: 'Profile customization', diff --git a/fluxer_app/src/features/user/components/settings_utils/section_registry/NotificationsSections.ts b/fluxer_app/src/features/user/components/settings_utils/section_registry/NotificationsSections.ts index 3bed6d312..ab5da2fc1 100644 --- a/fluxer_app/src/features/user/components/settings_utils/section_registry/NotificationsSections.ts +++ b/fluxer_app/src/features/user/components/settings_utils/section_registry/NotificationsSections.ts @@ -1,12 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {GENERAL_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; -import { - VOICE_DEAFEN_DESCRIPTOR, - VOICE_DEAFEN_SOUND_DESCRIPTOR, -} from '@app/features/voice/utils/VoiceMessageDescriptors'; -import {msg} from '@lingui/core/macro'; -import type {SectionDefinition} from './SectionRegistryTypes'; +import type {SectionDefinition} from '@app/features/user/components/settings_utils/section_registry/SectionRegistryTypes'; import { ACCESSIBILITY_DESCRIPTOR, AUDIO_2_DESCRIPTOR, @@ -25,7 +20,12 @@ import { TTS_DESCRIPTOR, UNREAD_DESCRIPTOR, VOLUME_DESCRIPTOR, -} from './SharedDescriptors'; +} from '@app/features/user/components/settings_utils/section_registry/SharedDescriptors'; +import { + VOICE_DEAFEN_DESCRIPTOR, + VOICE_DEAFEN_SOUND_DESCRIPTOR, +} from '@app/features/voice/utils/VoiceMessageDescriptors'; +import {msg} from '@lingui/core/macro'; const NOTIFICATIONS_2_DESCRIPTOR = msg({ message: 'Notifications', diff --git a/fluxer_app/src/features/user/components/settings_utils/section_registry/PrivacySafetySections.ts b/fluxer_app/src/features/user/components/settings_utils/section_registry/PrivacySafetySections.ts index 1202fd17f..20d72d5a7 100644 --- a/fluxer_app/src/features/user/components/settings_utils/section_registry/PrivacySafetySections.ts +++ b/fluxer_app/src/features/user/components/settings_utils/section_registry/PrivacySafetySections.ts @@ -6,8 +6,7 @@ import { FRIENDS_OF_FRIENDS_DESCRIPTOR, } from '@app/features/i18n/utils/CommonMessageDescriptors'; import {ADD_FRIEND_DESCRIPTOR} from '@app/features/relationship/utils/RelationshipMessageDescriptors'; -import {msg} from '@lingui/core/macro'; -import type {SectionDefinition} from './SectionRegistryTypes'; +import type {SectionDefinition} from '@app/features/user/components/settings_utils/section_registry/SectionRegistryTypes'; import { DELETE_DESCRIPTOR, DIRECT_MESSAGE_DESCRIPTOR, @@ -15,7 +14,8 @@ import { FRIENDS_DESCRIPTOR, REMOVE_DESCRIPTOR, VOICE_DESCRIPTOR, -} from './SharedDescriptors'; +} from '@app/features/user/components/settings_utils/section_registry/SharedDescriptors'; +import {msg} from '@lingui/core/macro'; const FRIEND_REQUESTS_DESCRIPTOR = msg({ message: 'Friend requests', diff --git a/fluxer_app/src/features/user/components/settings_utils/section_registry/VoiceVideoSections.ts b/fluxer_app/src/features/user/components/settings_utils/section_registry/VoiceVideoSections.ts index 4f6550311..84ec299b9 100644 --- a/fluxer_app/src/features/user/components/settings_utils/section_registry/VoiceVideoSections.ts +++ b/fluxer_app/src/features/user/components/settings_utils/section_registry/VoiceVideoSections.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {SectionDefinition} from '@app/features/user/components/settings_utils/section_registry/SectionRegistryTypes'; +import { + AUDIO_2_DESCRIPTOR, + PLUTONIUM_DESCRIPTOR, + VOICE_DESCRIPTOR, + VOLUME_DESCRIPTOR, +} from '@app/features/user/components/settings_utils/section_registry/SharedDescriptors'; import { VOICE_DIRECT_INPUT_PROFILE_DESCRIPTOR, VOICE_ECHO_CANCELLATION_DESCRIPTOR, @@ -11,8 +18,6 @@ import { VOICE_OUTPUT_VOLUME_DESCRIPTOR, } from '@app/features/voice/utils/VoiceMessageDescriptors'; import {msg} from '@lingui/core/macro'; -import type {SectionDefinition} from './SectionRegistryTypes'; -import {AUDIO_2_DESCRIPTOR, PLUTONIUM_DESCRIPTOR, VOICE_DESCRIPTOR, VOLUME_DESCRIPTOR} from './SharedDescriptors'; const CONFIGURE_YOUR_MICROPHONE_SPEAKERS_INPUT_MODE_PROCESSING_AND_DESCRIPTOR = msg({ message: 'Configure your microphone, speakers, input mode, processing, and voice sounds.', diff --git a/fluxer_app/src/features/user/state/AdvancedSettings.test.ts b/fluxer_app/src/features/user/state/AdvancedSettings.test.ts index 56c9cf724..6ab735320 100644 --- a/fluxer_app/src/features/user/state/AdvancedSettings.test.ts +++ b/fluxer_app/src/features/user/state/AdvancedSettings.test.ts @@ -7,7 +7,7 @@ const KEEP_ATTACHMENTS_ON_EMPTY_MESSAGE_EDIT_STORAGE_KEY = 'AdvancedSettings:kee AppStorage.setItem(KEEP_ATTACHMENTS_ON_EMPTY_MESSAGE_EDIT_STORAGE_KEY, JSON.stringify(true)); -const {default: AdvancedSettings} = await import('./AdvancedSettings'); +const {default: AdvancedSettings} = await import('@app/features/user/state/AdvancedSettings'); describe('Advanced settings', () => { it('rehydrates the stored attachment edit preference', () => { diff --git a/fluxer_app/src/features/user/state/SyncedFieldBudget.test.ts b/fluxer_app/src/features/user/state/SyncedFieldBudget.test.ts index fa56e3ea6..fd65992c0 100644 --- a/fluxer_app/src/features/user/state/SyncedFieldBudget.test.ts +++ b/fluxer_app/src/features/user/state/SyncedFieldBudget.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {decideOversizePush} from '@app/features/user/state/SyncedFieldBudget'; import {describe, expect, it} from 'vitest'; -import {decideOversizePush} from './SyncedFieldBudget'; const MAX = 1000; diff --git a/fluxer_app/src/features/user/state/SyncedFieldStateMachine.test.ts b/fluxer_app/src/features/user/state/SyncedFieldStateMachine.test.ts index 848364f50..50559fc4b 100644 --- a/fluxer_app/src/features/user/state/SyncedFieldStateMachine.test.ts +++ b/fluxer_app/src/features/user/state/SyncedFieldStateMachine.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createSyncedFieldMachineSnapshot, type SyncedFieldMachineEvent, type SyncedFieldMachineSnapshot, selectSyncedFieldMachineModel, transitionSyncedFieldMachineSnapshot, -} from './SyncedFieldStateMachine'; +} from '@app/features/user/state/SyncedFieldStateMachine'; +import {describe, expect, it} from 'vitest'; const REMOTE_SNAPSHOT = Object.freeze({source: 'remote'}); const LOCAL_CANDIDATE = Object.freeze({source: 'local'}); diff --git a/fluxer_app/src/features/user/state/UnreadInboxVisibility.test.ts b/fluxer_app/src/features/user/state/UnreadInboxVisibility.test.ts index e9e40aa95..11abc15ce 100644 --- a/fluxer_app/src/features/user/state/UnreadInboxVisibility.test.ts +++ b/fluxer_app/src/features/user/state/UnreadInboxVisibility.test.ts @@ -1,8 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + resolveUnreadInboxVisibility, + type UnreadInboxVisibilityInput, +} from '@app/features/user/state/UnreadInboxVisibility'; import {MessageNotifications} from '@fluxer/constants/src/NotificationConstants'; import {describe, expect, it} from 'vitest'; -import {resolveUnreadInboxVisibility, type UnreadInboxVisibilityInput} from './UnreadInboxVisibility'; function input(overrides: Partial = {}): UnreadInboxVisibilityInput { return { diff --git a/fluxer_app/src/features/user/utils/AvatarUtils.ts b/fluxer_app/src/features/user/utils/AvatarUtils.ts index c7dd4a7ab..2567c7a59 100644 --- a/fluxer_app/src/features/user/utils/AvatarUtils.ts +++ b/fluxer_app/src/features/user/utils/AvatarUtils.ts @@ -8,9 +8,6 @@ import { MEDIA_PROXY_IMAGE_SIZE_LADDER, snapMediaProxyImageSize, } from '@app/features/messaging/utils/MediaProxyUtils'; - -export {MEDIA_PROXY_IMAGE_SIZE_LADDER, snapMediaProxyImageSize}; - import {cdnUrl, mediaUrl, setPathQueryParams} from '@app/features/messaging/utils/MessagingUrlUtils'; import type {User} from '@app/features/user/models/User'; import { @@ -26,6 +23,8 @@ import { import type {MediaProxyImageSize} from '@fluxer/constants/src/MediaProxyImageSizes'; import {SOUNDBOARD_SOUND_PATH_PREFIX} from '@fluxer/constants/src/SoundboardConstants'; +export {MEDIA_PROXY_IMAGE_SIZE_LADDER, snapMediaProxyImageSize}; + const GUILD_BANNER_CSS_WIDTH = 360; const GUILD_EMBED_SPLASH_CSS_WIDTH = 360; const GUILD_SPLASH_FALLBACK_CSS_WIDTH = 1024; diff --git a/fluxer_app/src/features/user/utils/FluxerTagDiscriminatorUtils.test.ts b/fluxer_app/src/features/user/utils/FluxerTagDiscriminatorUtils.test.ts index 67eb45269..d481a0b3c 100644 --- a/fluxer_app/src/features/user/utils/FluxerTagDiscriminatorUtils.test.ts +++ b/fluxer_app/src/features/user/utils/FluxerTagDiscriminatorUtils.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {isVisionaryDiscriminator0000Blocked} from '@app/features/user/utils/FluxerTagDiscriminatorUtils'; import {describe, expect, it} from 'vitest'; -import {isVisionaryDiscriminator0000Blocked} from './FluxerTagDiscriminatorUtils'; describe('isVisionaryDiscriminator0000Blocked', () => { it('allows #0000 on self-hosted instances', () => { diff --git a/fluxer_app/src/features/voice/commands/VoiceSettingsCommands.test.ts b/fluxer_app/src/features/voice/commands/VoiceSettingsCommands.test.ts index ef75a9ea0..ab6f64b4f 100644 --- a/fluxer_app/src/features/voice/commands/VoiceSettingsCommands.test.ts +++ b/fluxer_app/src/features/voice/commands/VoiceSettingsCommands.test.ts @@ -69,7 +69,7 @@ vi.mock('@app/features/voice/state/VoiceSettings', () => ({ }, })); -const VoiceSettingsCommands = await import('./VoiceSettingsCommands'); +const VoiceSettingsCommands = await import('@app/features/voice/commands/VoiceSettingsCommands'); describe('screen-share codec settings reactions', () => { beforeEach(() => { diff --git a/fluxer_app/src/features/voice/components/IncomingCallManagerStateMachine.test.ts b/fluxer_app/src/features/voice/components/IncomingCallManagerStateMachine.test.ts index a25d4bcfb..6776d4b69 100644 --- a/fluxer_app/src/features/voice/components/IncomingCallManagerStateMachine.test.ts +++ b/fluxer_app/src/features/voice/components/IncomingCallManagerStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createIncomingCallManagerSnapshot, type IncomingCallManagerSignals, @@ -9,7 +8,8 @@ import { selectIncomingCallManagerModel, shouldPlayIncomingRing, transitionIncomingCallManagerSnapshot, -} from './IncomingCallManagerStateMachine'; +} from '@app/features/voice/components/IncomingCallManagerStateMachine'; +import {describe, expect, it} from 'vitest'; function signals(overrides: Partial = {}): IncomingCallManagerSignals { return { diff --git a/fluxer_app/src/features/voice/components/VoiceCallLayoutContent.tsx b/fluxer_app/src/features/voice/components/VoiceCallLayoutContent.tsx index f07a30a5b..b43f60d85 100644 --- a/fluxer_app/src/features/voice/components/VoiceCallLayoutContent.tsx +++ b/fluxer_app/src/features/voice/components/VoiceCallLayoutContent.tsx @@ -18,6 +18,12 @@ import VoiceCallLayout from '@app/features/voice/state/VoiceCallLayout'; import {msg} from '@lingui/core/macro'; import {useLingui} from '@lingui/react/macro'; import {ParticipantContext, TrackRefContext, type TrackReferenceOrPlaceholder} from '@livekit/components-react'; +import {CaretDownIcon, CaretUpIcon, UsersIcon} from '@phosphor-icons/react'; +import {clsx} from 'clsx'; +import type {Participant} from 'livekit-client'; +import {observer} from 'mobx-react-lite'; +import type React from 'react'; +import {useCallback, useEffect, useMemo, useState} from 'react'; function trackToEntry(trackRef: TrackReferenceOrPlaceholder, index: number): VoiceGridEntry { const key = @@ -35,13 +41,6 @@ function trackToEntry(trackRef: TrackReferenceOrPlaceholder, index: number): Voi }; } -import {CaretDownIcon, CaretUpIcon, UsersIcon} from '@phosphor-icons/react'; -import {clsx} from 'clsx'; -import type {Participant} from 'livekit-client'; -import {observer} from 'mobx-react-lite'; -import type React from 'react'; -import {useCallback, useEffect, useMemo, useState} from 'react'; - const HIDE_PARTICIPANTS_DESCRIPTOR = msg({ message: 'Hide participants', comment: 'Tooltip / aria label on the participants-panel toggle in the voice call view (currently visible).', diff --git a/fluxer_app/src/features/voice/components/VoiceCallLayoutPresentationStateMachine.test.ts b/fluxer_app/src/features/voice/components/VoiceCallLayoutPresentationStateMachine.test.ts index d9cb7717a..82cdd1e33 100644 --- a/fluxer_app/src/features/voice/components/VoiceCallLayoutPresentationStateMachine.test.ts +++ b/fluxer_app/src/features/voice/components/VoiceCallLayoutPresentationStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createVoiceCallLayoutPresentationSnapshot, getVoiceCallLayoutPresentationStateValue, @@ -9,7 +8,8 @@ import { transitionVoiceCallLayoutPresentationSnapshot, type VoiceCallLayoutPresentationInput, type VoiceCallLayoutPresentationMachineSnapshot, -} from './VoiceCallLayoutPresentationStateMachine'; +} from '@app/features/voice/components/VoiceCallLayoutPresentationStateMachine'; +import {describe, expect, it} from 'vitest'; function input(overrides: Partial = {}): VoiceCallLayoutPresentationInput { return { diff --git a/fluxer_app/src/features/voice/components/VoiceFocusLayoutMetrics.test.ts b/fluxer_app/src/features/voice/components/VoiceFocusLayoutMetrics.test.ts index 60ad79fb1..adedca6dc 100644 --- a/fluxer_app/src/features/voice/components/VoiceFocusLayoutMetrics.test.ts +++ b/fluxer_app/src/features/voice/components/VoiceFocusLayoutMetrics.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {readFileSync} from 'node:fs'; -import {describe, expect, it} from 'vitest'; import { FOCUS_EXPANDED_MAIN_MIN_HEIGHT_PX, FOCUS_EXPANDED_MINI_COLUMN_RULES, FOCUS_EXPANDED_MINI_TILE_ASPECT_RATIO, getFocusExpandedMiniColumnCount, resolveFocusExpandedMainMetrics, -} from './VoiceFocusLayoutMetrics'; +} from '@app/features/voice/components/VoiceFocusLayoutMetrics'; +import {describe, expect, it} from 'vitest'; function sourceFile(name: string): string { return readFileSync(new URL(name, import.meta.url), 'utf8'); diff --git a/fluxer_app/src/features/voice/components/VoiceGridLayoutMetrics.test.ts b/fluxer_app/src/features/voice/components/VoiceGridLayoutMetrics.test.ts index d0f6599c0..ed615f14f 100644 --- a/fluxer_app/src/features/voice/components/VoiceGridLayoutMetrics.test.ts +++ b/fluxer_app/src/features/voice/components/VoiceGridLayoutMetrics.test.ts @@ -1,7 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {readFileSync} from 'node:fs'; -import {describe, expect, it} from 'vitest'; import { getVoiceGridColumnCount, getVoiceGridGap, @@ -16,7 +15,8 @@ import { VOICE_GRID_COMPACT_MIN_TILE_WIDTH_PX, VOICE_GRID_MIN_TILE_WIDTH_PX, VOICE_GRID_TILE_ASPECT_RATIO, -} from './VoiceGridLayoutMetrics'; +} from '@app/features/voice/components/VoiceGridLayoutMetrics'; +import {describe, expect, it} from 'vitest'; const EPSILON_PX = 0.001; diff --git a/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.test.ts b/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.test.ts index 674663cf8..65f61ae4b 100644 --- a/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.test.ts +++ b/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.test.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {VoiceState} from '@app/features/gateway/types/GatewayVoiceTypes'; +import {resolveVoiceParticipantAvatarEntryVoiceState} from '@app/features/voice/components/VoiceParticipantDisplayState'; import type {LivekitParticipantSnapshot} from '@app/features/voice/engine/VoiceParticipantStateMachine'; import {VoiceConnectionQuality} from '@app/features/voice/engine/VoiceTrackSource'; import {describe, expect, it} from 'vitest'; -import {resolveVoiceParticipantAvatarEntryVoiceState} from './VoiceParticipantDisplayState'; function createParticipantSnapshot(overrides: Partial = {}): LivekitParticipantSnapshot { return { diff --git a/fluxer_app/src/features/voice/components/VoiceParticipantDisplayState.test.ts b/fluxer_app/src/features/voice/components/VoiceParticipantDisplayState.test.ts index 61391d74f..88b0d8698 100644 --- a/fluxer_app/src/features/voice/components/VoiceParticipantDisplayState.test.ts +++ b/fluxer_app/src/features/voice/components/VoiceParticipantDisplayState.test.ts @@ -1,8 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {VoiceState} from '@app/features/gateway/types/GatewayVoiceTypes'; +import { + resolveVoiceParticipantDisplayState, + resolveVoiceParticipantSpeaking, +} from '@app/features/voice/components/VoiceParticipantDisplayState'; import {describe, expect, it} from 'vitest'; -import {resolveVoiceParticipantDisplayState, resolveVoiceParticipantSpeaking} from './VoiceParticipantDisplayState'; function voiceState(overrides: Partial): VoiceState { return overrides as VoiceState; diff --git a/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallHeightBounds.test.ts b/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallHeightBounds.test.ts index 496255bbe..00ca7e0a5 100644 --- a/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallHeightBounds.test.ts +++ b/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallHeightBounds.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { COMPACT_HEIGHT_CHAT_AREA_RESERVATION, COMPACT_HEIGHT_MIN, resolveCompactHeightMax, resolveCompactHeightMaxFromLayout, -} from './CompactVoiceCallHeightBounds'; +} from '@app/features/voice/components/compact_voice_call_view/CompactVoiceCallHeightBounds'; +import {describe, expect, it} from 'vitest'; describe('resolveCompactHeightMax', () => { it('reserves chat area space below the call view so the composer remains visible', () => { diff --git a/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallLayoutMetrics.test.ts b/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallLayoutMetrics.test.ts index 5c4bceef3..e1b5f0f0d 100644 --- a/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallLayoutMetrics.test.ts +++ b/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallLayoutMetrics.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { getCompactAudioAvatarLayoutStyle, resolveCompactAudioAvatarLayoutMetrics, resolveCompactControlGap, resolveCompactEdgeGradientExtension, -} from './CompactVoiceCallLayoutMetrics'; +} from '@app/features/voice/components/compact_voice_call_view/CompactVoiceCallLayoutMetrics'; +import {describe, expect, it} from 'vitest'; describe('CompactVoiceCallLayoutMetrics', () => { it('keeps the avatar row out of the compact footer gradient when controls are visible', () => { diff --git a/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallPresentationStateMachine.test.ts b/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallPresentationStateMachine.test.ts index b7e819cb8..b980657f3 100644 --- a/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallPresentationStateMachine.test.ts +++ b/fluxer_app/src/features/voice/components/compact_voice_call_view/CompactVoiceCallPresentationStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { type CompactVoiceCallPresentationInput, type CompactVoiceCallPresentationMachineSnapshot, @@ -9,7 +8,8 @@ import { resolveCompactVoiceCallPresentationModel, selectCompactVoiceCallPresentationModel, transitionCompactVoiceCallPresentationSnapshot, -} from './CompactVoiceCallPresentationStateMachine'; +} from '@app/features/voice/components/compact_voice_call_view/CompactVoiceCallPresentationStateMachine'; +import {describe, expect, it} from 'vitest'; function update( snapshot: CompactVoiceCallPresentationMachineSnapshot, diff --git a/fluxer_app/src/features/voice/components/media_player/utils/MediaSeekUtils.test.ts b/fluxer_app/src/features/voice/components/media_player/utils/MediaSeekUtils.test.ts index 146d39695..c1cabb475 100644 --- a/fluxer_app/src/features/voice/components/media_player/utils/MediaSeekUtils.test.ts +++ b/fluxer_app/src/features/voice/components/media_player/utils/MediaSeekUtils.test.ts @@ -2,7 +2,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {isAutoplayBlockedError} from '@app/features/voice/components/media_player/hooks/useMediaPlayer'; -import {afterEach, describe, expect, it} from 'vitest'; import { areBufferedSpanFractionsEqual, armPendingSeekTarget, @@ -17,7 +16,8 @@ import { readPendingSeekTarget, resolveDoubleTapSeekDirection, stepPlayheadPrediction, -} from './MediaSeekUtils'; +} from '@app/features/voice/components/media_player/utils/MediaSeekUtils'; +import {afterEach, describe, expect, it} from 'vitest'; function mediaWithBufferedRanges({ duration, diff --git a/fluxer_app/src/features/voice/components/modals/screen_share_picker_modal/shared.test.ts b/fluxer_app/src/features/voice/components/modals/screen_share_picker_modal/shared.test.ts index 2e2e38d91..4f5590e7e 100644 --- a/fluxer_app/src/features/voice/components/modals/screen_share_picker_modal/shared.test.ts +++ b/fluxer_app/src/features/voice/components/modals/screen_share_picker_modal/shared.test.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {DesktopSource, NativeScreenCaptureSource} from '@app/types/electron.d'; -import {describe, expect, test} from 'vitest'; import { findNativeCaptureSourceForDesktopSource, getDesktopSourceThumbnailStateKey, hasDesktopSourcesMissingThumbnails, isDisplaySource, mergeDesktopSources, -} from './shared'; +} from '@app/features/voice/components/modals/screen_share_picker_modal/shared'; +import type {DesktopSource, NativeScreenCaptureSource} from '@app/types/electron.d'; +import {describe, expect, test} from 'vitest'; const USABLE_IMAGE_DATA_URL = 'data:image/png;base64,aW1hZ2U='; diff --git a/fluxer_app/src/features/voice/components/voice_connection_status/LocalParticipantControlsStateMachine.test.ts b/fluxer_app/src/features/voice/components/voice_connection_status/LocalParticipantControlsStateMachine.test.ts index eb2216955..f82597a17 100644 --- a/fluxer_app/src/features/voice/components/voice_connection_status/LocalParticipantControlsStateMachine.test.ts +++ b/fluxer_app/src/features/voice/components/voice_connection_status/LocalParticipantControlsStateMachine.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { type LocalParticipantControlSignals, selectLocalParticipantControlsViewState, selectLocalParticipantMediaControlState, -} from './LocalParticipantControlsStateMachine'; +} from '@app/features/voice/components/voice_connection_status/LocalParticipantControlsStateMachine'; +import {describe, expect, it} from 'vitest'; function signals(overrides: Partial = {}): LocalParticipantControlSignals { return { diff --git a/fluxer_app/src/features/voice/engine/MediaEngineFacadeStateMachine.test.ts b/fluxer_app/src/features/voice/engine/MediaEngineFacadeStateMachine.test.ts index 417989721..073548513 100644 --- a/fluxer_app/src/features/voice/engine/MediaEngineFacadeStateMachine.test.ts +++ b/fluxer_app/src/features/voice/engine/MediaEngineFacadeStateMachine.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {GatewayErrorCodes} from '@fluxer/constants/src/GatewayConstants'; -import {describe, expect, it} from 'vitest'; import { createMediaEngineFacadeSnapshot, getMediaEngineFacadeStateValue, @@ -12,7 +10,9 @@ import { shouldImmediatelyDisconnectMediaEngineForServerVoiceStateRemoval, shouldRunMediaEngineDeferredDisconnect, transitionMediaEngineFacadeSnapshot, -} from './MediaEngineFacadeStateMachine'; +} from '@app/features/voice/engine/MediaEngineFacadeStateMachine'; +import {GatewayErrorCodes} from '@fluxer/constants/src/GatewayConstants'; +import {describe, expect, it} from 'vitest'; function connected(guildId: string | null = 'guild-1', channelId = 'channel-1') { return transitionMediaEngineFacadeSnapshot(createMediaEngineFacadeSnapshot(), { diff --git a/fluxer_app/src/features/voice/engine/ScreenShareCodecNegotiation.test.ts b/fluxer_app/src/features/voice/engine/ScreenShareCodecNegotiation.test.ts index 5f76ca5c2..070036f0b 100644 --- a/fluxer_app/src/features/voice/engine/ScreenShareCodecNegotiation.test.ts +++ b/fluxer_app/src/features/voice/engine/ScreenShareCodecNegotiation.test.ts @@ -86,7 +86,7 @@ const { computeNegotiatedVideoCodec, getScreenShareCodecPreferenceOrder, SCREEN_SHARE_CODEC_NEGOTIATION_TOPIC, -} = await import('./ScreenShareCodecNegotiation'); +} = await import('@app/features/voice/engine/ScreenShareCodecNegotiation'); const {resetCachedCodecCapabilities} = await import('@app/features/voice/utils/CodecCapabilityDetector'); const {RoomEvent} = await import('livekit-client'); diff --git a/fluxer_app/src/features/voice/engine/ScreenShareDecodeStallRenegotiation.test.ts b/fluxer_app/src/features/voice/engine/ScreenShareDecodeStallRenegotiation.test.ts index ce8446477..3e1b2abff 100644 --- a/fluxer_app/src/features/voice/engine/ScreenShareDecodeStallRenegotiation.test.ts +++ b/fluxer_app/src/features/voice/engine/ScreenShareDecodeStallRenegotiation.test.ts @@ -76,7 +76,7 @@ const { default: ScreenShareCodecNegotiation, buildLocalCodecAdvertisements, computeNegotiatedVideoCodec, -} = await import('./ScreenShareCodecNegotiation'); +} = await import('@app/features/voice/engine/ScreenShareCodecNegotiation'); const {findStalledVideoDecoder, scheduleScreenShareDecoderVerification} = await import( '@app/features/voice/utils/ScreenShareCodecDiagnostics' ); diff --git a/fluxer_app/src/features/voice/engine/Store.test.ts b/fluxer_app/src/features/voice/engine/Store.test.ts index c3c042035..303e2b199 100644 --- a/fluxer_app/src/features/voice/engine/Store.test.ts +++ b/fluxer_app/src/features/voice/engine/Store.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {Store} from '@app/features/voice/engine/Store'; import {autorun} from 'mobx'; import {describe, expect, it} from 'vitest'; -import {Store} from './Store'; class TestStore extends Store { bump(): void { diff --git a/fluxer_app/src/features/voice/engine/VoiceConnectionStateMachine.test.ts b/fluxer_app/src/features/voice/engine/VoiceConnectionStateMachine.test.ts index a94876b7b..2bfa7b7fd 100644 --- a/fluxer_app/src/features/voice/engine/VoiceConnectionStateMachine.test.ts +++ b/fluxer_app/src/features/voice/engine/VoiceConnectionStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { asVoiceEngineConnectionState, createVoiceConnectionSnapshot, @@ -10,7 +9,8 @@ import { transitionVoiceConnectionSnapshot, type VoiceConnectionSnapshot, VoiceEngineConnectionState, -} from './VoiceConnectionStateMachine'; +} from '@app/features/voice/engine/VoiceConnectionStateMachine'; +import {describe, expect, it} from 'vitest'; const roomA = {id: 'room-a'}; const roomB = {id: 'room-b'}; diff --git a/fluxer_app/src/features/voice/engine/VoiceGatewayStateMachine.test.ts b/fluxer_app/src/features/voice/engine/VoiceGatewayStateMachine.test.ts index 5e161464e..8b5a0038b 100644 --- a/fluxer_app/src/features/voice/engine/VoiceGatewayStateMachine.test.ts +++ b/fluxer_app/src/features/voice/engine/VoiceGatewayStateMachine.test.ts @@ -2,14 +2,14 @@ import type {GuildReadyData} from '@app/features/gateway/types/GatewayGuildTypes'; import type {VoiceState} from '@app/features/gateway/types/GatewayVoiceTypes'; -import {describe, expect, it} from 'vitest'; import { createVoiceGatewayStateSnapshot, transitionVoiceGatewayStateSnapshot, type VoiceGatewayStateContext, type VoiceGatewayStateEvent, type VoiceGatewayStateSnapshot, -} from './VoiceGatewayStateMachine'; +} from '@app/features/voice/engine/VoiceGatewayStateMachine'; +import {describe, expect, it} from 'vitest'; function voiceState(overrides: Partial = {}): VoiceState { return { diff --git a/fluxer_app/src/features/voice/engine/VoiceLocalAudioReconcilePolicy.test.ts b/fluxer_app/src/features/voice/engine/VoiceLocalAudioReconcilePolicy.test.ts index 94337e1f1..81ea0a74c 100644 --- a/fluxer_app/src/features/voice/engine/VoiceLocalAudioReconcilePolicy.test.ts +++ b/fluxer_app/src/features/voice/engine/VoiceLocalAudioReconcilePolicy.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createVoiceLocalAudioReconcileCoalescerSnapshot, createVoiceMicrophoneFailureLatchSnapshot, @@ -20,7 +19,8 @@ import { type VoiceLocalAudioReconcileCoalescerSnapshot, type VoiceMicrophoneFailureLatchEvent, type VoiceMicrophoneFailureLatchSnapshot, -} from './VoiceLocalAudioReconcilePolicy'; +} from '@app/features/voice/engine/VoiceLocalAudioReconcilePolicy'; +import {describe, expect, it} from 'vitest'; const RUNAWAY_RUN_LIMIT = 512; diff --git a/fluxer_app/src/features/voice/engine/VoiceLocalSpeakingGate.test.ts b/fluxer_app/src/features/voice/engine/VoiceLocalSpeakingGate.test.ts index a2674e3d6..daad25366 100644 --- a/fluxer_app/src/features/voice/engine/VoiceLocalSpeakingGate.test.ts +++ b/fluxer_app/src/features/voice/engine/VoiceLocalSpeakingGate.test.ts @@ -1,12 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import { - getLocalSpeakingThresholdRms, - LOCAL_MAX_RMS, - LOCAL_MIN_RMS, - SPEAKING_LOCAL_RELEASE_MS, -} from '@app/features/voice/engine/VoiceSpeakingThreshold'; -import {describe, expect, it} from 'vitest'; import { type LocalSpeakingOverrideInput, resolveLocalSpeakingOverrideState, @@ -15,7 +8,14 @@ import { updateVoiceActivityNoiseFloorRms, type VoiceActivityGateInput, type VoiceActivityGateState, -} from './VoiceLocalSpeakingGate'; +} from '@app/features/voice/engine/VoiceLocalSpeakingGate'; +import { + getLocalSpeakingThresholdRms, + LOCAL_MAX_RMS, + LOCAL_MIN_RMS, + SPEAKING_LOCAL_RELEASE_MS, +} from '@app/features/voice/engine/VoiceSpeakingThreshold'; +import {describe, expect, it} from 'vitest'; const UNMUTED_OPEN_MIC: LocalSpeakingOverrideInput = { pushToTalkActive: false, diff --git a/fluxer_app/src/features/voice/engine/VoiceMediaGraph.ts b/fluxer_app/src/features/voice/engine/VoiceMediaGraph.ts index 136b92b49..683491762 100644 --- a/fluxer_app/src/features/voice/engine/VoiceMediaGraph.ts +++ b/fluxer_app/src/features/voice/engine/VoiceMediaGraph.ts @@ -14,12 +14,12 @@ import { voiceMediaGraphPublicationMissingDeadlineKey, voiceMediaGraphWatchAttemptDeadlineKey, WATCH_ATTEMPT_TIMEOUT_MS, -} from './VoiceMediaGraphDeadlines'; +} from '@app/features/voice/engine/VoiceMediaGraphDeadlines'; import { reconcileVoiceMediaGraphSubscriptionEntry, voiceMediaGraphCommandAlreadyQueued, -} from './VoiceMediaGraphReconcile'; -import type {VoiceMediaGraphPartialTrackInfo} from './VoiceMediaGraphStats'; +} from '@app/features/voice/engine/VoiceMediaGraphReconcile'; +import type {VoiceMediaGraphPartialTrackInfo} from '@app/features/voice/engine/VoiceMediaGraphStats'; import { type VoiceMediaGraphStatsEntry, type VoiceMediaGraphStatsPlatform, @@ -27,7 +27,7 @@ import { type VoiceMediaGraphStatsTrackTarget, voiceMediaGraphStatsObservationMatchesTarget, voiceMediaGraphStatsTrackKey, -} from './VoiceMediaGraphStatsObservations'; +} from '@app/features/voice/engine/VoiceMediaGraphStatsObservations'; import type { VoiceMediaGraphPublicationLostEvent, VoiceMediaGraphPublicationObservedEvent, @@ -51,22 +51,25 @@ import type { VoiceMediaGraphSubscriptionSubscribeEvent, VoiceMediaGraphSubscriptionTarget, VoiceMediaGraphVideoQuality, -} from './VoiceMediaGraphSubscriptionTypes'; -import type {VoiceTrackSource} from './VoiceTrackSource'; +} from '@app/features/voice/engine/VoiceMediaGraphSubscriptionTypes'; +import type {VoiceTrackSource} from '@app/features/voice/engine/VoiceTrackSource'; export function voiceMediaGraphAttemptKeyIsOperation(attemptKey: string): boolean { assert.ok(attemptKey.length > 0, 'attemptKey is required'); return attemptKey.includes(':operation:'); } -export {systemVoiceMediaGraphClock, type VoiceMediaGraphClockPort} from './VoiceMediaGraphClock'; +export { + systemVoiceMediaGraphClock, + type VoiceMediaGraphClockPort, +} from '@app/features/voice/engine/VoiceMediaGraphClock'; export { buildVoiceMediaGraphNativeCameraQualityCommand, buildVoiceMediaGraphNativeCameraSubscriptionCommand, buildVoiceMediaGraphNativeScreenShareEnabledCommand, buildVoiceMediaGraphNativeScreenShareQualityCommand, buildVoiceMediaGraphNativeScreenShareSubscriptionCommands, -} from './VoiceMediaGraphCommands'; +} from '@app/features/voice/engine/VoiceMediaGraphCommands'; export { PUBLICATION_MISSING_TIMEOUT_MS, PUBLISHER_REPUBLISH_GRACE_MS, @@ -77,15 +80,18 @@ export { voiceMediaGraphPublicationMissingDeadlineKey, voiceMediaGraphWatchAttemptDeadlineKey, WATCH_ATTEMPT_TIMEOUT_MS, -} from './VoiceMediaGraphDeadlines'; -export {reconcileVoiceMediaGraphSubscriptionEntry, voiceMediaGraphCommandsEquivalent} from './VoiceMediaGraphReconcile'; +} from '@app/features/voice/engine/VoiceMediaGraphDeadlines'; +export { + reconcileVoiceMediaGraphSubscriptionEntry, + voiceMediaGraphCommandsEquivalent, +} from '@app/features/voice/engine/VoiceMediaGraphReconcile'; export { mergeVoiceMediaGraphTrackInfo, type VoiceMediaGraphNativeStatsTarget, type VoiceMediaGraphPartialTrackInfo, type VoiceMediaGraphPerTrackStatsTarget, type VoiceMediaGraphTrackInfo, -} from './VoiceMediaGraphStats'; +} from '@app/features/voice/engine/VoiceMediaGraphStats'; export type { VoiceMediaGraphStatsDirection, VoiceMediaGraphStatsEntry, @@ -93,7 +99,7 @@ export type { VoiceMediaGraphStatsPlatform, VoiceMediaGraphStatsTrackObservation, VoiceMediaGraphStatsTrackTarget, -} from './VoiceMediaGraphStatsObservations'; +} from '@app/features/voice/engine/VoiceMediaGraphStatsObservations'; export type { VoiceMediaGraphPublicationLostEvent, VoiceMediaGraphPublicationObservedEvent, @@ -125,7 +131,7 @@ export type { VoiceMediaGraphSubscriptionTarget, VoiceMediaGraphSubscriptionUnsubscribeEvent, VoiceMediaGraphVideoQuality, -} from './VoiceMediaGraphSubscriptionTypes'; +} from '@app/features/voice/engine/VoiceMediaGraphSubscriptionTypes'; export const VOICE_MEDIA_GRAPH_ENTRY_LIMIT = 256; export const VOICE_MEDIA_GRAPH_SCREEN_SHARE_SOURCE = 'screen_share'; diff --git a/fluxer_app/src/features/voice/engine/VoiceMediaGraphCommands.ts b/fluxer_app/src/features/voice/engine/VoiceMediaGraphCommands.ts index 5e0f3540a..ff6b8b632 100644 --- a/fluxer_app/src/features/voice/engine/VoiceMediaGraphCommands.ts +++ b/fluxer_app/src/features/voice/engine/VoiceMediaGraphCommands.ts @@ -4,8 +4,8 @@ import assert from 'node:assert/strict'; import type { VoiceMediaGraphRemoteSubscriptionCommand, VoiceMediaGraphVideoQuality, -} from './VoiceMediaGraphSubscriptionTypes'; -import {VoiceTrackSource} from './VoiceTrackSource'; +} from '@app/features/voice/engine/VoiceMediaGraphSubscriptionTypes'; +import {VoiceTrackSource} from '@app/features/voice/engine/VoiceTrackSource'; export function buildVoiceMediaGraphNativeScreenShareSubscriptionCommands(args: { participantIdentity: string; diff --git a/fluxer_app/src/features/voice/engine/VoiceMediaGraphInvariants.ts b/fluxer_app/src/features/voice/engine/VoiceMediaGraphInvariants.ts index 334ecf9f5..d138f7df8 100644 --- a/fluxer_app/src/features/voice/engine/VoiceMediaGraphInvariants.ts +++ b/fluxer_app/src/features/voice/engine/VoiceMediaGraphInvariants.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {VOICE_MEDIA_GRAPH_ENTRY_LIMIT, type VoiceMediaGraphSnapshot} from './VoiceMediaGraph'; +import {VOICE_MEDIA_GRAPH_ENTRY_LIMIT, type VoiceMediaGraphSnapshot} from '@app/features/voice/engine/VoiceMediaGraph'; function collectSubscriptionViolations(snapshot: VoiceMediaGraphSnapshot, violations: Array): void { let visited = 0; diff --git a/fluxer_app/src/features/voice/engine/VoiceMediaGraphReconcile.ts b/fluxer_app/src/features/voice/engine/VoiceMediaGraphReconcile.ts index 49c7bdd7b..dcd6314c3 100644 --- a/fluxer_app/src/features/voice/engine/VoiceMediaGraphReconcile.ts +++ b/fluxer_app/src/features/voice/engine/VoiceMediaGraphReconcile.ts @@ -4,7 +4,7 @@ import assert from 'node:assert/strict'; import type { VoiceMediaGraphSubscriptionCommand, VoiceMediaGraphSubscriptionEntry, -} from './VoiceMediaGraphSubscriptionTypes'; +} from '@app/features/voice/engine/VoiceMediaGraphSubscriptionTypes'; const VOICE_MEDIA_GRAPH_RECONCILE_SCAN_LIMIT = 2048; diff --git a/fluxer_app/src/features/voice/engine/VoiceMediaGraphStats.ts b/fluxer_app/src/features/voice/engine/VoiceMediaGraphStats.ts index 71027eb37..4fd60c94b 100644 --- a/fluxer_app/src/features/voice/engine/VoiceMediaGraphStats.ts +++ b/fluxer_app/src/features/voice/engine/VoiceMediaGraphStats.ts @@ -1,7 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2PerTrackStats} from '@fluxer/voice_engine_v2'; import { type VoiceMediaGraphStatsEntry, type VoiceMediaGraphStatsKind, @@ -10,8 +9,9 @@ import { type VoiceMediaGraphStatsTrackTarget, voiceMediaGraphStatsObservationMatchesTarget, voiceMediaGraphStatsTrackKey, -} from './VoiceMediaGraphStatsObservations'; -import type {VoiceTrackSource} from './VoiceTrackSource'; +} from '@app/features/voice/engine/VoiceMediaGraphStatsObservations'; +import type {VoiceTrackSource} from '@app/features/voice/engine/VoiceTrackSource'; +import type {VoiceEngineV2PerTrackStats} from '@fluxer/voice_engine_v2'; const VOICE_MEDIA_GRAPH_STATS_TRACK_LIMIT = 1024; diff --git a/fluxer_app/src/features/voice/engine/VoiceMediaGraphSubscriptionTypes.ts b/fluxer_app/src/features/voice/engine/VoiceMediaGraphSubscriptionTypes.ts index d6fe3453b..76afc683c 100644 --- a/fluxer_app/src/features/voice/engine/VoiceMediaGraphSubscriptionTypes.ts +++ b/fluxer_app/src/features/voice/engine/VoiceMediaGraphSubscriptionTypes.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceTrackSource} from './VoiceTrackSource'; +import type {VoiceTrackSource} from '@app/features/voice/engine/VoiceTrackSource'; export type VoiceMediaGraphVideoQuality = 'low' | 'medium' | 'high'; export type VoiceMediaGraphSubscriptionContext = 'focused' | 'carousel' | 'hidden'; diff --git a/fluxer_app/src/features/voice/engine/VoiceMediaGraphTileState.ts b/fluxer_app/src/features/voice/engine/VoiceMediaGraphTileState.ts index 58205b1ec..1723dc2e2 100644 --- a/fluxer_app/src/features/voice/engine/VoiceMediaGraphTileState.ts +++ b/fluxer_app/src/features/voice/engine/VoiceMediaGraphTileState.ts @@ -7,9 +7,9 @@ import { type VoiceMediaGraphFailure, type VoiceMediaGraphSnapshot, type VoiceMediaGraphSubscriptionEntry, -} from './VoiceMediaGraph'; -import {VOICE_MEDIA_GRAPH_FIRST_FRAME_TIMEOUT_FAILURE} from './VoiceMediaGraphDeadlines'; -import type {VoiceTrackSource} from './VoiceTrackSource'; +} from '@app/features/voice/engine/VoiceMediaGraph'; +import {VOICE_MEDIA_GRAPH_FIRST_FRAME_TIMEOUT_FAILURE} from '@app/features/voice/engine/VoiceMediaGraphDeadlines'; +import type {VoiceTrackSource} from '@app/features/voice/engine/VoiceTrackSource'; export const VOICE_MEDIA_GRAPH_FIRST_FRAME_RECOVERY_VISIBLE_MS = 30_000; diff --git a/fluxer_app/src/features/voice/engine/VoiceMediaGraphTimerScheduler.ts b/fluxer_app/src/features/voice/engine/VoiceMediaGraphTimerScheduler.ts index 7f82d22fd..fffe32b31 100644 --- a/fluxer_app/src/features/voice/engine/VoiceMediaGraphTimerScheduler.ts +++ b/fluxer_app/src/features/voice/engine/VoiceMediaGraphTimerScheduler.ts @@ -5,8 +5,8 @@ import { VOICE_MEDIA_GRAPH_ENTRY_LIMIT, type VoiceMediaGraphEvent, type VoiceMediaGraphSnapshot, -} from './VoiceMediaGraph'; -import {voiceMediaGraphStore} from './VoiceMediaGraphStore'; +} from '@app/features/voice/engine/VoiceMediaGraph'; +import {voiceMediaGraphStore} from '@app/features/voice/engine/VoiceMediaGraphStore'; export interface VoiceMediaGraphTimerSchedulerPlatform { setTimeout(callback: () => void, delayMs: number): unknown; diff --git a/fluxer_app/src/features/voice/engine/VoiceMediaStateMachine.test.ts b/fluxer_app/src/features/voice/engine/VoiceMediaStateMachine.test.ts index 901d497cb..3c6547a81 100644 --- a/fluxer_app/src/features/voice/engine/VoiceMediaStateMachine.test.ts +++ b/fluxer_app/src/features/voice/engine/VoiceMediaStateMachine.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { computeVoiceMediaEffectiveAudioState, createVoiceMediaSnapshot, transitionVoiceMediaSnapshot, type VoiceMediaAudioControls, type VoiceMediaSnapshot, -} from './VoiceMediaStateMachine'; +} from '@app/features/voice/engine/VoiceMediaStateMachine'; +import {describe, expect, it} from 'vitest'; const releasedPtt: VoiceMediaAudioControls = { pushToTalkActive: true, diff --git a/fluxer_app/src/features/voice/engine/VoiceParticipantStateMachine.test.ts b/fluxer_app/src/features/voice/engine/VoiceParticipantStateMachine.test.ts index 1b87131b5..fdfd4e1f3 100644 --- a/fluxer_app/src/features/voice/engine/VoiceParticipantStateMachine.test.ts +++ b/fluxer_app/src/features/voice/engine/VoiceParticipantStateMachine.test.ts @@ -1,12 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {SPEAKING_REMOTE_ATTACK_MS, SPEAKING_REMOTE_RELEASE_MS} from '@app/features/voice/engine/VoiceSpeakingThreshold'; -import { - VoiceConnectionQuality, - type VoiceConnectionQuality as VoiceConnectionQualityType, -} from '@app/features/voice/engine/VoiceTrackSource'; -import type {Participant, Room} from 'livekit-client'; -import {describe, expect, it} from 'vitest'; import { __TEST__, createLivekitParticipantSnapshot, @@ -18,7 +11,14 @@ import { transitionVoiceRemoteSpeakingSnapshot, type VoiceRemoteSpeakingCommand, type VoiceRemoteSpeakingSnapshot, -} from './VoiceParticipantStateMachine'; +} from '@app/features/voice/engine/VoiceParticipantStateMachine'; +import {SPEAKING_REMOTE_ATTACK_MS, SPEAKING_REMOTE_RELEASE_MS} from '@app/features/voice/engine/VoiceSpeakingThreshold'; +import { + VoiceConnectionQuality, + type VoiceConnectionQuality as VoiceConnectionQualityType, +} from '@app/features/voice/engine/VoiceTrackSource'; +import type {Participant, Room} from 'livekit-client'; +import {describe, expect, it} from 'vitest'; const connectionQuality = VoiceConnectionQuality.Good; diff --git a/fluxer_app/src/features/voice/engine/VoicePermissionStateMachine.test.ts b/fluxer_app/src/features/voice/engine/VoicePermissionStateMachine.test.ts index 77da1de58..4fd6ac97b 100644 --- a/fluxer_app/src/features/voice/engine/VoicePermissionStateMachine.test.ts +++ b/fluxer_app/src/features/voice/engine/VoicePermissionStateMachine.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceChannelPermissions} from '@app/features/voice/utils/VoicePermissionUtils'; -import {describe, expect, it} from 'vitest'; import { createVoicePermissionSnapshot, getVoicePermissionWatchStateValue, @@ -9,7 +7,9 @@ import { type VoicePermissionCommand, type VoicePermissionEvent, type VoicePermissionSnapshot, -} from './VoicePermissionStateMachine'; +} from '@app/features/voice/engine/VoicePermissionStateMachine'; +import type {VoiceChannelPermissions} from '@app/features/voice/utils/VoicePermissionUtils'; +import {describe, expect, it} from 'vitest'; const DEFAULT_PERMISSIONS: VoiceChannelPermissions = { canSpeak: true, diff --git a/fluxer_app/src/features/voice/engine/VoiceScreenShareStateMachine.test.ts b/fluxer_app/src/features/voice/engine/VoiceScreenShareStateMachine.test.ts index f85f0b5c2..74509fec9 100644 --- a/fluxer_app/src/features/voice/engine/VoiceScreenShareStateMachine.test.ts +++ b/fluxer_app/src/features/voice/engine/VoiceScreenShareStateMachine.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createVoiceScreenShareSnapshot, getVoiceScreenShareStateValue, transitionVoiceScreenShareSnapshot, type VoiceScreenShareSnapshot, -} from './VoiceScreenShareStateMachine'; +} from '@app/features/voice/engine/VoiceScreenShareStateMachine'; +import {describe, expect, it} from 'vitest'; const STREAM_KEY = 'guild-a:channel-a:connection-a'; diff --git a/fluxer_app/src/features/voice/engine/VoiceSelfJoinChime.test.ts b/fluxer_app/src/features/voice/engine/VoiceSelfJoinChime.test.ts index 77540cc57..78bab6076 100644 --- a/fluxer_app/src/features/voice/engine/VoiceSelfJoinChime.test.ts +++ b/fluxer_app/src/features/voice/engine/VoiceSelfJoinChime.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; import { discardVoiceJoinChimeSequence, resetSelfJoinChimesForTests, @@ -11,7 +10,8 @@ import { VOICE_JOIN_CHIME_SEQUENCE_RETENTION_MS, type VoiceJoinChimeSequenceResult, waitForVoiceJoinChimeSequence, -} from './VoiceSelfJoinChime'; +} from '@app/features/voice/engine/VoiceSelfJoinChime'; +import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; vi.mock('@app/features/ui/commands/SoundCommands', () => ({ playOneShotSoundImmediatelyBypassingSelfDeafened: vi.fn(() => Promise.resolve(true)), diff --git a/fluxer_app/src/features/voice/engine/VoiceStatsStateMachine.test.ts b/fluxer_app/src/features/voice/engine/VoiceStatsStateMachine.test.ts index 8884324de..2814e8d77 100644 --- a/fluxer_app/src/features/voice/engine/VoiceStatsStateMachine.test.ts +++ b/fluxer_app/src/features/voice/engine/VoiceStatsStateMachine.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceEngineV2PerTrackStats, VoiceEngineV2TransportInfo} from '@fluxer/voice_engine_v2'; -import {describe, expect, it} from 'vitest'; import { createInitialVoiceStats, createVoiceStatsSnapshot, @@ -11,7 +9,9 @@ import { selectVoiceStatsCollectionDecision, transitionVoiceStatsSnapshot, type VoiceStatsSnapshot, -} from './VoiceStatsStateMachine'; +} from '@app/features/voice/engine/VoiceStatsStateMachine'; +import type {VoiceEngineV2PerTrackStats, VoiceEngineV2TransportInfo} from '@fluxer/voice_engine_v2'; +import {describe, expect, it} from 'vitest'; const roomA = {id: 'room-a'}; const roomB = {id: 'room-b'}; diff --git a/fluxer_app/src/features/voice/engine/VoiceTrackPublicationUtils.ts b/fluxer_app/src/features/voice/engine/VoiceTrackPublicationUtils.ts index d4881e593..55e7b7122 100644 --- a/fluxer_app/src/features/voice/engine/VoiceTrackPublicationUtils.ts +++ b/fluxer_app/src/features/voice/engine/VoiceTrackPublicationUtils.ts @@ -1,7 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + asVoiceTrackSource, + type VoiceTrackSource, + VoiceTrackSource as VoiceTrackSourceValue, +} from '@app/features/voice/engine/VoiceTrackSource'; import type {LocalParticipant, LocalTrack, LocalTrackPublication} from 'livekit-client'; -import {asVoiceTrackSource, type VoiceTrackSource, VoiceTrackSource as VoiceTrackSourceValue} from './VoiceTrackSource'; interface LocalParticipantWithAudioPublications extends Pick {} interface LocalParticipantWithTrackPublications extends Pick {} diff --git a/fluxer_app/src/features/voice/engine/VoiceTrackSource.test.ts b/fluxer_app/src/features/voice/engine/VoiceTrackSource.test.ts index 2853d0b2d..8f1487088 100644 --- a/fluxer_app/src/features/voice/engine/VoiceTrackSource.test.ts +++ b/fluxer_app/src/features/voice/engine/VoiceTrackSource.test.ts @@ -1,7 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + asVoiceTrackSource, + isScreenShareAudioPublicationLike, + VoiceTrackSource, +} from '@app/features/voice/engine/VoiceTrackSource'; import {describe, expect, it} from 'vitest'; -import {asVoiceTrackSource, isScreenShareAudioPublicationLike, VoiceTrackSource} from './VoiceTrackSource'; describe('VoiceTrackSource', () => { it('normalizes native screen-share audio source aliases', () => { diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppAdapterAssertions.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppAdapterAssertions.test.ts index 0def32f58..2bb1afe98 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppAdapterAssertions.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppAdapterAssertions.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { assertBoolean, assertDisconnectReason, @@ -15,7 +14,8 @@ import { isMutedOrDeafened, isPermissionDeniedError, isReadyToRepublishTrack, -} from './VoiceEngineV2AppAdapterAssertions'; +} from '@app/features/voice/engine/v2/VoiceEngineV2AppAdapterAssertions'; +import {describe, expect, it} from 'vitest'; describe('VoiceEngineV2AppAdapterAssertions', () => { describe('assertNonEmptyString', () => { diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppAudioPreferencesSyncBinding.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppAudioPreferencesSyncBinding.ts index 1f772ea97..2cfd666be 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppAudioPreferencesSyncBinding.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppAudioPreferencesSyncBinding.ts @@ -3,16 +3,16 @@ import assert from 'node:assert/strict'; import ExperimentAssignments from '@app/features/experiment/state/ExperimentAssignments'; import VoiceDevicePermissionState from '@app/features/voice/engine/VoiceDevicePermissionState'; -import ParticipantVolume from '@app/features/voice/state/ParticipantVolume'; -import StreamAudioPrefs from '@app/features/voice/state/StreamAudioPrefs'; -import VoiceSettings from '@app/features/voice/state/VoiceSettings'; -import type {Room} from 'livekit-client'; import { createVoiceEngineV2AppAudioSettingsSnapshot, hasVoiceEngineV2InputProcessorSettingsChanged, hasVoiceEngineV2MicrophoneCaptureSettingsChanged, type VoiceEngineV2AppAudioSettingsSnapshot, -} from './VoiceEngineV2AppAudioSettingsSync'; +} from '@app/features/voice/engine/v2/VoiceEngineV2AppAudioSettingsSync'; +import ParticipantVolume from '@app/features/voice/state/ParticipantVolume'; +import StreamAudioPrefs from '@app/features/voice/state/StreamAudioPrefs'; +import VoiceSettings from '@app/features/voice/state/VoiceSettings'; +import type {Room} from 'livekit-client'; export interface VoiceEngineV2AppAudioPreferencesSnapshot { readonly audioSettings: VoiceEngineV2AppAudioSettingsSnapshot; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppCameraResolutionPresets.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppCameraResolutionPresets.test.ts index c28574e33..777bcfd42 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppCameraResolutionPresets.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppCameraResolutionPresets.test.ts @@ -1,9 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + getCameraCaptureDimensions, + pickCameraSubscriptionQuality, +} from '@app/features/voice/engine/v2/VoiceEngineV2AppCameraResolutionPresets'; import type {CameraResolution} from '@app/features/voice/state/VoiceSettings'; import {VideoPresets} from 'livekit-client'; import {describe, expect, it} from 'vitest'; -import {getCameraCaptureDimensions, pickCameraSubscriptionQuality} from './VoiceEngineV2AppCameraResolutionPresets'; const EXPECTED_PRESET_TABLE = [ {resolution: 'high', width: 1920, height: 1080, frameRate: 30, videoPreset: VideoPresets.h1080}, diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppControllerHostTestUtils.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppControllerHostTestUtils.ts index a9424e50a..0045b1735 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppControllerHostTestUtils.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppControllerHostTestUtils.ts @@ -1,14 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + createVoiceEngineV2AppControllerHost, + type VoiceEngineV2AppControllerHost, +} from '@app/features/voice/engine/v2/VoiceEngineV2AppControllerHost'; import { createVoiceEngineV2MemoryEventLogSpillSink, type VoiceEngineV2HostPorts, type VoiceEngineV2RuntimeClock, } from '@fluxer/voice_engine_v2'; -import { - createVoiceEngineV2AppControllerHost, - type VoiceEngineV2AppControllerHost, -} from './VoiceEngineV2AppControllerHost'; export interface VoiceEngineV2AppTestControllerHostOptions { ports: VoiceEngineV2HostPorts; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppDebugEventSinkHostAdapter.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppDebugEventSinkHostAdapter.ts index a0928b654..35d24ceed 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppDebugEventSinkHostAdapter.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppDebugEventSinkHostAdapter.ts @@ -8,6 +8,7 @@ import { openBrowserVoiceDebugEventSinkPopout, } from '@app/features/voice/diagnostics/VoiceDebugBrowserEventSinkPopout'; import {asVoiceTrackSource, VoiceTrackSource} from '@app/features/voice/engine/VoiceTrackSource'; +import {assertNonNullObject, assertString} from '@app/features/voice/engine/v2/VoiceEngineV2AppAdapterAssertions'; import type {DesktopVoiceDebugEventSinkEntry} from '@app/types/electron.d'; import type { LocalTrackPublication, @@ -18,7 +19,6 @@ import type { TrackPublication, } from 'livekit-client'; import {RoomEvent} from 'livekit-client'; -import {assertNonNullObject, assertString} from './VoiceEngineV2AppAdapterAssertions'; const logger = new Logger('VoiceEngineV2AppDebugEventSinkHostAdapter'); diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppDiagnosticsAdapter.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppDiagnosticsAdapter.test.ts index 84bd72fd9..fe30d388c 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppDiagnosticsAdapter.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppDiagnosticsAdapter.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createVoiceEngineV2AppDiagnosticsAdapter, VOICE_ENGINE_V2_DIAGNOSTICS_CODE_MAX_LENGTH, VOICE_ENGINE_V2_DIAGNOSTICS_MESSAGE_MAX_LENGTH, type VoiceEngineV2AppDiagnosticsLogger, type VoiceEngineV2DiagnosticsLevel, -} from './VoiceEngineV2AppDiagnosticsAdapter'; +} from '@app/features/voice/engine/v2/VoiceEngineV2AppDiagnosticsAdapter'; +import {describe, expect, it} from 'vitest'; interface FakeLoggerCall { level: VoiceEngineV2DiagnosticsLevel; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppEventLogSpillLoggerSink.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppEventLogSpillLoggerSink.test.ts index 5c4d2488a..d7d5f8f6c 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppEventLogSpillLoggerSink.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppEventLogSpillLoggerSink.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceEngineV2EventLogEntry} from '@fluxer/voice_engine_v2'; -import {describe, expect, it} from 'vitest'; import { createVoiceEngineV2AppEventLogSpillLoggerSink, type VoiceEngineV2AppEventLogSpillLogger, -} from './VoiceEngineV2AppEventLogSpillLoggerSink'; +} from '@app/features/voice/engine/v2/VoiceEngineV2AppEventLogSpillLoggerSink'; +import type {VoiceEngineV2EventLogEntry} from '@fluxer/voice_engine_v2'; +import {describe, expect, it} from 'vitest'; function makeEntry(sequence: number, atMs: number = sequence * 10): VoiceEngineV2EventLogEntry { return { diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppHostPorts.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppHostPorts.test.ts index d5a6c6b1d..d58a3b1cb 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppHostPorts.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppHostPorts.test.ts @@ -1,10 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createVoiceEngineV2AppTestControllerHost} from '@app/features/voice/engine/v2/VoiceEngineV2AppControllerHostTestUtils'; +import { + createVoiceEngineV2AppHostPorts, + createVoiceEngineV2AppIngestionPort, +} from '@app/features/voice/engine/v2/VoiceEngineV2AppHostPorts'; import type {VoiceEngineV2Event, VoiceEngineV2Stats} from '@fluxer/voice_engine_v2'; import {waitForRuntime} from '@fluxer/voice_engine_v2/testing'; import {describe, expect, it} from 'vitest'; -import {createVoiceEngineV2AppTestControllerHost} from './VoiceEngineV2AppControllerHostTestUtils'; -import {createVoiceEngineV2AppHostPorts, createVoiceEngineV2AppIngestionPort} from './VoiceEngineV2AppHostPorts'; type AppHostPortCall = | {type: 'gateway.writeVoiceState'} diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppHostPorts.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppHostPorts.ts index effb9b830..c93497bf7 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppHostPorts.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppHostPorts.ts @@ -1,5 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + VoiceEngineV2AppCapabilitiesAdapter, + type VoiceEngineV2NativeCapabilitiesBinding, +} from '@app/features/voice/engine/v2/VoiceEngineV2AppCapabilitiesAdapter'; +import type {VoiceEngineV2AppLifecycleAdapter} from '@app/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter'; +import type {VoiceEngineV2AppLiveKitExecutionAdapter} from '@app/features/voice/engine/v2/VoiceEngineV2AppLiveKitExecutionAdapter'; +import {createVoiceEngineV2AppSystemPermissionAdapter} from '@app/features/voice/engine/v2/VoiceEngineV2AppSystemPermissionAdapter'; import type { CapabilitiesPort, DevicePort, @@ -18,13 +25,6 @@ import type { VoiceEngineV2HostPorts, VoiceStateIngestionPort, } from '@fluxer/voice_engine_v2'; -import { - VoiceEngineV2AppCapabilitiesAdapter, - type VoiceEngineV2NativeCapabilitiesBinding, -} from './VoiceEngineV2AppCapabilitiesAdapter'; -import type {VoiceEngineV2AppLifecycleAdapter} from './VoiceEngineV2AppLifecycleAdapter'; -import type {VoiceEngineV2AppLiveKitExecutionAdapter} from './VoiceEngineV2AppLiveKitExecutionAdapter'; -import {createVoiceEngineV2AppSystemPermissionAdapter} from './VoiceEngineV2AppSystemPermissionAdapter'; export type VoiceEngineV2AppGatewayVoiceStateAdapter = GatewayPort; export type VoiceEngineV2AppVoiceStateIngestionAdapter = VoiceStateIngestionPort; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter.test.ts index 625d7f17a..953073335 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter.test.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {createVoiceEngineV2DeterministicClockPort} from '@fluxer/voice_engine_v2/runtime'; -import {describe, expect, it} from 'vitest'; -import type {VoiceEngineV2AppDiagnosticsLogger} from './VoiceEngineV2AppDiagnosticsAdapter'; +import type {VoiceEngineV2AppDiagnosticsLogger} from '@app/features/voice/engine/v2/VoiceEngineV2AppDiagnosticsAdapter'; import { createVoiceEngineV2AppLifecycleAdapter, LIFECYCLE_OPERATION_CAP, TEARDOWN_PER_DISPOSABLE_TIMEOUT_MS, type VoiceEngineV2AppLifecycleAdapter, type VoiceEngineV2AppLifecycleDisposable, -} from './VoiceEngineV2AppLifecycleAdapter'; +} from '@app/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter'; +import {createVoiceEngineV2DeterministicClockPort} from '@fluxer/voice_engine_v2/runtime'; +import {describe, expect, it} from 'vitest'; interface LoggerCall { readonly level: 'trace' | 'debug' | 'info' | 'warn' | 'error'; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter.ts index 61b488c35..c5c6464c5 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; +import type {VoiceEngineV2AppDiagnosticsLogger} from '@app/features/voice/engine/v2/VoiceEngineV2AppDiagnosticsAdapter'; import type {VoiceEngineV2ClockPort} from '@fluxer/voice_engine_v2/runtime'; -import type {VoiceEngineV2AppDiagnosticsLogger} from './VoiceEngineV2AppDiagnosticsAdapter'; export const LIFECYCLE_OPERATION_CAP = 4096; export const TEARDOWN_PER_DISPOSABLE_TIMEOUT_MS = 5000; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppMicrophoneTransaction.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppMicrophoneTransaction.test.ts index 7a0af9899..db6a2e845 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppMicrophoneTransaction.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppMicrophoneTransaction.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { chooseMicrophoneRefreshStrategy, computeSpeakingDetectorRms, @@ -8,7 +7,8 @@ import { createInitialMicrophoneRefreshState, readSpeakingDetectorThresholdRms, shouldReleaseSpeakingHold, -} from './VoiceEngineV2AppMicrophoneTransaction'; +} from '@app/features/voice/engine/v2/VoiceEngineV2AppMicrophoneTransaction'; +import {describe, expect, it} from 'vitest'; describe('VoiceEngineV2AppMicrophoneTransaction', () => { describe('createInitialMicrophoneEnableState', () => { diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppParticipantAdapter.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppParticipantAdapter.ts index b4e63cdc5..988dbdfb8 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppParticipantAdapter.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppParticipantAdapter.ts @@ -3,6 +3,7 @@ import assert from 'node:assert/strict'; import type {LivekitParticipantSnapshot} from '@app/features/voice/engine/VoiceParticipantStateMachine'; import {asVoiceConnectionQuality, VoiceTrackSource} from '@app/features/voice/engine/VoiceTrackSource'; +import {assertNonNullObject, assertString} from '@app/features/voice/engine/v2/VoiceEngineV2AppAdapterAssertions'; import type { VoiceEngineV2Controller, VoiceEngineV2Event, @@ -12,7 +13,6 @@ import type { } from '@fluxer/voice_engine_v2'; import type {Participant, Room, TrackPublication} from 'livekit-client'; import {Track} from 'livekit-client'; -import {assertNonNullObject, assertString} from './VoiceEngineV2AppAdapterAssertions'; const MAX_DISCARDED_CONNECTION_IDS = 4096; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppPermissionAdapter.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppPermissionAdapter.ts index 23897cecf..38770258d 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppPermissionAdapter.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppPermissionAdapter.ts @@ -30,7 +30,7 @@ export { createVoiceEngineV2AppSystemPermissionAdapter, VoiceEngineV2AppSystemPermissionAdapter, type VoiceEngineV2SystemPermissionsApi, -} from './VoiceEngineV2AppSystemPermissionAdapter'; +} from '@app/features/voice/engine/v2/VoiceEngineV2AppSystemPermissionAdapter'; const logger = new Logger('VoiceEngineV2AppPermissionAdapter'); diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProductionHostPorts.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProductionHostPorts.test.ts index 7bd9eea92..bd9efbd71 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProductionHostPorts.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProductionHostPorts.test.ts @@ -1,5 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createVoiceEngineV2AppTestControllerHost} from '@app/features/voice/engine/v2/VoiceEngineV2AppControllerHostTestUtils'; +import {createVoiceEngineV2AppIngestionPort} from '@app/features/voice/engine/v2/VoiceEngineV2AppHostPorts'; +import {createVoiceEngineV2AppLifecycleAdapter} from '@app/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter'; +import {createVoiceEngineV2AppProductionHostPorts} from '@app/features/voice/engine/v2/VoiceEngineV2AppProductionHostPorts'; +import type {VoiceEngineV2AppTimerScheduler} from '@app/features/voice/engine/v2/VoiceEngineV2AppTimerAdapter'; +import { + createVoiceEngineV2ShadowHostPorts, + type VoiceEngineV2ShadowHostPortCall, +} from '@app/features/voice/engine/v2/VoiceEngineV2ShadowHostPorts'; import { availableVoiceEngineV2Capabilities, type NativeMediaPort, @@ -14,12 +23,6 @@ import {createVoiceEngineV2DeterministicClockPort} from '@fluxer/voice_engine_v2 import {waitForRuntime} from '@fluxer/voice_engine_v2/testing'; import type {Room} from 'livekit-client'; import {describe, expect, it} from 'vitest'; -import {createVoiceEngineV2AppTestControllerHost} from './VoiceEngineV2AppControllerHostTestUtils'; -import {createVoiceEngineV2AppIngestionPort} from './VoiceEngineV2AppHostPorts'; -import {createVoiceEngineV2AppLifecycleAdapter} from './VoiceEngineV2AppLifecycleAdapter'; -import {createVoiceEngineV2AppProductionHostPorts} from './VoiceEngineV2AppProductionHostPorts'; -import type {VoiceEngineV2AppTimerScheduler} from './VoiceEngineV2AppTimerAdapter'; -import {createVoiceEngineV2ShadowHostPorts, type VoiceEngineV2ShadowHostPortCall} from './VoiceEngineV2ShadowHostPorts'; type ProductionCall = | {type: 'connect'; guildId: string | null; channelId: string} diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProductionHostPorts.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProductionHostPorts.ts index d403e6cf2..627e7e68e 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProductionHostPorts.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProductionHostPorts.ts @@ -1,5 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createVoiceEngineV2AppDevicesAdapter} from '@app/features/voice/engine/v2/VoiceEngineV2AppDevicesAdapter'; +import {createVoiceEngineV2AppDiagnosticsAdapter} from '@app/features/voice/engine/v2/VoiceEngineV2AppDiagnosticsAdapter'; +import { + createVoiceEngineV2AppHostPorts, + createVoiceEngineV2AppIngestionPort, + type VoiceEngineV2AppIngestionPort, +} from '@app/features/voice/engine/v2/VoiceEngineV2AppHostPorts'; +import { + createVoiceEngineV2AppLifecycleAdapter, + type VoiceEngineV2AppLifecycleAdapter, + type VoiceEngineV2AppLifecycleDisposable, +} from '@app/features/voice/engine/v2/VoiceEngineV2AppLifecycleAdapter'; +import { + type VoiceEngineV2AppLiveKitAudioOutputStore, + type VoiceEngineV2AppLiveKitConnectionDelegate, + VoiceEngineV2AppLiveKitExecutionAdapter, + type VoiceEngineV2AppLiveKitMediaDelegate, + type VoiceEngineV2AppLiveKitScreenShareDelegate, +} from '@app/features/voice/engine/v2/VoiceEngineV2AppLiveKitExecutionAdapter'; +import { + createVoiceEngineV2AppTimerAdapter, + type VoiceEngineV2AppTimerScheduler, +} from '@app/features/voice/engine/v2/VoiceEngineV2AppTimerAdapter'; import type { DevicePort, GatewayPort, @@ -10,26 +33,6 @@ import type { } from '@fluxer/voice_engine_v2'; import {createVoiceEngineV2SystemClockPort, type VoiceEngineV2ClockPort} from '@fluxer/voice_engine_v2/runtime'; import type {Room} from 'livekit-client'; -import {createVoiceEngineV2AppDevicesAdapter} from './VoiceEngineV2AppDevicesAdapter'; -import {createVoiceEngineV2AppDiagnosticsAdapter} from './VoiceEngineV2AppDiagnosticsAdapter'; -import { - createVoiceEngineV2AppHostPorts, - createVoiceEngineV2AppIngestionPort, - type VoiceEngineV2AppIngestionPort, -} from './VoiceEngineV2AppHostPorts'; -import { - createVoiceEngineV2AppLifecycleAdapter, - type VoiceEngineV2AppLifecycleAdapter, - type VoiceEngineV2AppLifecycleDisposable, -} from './VoiceEngineV2AppLifecycleAdapter'; -import { - type VoiceEngineV2AppLiveKitAudioOutputStore, - type VoiceEngineV2AppLiveKitConnectionDelegate, - VoiceEngineV2AppLiveKitExecutionAdapter, - type VoiceEngineV2AppLiveKitMediaDelegate, - type VoiceEngineV2AppLiveKitScreenShareDelegate, -} from './VoiceEngineV2AppLiveKitExecutionAdapter'; -import {createVoiceEngineV2AppTimerAdapter, type VoiceEngineV2AppTimerScheduler} from './VoiceEngineV2AppTimerAdapter'; export interface VoiceEngineV2AppProductionHostPortsLogger { trace(...args: Array): void; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProjectionStore.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProjectionStore.ts index f3621e448..d1971835d 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProjectionStore.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppProjectionStore.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; +import {Store} from '@app/features/voice/engine/Store'; +import type {VoiceEngineV2AppControllerHost} from '@app/features/voice/engine/v2/VoiceEngineV2AppControllerHost'; import type {VoiceEngineV2Model, VoiceEngineV2Snapshot} from '@fluxer/voice_engine_v2'; import {isVoiceEngineV2FrameReceivedEvent} from '@fluxer/voice_engine_v2/runtime'; -import {Store} from '../Store'; -import type {VoiceEngineV2AppControllerHost} from './VoiceEngineV2AppControllerHost'; export const FRAME_NOTIFY_FLUSH_INTERVAL_MS = 1000; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppRemoteSpeakingAdapter.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppRemoteSpeakingAdapter.ts index 08e671d8e..182440ce3 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppRemoteSpeakingAdapter.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppRemoteSpeakingAdapter.ts @@ -17,6 +17,11 @@ import { import {getSharedVoiceAudioContext} from '@app/features/voice/engine/VoiceSharedAudioContext'; import {getRemoteSpeakingThresholdRms} from '@app/features/voice/engine/VoiceSpeakingThreshold'; import {VoiceTrackKind, VoiceTrackSource} from '@app/features/voice/engine/VoiceTrackSource'; +import { + assertNonEmptyString, + assertNonNegativeFinite, + assertObjectLike, +} from '@app/features/voice/engine/v2/VoiceEngineV2AppAdapterAssertions'; import ParticipantVolume from '@app/features/voice/state/ParticipantVolume'; import { clearRemoteVoicePlaybackBoost, @@ -24,7 +29,6 @@ import { } from '@app/features/voice/state/RemoteVoicePlaybackBoost'; import VoiceSettings from '@app/features/voice/state/VoiceSettings'; import type {Participant, RemoteAudioTrack, RemoteTrack, RemoteTrackPublication, Room} from 'livekit-client'; -import {assertNonEmptyString, assertNonNegativeFinite, assertObjectLike} from './VoiceEngineV2AppAdapterAssertions'; const logger = new Logger('VoiceEngineV2AppRemoteSpeakingAdapter'); export const REMOTE_SPEAKING_ANALYSER_INTERVAL_MS = 50; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSelectors.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSelectors.test.ts index 36a2cbe76..9a52a1b1b 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSelectors.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSelectors.test.ts @@ -1,15 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import { - availableVoiceEngineV2Capabilities, - createVoiceEngineV2InitialSnapshot, - transitionVoiceEngineV2, - type VoiceEngineV2Event, - type VoiceEngineV2Snapshot, -} from '@fluxer/voice_engine_v2'; -import {replayVoiceEngineV2EventLogFixture, type VoiceEngineV2EventLogFixture} from '@fluxer/voice_engine_v2/testing'; -import {describe, expect, it} from 'vitest'; -import appVoiceSessionFixtureJson from '../../../../../../packages/voice_engine_v2/fixtures/event_logs/app_voice_session.json'; import { isVoiceEngineV2AppParticipantSpeaking, selectVoiceEngineV2AppConnection, @@ -32,7 +22,17 @@ import { selectVoiceEngineV2AppView, selectVoiceEngineV2AppWatchedStream, selectVoiceEngineV2AppWatchedStreams, -} from './VoiceEngineV2AppSelectors'; +} from '@app/features/voice/engine/v2/VoiceEngineV2AppSelectors'; +import { + availableVoiceEngineV2Capabilities, + createVoiceEngineV2InitialSnapshot, + transitionVoiceEngineV2, + type VoiceEngineV2Event, + type VoiceEngineV2Snapshot, +} from '@fluxer/voice_engine_v2'; +import appVoiceSessionFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/app_voice_session.json'; +import {replayVoiceEngineV2EventLogFixture, type VoiceEngineV2EventLogFixture} from '@fluxer/voice_engine_v2/testing'; +import {describe, expect, it} from 'vitest'; function replayEvents(events: Array): VoiceEngineV2Snapshot { let snapshot = createVoiceEngineV2InitialSnapshot(availableVoiceEngineV2Capabilities()); diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSelectors.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSelectors.ts index 89699ccd5..b32287dc0 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSelectors.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSelectors.ts @@ -1,6 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; +import {assertNonNullObject, assertString} from '@app/features/voice/engine/v2/VoiceEngineV2AppAdapterAssertions'; import { selectVoiceEngineV2Model, summarizeVoiceEngineV2Stats, @@ -24,7 +25,6 @@ import { type VoiceEngineV2TrackSource, type VoiceEngineV2WatchedStream, } from '@fluxer/voice_engine_v2'; -import {assertNonNullObject, assertString} from './VoiceEngineV2AppAdapterAssertions'; export type VoiceEngineV2AppProjectionSource = VoiceEngineV2Model | VoiceEngineV2Snapshot; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSourceLifecycleBridge.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSourceLifecycleBridge.ts index 35a52459d..3ef5416a4 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSourceLifecycleBridge.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppSourceLifecycleBridge.ts @@ -2,6 +2,7 @@ import assert from 'node:assert/strict'; import {Logger} from '@app/features/platform/utils/AppLogger'; +import {createVoiceEngineV2AppDiagnosticsAdapter} from '@app/features/voice/engine/v2/VoiceEngineV2AppDiagnosticsAdapter'; import type {NativeScreenCaptureLifecycleMessage} from '@app/types/electron.d'; import { type DiagnosticsPort, @@ -13,7 +14,6 @@ import { type VoiceEngineV2Event, type VoiceEngineV2SourceLifecycleTransitionedEvent, } from '@fluxer/voice_engine_v2'; -import {createVoiceEngineV2AppDiagnosticsAdapter} from './VoiceEngineV2AppDiagnosticsAdapter'; const VALID_LIFECYCLE_KINDS: ReadonlySet = new Set([ 'error', diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppStatsHostAdapter.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppStatsHostAdapter.ts index 63cc3f3c0..bb53f2594 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppStatsHostAdapter.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppStatsHostAdapter.ts @@ -17,6 +17,7 @@ import { type VoiceStatsSnapshot, } from '@app/features/voice/engine/VoiceStatsStateMachine'; import {asVoiceConnectionQuality, VoiceConnectionQuality} from '@app/features/voice/engine/VoiceTrackSource'; +import {assertFiniteNumber, assertNonNullObject} from '@app/features/voice/engine/v2/VoiceEngineV2AppAdapterAssertions'; import { classifyVideoDecoderAcceleration, classifyVideoEncoderAcceleration, @@ -30,7 +31,6 @@ import type { VoiceEngineV2TrackKind, } from '@fluxer/voice_engine_v2'; import type {Room} from 'livekit-client'; -import {assertFiniteNumber, assertNonNullObject} from './VoiceEngineV2AppAdapterAssertions'; const logger = new Logger('VoiceEngineV2AppStatsHostAdapter'); diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppTimerAdapter.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppTimerAdapter.test.ts index 731658df6..d4d7edb4d 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppTimerAdapter.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppTimerAdapter.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {createVoiceEngineV2DeterministicClockPort} from '@fluxer/voice_engine_v2/runtime'; -import {describe, expect, it} from 'vitest'; import { createVoiceEngineV2AppTimerAdapter, VOICE_ENGINE_V2_TIMER_REGISTRY_CAP, @@ -9,7 +7,9 @@ import { type VoiceEngineV2AppTimerHandle, VoiceEngineV2AppTimerRegistryFullError, type VoiceEngineV2AppTimerScheduler, -} from './VoiceEngineV2AppTimerAdapter'; +} from '@app/features/voice/engine/v2/VoiceEngineV2AppTimerAdapter'; +import {createVoiceEngineV2DeterministicClockPort} from '@fluxer/voice_engine_v2/runtime'; +import {describe, expect, it} from 'vitest'; interface FakeTimer { id: number; diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppVoiceStateAdapter.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppVoiceStateAdapter.test.ts index 94c3d820d..609863af3 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppVoiceStateAdapter.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2AppVoiceStateAdapter.test.ts @@ -3,9 +3,9 @@ import type {GuildReadyData} from '@app/features/gateway/types/GatewayGuildTypes'; import type {VoiceState} from '@app/features/gateway/types/GatewayVoiceTypes'; import {Logger} from '@app/features/platform/utils/AppLogger'; +import {VoiceEngineV2AppVoiceStateAdapter} from '@app/features/voice/engine/v2/VoiceEngineV2AppVoiceStateAdapter'; import {autorun} from 'mobx'; import {describe, expect, it, vi} from 'vitest'; -import {VoiceEngineV2AppVoiceStateAdapter} from './VoiceEngineV2AppVoiceStateAdapter'; function voiceState(overrides: Partial = {}): VoiceState { return { diff --git a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2ShadowHostPorts.test.ts b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2ShadowHostPorts.test.ts index 93d666216..8eb18ce2f 100644 --- a/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2ShadowHostPorts.test.ts +++ b/fluxer_app/src/features/voice/engine/v2/VoiceEngineV2ShadowHostPorts.test.ts @@ -1,9 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createVoiceEngineV2AppTestControllerHost} from '@app/features/voice/engine/v2/VoiceEngineV2AppControllerHostTestUtils'; +import { + createVoiceEngineV2ShadowHostPorts, + type VoiceEngineV2ShadowHostPortCall, +} from '@app/features/voice/engine/v2/VoiceEngineV2ShadowHostPorts'; import {waitForRuntime} from '@fluxer/voice_engine_v2/testing'; import {describe, expect, it} from 'vitest'; -import {createVoiceEngineV2AppTestControllerHost} from './VoiceEngineV2AppControllerHostTestUtils'; -import {createVoiceEngineV2ShadowHostPorts, type VoiceEngineV2ShadowHostPortCall} from './VoiceEngineV2ShadowHostPorts'; describe('VoiceEngineV2ShadowHostPorts', () => { it('records v2 command intent while returning deterministic host results', async () => { diff --git a/fluxer_app/src/features/voice/events/EntranceSoundPlay.test.ts b/fluxer_app/src/features/voice/events/EntranceSoundPlay.test.ts index 358063434..911706305 100644 --- a/fluxer_app/src/features/voice/events/EntranceSoundPlay.test.ts +++ b/fluxer_app/src/features/voice/events/EntranceSoundPlay.test.ts @@ -4,8 +4,8 @@ import type {GatewayHandlerContext} from '@app/features/gateway/events/EventRout import EntranceSoundPlaybackEngine from '@app/features/voice/engine/EntranceSoundPlaybackEngine'; import MediaEngine from '@app/features/voice/engine/MediaEngineFacade'; import {waitForVoiceJoinChimeSequence} from '@app/features/voice/engine/VoiceSelfJoinChime'; +import {handleEntranceSoundPlay} from '@app/features/voice/events/EntranceSoundPlay'; import {beforeEach, describe, expect, it, vi} from 'vitest'; -import {handleEntranceSoundPlay} from './EntranceSoundPlay'; vi.mock('@app/features/voice/engine/EntranceSoundPlaybackEngine', () => ({ default: {play: vi.fn(() => Promise.resolve())}, diff --git a/fluxer_app/src/features/voice/state/ActiveScreenShareSource.test.ts b/fluxer_app/src/features/voice/state/ActiveScreenShareSource.test.ts index 09e9652c8..8a67fb3c2 100644 --- a/fluxer_app/src/features/voice/state/ActiveScreenShareSource.test.ts +++ b/fluxer_app/src/features/voice/state/ActiveScreenShareSource.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import ActiveScreenShareSource from '@app/features/voice/state/ActiveScreenShareSource'; import {afterEach, describe, expect, it} from 'vitest'; -import ActiveScreenShareSource from './ActiveScreenShareSource'; describe('ActiveScreenShareSource', () => { afterEach(() => { diff --git a/fluxer_app/src/features/voice/state/LocalVoiceStateMachine.test.ts b/fluxer_app/src/features/voice/state/LocalVoiceStateMachine.test.ts index d1189554c..682ff511c 100644 --- a/fluxer_app/src/features/voice/state/LocalVoiceStateMachine.test.ts +++ b/fluxer_app/src/features/voice/state/LocalVoiceStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createLocalVoiceStateSnapshot, getActiveLocalVoiceState, @@ -8,7 +7,8 @@ import { type LocalVoiceStateEvent, type LocalVoiceStateSnapshot, transitionLocalVoiceStateSnapshot, -} from './LocalVoiceStateMachine'; +} from '@app/features/voice/state/LocalVoiceStateMachine'; +import {describe, expect, it} from 'vitest'; const CONNECTION_A = 'connection-a'; const CONNECTION_B = 'connection-b'; diff --git a/fluxer_app/src/features/voice/state/ScreenSharePiPStateMachine.test.ts b/fluxer_app/src/features/voice/state/ScreenSharePiPStateMachine.test.ts index 5798efa93..896329ed5 100644 --- a/fluxer_app/src/features/voice/state/ScreenSharePiPStateMachine.test.ts +++ b/fluxer_app/src/features/voice/state/ScreenSharePiPStateMachine.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createScreenSharePiPSnapshot, type ScreenSharePiPConditions, @@ -9,7 +8,8 @@ import { selectScreenSharePiPCommands, selectScreenSharePiPMode, transitionScreenSharePiPSnapshot, -} from './ScreenSharePiPStateMachine'; +} from '@app/features/voice/state/ScreenSharePiPStateMachine'; +import {describe, expect, it} from 'vitest'; function makeShare(overrides: Partial = {}): ScreenSharePiPScreenShare { return { diff --git a/fluxer_app/src/features/voice/state/ScreenShareWatchFailures.ts b/fluxer_app/src/features/voice/state/ScreenShareWatchFailures.ts index fc1e2b42a..24caa702c 100644 --- a/fluxer_app/src/features/voice/state/ScreenShareWatchFailures.ts +++ b/fluxer_app/src/features/voice/state/ScreenShareWatchFailures.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {RemoteTrackPublication} from 'livekit-client'; -import {runInAction} from 'mobx'; import { selectVoiceMediaGraphAttempt, selectVoiceMediaGraphFailure, @@ -10,9 +8,11 @@ import { VOICE_MEDIA_GRAPH_SCREEN_SHARE_SOURCE, type VoiceMediaGraphEvent, type VoiceMediaGraphSnapshot, -} from '../engine/VoiceMediaGraph'; -import {voiceMediaGraphStore} from '../engine/VoiceMediaGraphStore'; -import type {ScreenSharePublicationOperation} from '../utils/ScreenShareSubscriptionPolicy'; +} from '@app/features/voice/engine/VoiceMediaGraph'; +import {voiceMediaGraphStore} from '@app/features/voice/engine/VoiceMediaGraphStore'; +import type {ScreenSharePublicationOperation} from '@app/features/voice/utils/ScreenShareSubscriptionPolicy'; +import type {RemoteTrackPublication} from 'livekit-client'; +import {runInAction} from 'mobx'; export type {ScreenSharePublicationOperation}; diff --git a/fluxer_app/src/features/voice/state/VoiceSettingsCodecOptIn.test.ts b/fluxer_app/src/features/voice/state/VoiceSettingsCodecOptIn.test.ts index 848fb655e..d6144292d 100644 --- a/fluxer_app/src/features/voice/state/VoiceSettingsCodecOptIn.test.ts +++ b/fluxer_app/src/features/voice/state/VoiceSettingsCodecOptIn.test.ts @@ -50,7 +50,7 @@ async function loadVoiceSettings() { const debug = vi.spyOn(Logger.prototype, 'debug').mockImplementation(() => undefined); try { const [{default: VoiceSettings}, {default: MediaPermission}] = await Promise.all([ - import('./VoiceSettings'), + import('@app/features/voice/state/VoiceSettings'), import('@app/features/permissions/system/state/MediaPermission'), ]); await Promise.all([ @@ -74,7 +74,7 @@ async function loadVoiceSettings() { } const VoiceSettings = await loadVoiceSettings(); -const {applyManualAudioSourcesOptOutResetMigrationV1} = await import('./VoiceSettings'); +const {applyManualAudioSourcesOptOutResetMigrationV1} = await import('@app/features/voice/state/VoiceSettings'); describe('AV1/HEVC screen-share opt-in', () => { it('rewrites a stored AV1 screen-share preference back to automatic on first launch', () => { diff --git a/fluxer_app/src/features/voice/utils/AudioPublishOptions.test.ts b/fluxer_app/src/features/voice/utils/AudioPublishOptions.test.ts index 8209341c8..cfe81ae48 100644 --- a/fluxer_app/src/features/voice/utils/AudioPublishOptions.test.ts +++ b/fluxer_app/src/features/voice/utils/AudioPublishOptions.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {resolveVoiceChannelBitrate} from '@fluxer/constants/src/GuildConstants'; -import {describe, expect, it} from 'vitest'; import { buildMicrophonePublishOptions, normaliseAudioBitrateBps, OPUS_MAX_AUDIO_BITRATE_BPS, SCREEN_SHARE_AUDIO_PUBLISH_OPTIONS, -} from './AudioPublishOptions'; +} from '@app/features/voice/utils/AudioPublishOptions'; +import {resolveVoiceChannelBitrate} from '@fluxer/constants/src/GuildConstants'; +import {describe, expect, it} from 'vitest'; describe('normaliseAudioBitrateBps', () => { it('keeps stored channel bitrates in bits per second', () => { diff --git a/fluxer_app/src/features/voice/utils/CodecCapabilityDetector.test.ts b/fluxer_app/src/features/voice/utils/CodecCapabilityDetector.test.ts index 5f0c9fa44..df9a81110 100644 --- a/fluxer_app/src/features/voice/utils/CodecCapabilityDetector.test.ts +++ b/fluxer_app/src/features/voice/utils/CodecCapabilityDetector.test.ts @@ -72,7 +72,7 @@ const { resolveScreenShareEncoderVerificationAction, resolveVideoPublishCodecPolicy, selectAutomaticScreenShareCodec, -} = await import('./CodecCapabilityDetector'); +} = await import('@app/features/voice/utils/CodecCapabilityDetector'); const ALL_SOFTWARE: HardwareEncodeReport = { av1: 'software', diff --git a/fluxer_app/src/features/voice/utils/GpuEncoderCapabilities.test.ts b/fluxer_app/src/features/voice/utils/GpuEncoderCapabilities.test.ts index dc54078be..2f132f876 100644 --- a/fluxer_app/src/features/voice/utils/GpuEncoderCapabilities.test.ts +++ b/fluxer_app/src/features/voice/utils/GpuEncoderCapabilities.test.ts @@ -63,7 +63,7 @@ const { PCI_VENDOR_NVIDIA, probeWebRtcEncodeEfficiency, reconcileHardwareEncodeReport, -} = await import('./GpuEncoderCapabilities'); +} = await import('@app/features/voice/utils/GpuEncoderCapabilities'); const AMD_RDNA3_REPORT: HardwareEncodeReport = {...AMD_RDNA3_PLUS.caps, gpuFamily: AMD_RDNA3_PLUS.family}; const NVIDIA_REPORT: HardwareEncodeReport = {...NVIDIA_PRE_ADA.caps, gpuFamily: NVIDIA_PRE_ADA.family}; diff --git a/fluxer_app/src/features/voice/utils/LinuxAudioSourceRules.test.ts b/fluxer_app/src/features/voice/utils/LinuxAudioSourceRules.test.ts index c73a5ec5d..09c9801b7 100644 --- a/fluxer_app/src/features/voice/utils/LinuxAudioSourceRules.test.ts +++ b/fluxer_app/src/features/voice/utils/LinuxAudioSourceRules.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VirtmicNode} from '@app/types/electron.d'; -import {describe, expect, it} from 'vitest'; import { filterRoutableLinuxAudioSources, getLinuxAudioSourceDisplayName, @@ -13,7 +11,9 @@ import { toNativeLinuxAudioPattern, toNativeLinuxAudioPatterns, uniqueLinuxAudioSourceItems, -} from './LinuxAudioSourceRules'; +} from '@app/features/voice/utils/LinuxAudioSourceRules'; +import type {VirtmicNode} from '@app/types/electron.d'; +import {describe, expect, it} from 'vitest'; function node(overrides: VirtmicNode): VirtmicNode { return overrides; diff --git a/fluxer_app/src/features/voice/utils/ScreenShareAudioSummary.test.ts b/fluxer_app/src/features/voice/utils/ScreenShareAudioSummary.test.ts index 3741608c2..20ae4a6f4 100644 --- a/fluxer_app/src/features/voice/utils/ScreenShareAudioSummary.test.ts +++ b/fluxer_app/src/features/voice/utils/ScreenShareAudioSummary.test.ts @@ -16,7 +16,7 @@ const { NO_AUDIO_DESCRIPTOR, resolveScreenShareAudioSummary, SHARED_WINDOW_DESCRIPTOR, -} = await import('./ScreenShareAudioSummary'); +} = await import('@app/features/voice/utils/ScreenShareAudioSummary'); type ScreenShareAudioSummaryInput = Parameters[0]; function summary(overrides: Partial = {}) { diff --git a/fluxer_app/src/features/voice/utils/ScreenShareCodecDiagnostics.test.ts b/fluxer_app/src/features/voice/utils/ScreenShareCodecDiagnostics.test.ts index 4c9adc370..631761e53 100644 --- a/fluxer_app/src/features/voice/utils/ScreenShareCodecDiagnostics.test.ts +++ b/fluxer_app/src/features/voice/utils/ScreenShareCodecDiagnostics.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { confirmDecodeStall, findSoftwareVideoDecoder, findStalledVideoDecoder, isSoftwareVideoImplementation, type StalledVideoDecoderInfo, -} from './ScreenShareCodecDiagnostics'; +} from '@app/features/voice/utils/ScreenShareCodecDiagnostics'; +import {describe, expect, it} from 'vitest'; function createStatsReport(entries: Array>): RTCStatsReport { return new Map(entries.map((entry) => [entry.id as string, entry])) as unknown as RTCStatsReport; diff --git a/fluxer_app/src/features/voice/utils/ScreenShareCodecPolicy.ts b/fluxer_app/src/features/voice/utils/ScreenShareCodecPolicy.ts index f837421a9..2312a19d9 100644 --- a/fluxer_app/src/features/voice/utils/ScreenShareCodecPolicy.ts +++ b/fluxer_app/src/features/voice/utils/ScreenShareCodecPolicy.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import {PRODUCT_NAME} from '@app/features/app/config/I18nDisplayConstants'; +import type {HardwareEncodeReport} from '@app/features/voice/utils/GpuEncoderCapabilities'; import type {I18n} from '@lingui/core'; import {msg} from '@lingui/core/macro'; import type {VideoCodec} from 'livekit-client'; -import type {HardwareEncodeReport} from './GpuEncoderCapabilities'; const BEST_COMPRESSION_USE_IT_ONLY_WHEN_WEBRTC_EXPOSES_DESCRIPTOR = msg({ message: diff --git a/fluxer_app/src/features/voice/utils/ScreenShareOptions.test.ts b/fluxer_app/src/features/voice/utils/ScreenShareOptions.test.ts index a6f5466dd..6ca7e0160 100644 --- a/fluxer_app/src/features/voice/utils/ScreenShareOptions.test.ts +++ b/fluxer_app/src/features/voice/utils/ScreenShareOptions.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { buildScreenShareOptions, capScreenShareEncodingToDimensions, @@ -11,7 +10,8 @@ import { STREAMING_MODE_PRESETS, SUPPORTED_SCREEN_SHARE_FRAME_RATES, type SupportedScreenShareFrameRate, -} from './ScreenShareOptions'; +} from '@app/features/voice/utils/ScreenShareOptions'; +import {describe, expect, it} from 'vitest'; const RESOLUTIONS = ['low_240p', 'low_480p', 'medium', 'high', 'ultra', 'source'] as const; diff --git a/fluxer_app/src/features/voice/utils/StreamSettingsUpdatePolicy.test.ts b/fluxer_app/src/features/voice/utils/StreamSettingsUpdatePolicy.test.ts index 18518b845..3f3a36275 100644 --- a/fluxer_app/src/features/voice/utils/StreamSettingsUpdatePolicy.test.ts +++ b/fluxer_app/src/features/voice/utils/StreamSettingsUpdatePolicy.test.ts @@ -1,7 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {NativeAudioAvailability} from '@app/types/electron.d'; -import {describe, expect, it} from 'vitest'; import { canSelectManualAudioSources, isLinuxDesktopAudioShare, @@ -11,7 +9,9 @@ import { selectAppShareAudioRoute, shouldReconfigureAudioForActiveStreamSettings, supportsWindowShareAudioScope, -} from './StreamSettingsUpdatePolicy'; +} from '@app/features/voice/utils/StreamSettingsUpdatePolicy'; +import type {NativeAudioAvailability} from '@app/types/electron.d'; +import {describe, expect, it} from 'vitest'; const LINUX_PIPEWIRE: NativeAudioAvailability = { available: true, diff --git a/fluxer_app/src/features/voice/utils/VideoAccelerationClassification.test.ts b/fluxer_app/src/features/voice/utils/VideoAccelerationClassification.test.ts index 6d1365db8..cfd8d17c7 100644 --- a/fluxer_app/src/features/voice/utils/VideoAccelerationClassification.test.ts +++ b/fluxer_app/src/features/voice/utils/VideoAccelerationClassification.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { classifyVideoDecoderAcceleration, classifyVideoEncoderAcceleration, isHardwareVideoImplementation, isSoftwareVideoImplementation, -} from './VideoAccelerationClassification'; +} from '@app/features/voice/utils/VideoAccelerationClassification'; +import {describe, expect, it} from 'vitest'; describe('video acceleration implementation classification', () => { it('detects common software implementations', () => { diff --git a/fluxer_app/src/features/voice/utils/VoiceLatencySignal.test.ts b/fluxer_app/src/features/voice/utils/VoiceLatencySignal.test.ts index 2dd686e75..aaa02f6b3 100644 --- a/fluxer_app/src/features/voice/utils/VoiceLatencySignal.test.ts +++ b/fluxer_app/src/features/voice/utils/VoiceLatencySignal.test.ts @@ -1,7 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + getLatencySignalBaseline, + getLatencySignalState, + type LatencySignalSample, +} from '@app/features/voice/utils/VoiceLatencySignal'; import {describe, expect, it} from 'vitest'; -import {getLatencySignalBaseline, getLatencySignalState, type LatencySignalSample} from './VoiceLatencySignal'; function samples(...latencies: Array): Array { return latencies.map((latency) => ({latency})); diff --git a/fluxer_app/src/features/voice/utils/camera-effects/WebCameraEffectCustomImage.ts b/fluxer_app/src/features/voice/utils/camera-effects/WebCameraEffectCustomImage.ts index c17557a87..ea3bf3414 100644 --- a/fluxer_app/src/features/voice/utils/camera-effects/WebCameraEffectCustomImage.ts +++ b/fluxer_app/src/features/voice/utils/camera-effects/WebCameraEffectCustomImage.ts @@ -5,6 +5,7 @@ import { readBoundedResponseBlob, runWithResponseDeadline, } from '@app/features/voice/utils/camera-effects/BoundedResponse'; +import type {WebCameraEffectCustomFrameSource} from '@app/features/voice/utils/camera-effects/WebCameraEffectCustomFrameSource'; import {createWebCameraEffectImageFrameSource} from '@app/features/voice/utils/camera-effects/WebCameraEffectCustomFrameSource'; export type { @@ -18,8 +19,6 @@ export { WebCameraEffectCustomFrameSourceKind, } from '@app/features/voice/utils/camera-effects/WebCameraEffectCustomFrameSource'; -import type {WebCameraEffectCustomFrameSource} from '@app/features/voice/utils/camera-effects/WebCameraEffectCustomFrameSource'; - const MAX_CUSTOM_MEDIA_BYTES = 10 * 1024 * 1024; const MAX_CUSTOM_MEDIA_URL_LENGTH = 16 * 1024; const MAX_CUSTOM_MEDIA_RESPONSE_CHUNKS = 4096; diff --git a/fluxer_app/src/features/voice/utils/camera-effects/WebSelfieSegmenter.ts b/fluxer_app/src/features/voice/utils/camera-effects/WebSelfieSegmenter.ts index 08a1c4646..687bb83ba 100644 --- a/fluxer_app/src/features/voice/utils/camera-effects/WebSelfieSegmenter.ts +++ b/fluxer_app/src/features/voice/utils/camera-effects/WebSelfieSegmenter.ts @@ -10,6 +10,7 @@ import { readBoundedResponseArrayBuffer, runWithResponseDeadline, } from '@app/features/voice/utils/camera-effects/BoundedResponse'; +import modelAssetUrl from '@app/features/voice/utils/camera-effects/models/selfie_segmentation_256x256.onnx'; import { shapeWebCameraEffectMaskAlpha, WEB_CAMERA_EFFECT_MASK_CORE_GROW_MIN, @@ -23,7 +24,6 @@ import { } from '@app/features/voice/utils/camera-effects/WebCameraEffectMask'; import ortWasmUrl from 'onnxruntime-web/ort-wasm-simd-threaded.asyncify.wasm'; import type * as OrtNamespace from 'onnxruntime-web/webgpu'; -import modelAssetUrl from './models/selfie_segmentation_256x256.onnx'; export class MissingSegmentationAlphasOutputError extends Error { constructor() { diff --git a/fluxer_app/src/features/voice/utils/native_audio_capture_bridge/bridgeStats.test.ts b/fluxer_app/src/features/voice/utils/native_audio_capture_bridge/bridgeStats.test.ts index 29defd223..5cdc353e0 100644 --- a/fluxer_app/src/features/voice/utils/native_audio_capture_bridge/bridgeStats.test.ts +++ b/fluxer_app/src/features/voice/utils/native_audio_capture_bridge/bridgeStats.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it, vi} from 'vitest'; import { endBridgeStats, getBridgeStats, getEndedBridgeCaptures, recordBridgeFrame, startBridgeStats, -} from './bridgeStats'; +} from '@app/features/voice/utils/native_audio_capture_bridge/bridgeStats'; +import {describe, expect, it, vi} from 'vitest'; function recordFrames(captureId: string, count: number, peak: number, rms: number): void { for (let index = 0; index < count; index++) { diff --git a/fluxer_app/src/features/voice/utils/native_audio_capture_bridge/shared.test.ts b/fluxer_app/src/features/voice/utils/native_audio_capture_bridge/shared.test.ts index 9e89a4ad5..f02702555 100644 --- a/fluxer_app/src/features/voice/utils/native_audio_capture_bridge/shared.test.ts +++ b/fluxer_app/src/features/voice/utils/native_audio_capture_bridge/shared.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { GENERATOR_AUDIO_CHUNK_DURATION_US, mixToStereoInterleaved, NativeAudioFrameChunker, resampleInterleavedStereo, shouldMixSelfWindowAudioIntoSystemCapture, -} from './shared'; +} from '@app/features/voice/utils/native_audio_capture_bridge/shared'; +import {describe, expect, it} from 'vitest'; function expectSamples(actual: Float32Array, expected: ReadonlyArray): void { expect(Array.from(actual)).toEqual(expected); diff --git a/fluxer_app/src/lib/forms/RemoteFormReset.test.ts b/fluxer_app/src/lib/forms/RemoteFormReset.test.ts index d4a4e9620..cee358d1d 100644 --- a/fluxer_app/src/lib/forms/RemoteFormReset.test.ts +++ b/fluxer_app/src/lib/forms/RemoteFormReset.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { createRemoteFormResetMachineSnapshot, getRemoteFormResetDecision, @@ -8,7 +7,8 @@ import { type RemoteFormResetMachineEvent, type RemoteFormResetMachineSnapshot, transitionRemoteFormResetSnapshot, -} from './RemoteFormReset'; +} from '@app/lib/forms/RemoteFormReset'; +import {describe, expect, it} from 'vitest'; function transition( snapshot: RemoteFormResetMachineSnapshot, diff --git a/fluxer_app/src/lib/forms/TransientUploadFields.test.ts b/fluxer_app/src/lib/forms/TransientUploadFields.test.ts index dfd45ec4f..9751b6a68 100644 --- a/fluxer_app/src/lib/forms/TransientUploadFields.test.ts +++ b/fluxer_app/src/lib/forms/TransientUploadFields.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { assignTransientUploadFieldMutation, getTransientUploadFieldMutation, omitTransientUploadFields, -} from './TransientUploadFields'; +} from '@app/lib/forms/TransientUploadFields'; +import {describe, expect, it} from 'vitest'; describe('getTransientUploadFieldMutation', () => { it('preserves the existing remote asset when there is no explicit upload or clear', () => { diff --git a/fluxer_desktop/scripts/build.mjs b/fluxer_desktop/scripts/build.mjs index c317d6521..4060d6a33 100644 --- a/fluxer_desktop/scripts/build.mjs +++ b/fluxer_desktop/scripts/build.mjs @@ -33,46 +33,6 @@ const electronExternals = [ '@fluxer/webauthn', 'hunspell-asm', ]; -const pathAliasPlugin = { - name: 'path-alias', - setup(build) { - build.onResolve({filter: /^@electron\//}, (args) => { - const relativePath = args.path.replace(/^@electron\//, ''); - const absolutePath = path.join(SRC_DIR, relativePath); - const extensions = ['.tsx', '.ts', '.js', '.jsx']; - for (const ext of extensions) { - const fullPath = absolutePath + ext; - if (fs.existsSync(fullPath)) { - return {path: fullPath}; - } - } - for (const ext of extensions) { - const indexPath = path.join(absolutePath, `index${ext}`); - if (fs.existsSync(indexPath)) { - return {path: indexPath}; - } - } - return {path: `${absolutePath}.tsx`}; - }); - build.onResolve({filter: /^@fluxer\/voice_engine_v2(?:\/.*)?$/}, (args) => { - const packageSrcDir = path.join(ROOT_DIR, '..', 'packages', 'voice_engine_v2', 'src'); - if (args.path === '@fluxer/voice_engine_v2') { - return {path: path.join(packageSrcDir, 'index.ts')}; - } - const relativePath = args.path.replace(/^@fluxer\/voice_engine_v2\//, ''); - const directTsPath = path.join(packageSrcDir, `${relativePath}.ts`); - if (fs.existsSync(directTsPath)) { - return {path: directTsPath}; - } - const indexTsPath = path.join(packageSrcDir, relativePath, 'index.ts'); - if (fs.existsSync(indexTsPath)) { - return {path: indexTsPath}; - } - return {path: path.join(packageSrcDir, relativePath)}; - }); - }, -}; - function findNodeBinary(rootDir) { const matches = []; for (const entry of fs.readdirSync(rootDir)) { @@ -609,7 +569,6 @@ async function buildMain() { minify: isProduction, sourcemap: true, external: electronExternals, - plugins: [pathAliasPlugin], define: { 'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development'), ...publicBuildDefines, @@ -628,7 +587,6 @@ async function buildMain() { minify: isProduction, sourcemap: true, external: electronExternals, - plugins: [pathAliasPlugin], define: { 'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development'), ...publicBuildDefines, @@ -653,7 +611,6 @@ async function buildPreload() { minify: isProduction, sourcemap: true, external: electronExternals, - plugins: [pathAliasPlugin], define: { 'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development'), ...publicBuildDefines, diff --git a/fluxer_desktop/src/main/DisplayMedia.ts b/fluxer_desktop/src/main/DisplayMedia.ts index 4dd75c7a6..1197daee5 100644 --- a/fluxer_desktop/src/main/DisplayMedia.ts +++ b/fluxer_desktop/src/main/DisplayMedia.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {BrowserWindow, desktopCapturer, ipcMain, screen} from 'electron'; -import log from 'electron-log'; import { isListOnlyDesktopSourcesOption, isValidDesktopSourceId, isValidDisplayMediaRequestId, normalizeDesktopSourceTypes, shouldHonorSelectedAudio, -} from './DisplayMediaValidation'; -import {startWindowsScreenCaptureGuardForSource} from './WindowsScreenCaptureGuard'; +} from '@electron/main/DisplayMediaValidation'; +import {startWindowsScreenCaptureGuardForSource} from '@electron/main/WindowsScreenCaptureGuard'; +import {BrowserWindow, desktopCapturer, ipcMain, screen} from 'electron'; +import log from 'electron-log'; type DisplayMediaPortalSurfacePreference = 'window' | 'monitor'; diff --git a/fluxer_desktop/src/main/LinuxAudioCapture.ts b/fluxer_desktop/src/main/LinuxAudioCapture.ts index 5f06c02dd..71c3a9090 100644 --- a/fluxer_desktop/src/main/LinuxAudioCapture.ts +++ b/fluxer_desktop/src/main/LinuxAudioCapture.ts @@ -10,21 +10,21 @@ import type { VirtmicRoutingGraphResult, VirtmicUnavailableReason, } from '@electron/common/Types'; +import {buildFluxerAudioExcludePatterns, isFluxerAudioNode} from '@electron/main/FluxerAudioIdentity'; import {getLinuxPortalsMode, getNativeAudioMode} from '@electron/main/LaunchOptions'; -import {app, ipcMain} from 'electron'; -import {buildFluxerAudioExcludePatterns, isFluxerAudioNode} from './FluxerAudioIdentity'; import { isDBusObjectPathSegment, isWaylandSessionEnv, isX11SessionEnv, isX11WindowToken, parseWindowSourceToken, -} from './LinuxAudioCaptureHelpers'; +} from '@electron/main/LinuxAudioCaptureHelpers'; import { isValidVirtmicLinkOptions, isValidVirtmicNodeList, isValidVirtmicSystemLinkOptions, -} from './NativeAudioValidation'; +} from '@electron/main/NativeAudioValidation'; +import {app, ipcMain} from 'electron'; const logger = createChildLogger('LinuxAudioCapture'); const requireModule = createRequire(import.meta.url); diff --git a/fluxer_desktop/src/main/NativeAudio.ts b/fluxer_desktop/src/main/NativeAudio.ts index 66a2c7c06..f2c4d0be3 100644 --- a/fluxer_desktop/src/main/NativeAudio.ts +++ b/fluxer_desktop/src/main/NativeAudio.ts @@ -14,19 +14,19 @@ import type { VirtmicNode, VirtmicRoutingGraph, } from '@electron/common/Types'; +import {buildFluxerAudioExcludePatterns, isKnownFluxerAudioProcessPid} from '@electron/main/FluxerAudioIdentity'; import {getNativeAudioMode} from '@electron/main/LaunchOptions'; -import {ipcMain} from 'electron'; -import {buildFluxerAudioExcludePatterns, isKnownFluxerAudioProcessPid} from './FluxerAudioIdentity'; -import {resolveVirtmicWindowPid} from './LinuxAudioCapture'; -import {parseWindowSourceToken as parseDesktopWindowSourceToken} from './LinuxAudioCaptureHelpers'; -import {getTccStatus} from './MacTcc'; +import {resolveVirtmicWindowPid} from '@electron/main/LinuxAudioCapture'; +import {parseWindowSourceToken as parseDesktopWindowSourceToken} from '@electron/main/LinuxAudioCaptureHelpers'; +import {getTccStatus} from '@electron/main/MacTcc'; import { audioFrameDebugDetails, isValidAudioFrame, isValidLinuxRule, isValidTargetPid, normalizeTimestampUs, -} from './NativeAudioValidation'; +} from '@electron/main/NativeAudioValidation'; +import {ipcMain} from 'electron'; const logger = createChildLogger('NativeAudio'); const requireModule = createRequire(import.meta.url); diff --git a/fluxer_desktop/src/main/NativeScreenCapture.test.mjs b/fluxer_desktop/src/main/NativeScreenCapture.test.mjs index 24c9e2e77..3be665835 100644 --- a/fluxer_desktop/src/main/NativeScreenCapture.test.mjs +++ b/fluxer_desktop/src/main/NativeScreenCapture.test.mjs @@ -141,16 +141,16 @@ function loadNativeScreenCapture({platform = 'linux', addon, tccStatus = 'not-de }, }; } - if (specifier === './MacTcc') { + if (specifier === '@electron/main/MacTcc') { return {getTccStatus: () => tccStatus}; } - if (specifier === './NativeScreenCaptureValidation') { + if (specifier === '@electron/main/NativeScreenCaptureValidation') { return { isValidStartOptions: () => true, normalizeScreenCaptureDimension: (value) => value, }; } - if (specifier === './PrivilegedRendererDocuments') { + if (specifier === '@electron/main/PrivilegedRendererDocuments') { return {requirePrivilegedRendererDocumentSender: () => {}}; } throw new Error(`Unexpected import: ${specifier}`); diff --git a/fluxer_desktop/src/main/NativeScreenCapture.ts b/fluxer_desktop/src/main/NativeScreenCapture.ts index 9cd52cade..f193c3ca8 100644 --- a/fluxer_desktop/src/main/NativeScreenCapture.ts +++ b/fluxer_desktop/src/main/NativeScreenCapture.ts @@ -16,10 +16,10 @@ import type { NativeScreenCaptureStartResult, WindowsHagsState, } from '@electron/common/Types'; +import {getTccStatus} from '@electron/main/MacTcc'; +import {isValidStartOptions, normalizeScreenCaptureDimension} from '@electron/main/NativeScreenCaptureValidation'; +import {requirePrivilegedRendererDocumentSender} from '@electron/main/PrivilegedRendererDocuments'; import {ipcMain} from 'electron'; -import {getTccStatus} from './MacTcc'; -import {isValidStartOptions, normalizeScreenCaptureDimension} from './NativeScreenCaptureValidation'; -import {requirePrivilegedRendererDocumentSender} from './PrivilegedRendererDocuments'; const logger = createChildLogger('NativeScreenCapture'); const requireModule = createRequire(import.meta.url); diff --git a/fluxer_desktop/src/main/StreamingPriority.test.mjs b/fluxer_desktop/src/main/StreamingPriority.test.mjs index 57beb6c0a..266e08617 100644 --- a/fluxer_desktop/src/main/StreamingPriority.test.mjs +++ b/fluxer_desktop/src/main/StreamingPriority.test.mjs @@ -116,7 +116,7 @@ function loadStreamingPriority({ if (specifier === 'node:os') return osModule; if (specifier === 'electron') return {app, powerSaveBlocker}; if (specifier === 'electron-log') return log; - if (specifier === './WindowsScreenCaptureGuard') return guard; + if (specifier === '@electron/main/WindowsScreenCaptureGuard') return guard; throw new Error(`Unexpected import: ${specifier}`); } diff --git a/fluxer_desktop/src/main/StreamingPriority.ts b/fluxer_desktop/src/main/StreamingPriority.ts index 85a4f81b6..3ee64f463 100644 --- a/fluxer_desktop/src/main/StreamingPriority.ts +++ b/fluxer_desktop/src/main/StreamingPriority.ts @@ -2,9 +2,9 @@ import {createRequire} from 'node:module'; import os from 'node:os'; +import {retainWindowsScreenCaptureGuard, stopWindowsScreenCaptureGuard} from '@electron/main/WindowsScreenCaptureGuard'; import {app, powerSaveBlocker} from 'electron'; import log from 'electron-log'; -import {retainWindowsScreenCaptureGuard, stopWindowsScreenCaptureGuard} from './WindowsScreenCaptureGuard'; const STREAMING_PRIORITY = os.constants?.priority?.PRIORITY_ABOVE_NORMAL ?? -7; const CAN_ELEVATE_PROCESS_PRIORITY = process.platform === 'win32'; diff --git a/fluxer_desktop/tsconfig.json b/fluxer_desktop/tsconfig.json index 232963987..ad3850557 100644 --- a/fluxer_desktop/tsconfig.json +++ b/fluxer_desktop/tsconfig.json @@ -15,7 +15,7 @@ "paths": { "@electron/*": ["./src/*"], "@fluxer/voice_engine_v2": ["../packages/voice_engine_v2/src/index.ts"], - "@fluxer/voice_engine_v2/*": ["../packages/voice_engine_v2/src/*"] + "@fluxer/voice_engine_v2/*": ["../packages/voice_engine_v2/*"] } }, "include": ["src/**/*", "../packages/voice_engine_v2/src/**/*"], diff --git a/fluxer_docs/scripts/DocsTableWidth.ts b/fluxer_docs/scripts/DocsTableWidth.ts index e6e886643..a0d5d2928 100644 --- a/fluxer_docs/scripts/DocsTableWidth.ts +++ b/fluxer_docs/scripts/DocsTableWidth.ts @@ -12,7 +12,7 @@ import { TABLE_MAX_COLUMNS, TABLE_MAX_IDENT_CHARS, TABLE_WIDE_TIER_PX, -} from '../src/table/DocsTableMetrics.ts'; +} from '@/table/DocsTableMetrics.ts'; import {splitTableRow} from './DocsSource.ts'; export { diff --git a/fluxer_docs/scripts/Healthcheck.ts b/fluxer_docs/scripts/Healthcheck.ts index 116c0e8da..09aeb740c 100644 --- a/fluxer_docs/scripts/Healthcheck.ts +++ b/fluxer_docs/scripts/Healthcheck.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {checkAstroServerHealth} from '../src/server/AstroServer'; -import {docsListenHost, docsListenPort} from '../src/server/DocsConfig'; +import {checkAstroServerHealth} from '@/server/AstroServer'; +import {docsListenHost, docsListenPort} from '@/server/DocsConfig'; await checkAstroServerHealth({ listenHost: docsListenHost(), diff --git a/fluxer_docs/scripts/StartServer.ts b/fluxer_docs/scripts/StartServer.ts index 311a58fd2..7b42f2c7b 100644 --- a/fluxer_docs/scripts/StartServer.ts +++ b/fluxer_docs/scripts/StartServer.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {runAstroServer} from '../src/server/AstroServer'; -import {docsListenHost, docsListenPort, docsPublicEndpoint} from '../src/server/DocsConfig'; +import {runAstroServer} from '@/server/AstroServer'; +import {docsListenHost, docsListenPort, docsPublicEndpoint} from '@/server/DocsConfig'; await runAstroServer({ entrypoint: new URL('../dist/server/entry.mjs', import.meta.url), diff --git a/fluxer_docs/scripts/VerifyDocsCoverage.ts b/fluxer_docs/scripts/VerifyDocsCoverage.ts index 2e63ef48b..dbedbd22a 100644 --- a/fluxer_docs/scripts/VerifyDocsCoverage.ts +++ b/fluxer_docs/scripts/VerifyDocsCoverage.ts @@ -10,8 +10,7 @@ import {fileURLToPath} from 'node:url'; import {parseArgs} from 'node:util'; import {extractRoutesFromControllers} from '@fluxer/openapi/src/extractors/RouteExtractor'; import type {OpenAPIDocument} from '@fluxer/openapi/src/OpenAPITypes'; -import {installerChecksumLine} from '../src/installer/InstallerDigest.ts'; - +import {installerChecksumLine} from '@/installer/InstallerDigest.ts'; import {type DocsRouteHeader, readRouteHeaders} from './DocsRouteHeaders.ts'; import {DOCS_ROOT, HTTP_METHODS, type MarkdownPage, readMarkdownPages, routeShape} from './DocsSource.ts'; @@ -1321,7 +1320,7 @@ console.log('self-hosting guide against deploy/self-hosting'); const digestBearing: Array<[string, string]> = []; for (const endpoint of INSTALLER_ENDPOINTS) { const source = await readFile(fileURLToPath(new URL(`../src/pages/${endpoint}`, import.meta.url)), 'utf8'); - if (!source.includes("from '../installer/Installer'")) { + if (!source.includes("from '@/installer/Installer'")) { problems.push(`src/pages/${endpoint} no longer serves the script through src/installer/Installer`); } digestBearing.push([`src/pages/${endpoint}`, source]); diff --git a/fluxer_docs/scripts/VerifyDocsSchemas.ts b/fluxer_docs/scripts/VerifyDocsSchemas.ts index afa54b8a2..73c0af737 100644 --- a/fluxer_docs/scripts/VerifyDocsSchemas.ts +++ b/fluxer_docs/scripts/VerifyDocsSchemas.ts @@ -8,7 +8,6 @@ import type { OpenAPISchema as SchemaNode, OpenAPIDocument as Spec, } from '@fluxer/openapi/src/OpenAPITypes'; - import {readRouteHeaders} from './DocsRouteHeaders.ts'; import {DOCS_ROOT, HTTP_METHODS, readMarkdownPages, routeShape, slugifyHeading, splitTableRow} from './DocsSource.ts'; diff --git a/fluxer_docs/scripts/VerifyDocsSidebar.ts b/fluxer_docs/scripts/VerifyDocsSidebar.ts index 56d521456..2b4335b17 100644 --- a/fluxer_docs/scripts/VerifyDocsSidebar.ts +++ b/fluxer_docs/scripts/VerifyDocsSidebar.ts @@ -3,7 +3,6 @@ import {readFile} from 'node:fs/promises'; import path from 'node:path'; import {fileURLToPath} from 'node:url'; - import {DOCS_ROOT, listMarkdownFiles, slugifyHeading} from './DocsSource.ts'; const ASTRO_CONFIG = fileURLToPath(new URL('../astro.config.ts', import.meta.url)); diff --git a/fluxer_docs/src/components/TableOfContents.astro b/fluxer_docs/src/components/TableOfContents.astro index dc419c493..5eb9249e1 100644 --- a/fluxer_docs/src/components/TableOfContents.astro +++ b/fluxer_docs/src/components/TableOfContents.astro @@ -1,7 +1,7 @@ --- // SPDX-License-Identifier: AGPL-3.0-or-later -import TableOfContentsList from './TableOfContentsList.astro'; +import TableOfContentsList from '@/components/TableOfContentsList.astro'; const {toc} = Astro.locals.starlightRoute; --- diff --git a/fluxer_docs/src/installer/Installer.ts b/fluxer_docs/src/installer/Installer.ts index 645726d1b..1cb91ba93 100644 --- a/fluxer_docs/src/installer/Installer.ts +++ b/fluxer_docs/src/installer/Installer.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {installerChecksumLine, installerDigest} from './InstallerDigest'; -import powershellInstallerSource from './install.ps1?raw'; -import shellInstallerSource from './install.sh?raw'; +import {installerChecksumLine, installerDigest} from '@/installer/InstallerDigest'; +import powershellInstallerSource from '@/installer/install.ps1?raw'; +import shellInstallerSource from '@/installer/install.sh?raw'; const CONTENT_TYPE = 'text/plain; charset=utf-8'; const CACHE_CONTROL = 'no-store'; diff --git a/fluxer_docs/src/pages/install.ps1.sha256.ts b/fluxer_docs/src/pages/install.ps1.sha256.ts index e4cc52231..41bfef590 100644 --- a/fluxer_docs/src/pages/install.ps1.sha256.ts +++ b/fluxer_docs/src/pages/install.ps1.sha256.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {APIRoute} from 'astro'; -import {installerChecksumResponse, powershellInstaller} from '../installer/Installer'; +import {installerChecksumResponse, powershellInstaller} from '@/installer/Installer'; export const prerender = false; diff --git a/fluxer_docs/src/pages/install.ps1.ts b/fluxer_docs/src/pages/install.ps1.ts index dd01336bd..b6e55a55f 100644 --- a/fluxer_docs/src/pages/install.ps1.ts +++ b/fluxer_docs/src/pages/install.ps1.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {APIRoute} from 'astro'; -import {installerScriptResponse, powershellInstaller} from '../installer/Installer'; +import {installerScriptResponse, powershellInstaller} from '@/installer/Installer'; export const prerender = false; diff --git a/fluxer_docs/src/pages/install.sh.sha256.ts b/fluxer_docs/src/pages/install.sh.sha256.ts index 481c97aff..1d246020f 100644 --- a/fluxer_docs/src/pages/install.sh.sha256.ts +++ b/fluxer_docs/src/pages/install.sh.sha256.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {APIRoute} from 'astro'; -import {installerChecksumResponse, shellInstaller} from '../installer/Installer'; +import {installerChecksumResponse, shellInstaller} from '@/installer/Installer'; export const prerender = false; diff --git a/fluxer_docs/src/pages/install.sh.ts b/fluxer_docs/src/pages/install.sh.ts index 39813456f..47bd19c94 100644 --- a/fluxer_docs/src/pages/install.sh.ts +++ b/fluxer_docs/src/pages/install.sh.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import type {APIRoute} from 'astro'; -import {installerScriptResponse, shellInstaller} from '../installer/Installer'; +import {installerScriptResponse, shellInstaller} from '@/installer/Installer'; export const prerender = false; diff --git a/fluxer_docs/src/server/AstroServer.ts b/fluxer_docs/src/server/AstroServer.ts index e40686465..e4713807e 100644 --- a/fluxer_docs/src/server/AstroServer.ts +++ b/fluxer_docs/src/server/AstroServer.ts @@ -5,7 +5,7 @@ import {createServer, type IncomingMessage, type Server, type ServerResponse} fr import path from 'node:path'; import {fileURLToPath} from 'node:url'; import send from 'send'; -import {type AstroServerShutdown, AstroServerTermination} from './AstroServerTermination'; +import {type AstroServerShutdown, AstroServerTermination} from '@/server/AstroServerTermination'; import { CanonicalNetworkProtocol, getNodeErrorCode, @@ -16,8 +16,8 @@ import { MIMEType, NodeErrorCode, OUTBOUND_USER_AGENT, -} from './HTTPConstants'; -import {siteSecurityHeaders} from './SecurityHeaders'; +} from '@/server/HTTPConstants'; +import {siteSecurityHeaders} from '@/server/SecurityHeaders'; const HEALTH_PATH = '/_health'; const HEALTH_RESPONSE_BODY = JSON.stringify({status: 'ok'}); diff --git a/fluxer_docs/src/server/SecurityHeaders.ts b/fluxer_docs/src/server/SecurityHeaders.ts index d935c4811..5d1cc7461 100644 --- a/fluxer_docs/src/server/SecurityHeaders.ts +++ b/fluxer_docs/src/server/SecurityHeaders.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {HTTPHeader} from './HTTPConstants'; +import {HTTPHeader} from '@/server/HTTPConstants'; const PERMISSIONS_POLICY = 'accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()'; diff --git a/packages/config/src/MasterConfig.ts b/packages/config/src/MasterConfig.ts index 1cf88abc6..7a6d75731 100644 --- a/packages/config/src/MasterConfig.ts +++ b/packages/config/src/MasterConfig.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {DerivedEndpoints} from './EndpointDerivation'; +import type {DerivedEndpoints} from '@fluxer/config/src/EndpointDerivation'; export type RuntimeEnv = 'development' | 'production' | 'test'; export type DatabaseBackend = 'postgres' | 'cassandra'; diff --git a/packages/config/src/__tests__/NonDefaultPortCompose.test.ts b/packages/config/src/__tests__/NonDefaultPortCompose.test.ts index ab4e28ed5..fb61a6c58 100644 --- a/packages/config/src/__tests__/NonDefaultPortCompose.test.ts +++ b/packages/config/src/__tests__/NonDefaultPortCompose.test.ts @@ -1,12 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {serviceEnvironment, serviceList, serviceNames} from '@fluxer/config/src/__tests__/SelfHostingCompose'; import {loadConfig, resetConfig} from '@fluxer/config/src/ConfigLoader'; import {normalizePublicEndpoint} from '@fluxer/config/src/EndpointDerivation'; import type {MasterConfig} from '@fluxer/config/src/MasterConfig'; import {afterEach, beforeEach, describe, expect, test, vi} from 'vitest'; -import {serviceEnvironment, serviceList, serviceNames} from './SelfHostingCompose'; - const DOMAIN = 'chat.example.com'; const PUBLIC_PORT = '19080'; const ORIGIN_PORT = '29080'; diff --git a/packages/config/src/__tests__/SelfHostingComposeEnvironment.test.ts b/packages/config/src/__tests__/SelfHostingComposeEnvironment.test.ts index 6fa908cd2..76c088609 100644 --- a/packages/config/src/__tests__/SelfHostingComposeEnvironment.test.ts +++ b/packages/config/src/__tests__/SelfHostingComposeEnvironment.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {serviceEnvironment, serviceNames, sharedEnvironment} from '@fluxer/config/src/__tests__/SelfHostingCompose'; import {describe, expect, test} from 'vitest'; -import {serviceEnvironment, serviceNames, sharedEnvironment} from './SelfHostingCompose'; describe('the shipped compose stack wires every service it starts', () => { test('no service sizes a pool for a connection it cannot make', () => { diff --git a/packages/config/src/__tests__/SelfHostingObjectStoreAuth.test.ts b/packages/config/src/__tests__/SelfHostingObjectStoreAuth.test.ts index 06b664cf9..897240d28 100644 --- a/packages/config/src/__tests__/SelfHostingObjectStoreAuth.test.ts +++ b/packages/config/src/__tests__/SelfHostingObjectStoreAuth.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {composeService, serviceEnvironment, serviceList} from '@fluxer/config/src/__tests__/SelfHostingCompose'; import {describe, expect, test} from 'vitest'; -import {composeService, serviceEnvironment, serviceList} from './SelfHostingCompose'; describe('the shipped object store checks the credentials the stack sends', () => { const entrypoint = serviceList('seaweedfs-init', 'entrypoint'); diff --git a/packages/constants/src/BotPermissionUtils.test.ts b/packages/constants/src/BotPermissionUtils.test.ts index 5bc8c881d..031fc09c3 100644 --- a/packages/constants/src/BotPermissionUtils.test.ts +++ b/packages/constants/src/BotPermissionUtils.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {canAuthorizeBotInvite, normalizeBotInvitePermissions} from '@fluxer/constants/src/BotPermissionUtils'; +import {Permissions} from '@fluxer/constants/src/ChannelConstants'; import {describe, expect, it} from 'vitest'; -import {canAuthorizeBotInvite, normalizeBotInvitePermissions} from './BotPermissionUtils'; -import {Permissions} from './ChannelConstants'; describe('canAuthorizeBotInvite', () => { it('requires permission to invite bots even when no permissions are requested', () => { diff --git a/packages/constants/src/BotPermissionUtils.ts b/packages/constants/src/BotPermissionUtils.ts index b286c4c0f..c79f58cb3 100644 --- a/packages/constants/src/BotPermissionUtils.ts +++ b/packages/constants/src/BotPermissionUtils.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {ALL_PERMISSIONS, Permissions} from './ChannelConstants'; +import {ALL_PERMISSIONS, Permissions} from '@fluxer/constants/src/ChannelConstants'; export function normalizeBotInvitePermissions(requestedPermissions: bigint): bigint { return requestedPermissions & ALL_PERMISSIONS; diff --git a/packages/constants/src/EntranceSoundConstants.test.ts b/packages/constants/src/EntranceSoundConstants.test.ts index 7b8832b28..26d52d9eb 100644 --- a/packages/constants/src/EntranceSoundConstants.test.ts +++ b/packages/constants/src/EntranceSoundConstants.test.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + entranceSoundExtensionFromFormat, + entranceSoundExtensionFromMime, +} from '@fluxer/constants/src/EntranceSoundConstants'; import {describe, expect, test} from 'vitest'; -import {entranceSoundExtensionFromFormat, entranceSoundExtensionFromMime} from './EntranceSoundConstants'; describe('entrance sound format detection', () => { test('accepts wav metadata produced by the in-app trimmer', () => { diff --git a/packages/constants/src/GuildConstants.test.ts b/packages/constants/src/GuildConstants.test.ts index f7390e5c7..5e3ddd528 100644 --- a/packages/constants/src/GuildConstants.test.ts +++ b/packages/constants/src/GuildConstants.test.ts @@ -1,12 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { clampVoiceChannelBitrate, GuildFeatures, getMaxVoiceChannelBitrate, resolveVoiceChannelBitrate, -} from './GuildConstants'; +} from '@fluxer/constants/src/GuildConstants'; +import {describe, expect, it} from 'vitest'; describe('getMaxVoiceChannelBitrate', () => { it('caps a guild holding no audio bitrate feature at 96 kbps', () => { diff --git a/packages/constants/src/LimitConstants.ts b/packages/constants/src/LimitConstants.ts index 5e5b39278..0f5d1282d 100644 --- a/packages/constants/src/LimitConstants.ts +++ b/packages/constants/src/LimitConstants.ts @@ -1,5 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {ASSET_FORMAT_POLICY} from '@fluxer/constants/src/AssetFormatPolicy'; + export const MAX_GUILDS_PREMIUM = 200; export const MAX_GUILD_CHANNELS = 500; export const MAX_CHANNELS_PER_CATEGORY = 50; @@ -53,8 +55,6 @@ export const MAX_KATEX_RENDER_CONTROL_SEQUENCE_COUNT = 64; export const MAX_CODE_HIGHLIGHT_SOURCE_LENGTH = 50_000; export const MAX_CODE_HIGHLIGHT_OUTPUT_LENGTH = 200_000; -import {ASSET_FORMAT_POLICY} from '@fluxer/constants/src/AssetFormatPolicy'; - export const MAX_BIO_LENGTH = 320; export const AVATAR_MAX_SIZE = ASSET_FORMAT_POLICY.avatar.maxBytes; export const MAX_RELATIONSHIPS = 1000; diff --git a/packages/errors/src/i18n/ErrorI18nLocales.ts b/packages/errors/src/i18n/ErrorI18nLocales.ts index a6792399b..4b3c7b5b4 100644 --- a/packages/errors/src/i18n/ErrorI18nLocales.ts +++ b/packages/errors/src/i18n/ErrorI18nLocales.ts @@ -1,39 +1,39 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {ErrorI18nKey} from './ErrorI18nMessages'; -import ERROR_I18N_AR_MESSAGES from './locales/ar'; -import ERROR_I18N_BG_MESSAGES from './locales/bg'; -import ERROR_I18N_CS_MESSAGES from './locales/cs'; -import ERROR_I18N_DA_MESSAGES from './locales/da'; -import ERROR_I18N_DE_MESSAGES from './locales/de'; -import ERROR_I18N_EL_MESSAGES from './locales/el'; -import ERROR_I18N_EN_GB_MESSAGES from './locales/en-GB'; -import ERROR_I18N_ES_419_MESSAGES from './locales/es-419'; -import ERROR_I18N_ES_ES_MESSAGES from './locales/es-ES'; -import ERROR_I18N_FI_MESSAGES from './locales/fi'; -import ERROR_I18N_FR_MESSAGES from './locales/fr'; -import ERROR_I18N_HE_MESSAGES from './locales/he'; -import ERROR_I18N_HI_MESSAGES from './locales/hi'; -import ERROR_I18N_HR_MESSAGES from './locales/hr'; -import ERROR_I18N_HU_MESSAGES from './locales/hu'; -import ERROR_I18N_ID_MESSAGES from './locales/id'; -import ERROR_I18N_IT_MESSAGES from './locales/it'; -import ERROR_I18N_JA_MESSAGES from './locales/ja'; -import ERROR_I18N_KO_MESSAGES from './locales/ko'; -import ERROR_I18N_LT_MESSAGES from './locales/lt'; -import ERROR_I18N_NL_MESSAGES from './locales/nl'; -import ERROR_I18N_NO_MESSAGES from './locales/no'; -import ERROR_I18N_PL_MESSAGES from './locales/pl'; -import ERROR_I18N_PT_BR_MESSAGES from './locales/pt-BR'; -import ERROR_I18N_RO_MESSAGES from './locales/ro'; -import ERROR_I18N_RU_MESSAGES from './locales/ru'; -import ERROR_I18N_SV_SE_MESSAGES from './locales/sv-SE'; -import ERROR_I18N_TH_MESSAGES from './locales/th'; -import ERROR_I18N_TR_MESSAGES from './locales/tr'; -import ERROR_I18N_UK_MESSAGES from './locales/uk'; -import ERROR_I18N_VI_MESSAGES from './locales/vi'; -import ERROR_I18N_ZH_CN_MESSAGES from './locales/zh-CN'; -import ERROR_I18N_ZH_TW_MESSAGES from './locales/zh-TW'; +import type {ErrorI18nKey} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; +import ERROR_I18N_AR_MESSAGES from '@fluxer/errors/src/i18n/locales/ar'; +import ERROR_I18N_BG_MESSAGES from '@fluxer/errors/src/i18n/locales/bg'; +import ERROR_I18N_CS_MESSAGES from '@fluxer/errors/src/i18n/locales/cs'; +import ERROR_I18N_DA_MESSAGES from '@fluxer/errors/src/i18n/locales/da'; +import ERROR_I18N_DE_MESSAGES from '@fluxer/errors/src/i18n/locales/de'; +import ERROR_I18N_EL_MESSAGES from '@fluxer/errors/src/i18n/locales/el'; +import ERROR_I18N_EN_GB_MESSAGES from '@fluxer/errors/src/i18n/locales/en-GB'; +import ERROR_I18N_ES_419_MESSAGES from '@fluxer/errors/src/i18n/locales/es-419'; +import ERROR_I18N_ES_ES_MESSAGES from '@fluxer/errors/src/i18n/locales/es-ES'; +import ERROR_I18N_FI_MESSAGES from '@fluxer/errors/src/i18n/locales/fi'; +import ERROR_I18N_FR_MESSAGES from '@fluxer/errors/src/i18n/locales/fr'; +import ERROR_I18N_HE_MESSAGES from '@fluxer/errors/src/i18n/locales/he'; +import ERROR_I18N_HI_MESSAGES from '@fluxer/errors/src/i18n/locales/hi'; +import ERROR_I18N_HR_MESSAGES from '@fluxer/errors/src/i18n/locales/hr'; +import ERROR_I18N_HU_MESSAGES from '@fluxer/errors/src/i18n/locales/hu'; +import ERROR_I18N_ID_MESSAGES from '@fluxer/errors/src/i18n/locales/id'; +import ERROR_I18N_IT_MESSAGES from '@fluxer/errors/src/i18n/locales/it'; +import ERROR_I18N_JA_MESSAGES from '@fluxer/errors/src/i18n/locales/ja'; +import ERROR_I18N_KO_MESSAGES from '@fluxer/errors/src/i18n/locales/ko'; +import ERROR_I18N_LT_MESSAGES from '@fluxer/errors/src/i18n/locales/lt'; +import ERROR_I18N_NL_MESSAGES from '@fluxer/errors/src/i18n/locales/nl'; +import ERROR_I18N_NO_MESSAGES from '@fluxer/errors/src/i18n/locales/no'; +import ERROR_I18N_PL_MESSAGES from '@fluxer/errors/src/i18n/locales/pl'; +import ERROR_I18N_PT_BR_MESSAGES from '@fluxer/errors/src/i18n/locales/pt-BR'; +import ERROR_I18N_RO_MESSAGES from '@fluxer/errors/src/i18n/locales/ro'; +import ERROR_I18N_RU_MESSAGES from '@fluxer/errors/src/i18n/locales/ru'; +import ERROR_I18N_SV_SE_MESSAGES from '@fluxer/errors/src/i18n/locales/sv-SE'; +import ERROR_I18N_TH_MESSAGES from '@fluxer/errors/src/i18n/locales/th'; +import ERROR_I18N_TR_MESSAGES from '@fluxer/errors/src/i18n/locales/tr'; +import ERROR_I18N_UK_MESSAGES from '@fluxer/errors/src/i18n/locales/uk'; +import ERROR_I18N_VI_MESSAGES from '@fluxer/errors/src/i18n/locales/vi'; +import ERROR_I18N_ZH_CN_MESSAGES from '@fluxer/errors/src/i18n/locales/zh-CN'; +import ERROR_I18N_ZH_TW_MESSAGES from '@fluxer/errors/src/i18n/locales/zh-TW'; export const ERROR_I18N_LOCALE_MESSAGES = { ar: ERROR_I18N_AR_MESSAGES, diff --git a/packages/errors/src/i18n/ErrorI18nTypes.generated.ts b/packages/errors/src/i18n/ErrorI18nTypes.generated.ts index 81137be6a..a849f3687 100644 --- a/packages/errors/src/i18n/ErrorI18nTypes.generated.ts +++ b/packages/errors/src/i18n/ErrorI18nTypes.generated.ts @@ -1,3 +1,3 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -export type {ErrorI18nKey} from './ErrorI18nMessages'; +export type {ErrorI18nKey} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; diff --git a/packages/errors/src/i18n/locales/ar.ts b/packages/errors/src/i18n/locales/ar.ts index 223c2320c..39b7fda03 100644 --- a/packages/errors/src/i18n/locales/ar.ts +++ b/packages/errors/src/i18n/locales/ar.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_AR_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "المراسلة معطلة.", diff --git a/packages/errors/src/i18n/locales/bg.ts b/packages/errors/src/i18n/locales/bg.ts index f47bc0b25..774fd2110 100644 --- a/packages/errors/src/i18n/locales/bg.ts +++ b/packages/errors/src/i18n/locales/bg.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_BG_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Комуникацията е деактивирана.", diff --git a/packages/errors/src/i18n/locales/cs.ts b/packages/errors/src/i18n/locales/cs.ts index e5bfe8056..5046e3bb5 100644 --- a/packages/errors/src/i18n/locales/cs.ts +++ b/packages/errors/src/i18n/locales/cs.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_CS_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Komunikace je zakázána.", diff --git a/packages/errors/src/i18n/locales/da.ts b/packages/errors/src/i18n/locales/da.ts index 616086bbf..235bfb3f7 100644 --- a/packages/errors/src/i18n/locales/da.ts +++ b/packages/errors/src/i18n/locales/da.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_DA_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Kommunikation er slået fra.", diff --git a/packages/errors/src/i18n/locales/de.ts b/packages/errors/src/i18n/locales/de.ts index ad98a35b7..ee77ca6c0 100644 --- a/packages/errors/src/i18n/locales/de.ts +++ b/packages/errors/src/i18n/locales/de.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_DE_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Kommunikation ist deaktiviert.", diff --git a/packages/errors/src/i18n/locales/el.ts b/packages/errors/src/i18n/locales/el.ts index 8efcda12c..c2b32919e 100644 --- a/packages/errors/src/i18n/locales/el.ts +++ b/packages/errors/src/i18n/locales/el.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_EL_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Η επικοινωνία είναι απενεργοποιημένη.", diff --git a/packages/errors/src/i18n/locales/en-GB.ts b/packages/errors/src/i18n/locales/en-GB.ts index e7d4f3a78..d182206a8 100644 --- a/packages/errors/src/i18n/locales/en-GB.ts +++ b/packages/errors/src/i18n/locales/en-GB.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_EN_GB_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Communication is disabled.", diff --git a/packages/errors/src/i18n/locales/es-419.ts b/packages/errors/src/i18n/locales/es-419.ts index 98afdf603..4bf2011ea 100644 --- a/packages/errors/src/i18n/locales/es-419.ts +++ b/packages/errors/src/i18n/locales/es-419.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_ES_419_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "La comunicación está deshabilitada.", diff --git a/packages/errors/src/i18n/locales/es-ES.ts b/packages/errors/src/i18n/locales/es-ES.ts index 5969690d2..8fcc74752 100644 --- a/packages/errors/src/i18n/locales/es-ES.ts +++ b/packages/errors/src/i18n/locales/es-ES.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_ES_ES_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "La comunicación está deshabilitada.", diff --git a/packages/errors/src/i18n/locales/fi.ts b/packages/errors/src/i18n/locales/fi.ts index 6a31baaa1..63d0428ba 100644 --- a/packages/errors/src/i18n/locales/fi.ts +++ b/packages/errors/src/i18n/locales/fi.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_FI_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Viestintä on poistettu käytöstä.", diff --git a/packages/errors/src/i18n/locales/fr.ts b/packages/errors/src/i18n/locales/fr.ts index a8df5b170..7d8f195f1 100644 --- a/packages/errors/src/i18n/locales/fr.ts +++ b/packages/errors/src/i18n/locales/fr.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_FR_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "La communication est désactivée.", diff --git a/packages/errors/src/i18n/locales/he.ts b/packages/errors/src/i18n/locales/he.ts index 51211edb4..7694715b1 100644 --- a/packages/errors/src/i18n/locales/he.ts +++ b/packages/errors/src/i18n/locales/he.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_HE_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "התקשורת מושבתת.", diff --git a/packages/errors/src/i18n/locales/hi.ts b/packages/errors/src/i18n/locales/hi.ts index f1b6e5187..86f2c4974 100644 --- a/packages/errors/src/i18n/locales/hi.ts +++ b/packages/errors/src/i18n/locales/hi.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_HI_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "कम्युनिकेशन डिसेबल कर दिया गया है.", diff --git a/packages/errors/src/i18n/locales/hr.ts b/packages/errors/src/i18n/locales/hr.ts index db2536d24..6548bc92b 100644 --- a/packages/errors/src/i18n/locales/hr.ts +++ b/packages/errors/src/i18n/locales/hr.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_HR_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Komunikacija je isključena.", diff --git a/packages/errors/src/i18n/locales/hu.ts b/packages/errors/src/i18n/locales/hu.ts index 86c5403a0..256bd26a3 100644 --- a/packages/errors/src/i18n/locales/hu.ts +++ b/packages/errors/src/i18n/locales/hu.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_HU_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "A kommunikáció letiltva.", diff --git a/packages/errors/src/i18n/locales/id.ts b/packages/errors/src/i18n/locales/id.ts index 4ab61f76c..6d73d7a82 100644 --- a/packages/errors/src/i18n/locales/id.ts +++ b/packages/errors/src/i18n/locales/id.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_ID_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Komunikasi dinonaktifkan.", diff --git a/packages/errors/src/i18n/locales/it.ts b/packages/errors/src/i18n/locales/it.ts index 3d04ebab5..3d354a6d0 100644 --- a/packages/errors/src/i18n/locales/it.ts +++ b/packages/errors/src/i18n/locales/it.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_IT_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "La comunicazione è disabilitata.", diff --git a/packages/errors/src/i18n/locales/ja.ts b/packages/errors/src/i18n/locales/ja.ts index ebc8cec7c..2cff540fb 100644 --- a/packages/errors/src/i18n/locales/ja.ts +++ b/packages/errors/src/i18n/locales/ja.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_JA_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "メッセージ機能が無効です。", diff --git a/packages/errors/src/i18n/locales/ko.ts b/packages/errors/src/i18n/locales/ko.ts index b0fcab83e..d8fa01d0b 100644 --- a/packages/errors/src/i18n/locales/ko.ts +++ b/packages/errors/src/i18n/locales/ko.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_KO_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "메시지 보내기가 비활성화되었어요.", diff --git a/packages/errors/src/i18n/locales/lt.ts b/packages/errors/src/i18n/locales/lt.ts index bad2197d7..358c92fe0 100644 --- a/packages/errors/src/i18n/locales/lt.ts +++ b/packages/errors/src/i18n/locales/lt.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_LT_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Bendravimas išjungtas.", diff --git a/packages/errors/src/i18n/locales/nl.ts b/packages/errors/src/i18n/locales/nl.ts index f6fc8fa25..da74db276 100644 --- a/packages/errors/src/i18n/locales/nl.ts +++ b/packages/errors/src/i18n/locales/nl.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_NL_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Communicatie is uitgeschakeld.", diff --git a/packages/errors/src/i18n/locales/no.ts b/packages/errors/src/i18n/locales/no.ts index a8f3a42ab..5c39039c8 100644 --- a/packages/errors/src/i18n/locales/no.ts +++ b/packages/errors/src/i18n/locales/no.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_NO_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Kommunikasjon er deaktivert.", diff --git a/packages/errors/src/i18n/locales/pl.ts b/packages/errors/src/i18n/locales/pl.ts index cd3fd49e6..ef8aa469f 100644 --- a/packages/errors/src/i18n/locales/pl.ts +++ b/packages/errors/src/i18n/locales/pl.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_PL_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Komunikacja wyłączona.", diff --git a/packages/errors/src/i18n/locales/pt-BR.ts b/packages/errors/src/i18n/locales/pt-BR.ts index f9077fda1..6b6516eb2 100644 --- a/packages/errors/src/i18n/locales/pt-BR.ts +++ b/packages/errors/src/i18n/locales/pt-BR.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_PT_BR_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "A comunicação está desativada.", diff --git a/packages/errors/src/i18n/locales/ro.ts b/packages/errors/src/i18n/locales/ro.ts index 571a338f0..9de2aa857 100644 --- a/packages/errors/src/i18n/locales/ro.ts +++ b/packages/errors/src/i18n/locales/ro.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_RO_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Comunicarea este dezactivată.", diff --git a/packages/errors/src/i18n/locales/ru.ts b/packages/errors/src/i18n/locales/ru.ts index 5ce91513a..c036bbe73 100644 --- a/packages/errors/src/i18n/locales/ru.ts +++ b/packages/errors/src/i18n/locales/ru.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_RU_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Общение отключено.", diff --git a/packages/errors/src/i18n/locales/sv-SE.ts b/packages/errors/src/i18n/locales/sv-SE.ts index 138e52e57..968bd255d 100644 --- a/packages/errors/src/i18n/locales/sv-SE.ts +++ b/packages/errors/src/i18n/locales/sv-SE.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_SV_SE_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Kommunikationen är inaktiverad.", diff --git a/packages/errors/src/i18n/locales/th.ts b/packages/errors/src/i18n/locales/th.ts index 05853d7f5..22dbdff79 100644 --- a/packages/errors/src/i18n/locales/th.ts +++ b/packages/errors/src/i18n/locales/th.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_TH_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "ปิดใช้งานการสื่อสารแล้ว", diff --git a/packages/errors/src/i18n/locales/tr.ts b/packages/errors/src/i18n/locales/tr.ts index fc6c78177..04704320a 100644 --- a/packages/errors/src/i18n/locales/tr.ts +++ b/packages/errors/src/i18n/locales/tr.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_TR_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "İletişim devre dışı bırakıldı.", diff --git a/packages/errors/src/i18n/locales/uk.ts b/packages/errors/src/i18n/locales/uk.ts index 53932ab29..37429447d 100644 --- a/packages/errors/src/i18n/locales/uk.ts +++ b/packages/errors/src/i18n/locales/uk.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_UK_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Спілкування вимкнено.", diff --git a/packages/errors/src/i18n/locales/vi.ts b/packages/errors/src/i18n/locales/vi.ts index c8e0e11e0..dac54e820 100644 --- a/packages/errors/src/i18n/locales/vi.ts +++ b/packages/errors/src/i18n/locales/vi.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_VI_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "Tính năng giao tiếp đã bị tắt.", diff --git a/packages/errors/src/i18n/locales/zh-CN.ts b/packages/errors/src/i18n/locales/zh-CN.ts index fb0cd29e5..1d8f370d0 100644 --- a/packages/errors/src/i18n/locales/zh-CN.ts +++ b/packages/errors/src/i18n/locales/zh-CN.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_ZH_CN_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "通信已禁用。", diff --git a/packages/errors/src/i18n/locales/zh-TW.ts b/packages/errors/src/i18n/locales/zh-TW.ts index 9ebd6bab0..567f20531 100644 --- a/packages/errors/src/i18n/locales/zh-TW.ts +++ b/packages/errors/src/i18n/locales/zh-TW.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {defineErrorI18nLocaleMessages} from '../ErrorI18nMessages'; +import {defineErrorI18nLocaleMessages} from '@fluxer/errors/src/i18n/ErrorI18nMessages'; const ERROR_I18N_ZH_TW_MESSAGES = defineErrorI18nLocaleMessages({ "account.communication_disabled": "通訊功能已停用。", diff --git a/packages/hono/src/tests/ServerTimeouts.test.ts b/packages/hono/src/tests/ServerTimeouts.test.ts index e35afce95..95ecee2c3 100644 --- a/packages/hono/src/tests/ServerTimeouts.test.ts +++ b/packages/hono/src/tests/ServerTimeouts.test.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {createServer} from '@fluxer/hono/src/Server'; import {Hono} from 'hono'; import {afterEach, describe, expect, it} from 'vitest'; -import {createServer} from '../Server'; const servers: Array<{close: (cb: () => void) => void}> = []; diff --git a/packages/i18n/scripts/SyncStaticI18nCatalogs.ts b/packages/i18n/scripts/SyncStaticI18nCatalogs.ts index ece96eb1d..5e823e2ee 100644 --- a/packages/i18n/scripts/SyncStaticI18nCatalogs.ts +++ b/packages/i18n/scripts/SyncStaticI18nCatalogs.ts @@ -77,7 +77,7 @@ const CATALOGS: Array = [ sourceExportName: 'ERROR_I18N_MESSAGES', weblateDir: path.join(REPO_ROOT, 'packages/errors/src/i18n/weblate'), localeTsDir: path.join(REPO_ROOT, 'packages/errors/src/i18n/locales'), - defineImportPath: '../ErrorI18nMessages', + defineImportPath: '@fluxer/errors/src/i18n/ErrorI18nMessages', defineFunctionName: 'defineErrorI18nLocaleMessages', exportPrefix: 'ERROR_I18N', }, @@ -88,7 +88,7 @@ const CATALOGS: Array = [ sourceExportName: 'EMAIL_I18N_MESSAGES', weblateDir: path.join(REPO_ROOT, 'fluxer_api/pkgs/email/src/email_i18n/weblate'), localeTsDir: path.join(REPO_ROOT, 'fluxer_api/pkgs/email/src/email_i18n/locales'), - defineImportPath: '../EmailI18nMessages', + defineImportPath: '@pkgs/email/src/email_i18n/EmailI18nMessages', defineFunctionName: 'defineEmailI18nLocaleMessages', exportPrefix: 'EMAIL_I18N', }, diff --git a/packages/instance_bootstrap/src/AgeGeos.ts b/packages/instance_bootstrap/src/AgeGeos.ts index 88f888f1d..960d4b0eb 100644 --- a/packages/instance_bootstrap/src/AgeGeos.ts +++ b/packages/instance_bootstrap/src/AgeGeos.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import ageGeos from '@fluxer/constants/src/AgeGeos.json' with {type: 'json'}; -import type {GeoEntry} from './Types'; +import type {GeoEntry} from '@fluxer/instance_bootstrap/src/Types'; export const AGE_RESTRICTED_GEOS: ReadonlyArray = ageGeos.ageRestrictedGeos; export const AGE_BLOCKED_GEOS: ReadonlyArray = ageGeos.ageBlockedGeos; diff --git a/packages/instance_bootstrap/src/BuildDiscovery.ts b/packages/instance_bootstrap/src/BuildDiscovery.ts index 9cf8191cc..b365a7a36 100644 --- a/packages/instance_bootstrap/src/BuildDiscovery.ts +++ b/packages/instance_bootstrap/src/BuildDiscovery.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {LimitConfigSnapshot, LimitConfigWireFormat} from '@fluxer/limits/src/LimitTypes'; import type { InstanceAppPublic, InstanceCaptcha, @@ -13,7 +12,8 @@ import type { InstanceRegistration, InstanceServices, InstanceSso, -} from './Types'; +} from '@fluxer/instance_bootstrap/src/Types'; +import type {LimitConfigSnapshot, LimitConfigWireFormat} from '@fluxer/limits/src/LimitTypes'; export interface DiscoveryStaticInput { apiCodeVersion: number; diff --git a/packages/openapi/src/extractors/StaticPathResolver.ts b/packages/openapi/src/extractors/StaticPathResolver.ts index 88c794ff6..91dbee3b8 100644 --- a/packages/openapi/src/extractors/StaticPathResolver.ts +++ b/packages/openapi/src/extractors/StaticPathResolver.ts @@ -1,9 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import * as path from 'node:path'; -import {type BinaryExpression, type Identifier, Node, type Project, type SourceFile, SyntaxKind} from 'ts-morph'; +import {type BinaryExpression, type Identifier, Node, type Project, type SourceFile, SyntaxKind, ts} from 'ts-morph'; export const UNRESOLVED = Symbol('unresolved'); +const APP_ALIAS_PREFIX = '@app/'; + type StaticPrimitive = string | number | boolean | null; export type StaticValue = @@ -51,6 +53,7 @@ export function getIdentifierDeclarations(node: Identifier): ReadonlyArray export class StaticPathResolver { private readonly inFlight = new Set(); + private readonly appSourceRoots = new Map(); constructor(private readonly project: Project) {} @@ -338,11 +341,44 @@ export class StaticPathResolver { return null; } + private resolveSpecifierBase(fromPath: string, specifier: string): string | null { + if (specifier.startsWith('.')) { + return path.resolve(path.dirname(fromPath), specifier); + } + if (!specifier.startsWith(APP_ALIAS_PREFIX)) { + return null; + } + const sourceRoot = this.findAppSourceRoot(path.dirname(fromPath)); + return sourceRoot == null ? null : path.join(sourceRoot, specifier.slice(APP_ALIAS_PREFIX.length)); + } + + private findAppSourceRoot(directory: string): string | null { + const cached = this.appSourceRoots.get(directory); + if (cached !== undefined) { + return cached; + } + const fileSystem = this.project.getFileSystem(); + const tsconfigPath = path.join(directory, 'tsconfig.json'); + const parent = path.dirname(directory); + let sourceRoot: string | null = null; + if (fileSystem.fileExistsSync(tsconfigPath)) { + const {config} = ts.readConfigFile(tsconfigPath, (filePath) => fileSystem.readFileSync(filePath)); + const target = config?.compilerOptions?.paths?.[`${APP_ALIAS_PREFIX}*`]?.[0]; + if (typeof target === 'string' && target.endsWith('/*')) { + sourceRoot = path.resolve(directory, target.slice(0, -2)); + } + } else if (parent !== directory) { + sourceRoot = this.findAppSourceRoot(parent); + } + this.appSourceRoots.set(directory, sourceRoot); + return sourceRoot; + } + private resolveModule(from: SourceFile, specifier: string): SourceFile | null { - if (!specifier.startsWith('.')) { + const base = this.resolveSpecifierBase(from.getFilePath(), specifier); + if (base == null) { return null; } - const base = path.resolve(path.dirname(from.getFilePath()), specifier); for (const candidate of [`${base}.ts`, `${base}.tsx`, `${base}/index.ts`, base]) { const existing = this.project.getSourceFile(candidate); if (existing != null) { diff --git a/packages/openapi/src/extractors/__tests__/StaticPathResolver.test.ts b/packages/openapi/src/extractors/__tests__/StaticPathResolver.test.ts index 6dcd18caf..688289ae5 100644 --- a/packages/openapi/src/extractors/__tests__/StaticPathResolver.test.ts +++ b/packages/openapi/src/extractors/__tests__/StaticPathResolver.test.ts @@ -33,3 +33,29 @@ describe('static route expressions', () => { expect(resolveExpression(`paths[${JSON.stringify(index)}]`)).toBe(UNRESOLVED); }); }); + +describe('imported route constants', () => { + function resolveImportedPath(specifier: string) { + const project = new Project({useInMemoryFileSystem: true}); + project + .getFileSystem() + .writeFileSync('/api/tsconfig.json', JSON.stringify({compilerOptions: {paths: {'@app/*': ['./src/*']}}})); + project.createSourceFile('/api/src/constants/Routes.ts', "export const USERS_ROUTE = '/users';"); + const controller = project.createSourceFile( + '/api/src/users/UserController.ts', + `import {USERS_ROUTE} from '${specifier}'; const path = USERS_ROUTE;`, + ); + return new StaticPathResolver(project).resolve( + controller.getVariableDeclarationOrThrow('path').getInitializerOrThrow(), + EMPTY_SCOPE, + ); + } + + it.each(['../constants/Routes', '@app/constants/Routes'])('follows %s to the exported constant', (specifier) => { + expect(resolveImportedPath(specifier)).toBe('/users'); + }); + + it('does not follow a bare package import', () => { + expect(resolveImportedPath('@fluxer/constants/src/Routes')).toBe(UNRESOLVED); + }); +}); diff --git a/packages/schema/src/domains/admin/VoiceNoiseSuppressionSchemas.ts b/packages/schema/src/domains/admin/VoiceNoiseSuppressionSchemas.ts index c471cdae4..913f2306b 100644 --- a/packages/schema/src/domains/admin/VoiceNoiseSuppressionSchemas.ts +++ b/packages/schema/src/domains/admin/VoiceNoiseSuppressionSchemas.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {EXPERIMENT_BUCKET_RESOLUTION, experimentBucket} from '@fluxer/schema/src/domains/experiment/ExperimentBucket'; import {z} from 'zod'; -import {EXPERIMENT_BUCKET_RESOLUTION, experimentBucket} from '../experiment/ExperimentBucket'; export const VOICE_NOISE_SUPPRESSION_BACKENDS = [ 'none', diff --git a/packages/schema/src/domains/experiment/ExperimentSchemas.ts b/packages/schema/src/domains/experiment/ExperimentSchemas.ts index 39cf73c5d..73c36f9cc 100644 --- a/packages/schema/src/domains/experiment/ExperimentSchemas.ts +++ b/packages/schema/src/domains/experiment/ExperimentSchemas.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {z} from 'zod'; import { INERT_VOICE_NOISE_SUPPRESSION_ASSIGNMENT, VoiceNoiseSuppressionAssignmentResponse, -} from '../admin/VoiceNoiseSuppressionSchemas'; +} from '@fluxer/schema/src/domains/admin/VoiceNoiseSuppressionSchemas'; +import {z} from 'zod'; export const EXPERIMENT_MIN_POLL_INTERVAL_SECONDS = 60; export const EXPERIMENT_MAX_POLL_INTERVAL_SECONDS = 86400; diff --git a/packages/schema/src/domains/tests/GatewayRolloutSchemas.test.ts b/packages/schema/src/domains/tests/GatewayRolloutSchemas.test.ts index a1a8cfd0c..e98097f38 100644 --- a/packages/schema/src/domains/tests/GatewayRolloutSchemas.test.ts +++ b/packages/schema/src/domains/tests/GatewayRolloutSchemas.test.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import { + GatewayRolloutConfigSchema, + GatewayRolloutConfigUpdateRequest, +} from '@fluxer/schema/src/domains/admin/GatewayRolloutSchemas'; import {describe, expect, test} from 'vitest'; -import {GatewayRolloutConfigSchema, GatewayRolloutConfigUpdateRequest} from '../admin/GatewayRolloutSchemas'; describe('gateway rollout schemas', () => { test('full config applies defaults for omitted values', () => { diff --git a/packages/schema/src/domains/tests/JobsSchemas.test.ts b/packages/schema/src/domains/tests/JobsSchemas.test.ts index 4be7a14bb..9c47e0c40 100644 --- a/packages/schema/src/domains/tests/JobsSchemas.test.ts +++ b/packages/schema/src/domains/tests/JobsSchemas.test.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {JobLedgerEntrySchema, ListJobsQuery, ListJobsRequest} from '@fluxer/schema/src/domains/admin/JobsSchemas'; import {describe, expect, test} from 'vitest'; -import {JobLedgerEntrySchema, ListJobsQuery, ListJobsRequest} from '../admin/JobsSchemas'; describe('jobs schemas', () => { test('the job status enum rejects failed, which the ledger never writes', () => { diff --git a/packages/voice_engine_v2/src/bridge/bridge_contract.test.ts b/packages/voice_engine_v2/src/bridge/bridge_contract.test.ts index d047014b4..d631ddb7f 100644 --- a/packages/voice_engine_v2/src/bridge/bridge_contract.test.ts +++ b/packages/voice_engine_v2/src/bridge/bridge_contract.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { assertAudioFrameInvariants, assertVideoFrameInvariants, @@ -8,14 +7,15 @@ import { VOICE_ENGINE_V2_VIDEO_DIMENSION_MAX, VOICE_ENGINE_V2_VIDEO_FRAME_BYTES_MAX, VoiceEngineV2FfiAssertError, -} from './ffi_assertions'; +} from '@fluxer/voice_engine_v2/src/bridge/ffi_assertions'; import { assertVoiceEngineV2BridgeAudioOptionsInvariants, assertVoiceEngineV2BridgeVideoOptionsInvariants, normalizeVoiceEngineV2BridgeHardwareEncoderCapabilities, unavailableVoiceEngineV2BridgeHardwareEncoderCapabilities, VOICE_ENGINE_V2_HARDWARE_ENCODER_IPC_CHANNEL, -} from './index'; +} from '@fluxer/voice_engine_v2/src/bridge/index'; +import {describe, expect, it} from 'vitest'; describe('voice engine v2 bridge contract', () => { it('pins the hardware encoder ipc channel shared by preload and the main process', () => { diff --git a/packages/voice_engine_v2/src/bridge/index.ts b/packages/voice_engine_v2/src/bridge/index.ts index ba612ca6c..0d55b7182 100644 --- a/packages/voice_engine_v2/src/bridge/index.ts +++ b/packages/voice_engine_v2/src/bridge/index.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceEngineV2HardwareEncoderCapabilities} from '../protocol'; -import {assertAudioFrameInvariants, assertVideoFrameInvariants} from './ffi_assertions'; +import { + assertAudioFrameInvariants, + assertVideoFrameInvariants, +} from '@fluxer/voice_engine_v2/src/bridge/ffi_assertions'; +import type {VoiceEngineV2HardwareEncoderCapabilities} from '@fluxer/voice_engine_v2/src/protocol'; export const VOICE_ENGINE_V2_HARDWARE_ENCODER_IPC_CHANNEL = 'voice-engine-v2:get-hardware-encoder-capabilities'; diff --git a/packages/voice_engine_v2/src/core/commandCompletion.ts b/packages/voice_engine_v2/src/core/commandCompletion.ts index b1ff679eb..380b8a23b 100644 --- a/packages/voice_engine_v2/src/core/commandCompletion.ts +++ b/packages/voice_engine_v2/src/core/commandCompletion.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Command} from '../protocol/commands'; -import type {VoiceEngineV2Snapshot} from './state'; +import type {VoiceEngineV2Snapshot} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; export function isVoiceEngineV2CommandCompletionStale( snapshot: VoiceEngineV2Snapshot, diff --git a/packages/voice_engine_v2/src/core/connectionGatewayFixtures.test.ts b/packages/voice_engine_v2/src/core/connectionGatewayFixtures.test.ts index c69ceb472..d6d81bb14 100644 --- a/packages/voice_engine_v2/src/core/connectionGatewayFixtures.test.ts +++ b/packages/voice_engine_v2/src/core/connectionGatewayFixtures.test.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import gatewayConnectionFixtureJson from '../../fixtures/event_logs/gateway_connection.json'; -import reconnectChannelMoveFixtureJson from '../../fixtures/event_logs/reconnect_channel_move.json'; -import resumePreservesMediaFixtureJson from '../../fixtures/event_logs/resume_preserves_media.json'; -import staleConnectionFixtureJson from '../../fixtures/event_logs/stale_connection.json'; -import teardownRendererWindowFixtureJson from '../../fixtures/event_logs/teardown_renderer_window.json'; -import type {VoiceEngineV2Command} from '../protocol/commands'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import {transitionVoiceEngineV2} from './reducer'; +import gatewayConnectionFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/gateway_connection.json'; +import reconnectChannelMoveFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/reconnect_channel_move.json'; +import resumePreservesMediaFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/resume_preserves_media.json'; +import staleConnectionFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/stale_connection.json'; +import teardownRendererWindowFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/teardown_renderer_window.json'; +import {transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; import { availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot, type VoiceEngineV2OperationStatus, type VoiceEngineV2Snapshot, -} from './state'; +} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import {describe, expect, it} from 'vitest'; interface VoiceEngineV2ConnectionGatewayFixtureStep { name: string; diff --git a/packages/voice_engine_v2/src/core/fixtures.test.ts b/packages/voice_engine_v2/src/core/fixtures.test.ts index 5f6f55f00..b5fd1dbf3 100644 --- a/packages/voice_engine_v2/src/core/fixtures.test.ts +++ b/packages/voice_engine_v2/src/core/fixtures.test.ts @@ -1,18 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import fixtureJson from '@fluxer/voice_engine_v2/fixtures/basic_session.json'; +import cameraInPlaceUpdateFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/camera_in_place_update.json'; +import codecRepublishFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/codec_republish.json'; +import nativeFrameSinkFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/native_frame_sink.json'; +import nativeZeroCopyScreenFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/native_zero_copy_screen.json'; +import screenAudioInclusionToggleFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/screen_audio_inclusion_toggle.json'; +import screenAudioRoutingFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/screen_audio_routing.json'; +import screenShareStartUpdateStopFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/screen_share_start_update_stop.json'; +import externallyEstablishedFixtureJson from '@fluxer/voice_engine_v2/fixtures/externally_established_session.json'; +import {transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; +import { + availableVoiceEngineV2Capabilities, + createVoiceEngineV2InitialSnapshot, +} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command, VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol'; import {describe, expect, it} from 'vitest'; -import fixtureJson from '../../fixtures/basic_session.json'; -import cameraInPlaceUpdateFixtureJson from '../../fixtures/event_logs/camera_in_place_update.json'; -import codecRepublishFixtureJson from '../../fixtures/event_logs/codec_republish.json'; -import nativeFrameSinkFixtureJson from '../../fixtures/event_logs/native_frame_sink.json'; -import nativeZeroCopyScreenFixtureJson from '../../fixtures/event_logs/native_zero_copy_screen.json'; -import screenAudioInclusionToggleFixtureJson from '../../fixtures/event_logs/screen_audio_inclusion_toggle.json'; -import screenAudioRoutingFixtureJson from '../../fixtures/event_logs/screen_audio_routing.json'; -import screenShareStartUpdateStopFixtureJson from '../../fixtures/event_logs/screen_share_start_update_stop.json'; -import externallyEstablishedFixtureJson from '../../fixtures/externally_established_session.json'; -import type {VoiceEngineV2Command, VoiceEngineV2Event} from '../protocol'; -import {transitionVoiceEngineV2} from './reducer'; -import {availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot} from './state'; interface VoiceEngineV2FixtureExpected { nextOperationId: number; diff --git a/packages/voice_engine_v2/src/core/index.ts b/packages/voice_engine_v2/src/core/index.ts index f1c0adc1c..3a9ae797b 100644 --- a/packages/voice_engine_v2/src/core/index.ts +++ b/packages/voice_engine_v2/src/core/index.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -export {isVoiceEngineV2CommandCompletionStale, transitionVoiceEngineV2} from './reducer'; -export {shouldApplyGatewayVoiceStateEcho} from './reducers/gateway'; +export {isVoiceEngineV2CommandCompletionStale, transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; +export {shouldApplyGatewayVoiceStateEcho} from '@fluxer/voice_engine_v2/src/core/reducers/gateway'; export type { VoiceEngineV2CapabilitiesProjection, VoiceEngineV2DeviceProjection, @@ -10,7 +10,7 @@ export type { VoiceEngineV2StatsPresentationNetworkSummary, VoiceEngineV2StatsPresentationProjection, VoiceEngineV2StatsProjection, -} from './selectors'; +} from '@fluxer/voice_engine_v2/src/core/selectors'; export { selectVoiceEngineV2CapabilitiesProjection, selectVoiceEngineV2ConnectionProjection, @@ -26,7 +26,7 @@ export { selectVoiceEngineV2StatsProjection, selectVoiceEngineV2StatsSummary, selectVoiceEngineV2WatchedStreams, -} from './selectors'; +} from '@fluxer/voice_engine_v2/src/core/selectors'; export type { SourceLifecycleState, VoiceEngineV2ConnectionState, @@ -49,11 +49,11 @@ export type { VoiceEngineV2RoomState, VoiceEngineV2Snapshot, VoiceEngineV2Transition, -} from './state'; +} from '@fluxer/voice_engine_v2/src/core/state'; export { availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot, createVoiceEngineV2PermissionResult, emptyVoiceEngineV2DeviceInventory, unavailableVoiceEngineV2Capabilities, -} from './state'; +} from '@fluxer/voice_engine_v2/src/core/state'; diff --git a/packages/voice_engine_v2/src/core/localMediaFixtures.test.ts b/packages/voice_engine_v2/src/core/localMediaFixtures.test.ts index 1a17e42f4..1b26a000d 100644 --- a/packages/voice_engine_v2/src/core/localMediaFixtures.test.ts +++ b/packages/voice_engine_v2/src/core/localMediaFixtures.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import deviceHotswapFixtureJson from '../../fixtures/event_logs/device_hotswap.json'; -import localMediaFixtureJson from '../../fixtures/event_logs/local_media.json'; -import microphoneFailureRecoveryFixtureJson from '../../fixtures/event_logs/microphone_failure_recovery.json'; -import permissionsRecoveryFixtureJson from '../../fixtures/event_logs/permissions_recovery.json'; -import pttPtmFixtureJson from '../../fixtures/event_logs/ptt_ptm.json'; -import type {VoiceEngineV2Command, VoiceEngineV2Event} from '../protocol'; -import {transitionVoiceEngineV2} from './reducer'; +import deviceHotswapFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/device_hotswap.json'; +import localMediaFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/local_media.json'; +import microphoneFailureRecoveryFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/microphone_failure_recovery.json'; +import permissionsRecoveryFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/permissions_recovery.json'; +import pttPtmFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/ptt_ptm.json'; +import {transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; import { availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot, type VoiceEngineV2Snapshot, -} from './state'; +} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command, VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol'; +import {describe, expect, it} from 'vitest'; interface LocalMediaSnapshotExpectation { nextOperationId?: number; diff --git a/packages/voice_engine_v2/src/core/observability_fixtures.test.ts b/packages/voice_engine_v2/src/core/observability_fixtures.test.ts index c53f2e814..14721b8f1 100644 --- a/packages/voice_engine_v2/src/core/observability_fixtures.test.ts +++ b/packages/voice_engine_v2/src/core/observability_fixtures.test.ts @@ -1,26 +1,26 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import capabilitiesLifecycleFixtureJson from '../../fixtures/event_logs/capabilities_lifecycle.json'; -import deviceInventoryFixtureJson from '../../fixtures/event_logs/device_inventory.json'; -import diagnosticsLifecycleFixtureJson from '../../fixtures/event_logs/diagnostics_lifecycle.json'; -import e2eeLifecycleFixtureJson from '../../fixtures/event_logs/e2ee_lifecycle.json'; -import statsLifecycleFixtureJson from '../../fixtures/event_logs/stats_lifecycle.json'; -import type {VoiceEngineV2Command} from '../protocol/commands'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import {transitionVoiceEngineV2} from './reducer'; +import capabilitiesLifecycleFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/capabilities_lifecycle.json'; +import deviceInventoryFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/device_inventory.json'; +import diagnosticsLifecycleFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/diagnostics_lifecycle.json'; +import e2eeLifecycleFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/e2ee_lifecycle.json'; +import statsLifecycleFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/stats_lifecycle.json'; +import {transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; import { selectVoiceEngineV2CapabilitiesProjection, selectVoiceEngineV2DeviceProjection, selectVoiceEngineV2DiagnosticsProjection, selectVoiceEngineV2E2eeProjection, selectVoiceEngineV2StatsProjection, -} from './selectors'; +} from '@fluxer/voice_engine_v2/src/core/selectors'; import { availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot, type VoiceEngineV2Snapshot, -} from './state'; +} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import {describe, expect, it} from 'vitest'; interface VoiceEngineV2EventLogFixture { name: string; diff --git a/packages/voice_engine_v2/src/core/participants_tracks.test.ts b/packages/voice_engine_v2/src/core/participants_tracks.test.ts index 9daeb2f3b..e081a26c8 100644 --- a/packages/voice_engine_v2/src/core/participants_tracks.test.ts +++ b/packages/voice_engine_v2/src/core/participants_tracks.test.ts @@ -1,27 +1,30 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import inboundVideoFrameStatsFixtureJson from '../../fixtures/event_logs/inbound_video_frame_stats.json'; -import inboundVideoFramesFixtureJson from '../../fixtures/event_logs/inbound_video_frames.json'; -import participantsTracksFixtureJson from '../../fixtures/event_logs/participants_tracks.json'; -import subscriptionQualityFixtureJson from '../../fixtures/event_logs/subscription_quality.json'; -import watchedStreamsFixtureJson from '../../fixtures/event_logs/watched_streams.json'; -import type {VoiceEngineV2Command} from '../protocol/commands'; -import type {VoiceEngineV2Event} from '../protocol/events'; +import inboundVideoFrameStatsFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/inbound_video_frame_stats.json'; +import inboundVideoFramesFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/inbound_video_frames.json'; +import participantsTracksFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/participants_tracks.json'; +import subscriptionQualityFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/subscription_quality.json'; +import watchedStreamsFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/watched_streams.json'; +import {transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; +import { + selectVoiceEngineV2ParticipantProjection, + selectVoiceEngineV2WatchedStreams, +} from '@fluxer/voice_engine_v2/src/core/selectors'; +import { + availableVoiceEngineV2Capabilities, + createVoiceEngineV2InitialSnapshot, + type VoiceEngineV2Snapshot, +} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2InboundVideoTrack, VoiceEngineV2Participant, VoiceEngineV2RemoteTrackSubscriptionOptions, VoiceEngineV2Track, VoiceEngineV2WatchedStream, -} from '../protocol/types'; -import {transitionVoiceEngineV2} from './reducer'; -import {selectVoiceEngineV2ParticipantProjection, selectVoiceEngineV2WatchedStreams} from './selectors'; -import { - availableVoiceEngineV2Capabilities, - createVoiceEngineV2InitialSnapshot, - type VoiceEngineV2Snapshot, -} from './state'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import {describe, expect, it} from 'vitest'; interface ParticipantsTracksFixtureExpected { participants?: Array; diff --git a/packages/voice_engine_v2/src/core/reducer.bench.ts b/packages/voice_engine_v2/src/core/reducer.bench.ts index 68bf0e64c..40bd7178c 100644 --- a/packages/voice_engine_v2/src/core/reducer.bench.ts +++ b/packages/voice_engine_v2/src/core/reducer.bench.ts @@ -1,8 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {bench, describe} from 'vitest'; -import basicSessionFixture from '../../fixtures/basic_session.json'; -import type {VoiceEngineV2Event} from '../protocol/events'; +import basicSessionFixture from '@fluxer/voice_engine_v2/fixtures/basic_session.json'; +import {transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; +import { + availableVoiceEngineV2Capabilities, + createVoiceEngineV2InitialSnapshot, + type VoiceEngineV2Snapshot, +} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2InboundVideoFrame, VoiceEngineV2InboundVideoFrameStats, @@ -10,13 +15,8 @@ import type { VoiceEngineV2Participant, VoiceEngineV2ScreenOptions, VoiceEngineV2Stats, -} from '../protocol/types'; -import {transitionVoiceEngineV2} from './reducer'; -import { - availableVoiceEngineV2Capabilities, - createVoiceEngineV2InitialSnapshot, - type VoiceEngineV2Snapshot, -} from './state'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import {bench, describe} from 'vitest'; interface VoiceEngineV2BenchFixture { events: Array; diff --git a/packages/voice_engine_v2/src/core/reducer.test.ts b/packages/voice_engine_v2/src/core/reducer.test.ts index b32f3640f..2f5572e71 100644 --- a/packages/voice_engine_v2/src/core/reducer.test.ts +++ b/packages/voice_engine_v2/src/core/reducer.test.ts @@ -1,17 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import type {VoiceEngineV2DiagnosticEntry} from '../protocol/types'; -import {transitionVoiceEngineV2} from './reducer'; -import {VOICE_ENGINE_V2_TERMINAL_OPERATIONS_KEPT_MAX} from './reducers/_helpers'; -import {selectVoiceEngineV2FailedSourceIds, selectVoiceEngineV2SourceLifecycle} from './selectors'; +import {transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; +import {VOICE_ENGINE_V2_TERMINAL_OPERATIONS_KEPT_MAX} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import { + selectVoiceEngineV2FailedSourceIds, + selectVoiceEngineV2SourceLifecycle, +} from '@fluxer/voice_engine_v2/src/core/selectors'; import { availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot, unavailableVoiceEngineV2Capabilities, type VoiceEngineV2Snapshot, -} from './state'; +} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type {VoiceEngineV2DiagnosticEntry} from '@fluxer/voice_engine_v2/src/protocol/types'; +import {describe, expect, it} from 'vitest'; function initialSnapshot(): VoiceEngineV2Snapshot { return createVoiceEngineV2InitialSnapshot(availableVoiceEngineV2Capabilities()); diff --git a/packages/voice_engine_v2/src/core/reducer.ts b/packages/voice_engine_v2/src/core/reducer.ts index d60e5d82c..3a0f167f9 100644 --- a/packages/voice_engine_v2/src/core/reducer.ts +++ b/packages/voice_engine_v2/src/core/reducer.ts @@ -1,17 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../protocol/events'; import { dispatchLocalMediaEvent, dispatchObservabilityEvent, dispatchPlatformEvent, dispatchRuntimeEvent, dispatchSessionEvent, -} from './reducers/_dispatch'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from './state'; +} from '@fluxer/voice_engine_v2/src/core/reducers/_dispatch'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; -export {isVoiceEngineV2CommandCompletionStale} from './commandCompletion'; +export {isVoiceEngineV2CommandCompletionStale} from '@fluxer/voice_engine_v2/src/core/commandCompletion'; export function transitionVoiceEngineV2( snapshot: VoiceEngineV2Snapshot, diff --git a/packages/voice_engine_v2/src/core/reducers/_dispatch.ts b/packages/voice_engine_v2/src/core/reducers/_dispatch.ts index 3e2f7e194..75148786f 100644 --- a/packages/voice_engine_v2/src/core/reducers/_dispatch.ts +++ b/packages/voice_engine_v2/src/core/reducers/_dispatch.ts @@ -1,34 +1,34 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {planDesiredState} from './_plan'; -import {transitionCamera} from './camera'; -import {transitionCapabilities} from './capabilities'; -import {transitionCommand} from './command'; -import {transitionConnection} from './connection'; -import {transitionData} from './data'; -import {transitionDevices} from './devices'; -import {transitionE2ee} from './e2ee'; -import {transitionGateway} from './gateway'; -import {transitionImplementation} from './implementation'; -import {transitionInboundVideo} from './inboundVideo'; -import {transitionLifecycle} from './lifecycle'; -import {transitionMicrophone} from './microphone'; -import {transitionNativeAudioTap} from './nativeAudioTap'; -import {transitionNativeCapture} from './nativeCapture'; -import {transitionNativeFrameSink} from './nativeFrameSink'; -import {transitionOutputDevice} from './outputDevice'; -import {transitionParticipantVolume} from './participantVolume'; -import {transitionPermissions} from './permissions'; -import {transitionRemoteTrackSubscription} from './remoteTrackSubscription'; -import {transitionRoom} from './room'; -import {transitionScreen} from './screen'; -import {transitionScreenAudio} from './screenAudio'; -import {transitionSourceLifecycles} from './sourceLifecycles'; -import {transitionStats} from './stats'; -import {transitionUtilityPorts} from './utilityPorts'; +import {planDesiredState} from '@fluxer/voice_engine_v2/src/core/reducers/_plan'; +import {transitionCamera} from '@fluxer/voice_engine_v2/src/core/reducers/camera'; +import {transitionCapabilities} from '@fluxer/voice_engine_v2/src/core/reducers/capabilities'; +import {transitionCommand} from '@fluxer/voice_engine_v2/src/core/reducers/command'; +import {transitionConnection} from '@fluxer/voice_engine_v2/src/core/reducers/connection'; +import {transitionData} from '@fluxer/voice_engine_v2/src/core/reducers/data'; +import {transitionDevices} from '@fluxer/voice_engine_v2/src/core/reducers/devices'; +import {transitionE2ee} from '@fluxer/voice_engine_v2/src/core/reducers/e2ee'; +import {transitionGateway} from '@fluxer/voice_engine_v2/src/core/reducers/gateway'; +import {transitionImplementation} from '@fluxer/voice_engine_v2/src/core/reducers/implementation'; +import {transitionInboundVideo} from '@fluxer/voice_engine_v2/src/core/reducers/inboundVideo'; +import {transitionLifecycle} from '@fluxer/voice_engine_v2/src/core/reducers/lifecycle'; +import {transitionMicrophone} from '@fluxer/voice_engine_v2/src/core/reducers/microphone'; +import {transitionNativeAudioTap} from '@fluxer/voice_engine_v2/src/core/reducers/nativeAudioTap'; +import {transitionNativeCapture} from '@fluxer/voice_engine_v2/src/core/reducers/nativeCapture'; +import {transitionNativeFrameSink} from '@fluxer/voice_engine_v2/src/core/reducers/nativeFrameSink'; +import {transitionOutputDevice} from '@fluxer/voice_engine_v2/src/core/reducers/outputDevice'; +import {transitionParticipantVolume} from '@fluxer/voice_engine_v2/src/core/reducers/participantVolume'; +import {transitionPermissions} from '@fluxer/voice_engine_v2/src/core/reducers/permissions'; +import {transitionRemoteTrackSubscription} from '@fluxer/voice_engine_v2/src/core/reducers/remoteTrackSubscription'; +import {transitionRoom} from '@fluxer/voice_engine_v2/src/core/reducers/room'; +import {transitionScreen} from '@fluxer/voice_engine_v2/src/core/reducers/screen'; +import {transitionScreenAudio} from '@fluxer/voice_engine_v2/src/core/reducers/screenAudio'; +import {transitionSourceLifecycles} from '@fluxer/voice_engine_v2/src/core/reducers/sourceLifecycles'; +import {transitionStats} from '@fluxer/voice_engine_v2/src/core/reducers/stats'; +import {transitionUtilityPorts} from '@fluxer/voice_engine_v2/src/core/reducers/utilityPorts'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; export function dispatchLocalMediaEvent( snapshot: VoiceEngineV2Snapshot, diff --git a/packages/voice_engine_v2/src/core/reducers/_helpers.ts b/packages/voice_engine_v2/src/core/reducers/_helpers.ts index 08be84510..21d153128 100644 --- a/packages/voice_engine_v2/src/core/reducers/_helpers.ts +++ b/packages/voice_engine_v2/src/core/reducers/_helpers.ts @@ -1,7 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {getVoiceEngineV2CommandResourceKey, type VoiceEngineV2Command} from '../../protocol/commands'; +import type { + VoiceEngineV2OperationState, + VoiceEngineV2OperationStatus, + VoiceEngineV2Snapshot, + VoiceEngineV2Transition, +} from '@fluxer/voice_engine_v2/src/core/state'; +import { + getVoiceEngineV2CommandResourceKey, + type VoiceEngineV2Command, +} from '@fluxer/voice_engine_v2/src/protocol/commands'; import type { VoiceEngineV2DataOptions, VoiceEngineV2DiagnosticEntry, @@ -11,13 +20,7 @@ import type { VoiceEngineV2ParticipantVolumeOptions, VoiceEngineV2RemoteTrackSubscriptionOptions, VoiceEngineV2ResourceKey, -} from '../../protocol/types'; -import type { - VoiceEngineV2OperationState, - VoiceEngineV2OperationStatus, - VoiceEngineV2Snapshot, - VoiceEngineV2Transition, -} from '../state'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; export const VOICE_ENGINE_V2_TERMINAL_OPERATIONS_KEPT_MAX = 64; const VOICE_ENGINE_V2_DIAGNOSTICS_KEPT_MAX = 200; diff --git a/packages/voice_engine_v2/src/core/reducers/_media.ts b/packages/voice_engine_v2/src/core/reducers/_media.ts index 3a988b518..fc9b72d26 100644 --- a/packages/voice_engine_v2/src/core/reducers/_media.ts +++ b/packages/voice_engine_v2/src/core/reducers/_media.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Error, VoiceEngineV2OperationId} from '../../protocol/types'; -import type {VoiceEngineV2LocalMediaState, VoiceEngineV2Snapshot} from '../state'; +import type {VoiceEngineV2LocalMediaState, VoiceEngineV2Snapshot} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Error, VoiceEngineV2OperationId} from '@fluxer/voice_engine_v2/src/protocol/types'; export function applyMediaSuccess( state: VoiceEngineV2LocalMediaState, diff --git a/packages/voice_engine_v2/src/core/reducers/_plan.ts b/packages/voice_engine_v2/src/core/reducers/_plan.ts index 0181dda38..a1cd3cae0 100644 --- a/packages/voice_engine_v2/src/core/reducers/_plan.ts +++ b/packages/voice_engine_v2/src/core/reducers/_plan.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Command} from '../../protocol/commands'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, appendTransition} from './_helpers'; -import {beginCameraPublish} from './camera'; -import {beginMicrophonePublish} from './microphone'; -import {beginScreenPublish} from './screen'; -import {beginScreenAudioPublish} from './screenAudio'; +import {allocateOperation, appendTransition} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import {beginCameraPublish} from '@fluxer/voice_engine_v2/src/core/reducers/camera'; +import {beginMicrophonePublish} from '@fluxer/voice_engine_v2/src/core/reducers/microphone'; +import {beginScreenPublish} from '@fluxer/voice_engine_v2/src/core/reducers/screen'; +import {beginScreenAudioPublish} from '@fluxer/voice_engine_v2/src/core/reducers/screenAudio'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; function planDesiredLocalMedia(snapshot: VoiceEngineV2Snapshot): VoiceEngineV2Transition { assert.ok(snapshot != null, 'planDesiredLocalMedia snapshot must not be null'); diff --git a/packages/voice_engine_v2/src/core/reducers/_zeroCopy.ts b/packages/voice_engine_v2/src/core/reducers/_zeroCopy.ts index 5db76e379..2aa7291a3 100644 --- a/packages/voice_engine_v2/src/core/reducers/_zeroCopy.ts +++ b/packages/voice_engine_v2/src/core/reducers/_zeroCopy.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Error} from '../../protocol/types'; -import {implementationError} from './_helpers'; +import {implementationError} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Error} from '@fluxer/voice_engine_v2/src/protocol/types'; export function nativeZeroCopyRequiredError( resource: 'capture' | 'frame' | 'frameSink' | 'hardwareEncoder', diff --git a/packages/voice_engine_v2/src/core/reducers/camera.ts b/packages/voice_engine_v2/src/core/reducers/camera.ts index 9526032a5..4fbdfa4dc 100644 --- a/packages/voice_engine_v2/src/core/reducers/camera.ts +++ b/packages/voice_engine_v2/src/core/reducers/camera.ts @@ -1,17 +1,27 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {planVoiceEngineV2CameraEncodingChange} from '../../policies/cameraShare'; -import type {VoiceEngineV2Event} from '../../protocol/events'; +import { + allocateOperation, + failUnpublish, + invalidArgument, + isConnected, + unsupportedCapability, +} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import { + applyMediaFailure, + applyMediaSuccess, + completeUnpublish, +} from '@fluxer/voice_engine_v2/src/core/reducers/_media'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import {planVoiceEngineV2CameraEncodingChange} from '@fluxer/voice_engine_v2/src/policies/cameraShare'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2CameraEncodingOptions, VoiceEngineV2CameraOptions, VoiceEngineV2Error, VoiceEngineV2OperationId, -} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, failUnpublish, invalidArgument, isConnected, unsupportedCapability} from './_helpers'; -import {applyMediaFailure, applyMediaSuccess, completeUnpublish} from './_media'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2CameraEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/capabilities.ts b/packages/voice_engine_v2/src/core/reducers/capabilities.ts index 7953bd0b6..88cdea76a 100644 --- a/packages/voice_engine_v2/src/core/reducers/capabilities.ts +++ b/packages/voice_engine_v2/src/core/reducers/capabilities.ts @@ -1,14 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; +import { + allocateOperation, + markOperation, + queueCommand, + unsupportedCapability, +} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2Error, VoiceEngineV2HardwareEncoderCapabilities, VoiceEngineV2OperationId, -} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, markOperation, queueCommand, unsupportedCapability} from './_helpers'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2CapabilitiesEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/command.ts b/packages/voice_engine_v2/src/core/reducers/command.ts index f075d4ed6..1e9556e5f 100644 --- a/packages/voice_engine_v2/src/core/reducers/command.ts +++ b/packages/voice_engine_v2/src/core/reducers/command.ts @@ -1,10 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {getVoiceEngineV2CommandTypeResourceKey} from '../../protocol/commands'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, clearOperationForResource, markOperation, queueCommand} from './_helpers'; +import { + allocateOperation, + clearOperationForResource, + markOperation, + queueCommand, +} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import {getVoiceEngineV2CommandTypeResourceKey} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; type VoiceEngineV2CommandEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/connection.ts b/packages/voice_engine_v2/src/core/reducers/connection.ts index b7bf899d5..1ccd52c64 100644 --- a/packages/voice_engine_v2/src/core/reducers/connection.ts +++ b/packages/voice_engine_v2/src/core/reducers/connection.ts @@ -1,18 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Command} from '../../protocol/commands'; -import type {VoiceEngineV2Event} from '../../protocol/events'; +import { + allocateOperation, + markOperation, + queueCommand, + recordQueuedCommand, + unsupportedCapability, +} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import {resetPublishedMedia} from '@fluxer/voice_engine_v2/src/core/reducers/_media'; +import { + createVoiceEngineV2InitialSnapshot, + type VoiceEngineV2Snapshot, + type VoiceEngineV2Transition, +} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2ConnectOptions, VoiceEngineV2DisconnectReason, VoiceEngineV2Error, VoiceEngineV2LifecycleReason, VoiceEngineV2OperationId, -} from '../../protocol/types'; -import {createVoiceEngineV2InitialSnapshot, type VoiceEngineV2Snapshot, type VoiceEngineV2Transition} from '../state'; -import {allocateOperation, markOperation, queueCommand, recordQueuedCommand, unsupportedCapability} from './_helpers'; -import {resetPublishedMedia} from './_media'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2ConnectionEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/data.ts b/packages/voice_engine_v2/src/core/reducers/data.ts index ac8d48097..65c7debdc 100644 --- a/packages/voice_engine_v2/src/core/reducers/data.ts +++ b/packages/voice_engine_v2/src/core/reducers/data.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {commandIfConnected} from './_helpers'; +import {commandIfConnected} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; type VoiceEngineV2DataEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/devices.ts b/packages/voice_engine_v2/src/core/reducers/devices.ts index 699a6d3f7..0e4f8400f 100644 --- a/packages/voice_engine_v2/src/core/reducers/devices.ts +++ b/packages/voice_engine_v2/src/core/reducers/devices.ts @@ -1,12 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Command} from '../../protocol/commands'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2DeviceInventory, VoiceEngineV2Error, VoiceEngineV2OperationId} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, appendTransition, markOperation, queueCommand} from './_helpers'; -import {planMicrophoneDeviceChange} from './microphone'; +import { + allocateOperation, + appendTransition, + markOperation, + queueCommand, +} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import {planMicrophoneDeviceChange} from '@fluxer/voice_engine_v2/src/core/reducers/microphone'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type { + VoiceEngineV2DeviceInventory, + VoiceEngineV2Error, + VoiceEngineV2OperationId, +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2DevicesEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/e2ee.ts b/packages/voice_engine_v2/src/core/reducers/e2ee.ts index ea8620749..7d8014eea 100644 --- a/packages/voice_engine_v2/src/core/reducers/e2ee.ts +++ b/packages/voice_engine_v2/src/core/reducers/e2ee.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, markOperation, queueCommand} from './_helpers'; +import {allocateOperation, markOperation, queueCommand} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; type VoiceEngineV2E2eeEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/gateway.reconcile.test.ts b/packages/voice_engine_v2/src/core/reducers/gateway.reconcile.test.ts index 461c73904..4bd26a8d8 100644 --- a/packages/voice_engine_v2/src/core/reducers/gateway.reconcile.test.ts +++ b/packages/voice_engine_v2/src/core/reducers/gateway.reconcile.test.ts @@ -1,16 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import type {VoiceEngineV2GatewayDesiredVoiceState, VoiceEngineV2GatewayVoiceState} from '../../protocol/types'; -import {transitionVoiceEngineV2} from '../reducer'; -import type {VoiceEngineV2GatewayState, VoiceEngineV2Snapshot} from '../state'; -import {availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot} from '../state'; +import {transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; import { deriveVoiceEngineV2DesiredGatewayVoiceState, gatewayVoiceStateWriteMatchesReported, reconcileGatewayVoiceState, shouldApplyGatewayVoiceStateEcho, -} from './gateway'; +} from '@fluxer/voice_engine_v2/src/core/reducers/gateway'; +import type {VoiceEngineV2GatewayState, VoiceEngineV2Snapshot} from '@fluxer/voice_engine_v2/src/core/state'; +import { + availableVoiceEngineV2Capabilities, + createVoiceEngineV2InitialSnapshot, +} from '@fluxer/voice_engine_v2/src/core/state'; +import type { + VoiceEngineV2GatewayDesiredVoiceState, + VoiceEngineV2GatewayVoiceState, +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import {describe, expect, it} from 'vitest'; function reported(overrides: Partial = {}): VoiceEngineV2GatewayVoiceState { return { diff --git a/packages/voice_engine_v2/src/core/reducers/gateway.ts b/packages/voice_engine_v2/src/core/reducers/gateway.ts index 3b20bf6a6..7423d2d64 100644 --- a/packages/voice_engine_v2/src/core/reducers/gateway.ts +++ b/packages/voice_engine_v2/src/core/reducers/gateway.ts @@ -1,17 +1,25 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; +import { + allocateOperation, + isConnected, + markOperation, + queueCommand, +} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import { + beginGatewayVoiceStateClear, + planPendingConnectionTeardown, +} from '@fluxer/voice_engine_v2/src/core/reducers/connection'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2Error, VoiceEngineV2GatewayDesiredVoiceState, VoiceEngineV2GatewayVoiceState, VoiceEngineV2GatewayVoiceStateWrite, VoiceEngineV2OperationId, -} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, isConnected, markOperation, queueCommand} from './_helpers'; -import {beginGatewayVoiceStateClear, planPendingConnectionTeardown} from './connection'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2GatewayEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/implementation.ts b/packages/voice_engine_v2/src/core/reducers/implementation.ts index 61236bc52..9d64c99de 100644 --- a/packages/voice_engine_v2/src/core/reducers/implementation.ts +++ b/packages/voice_engine_v2/src/core/reducers/implementation.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, recordFailure} from './_helpers'; +import {allocateOperation, recordFailure} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; type VoiceEngineV2ImplementationEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/inboundVideo.ts b/packages/voice_engine_v2/src/core/reducers/inboundVideo.ts index deac60734..d36810c35 100644 --- a/packages/voice_engine_v2/src/core/reducers/inboundVideo.ts +++ b/packages/voice_engine_v2/src/core/reducers/inboundVideo.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2InboundVideoFrame, VoiceEngineV2InboundVideoFrameStats, VoiceEngineV2InboundVideoTrackSubscription, -} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2InboundVideoEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/lifecycle.ts b/packages/voice_engine_v2/src/core/reducers/lifecycle.ts index 154ded5c7..ce554f886 100644 --- a/packages/voice_engine_v2/src/core/reducers/lifecycle.ts +++ b/packages/voice_engine_v2/src/core/reducers/lifecycle.ts @@ -1,11 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {markOperation} from './_helpers'; -import {resetPublishedMedia} from './_media'; -import {planPendingConnectionTeardown, resetAfterDisconnect} from './connection'; +import {markOperation} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import {resetPublishedMedia} from '@fluxer/voice_engine_v2/src/core/reducers/_media'; +import { + planPendingConnectionTeardown, + resetAfterDisconnect, +} from '@fluxer/voice_engine_v2/src/core/reducers/connection'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; type VoiceEngineV2LifecycleEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/microphone.ts b/packages/voice_engine_v2/src/core/reducers/microphone.ts index 1709a1af1..5299ffabf 100644 --- a/packages/voice_engine_v2/src/core/reducers/microphone.ts +++ b/packages/voice_engine_v2/src/core/reducers/microphone.ts @@ -1,19 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import { - getVoiceEngineV2MicrophoneOperationFailureAction, - type VoiceEngineV2MicrophoneOperationFailureAction, -} from '../../policies/microphoneFailureAction'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type { - VoiceEngineV2AudioControls, - VoiceEngineV2Error, - VoiceEngineV2MicrophoneOptions, - VoiceEngineV2OperationId, - VoiceEngineV2PermissionResult, -} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; import { allocateOperation, beginUnpublish, @@ -21,8 +8,21 @@ import { isConnected, markOperation, unsupportedCapability, -} from './_helpers'; -import {applyMediaFailure, completeUnpublish} from './_media'; +} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import {applyMediaFailure, completeUnpublish} from '@fluxer/voice_engine_v2/src/core/reducers/_media'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import { + getVoiceEngineV2MicrophoneOperationFailureAction, + type VoiceEngineV2MicrophoneOperationFailureAction, +} from '@fluxer/voice_engine_v2/src/policies/microphoneFailureAction'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type { + VoiceEngineV2AudioControls, + VoiceEngineV2Error, + VoiceEngineV2MicrophoneOptions, + VoiceEngineV2OperationId, + VoiceEngineV2PermissionResult, +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2MicrophoneEvent = Extract< VoiceEngineV2Event, diff --git a/packages/voice_engine_v2/src/core/reducers/nativeAudioTap.ts b/packages/voice_engine_v2/src/core/reducers/nativeAudioTap.ts index fc7662539..3ec49c346 100644 --- a/packages/voice_engine_v2/src/core/reducers/nativeAudioTap.ts +++ b/packages/voice_engine_v2/src/core/reducers/nativeAudioTap.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, queueCommand} from './_helpers'; +import {allocateOperation, queueCommand} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; type VoiceEngineV2NativeAudioTapEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/nativeCapture.ts b/packages/voice_engine_v2/src/core/reducers/nativeCapture.ts index 2d4fb5fab..5396d3ff9 100644 --- a/packages/voice_engine_v2/src/core/reducers/nativeCapture.ts +++ b/packages/voice_engine_v2/src/core/reducers/nativeCapture.ts @@ -1,16 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Command} from '../../protocol/commands'; -import type {VoiceEngineV2Event} from '../../protocol/events'; +import {allocateOperation, markOperation, queueCommand} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import { + nativeZeroCopyRequiredError, + unavailableZeroCopyTransportError, +} from '@fluxer/voice_engine_v2/src/core/reducers/_zeroCopy'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2Error, VoiceEngineV2NativeCaptureOptions, VoiceEngineV2OperationId, -} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, markOperation, queueCommand} from './_helpers'; -import {nativeZeroCopyRequiredError, unavailableZeroCopyTransportError} from './_zeroCopy'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2NativeCaptureEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/nativeFrameSink.ts b/packages/voice_engine_v2/src/core/reducers/nativeFrameSink.ts index c28f48ae2..c37784f5e 100644 --- a/packages/voice_engine_v2/src/core/reducers/nativeFrameSink.ts +++ b/packages/voice_engine_v2/src/core/reducers/nativeFrameSink.ts @@ -1,11 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2NativeFrameSinkOptions} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, queueCommand} from './_helpers'; -import {nativeZeroCopyRequiredError, unavailableZeroCopyTransportError} from './_zeroCopy'; +import {allocateOperation, queueCommand} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import { + nativeZeroCopyRequiredError, + unavailableZeroCopyTransportError, +} from '@fluxer/voice_engine_v2/src/core/reducers/_zeroCopy'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type {VoiceEngineV2NativeFrameSinkOptions} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2NativeFrameSinkEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/outputDevice.ts b/packages/voice_engine_v2/src/core/reducers/outputDevice.ts index 27e9b48fc..a5397a391 100644 --- a/packages/voice_engine_v2/src/core/reducers/outputDevice.ts +++ b/packages/voice_engine_v2/src/core/reducers/outputDevice.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {commandIfConnected} from './_helpers'; +import {commandIfConnected} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; type VoiceEngineV2OutputDeviceEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/participantVolume.ts b/packages/voice_engine_v2/src/core/reducers/participantVolume.ts index 107f81e05..5b4e259bd 100644 --- a/packages/voice_engine_v2/src/core/reducers/participantVolume.ts +++ b/packages/voice_engine_v2/src/core/reducers/participantVolume.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {commandIfConnected} from './_helpers'; +import {commandIfConnected} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; type VoiceEngineV2ParticipantVolumeEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/permissions.ts b/packages/voice_engine_v2/src/core/reducers/permissions.ts index fbc105798..1fcb8176a 100644 --- a/packages/voice_engine_v2/src/core/reducers/permissions.ts +++ b/packages/voice_engine_v2/src/core/reducers/permissions.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; +import {allocateOperation, markOperation, queueCommand} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import {applyMicrophonePermissionResult} from '@fluxer/voice_engine_v2/src/core/reducers/microphone'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2Error, VoiceEngineV2OperationId, VoiceEngineV2PermissionName, VoiceEngineV2PermissionResult, -} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, markOperation, queueCommand} from './_helpers'; -import {applyMicrophonePermissionResult} from './microphone'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2PermissionsEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/remoteTrackSubscription.ts b/packages/voice_engine_v2/src/core/reducers/remoteTrackSubscription.ts index 3fea4af88..fbd86e161 100644 --- a/packages/voice_engine_v2/src/core/reducers/remoteTrackSubscription.ts +++ b/packages/voice_engine_v2/src/core/reducers/remoteTrackSubscription.ts @@ -1,15 +1,15 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; +import {appendTransition, commandIfConnected} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2RemoteTrackSubscriptionOptions, VoiceEngineV2Track, VoiceEngineV2WatchedStream, VoiceEngineV2WatchedStreamKey, -} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {appendTransition, commandIfConnected} from './_helpers'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2RemoteTrackSubscriptionEvent = Extract< VoiceEngineV2Event, diff --git a/packages/voice_engine_v2/src/core/reducers/room.ts b/packages/voice_engine_v2/src/core/reducers/room.ts index 3da64df6c..2cdc68a03 100644 --- a/packages/voice_engine_v2/src/core/reducers/room.ts +++ b/packages/voice_engine_v2/src/core/reducers/room.ts @@ -1,11 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Participant, VoiceEngineV2Track} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {removeInboundVideoTrack} from './inboundVideo'; -import {clearWatchedStreamTrack, syncWatchedStreamTrack} from './remoteTrackSubscription'; +import {removeInboundVideoTrack} from '@fluxer/voice_engine_v2/src/core/reducers/inboundVideo'; +import { + clearWatchedStreamTrack, + syncWatchedStreamTrack, +} from '@fluxer/voice_engine_v2/src/core/reducers/remoteTrackSubscription'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type {VoiceEngineV2Participant, VoiceEngineV2Track} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2RoomEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/screen.ts b/packages/voice_engine_v2/src/core/reducers/screen.ts index 701c91828..82b2912db 100644 --- a/packages/voice_engine_v2/src/core/reducers/screen.ts +++ b/packages/voice_engine_v2/src/core/reducers/screen.ts @@ -1,15 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {planVoiceEngineV2ScreenEncodingChange} from '../../policies/screenShare'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type { - VoiceEngineV2Error, - VoiceEngineV2OperationId, - VoiceEngineV2ScreenEncodingOptions, - VoiceEngineV2ScreenOptions, -} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; import { allocateOperation, beginUnpublish, @@ -17,9 +8,25 @@ import { invalidArgument, isConnected, unsupportedCapability, -} from './_helpers'; -import {applyMediaFailure, applyMediaSuccess, completeUnpublish} from './_media'; -import {nativeZeroCopyRequiredError, unavailableZeroCopyTransportError} from './_zeroCopy'; +} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import { + applyMediaFailure, + applyMediaSuccess, + completeUnpublish, +} from '@fluxer/voice_engine_v2/src/core/reducers/_media'; +import { + nativeZeroCopyRequiredError, + unavailableZeroCopyTransportError, +} from '@fluxer/voice_engine_v2/src/core/reducers/_zeroCopy'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import {planVoiceEngineV2ScreenEncodingChange} from '@fluxer/voice_engine_v2/src/policies/screenShare'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type { + VoiceEngineV2Error, + VoiceEngineV2OperationId, + VoiceEngineV2ScreenEncodingOptions, + VoiceEngineV2ScreenOptions, +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2ScreenEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/screenAudio.ts b/packages/voice_engine_v2/src/core/reducers/screenAudio.ts index 7185b4a04..af6b48f8a 100644 --- a/packages/voice_engine_v2/src/core/reducers/screenAudio.ts +++ b/packages/voice_engine_v2/src/core/reducers/screenAudio.ts @@ -1,9 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Error, VoiceEngineV2OperationId, VoiceEngineV2ScreenAudioOptions} from '../../protocol/types'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; import { allocateOperation, beginUnpublish, @@ -11,8 +8,19 @@ import { invalidArgument, isConnected, unsupportedCapability, -} from './_helpers'; -import {applyMediaFailure, applyMediaSuccess, completeUnpublish} from './_media'; +} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import { + applyMediaFailure, + applyMediaSuccess, + completeUnpublish, +} from '@fluxer/voice_engine_v2/src/core/reducers/_media'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type { + VoiceEngineV2Error, + VoiceEngineV2OperationId, + VoiceEngineV2ScreenAudioOptions, +} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2ScreenAudioEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/reducers/sourceLifecycles.ts b/packages/voice_engine_v2/src/core/reducers/sourceLifecycles.ts index b85337565..f9338ad4b 100644 --- a/packages/voice_engine_v2/src/core/reducers/sourceLifecycles.ts +++ b/packages/voice_engine_v2/src/core/reducers/sourceLifecycles.ts @@ -1,14 +1,17 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; +import {allocateOperation, appendDiagnostic, queueCommand} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; import type { VoiceEngineV2SourceLifecycleRemovedEvent, VoiceEngineV2SourceLifecycleTransitionedEvent, -} from '../../protocol/events'; -import type {VoiceEngineV2DiagnosticEntry} from '../../protocol/types'; -import type {SourceFault, SourceLifecycleState} from '../../source_isolation/SourceLifecycleState'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, appendDiagnostic, queueCommand} from './_helpers'; +} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type {VoiceEngineV2DiagnosticEntry} from '@fluxer/voice_engine_v2/src/protocol/types'; +import type { + SourceFault, + SourceLifecycleState, +} from '@fluxer/voice_engine_v2/src/source_isolation/SourceLifecycleState'; const SOURCE_LIFECYCLE_DIAGNOSTICS_CODE = 'sourceFailed'; diff --git a/packages/voice_engine_v2/src/core/reducers/stats.ts b/packages/voice_engine_v2/src/core/reducers/stats.ts index 75f687ace..956c3594b 100644 --- a/packages/voice_engine_v2/src/core/reducers/stats.ts +++ b/packages/voice_engine_v2/src/core/reducers/stats.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {commandIfConnected} from './_helpers'; +import {commandIfConnected} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; type VoiceEngineV2StatsEvent = Extract< VoiceEngineV2Event, diff --git a/packages/voice_engine_v2/src/core/reducers/utilityPorts.ts b/packages/voice_engine_v2/src/core/reducers/utilityPorts.ts index 23c5fd67d..74bcc9686 100644 --- a/packages/voice_engine_v2/src/core/reducers/utilityPorts.ts +++ b/packages/voice_engine_v2/src/core/reducers/utilityPorts.ts @@ -1,9 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../../protocol/events'; -import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '../state'; -import {allocateOperation, appendDiagnostic, markOperation, queueCommand} from './_helpers'; +import { + allocateOperation, + appendDiagnostic, + markOperation, + queueCommand, +} from '@fluxer/voice_engine_v2/src/core/reducers/_helpers'; +import type {VoiceEngineV2Snapshot, VoiceEngineV2Transition} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; type VoiceEngineV2UtilityPortsEvent = Extract; diff --git a/packages/voice_engine_v2/src/core/selectors.ts b/packages/voice_engine_v2/src/core/selectors.ts index 8407df94d..31c10ce96 100644 --- a/packages/voice_engine_v2/src/core/selectors.ts +++ b/packages/voice_engine_v2/src/core/selectors.ts @@ -1,12 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {VoiceEngineV2Snapshot} from '@fluxer/voice_engine_v2/src/core/state'; import { hasVoiceEngineV2NativeNvencEncoder, hasVoiceEngineV2ZeroCopyNativeInput, summarizeVoiceEngineV2Stats, type VoiceEngineV2StatsNetworkSummary, type VoiceEngineV2StatsSummary, -} from '../policies'; +} from '@fluxer/voice_engine_v2/src/policies'; import type { VoiceEngineV2AudioInputDevice, VoiceEngineV2AudioOutputDevice, @@ -26,9 +27,8 @@ import type { VoiceEngineV2Stats, VoiceEngineV2Track, VoiceEngineV2WatchedStream, -} from '../protocol/types'; -import type {SourceLifecycleState} from '../source_isolation/SourceLifecycleState'; -import type {VoiceEngineV2Snapshot} from './state'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import type {SourceLifecycleState} from '@fluxer/voice_engine_v2/src/source_isolation/SourceLifecycleState'; export interface VoiceEngineV2ParticipantProjection { participants: Array; diff --git a/packages/voice_engine_v2/src/core/state.ts b/packages/voice_engine_v2/src/core/state.ts index cfb02ef80..6a56add6e 100644 --- a/packages/voice_engine_v2/src/core/state.ts +++ b/packages/voice_engine_v2/src/core/state.ts @@ -1,10 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceEngineV2Command} from '../protocol/commands'; -import type {SourceLifecycleState} from '../source_isolation/SourceLifecycleState'; - -export type {SourceLifecycleState} from '../source_isolation/SourceLifecycleState'; - +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; import type { VoiceEngineV2AudioControls, VoiceEngineV2CameraOptions, @@ -41,7 +37,10 @@ import type { VoiceEngineV2Stats, VoiceEngineV2Track, VoiceEngineV2WatchedStream, -} from '../protocol/types'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import type {SourceLifecycleState} from '@fluxer/voice_engine_v2/src/source_isolation/SourceLifecycleState'; + +export type {SourceLifecycleState} from '@fluxer/voice_engine_v2/src/source_isolation/SourceLifecycleState'; export interface VoiceEngineV2ConnectionState { status: VoiceEngineV2ConnectionStatus; diff --git a/packages/voice_engine_v2/src/fuzz/ReducerFuzzer.ts b/packages/voice_engine_v2/src/fuzz/ReducerFuzzer.ts index 604d74da4..b2c8b3eda 100644 --- a/packages/voice_engine_v2/src/fuzz/ReducerFuzzer.ts +++ b/packages/voice_engine_v2/src/fuzz/ReducerFuzzer.ts @@ -1,16 +1,22 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Snapshot} from '../core/state'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import type {VoiceEngineV2DisconnectReason, VoiceEngineV2LifecycleReason} from '../protocol/types'; -import {createVoiceEngineV2MemoryEventLogSpillSink} from '../runtime/eventLogRing'; -import {createVoiceEngineV2DeterministicClockPort} from '../runtime/platformPort'; -import {assertEventLogInvariants, VoiceEngineV2Runtime} from '../runtime/VoiceEngineV2Runtime'; -import {hashSnapshot} from '../simulation/Simulator'; -import {type SimulatorDriverFaultPolicy, VoiceEngineV2SimulatorDriver} from '../simulation/SimulatorPorts'; -import {VoiceEngineV2TestImplementation} from '../testing/VoiceEngineV2TestImplementation'; -import {FuzzPrng} from './FuzzPrng'; +import type {VoiceEngineV2Snapshot} from '@fluxer/voice_engine_v2/src/core/state'; +import {FuzzPrng} from '@fluxer/voice_engine_v2/src/fuzz/FuzzPrng'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type { + VoiceEngineV2DisconnectReason, + VoiceEngineV2LifecycleReason, +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import {createVoiceEngineV2MemoryEventLogSpillSink} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; +import {createVoiceEngineV2DeterministicClockPort} from '@fluxer/voice_engine_v2/src/runtime/platformPort'; +import {assertEventLogInvariants, VoiceEngineV2Runtime} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; +import {hashSnapshot} from '@fluxer/voice_engine_v2/src/simulation/Simulator'; +import { + type SimulatorDriverFaultPolicy, + VoiceEngineV2SimulatorDriver, +} from '@fluxer/voice_engine_v2/src/simulation/SimulatorPorts'; +import {VoiceEngineV2TestImplementation} from '@fluxer/voice_engine_v2/src/testing/VoiceEngineV2TestImplementation'; const FUZZ_ITERATIONS_MAX = 1024; diff --git a/packages/voice_engine_v2/src/fuzz/externalConnection.test.ts b/packages/voice_engine_v2/src/fuzz/externalConnection.test.ts index d640e21fd..788b45436 100644 --- a/packages/voice_engine_v2/src/fuzz/externalConnection.test.ts +++ b/packages/voice_engine_v2/src/fuzz/externalConnection.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import {FuzzPrng} from './FuzzPrng'; +import {FuzzPrng} from '@fluxer/voice_engine_v2/src/fuzz/FuzzPrng'; import { EXTERNAL_CONNECTION_EVENT_KINDS, FUZZ_REDUCER_ARBITRARY_ITERATIONS, FUZZ_REDUCER_EXTERNAL_CONNECTION_ITERATIONS, ReducerFuzzer, -} from './ReducerFuzzer'; +} from '@fluxer/voice_engine_v2/src/fuzz/ReducerFuzzer'; +import {describe, expect, it} from 'vitest'; const SEEDS: ReadonlyArray = [1, 2, 7, 13, 99]; diff --git a/packages/voice_engine_v2/src/fuzz/reducer.test.ts b/packages/voice_engine_v2/src/fuzz/reducer.test.ts index 26d1a9c17..df10e0bab 100644 --- a/packages/voice_engine_v2/src/fuzz/reducer.test.ts +++ b/packages/voice_engine_v2/src/fuzz/reducer.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import {FuzzPrng} from './FuzzPrng'; +import {FuzzPrng} from '@fluxer/voice_engine_v2/src/fuzz/FuzzPrng'; import { FUZZ_REDUCER_ARBITRARY_ITERATIONS, FUZZ_REDUCER_NEGATIVE_ITERATIONS, FUZZ_REDUCER_POSITIVE_ITERATIONS, ReducerFuzzer, -} from './ReducerFuzzer'; +} from '@fluxer/voice_engine_v2/src/fuzz/ReducerFuzzer'; +import {describe, expect, it} from 'vitest'; const SEEDS: ReadonlyArray = [1, 2, 7, 13]; diff --git a/packages/voice_engine_v2/src/implementations/VoiceEngineV2HostPortImplementation.ts b/packages/voice_engine_v2/src/implementations/VoiceEngineV2HostPortImplementation.ts index a6f3ca3b4..ef26fd7f4 100644 --- a/packages/voice_engine_v2/src/implementations/VoiceEngineV2HostPortImplementation.ts +++ b/packages/voice_engine_v2/src/implementations/VoiceEngineV2HostPortImplementation.ts @@ -1,5 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {VoiceEngineV2ExternalEventListener} from '@fluxer/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase'; +import { + type VoiceEngineV2Driver, + VoiceEngineV2ImplementationBase, +} from '@fluxer/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase'; import type { CapabilitiesPort, DevicePort, @@ -16,8 +21,8 @@ import type { VoiceEngineV2EventSourcePort, VoiceEngineV2HostPorts, VoiceStateIngestionPort, -} from '../ports'; -import {unsupportedPortError} from '../ports'; +} from '@fluxer/voice_engine_v2/src/ports'; +import {unsupportedPortError} from '@fluxer/voice_engine_v2/src/ports'; import type { VoiceEngineV2CameraEncodingOptions, VoiceEngineV2CameraOptions, @@ -40,9 +45,7 @@ import type { VoiceEngineV2ScreenEncodingOptions, VoiceEngineV2ScreenOptions, VoiceEngineV2Stats, -} from '../protocol'; -import type {VoiceEngineV2ExternalEventListener} from './VoiceEngineV2ImplementationBase'; -import {type VoiceEngineV2Driver, VoiceEngineV2ImplementationBase} from './VoiceEngineV2ImplementationBase'; +} from '@fluxer/voice_engine_v2/src/protocol'; export class VoiceEngineV2HostPortImplementation extends VoiceEngineV2ImplementationBase { readonly kind = 'native' as const; diff --git a/packages/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase.ts b/packages/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase.ts index 270e8874c..ab4c99572 100644 --- a/packages/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase.ts +++ b/packages/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceEngineV2Command} from '../protocol/commands'; -import type {VoiceEngineV2Event} from '../protocol/events'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2CameraEncodingOptions, VoiceEngineV2CameraOptions, @@ -26,7 +26,7 @@ import type { VoiceEngineV2ScreenEncodingOptions, VoiceEngineV2ScreenOptions, VoiceEngineV2Stats, -} from '../protocol/types'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; export interface VoiceEngineV2CommandSuccess { ok: true; diff --git a/packages/voice_engine_v2/src/implementations/index.ts b/packages/voice_engine_v2/src/implementations/index.ts index 3c68c2971..b90c6a373 100644 --- a/packages/voice_engine_v2/src/implementations/index.ts +++ b/packages/voice_engine_v2/src/implementations/index.ts @@ -1,6 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -export {VoiceEngineV2HostPortDriver, VoiceEngineV2HostPortImplementation} from './VoiceEngineV2HostPortImplementation'; +export { + VoiceEngineV2HostPortDriver, + VoiceEngineV2HostPortImplementation, +} from '@fluxer/voice_engine_v2/src/implementations/VoiceEngineV2HostPortImplementation'; export type { VoiceEngineV2CommandFailure, VoiceEngineV2CommandResult, @@ -8,5 +11,8 @@ export type { VoiceEngineV2Driver, VoiceEngineV2ExternalEventListener, VoiceEngineV2Implementation, -} from './VoiceEngineV2ImplementationBase'; -export {errorToVoiceEngineV2Error, VoiceEngineV2ImplementationBase} from './VoiceEngineV2ImplementationBase'; +} from '@fluxer/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase'; +export { + errorToVoiceEngineV2Error, + VoiceEngineV2ImplementationBase, +} from '@fluxer/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase'; diff --git a/packages/voice_engine_v2/src/index.ts b/packages/voice_engine_v2/src/index.ts index bccb6454b..185323b5f 100644 --- a/packages/voice_engine_v2/src/index.ts +++ b/packages/voice_engine_v2/src/index.ts @@ -28,7 +28,7 @@ export type { VoiceEngineV2StatsPresentationProjection, VoiceEngineV2StatsProjection, VoiceEngineV2Transition, -} from './core'; +} from '@fluxer/voice_engine_v2/src/core'; export { availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot, @@ -50,7 +50,7 @@ export { shouldApplyGatewayVoiceStateEcho, transitionVoiceEngineV2, unavailableVoiceEngineV2Capabilities, -} from './core'; +} from '@fluxer/voice_engine_v2/src/core'; export type { VoiceEngineV2CommandFailure, VoiceEngineV2CommandResult, @@ -58,13 +58,13 @@ export type { VoiceEngineV2Driver, VoiceEngineV2ExternalEventListener, VoiceEngineV2Implementation, -} from './implementations'; +} from '@fluxer/voice_engine_v2/src/implementations'; export { errorToVoiceEngineV2Error, VoiceEngineV2HostPortDriver, VoiceEngineV2HostPortImplementation, VoiceEngineV2ImplementationBase, -} from './implementations'; +} from '@fluxer/voice_engine_v2/src/implementations'; export type { VoiceEngineV2CameraEncodingPlan, VoiceEngineV2CameraEncodingPlanAction, @@ -92,7 +92,7 @@ export type { VoiceStatsTrackRoleCandidate, VoiceStatsTrackRoleSelection, VoiceStatsTrackSummary, -} from './policies'; +} from '@fluxer/voice_engine_v2/src/policies'; export { applyVoiceEngineV2CameraEncodingOptions, applyVoiceEngineV2ScreenEncodingOptions, @@ -110,7 +110,7 @@ export { summarizeVoiceEngineV2Stats, unavailableVoiceEngineV2HardwareEncoderCapabilities, VoiceEngineV2StatsTrackSource, -} from './policies'; +} from '@fluxer/voice_engine_v2/src/policies'; export type { CapabilitiesPort, DevicePort, @@ -128,8 +128,8 @@ export type { VoiceEngineV2HostEventListener, VoiceEngineV2HostPorts, VoiceStateIngestionPort, -} from './ports'; -export {unsupportedPortError} from './ports'; +} from '@fluxer/voice_engine_v2/src/ports'; +export {unsupportedPortError} from '@fluxer/voice_engine_v2/src/ports'; export type { VoiceEngineV2AudioControls, VoiceEngineV2AudioControlsPatch, @@ -216,11 +216,11 @@ export type { VoiceEngineV2VoiceStats, VoiceEngineV2WatchedStream, VoiceEngineV2WatchedStreamKey, -} from './protocol'; +} from '@fluxer/voice_engine_v2/src/protocol'; export { getVoiceEngineV2CommandResourceKey, getVoiceEngineV2CommandTypeResourceKey, -} from './protocol'; +} from '@fluxer/voice_engine_v2/src/protocol'; export type { VoiceEngineV2EventLogEntry, VoiceEngineV2EventLogSpillSink, @@ -229,13 +229,13 @@ export type { VoiceEngineV2RuntimeListener, VoiceEngineV2RuntimeListenerPayload, VoiceEngineV2RuntimeOptions, -} from './runtime'; +} from '@fluxer/voice_engine_v2/src/runtime'; export { commandResultToEvent, createVoiceEngineV2MemoryEventLogSpillSink, VoiceEngineV2Controller, VoiceEngineV2Runtime, -} from './runtime'; +} from '@fluxer/voice_engine_v2/src/runtime'; export type { SourceFault, SourceLifecycleAction, @@ -245,7 +245,7 @@ export type { SourceLifecycleSnapshotEntry, SourceLifecycleState, SourceLifecycleTransitionResult, -} from './source_isolation'; +} from '@fluxer/voice_engine_v2/src/source_isolation'; export { computeReconnectBackoffMs, createInitialActiveState, @@ -256,4 +256,4 @@ export { SourceLifecycleError, SourceLifecycleRegistry, transitionSourceLifecycle, -} from './source_isolation'; +} from '@fluxer/voice_engine_v2/src/source_isolation'; diff --git a/packages/voice_engine_v2/src/policies/cameraShare.ts b/packages/voice_engine_v2/src/policies/cameraShare.ts index 187e4983e..89725b41e 100644 --- a/packages/voice_engine_v2/src/policies/cameraShare.ts +++ b/packages/voice_engine_v2/src/policies/cameraShare.ts @@ -1,6 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceEngineV2CameraEncodingOptions, VoiceEngineV2CameraOptions, VoiceEngineV2Error} from '../protocol'; +import type { + VoiceEngineV2CameraEncodingOptions, + VoiceEngineV2CameraOptions, + VoiceEngineV2Error, +} from '@fluxer/voice_engine_v2/src/protocol'; export type VoiceEngineV2CameraEncodingPlanAction = 'noop' | 'updateEncoding' | 'republish' | 'reject'; diff --git a/packages/voice_engine_v2/src/policies/hardwareEncoderCapabilities.ts b/packages/voice_engine_v2/src/policies/hardwareEncoderCapabilities.ts index 77ec3bc41..6da6601e6 100644 --- a/packages/voice_engine_v2/src/policies/hardwareEncoderCapabilities.ts +++ b/packages/voice_engine_v2/src/policies/hardwareEncoderCapabilities.ts @@ -1,6 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceEngineV2HardwareEncoderCapabilities, VoiceEngineV2VideoCodec} from '../protocol'; +import type { + VoiceEngineV2HardwareEncoderCapabilities, + VoiceEngineV2VideoCodec, +} from '@fluxer/voice_engine_v2/src/protocol'; const ZERO_COPY_NATIVE_INPUTS = new Set(['dmabuf', 'd3d11Texture', 'd3d11-texture', 'cvPixelBuffer', 'sharedTexture']); diff --git a/packages/voice_engine_v2/src/policies/index.ts b/packages/voice_engine_v2/src/policies/index.ts index 999679d8a..094a3119a 100644 --- a/packages/voice_engine_v2/src/policies/index.ts +++ b/packages/voice_engine_v2/src/policies/index.ts @@ -5,29 +5,35 @@ export type { VoiceEngineV2CameraEncodingPlanAction, VoiceEngineV2CameraEncodingPlanInput, VoiceEngineV2CameraEncodingPlanReason, -} from './cameraShare'; -export {applyVoiceEngineV2CameraEncodingOptions, planVoiceEngineV2CameraEncodingChange} from './cameraShare'; +} from '@fluxer/voice_engine_v2/src/policies/cameraShare'; +export { + applyVoiceEngineV2CameraEncodingOptions, + planVoiceEngineV2CameraEncodingChange, +} from '@fluxer/voice_engine_v2/src/policies/cameraShare'; export { hasVoiceEngineV2NativeHardwareEncoder, hasVoiceEngineV2NativeNvencEncoder, hasVoiceEngineV2ZeroCopyNativeInput, normalizeVoiceEngineV2HardwareEncoderCapabilities, unavailableVoiceEngineV2HardwareEncoderCapabilities, -} from './hardwareEncoderCapabilities'; +} from '@fluxer/voice_engine_v2/src/policies/hardwareEncoderCapabilities'; export type { VoiceEngineV2MicrophoneFailureContext, VoiceEngineV2MicrophoneOperationFailureAction, VoiceEngineV2OperationFailureLike, VoiceEngineV2OperationResultLike, -} from './microphoneFailureAction'; -export {getVoiceEngineV2MicrophoneOperationFailureAction} from './microphoneFailureAction'; +} from '@fluxer/voice_engine_v2/src/policies/microphoneFailureAction'; +export {getVoiceEngineV2MicrophoneOperationFailureAction} from '@fluxer/voice_engine_v2/src/policies/microphoneFailureAction'; export type { VoiceEngineV2ScreenEncodingPlan, VoiceEngineV2ScreenEncodingPlanAction, VoiceEngineV2ScreenEncodingPlanInput, VoiceEngineV2ScreenEncodingPlanReason, -} from './screenShare'; -export {applyVoiceEngineV2ScreenEncodingOptions, planVoiceEngineV2ScreenEncodingChange} from './screenShare'; +} from '@fluxer/voice_engine_v2/src/policies/screenShare'; +export { + applyVoiceEngineV2ScreenEncodingOptions, + planVoiceEngineV2ScreenEncodingChange, +} from '@fluxer/voice_engine_v2/src/policies/screenShare'; export type { VoiceEngineV2StatsNetworkSummary, VoiceEngineV2StatsSummary, @@ -43,7 +49,7 @@ export type { VoiceStatsTrackRoleCandidate, VoiceStatsTrackRoleSelection, VoiceStatsTrackSummary, -} from './voiceStats'; +} from '@fluxer/voice_engine_v2/src/policies/voiceStats'; export { asVoiceEngineV2StatsTrackSource, classifyVoiceEngineV2TrackStats, @@ -51,4 +57,4 @@ export { coerceVoiceEngineV2Stats, summarizeVoiceEngineV2Stats, VoiceEngineV2StatsTrackSource, -} from './voiceStats'; +} from '@fluxer/voice_engine_v2/src/policies/voiceStats'; diff --git a/packages/voice_engine_v2/src/policies/policies.test.ts b/packages/voice_engine_v2/src/policies/policies.test.ts index 9dad2e953..a3f760e0e 100644 --- a/packages/voice_engine_v2/src/policies/policies.test.ts +++ b/packages/voice_engine_v2/src/policies/policies.test.ts @@ -1,20 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import cameraShareEncodingPlanFixtures from '../../fixtures/policies/camera_share_encoding_plan.json'; -import hardwareEncoderCapabilityFixtures from '../../fixtures/policies/hardware_encoder_capabilities.json'; -import microphoneFailureFixtures from '../../fixtures/policies/microphone_failure_action.json'; -import screenShareEncodingPlanFixtures from '../../fixtures/policies/screen_share_encoding_plan.json'; -import voiceStatsCoercionFixtures from '../../fixtures/policies/voice_stats_coercion.json'; -import voiceStatsSummaryFixtures from '../../fixtures/policies/voice_stats_summary.json'; -import voiceTrackClassificationFixtures from '../../fixtures/policies/voice_track_classification.json'; -import type { - VoiceEngineV2CameraEncodingOptions, - VoiceEngineV2CameraOptions, - VoiceEngineV2ScreenEncodingOptions, - VoiceEngineV2ScreenOptions, - VoiceEngineV2Stats, -} from '../protocol'; +import cameraShareEncodingPlanFixtures from '@fluxer/voice_engine_v2/fixtures/policies/camera_share_encoding_plan.json'; +import hardwareEncoderCapabilityFixtures from '@fluxer/voice_engine_v2/fixtures/policies/hardware_encoder_capabilities.json'; +import microphoneFailureFixtures from '@fluxer/voice_engine_v2/fixtures/policies/microphone_failure_action.json'; +import screenShareEncodingPlanFixtures from '@fluxer/voice_engine_v2/fixtures/policies/screen_share_encoding_plan.json'; +import voiceStatsCoercionFixtures from '@fluxer/voice_engine_v2/fixtures/policies/voice_stats_coercion.json'; +import voiceStatsSummaryFixtures from '@fluxer/voice_engine_v2/fixtures/policies/voice_stats_summary.json'; +import voiceTrackClassificationFixtures from '@fluxer/voice_engine_v2/fixtures/policies/voice_track_classification.json'; import { classifyVoiceEngineV2TrackStats, coerceVoiceEngineV2Stats, @@ -29,7 +21,15 @@ import { type VoiceEngineV2StatsSummary, type VoiceEngineV2StatsTrackClassificationInput, type VoiceEngineV2StatsTrackRoleSelection, -} from './index'; +} from '@fluxer/voice_engine_v2/src/policies/index'; +import type { + VoiceEngineV2CameraEncodingOptions, + VoiceEngineV2CameraOptions, + VoiceEngineV2ScreenEncodingOptions, + VoiceEngineV2ScreenOptions, + VoiceEngineV2Stats, +} from '@fluxer/voice_engine_v2/src/protocol'; +import {describe, expect, it} from 'vitest'; interface MicrophoneFailureFixture { name: string; diff --git a/packages/voice_engine_v2/src/policies/screenShare.ts b/packages/voice_engine_v2/src/policies/screenShare.ts index df8ca45bb..8abcf937a 100644 --- a/packages/voice_engine_v2/src/policies/screenShare.ts +++ b/packages/voice_engine_v2/src/policies/screenShare.ts @@ -1,6 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceEngineV2Error, VoiceEngineV2ScreenEncodingOptions, VoiceEngineV2ScreenOptions} from '../protocol'; +import type { + VoiceEngineV2Error, + VoiceEngineV2ScreenEncodingOptions, + VoiceEngineV2ScreenOptions, +} from '@fluxer/voice_engine_v2/src/protocol'; export type VoiceEngineV2ScreenEncodingPlanAction = 'noop' | 'updateEncoding' | 'republish' | 'reject'; diff --git a/packages/voice_engine_v2/src/policies/voiceStats.ts b/packages/voice_engine_v2/src/policies/voiceStats.ts index 97d7a6bde..2d690fd6a 100644 --- a/packages/voice_engine_v2/src/policies/voiceStats.ts +++ b/packages/voice_engine_v2/src/policies/voiceStats.ts @@ -6,7 +6,7 @@ import type { VoiceEngineV2SendStats, VoiceEngineV2Stats, VoiceEngineV2TrackKind, -} from '../protocol'; +} from '@fluxer/voice_engine_v2/src/protocol'; export const VoiceEngineV2StatsTrackSource = Object.freeze({ Microphone: 'microphone', diff --git a/packages/voice_engine_v2/src/ports/index.ts b/packages/voice_engine_v2/src/ports/index.ts index 85580df90..dfeeb2a4b 100644 --- a/packages/voice_engine_v2/src/ports/index.ts +++ b/packages/voice_engine_v2/src/ports/index.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceEngineV2Event} from '../protocol/events'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2CameraEncodingOptions, VoiceEngineV2CameraOptions, @@ -25,7 +25,7 @@ import type { VoiceEngineV2ScreenOptions, VoiceEngineV2Stats, VoiceEngineV2TimerOptions, -} from '../protocol/types'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; export type VoiceEngineV2HostEventListener = (event: VoiceEngineV2Event) => void; diff --git a/packages/voice_engine_v2/src/protocol/commands.ts b/packages/voice_engine_v2/src/protocol/commands.ts index db3ca0bf0..6bb6b30c4 100644 --- a/packages/voice_engine_v2/src/protocol/commands.ts +++ b/packages/voice_engine_v2/src/protocol/commands.ts @@ -23,7 +23,7 @@ import type { VoiceEngineV2ScreenEncodingOptions, VoiceEngineV2ScreenOptions, VoiceEngineV2TimerOptions, -} from './types'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; export type VoiceEngineV2Command = | {type: 'implementation.prewarm'; operationId: VoiceEngineV2OperationId} diff --git a/packages/voice_engine_v2/src/protocol/events.ts b/packages/voice_engine_v2/src/protocol/events.ts index 584f5443b..be8eb3ee4 100644 --- a/packages/voice_engine_v2/src/protocol/events.ts +++ b/packages/voice_engine_v2/src/protocol/events.ts @@ -1,25 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {SourceFault, SourceLifecycleState} from '../source_isolation/SourceLifecycleState'; -import type {VoiceEngineV2CommandType} from './commands'; - -export type VoiceEngineV2SourceLifecycleTransitionKind = SourceLifecycleState['kind']; - -export interface VoiceEngineV2SourceLifecycleTransitionedEvent { - type: 'sourceLifecycle.transitioned'; - sourceId: string; - kind: VoiceEngineV2SourceLifecycleTransitionKind; - since: bigint; - attempts: number; - fault: SourceFault | null; - atMs: number; -} - -export interface VoiceEngineV2SourceLifecycleRemovedEvent { - type: 'sourceLifecycle.removed'; - sourceId: string; -} - +import type {VoiceEngineV2CommandType} from '@fluxer/voice_engine_v2/src/protocol/commands'; import type { VoiceEngineV2AudioControlsPatch, VoiceEngineV2CameraEncodingOptions, @@ -63,7 +44,28 @@ import type { VoiceEngineV2Track, VoiceEngineV2WatchedStream, VoiceEngineV2WatchedStreamKey, -} from './types'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import type { + SourceFault, + SourceLifecycleState, +} from '@fluxer/voice_engine_v2/src/source_isolation/SourceLifecycleState'; + +export type VoiceEngineV2SourceLifecycleTransitionKind = SourceLifecycleState['kind']; + +export interface VoiceEngineV2SourceLifecycleTransitionedEvent { + type: 'sourceLifecycle.transitioned'; + sourceId: string; + kind: VoiceEngineV2SourceLifecycleTransitionKind; + since: bigint; + attempts: number; + fault: SourceFault | null; + atMs: number; +} + +export interface VoiceEngineV2SourceLifecycleRemovedEvent { + type: 'sourceLifecycle.removed'; + sourceId: string; +} export type VoiceEngineV2Event = | {type: 'implementation.prewarmRequested'} diff --git a/packages/voice_engine_v2/src/protocol/index.ts b/packages/voice_engine_v2/src/protocol/index.ts index 445cb6b33..d2911e3af 100644 --- a/packages/voice_engine_v2/src/protocol/index.ts +++ b/packages/voice_engine_v2/src/protocol/index.ts @@ -1,13 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -export type {VoiceEngineV2Command, VoiceEngineV2CommandType} from './commands'; -export {getVoiceEngineV2CommandResourceKey, getVoiceEngineV2CommandTypeResourceKey} from './commands'; +export type {VoiceEngineV2Command, VoiceEngineV2CommandType} from '@fluxer/voice_engine_v2/src/protocol/commands'; +export { + getVoiceEngineV2CommandResourceKey, + getVoiceEngineV2CommandTypeResourceKey, +} from '@fluxer/voice_engine_v2/src/protocol/commands'; export type { VoiceEngineV2Event, VoiceEngineV2SourceLifecycleRemovedEvent, VoiceEngineV2SourceLifecycleTransitionedEvent, VoiceEngineV2SourceLifecycleTransitionKind, -} from './events'; +} from '@fluxer/voice_engine_v2/src/protocol/events'; export type { VoiceEngineV2AudioControls, VoiceEngineV2AudioControlsPatch, @@ -88,4 +91,4 @@ export type { VoiceEngineV2VoiceStats, VoiceEngineV2WatchedStream, VoiceEngineV2WatchedStreamKey, -} from './types'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; diff --git a/packages/voice_engine_v2/src/runtime/VoiceEngineV2Controller.test.ts b/packages/voice_engine_v2/src/runtime/VoiceEngineV2Controller.test.ts index c516c7a0a..9267a9962 100644 --- a/packages/voice_engine_v2/src/runtime/VoiceEngineV2Controller.test.ts +++ b/packages/voice_engine_v2/src/runtime/VoiceEngineV2Controller.test.ts @@ -1,12 +1,19 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type { + VoiceEngineV2CommandResult, + VoiceEngineV2Implementation, +} from '@fluxer/voice_engine_v2/src/implementations'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol'; +import {createVoiceEngineV2MemoryEventLogSpillSink} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; +import {VoiceEngineV2Controller} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Controller'; +import {VoiceEngineV2Runtime} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; +import { + FakeVoiceEngineV2Driver, + VoiceEngineV2TestImplementation, + waitForRuntime, +} from '@fluxer/voice_engine_v2/src/testing'; import {describe, expect, it} from 'vitest'; -import type {VoiceEngineV2CommandResult, VoiceEngineV2Implementation} from '../implementations'; -import type {VoiceEngineV2Command} from '../protocol'; -import {FakeVoiceEngineV2Driver, VoiceEngineV2TestImplementation, waitForRuntime} from '../testing'; -import {createVoiceEngineV2MemoryEventLogSpillSink} from './eventLogRing'; -import {VoiceEngineV2Controller} from './VoiceEngineV2Controller'; -import {VoiceEngineV2Runtime} from './VoiceEngineV2Runtime'; interface DeferredCommand { command: VoiceEngineV2Command; diff --git a/packages/voice_engine_v2/src/runtime/VoiceEngineV2Controller.ts b/packages/voice_engine_v2/src/runtime/VoiceEngineV2Controller.ts index a66968225..4abb5604e 100644 --- a/packages/voice_engine_v2/src/runtime/VoiceEngineV2Controller.ts +++ b/packages/voice_engine_v2/src/runtime/VoiceEngineV2Controller.ts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {selectVoiceEngineV2Model, type VoiceEngineV2Snapshot} from '../core'; +import {selectVoiceEngineV2Model, type VoiceEngineV2Snapshot} from '@fluxer/voice_engine_v2/src/core'; import type { VoiceEngineV2AudioControlsPatch, VoiceEngineV2CameraEncodingOptions, @@ -28,9 +28,12 @@ import type { VoiceEngineV2TimerOptions, VoiceEngineV2WatchedStream, VoiceEngineV2WatchedStreamKey, -} from '../protocol'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import type {VoiceEngineV2Runtime, VoiceEngineV2RuntimeListener} from './VoiceEngineV2Runtime'; +} from '@fluxer/voice_engine_v2/src/protocol'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type { + VoiceEngineV2Runtime, + VoiceEngineV2RuntimeListener, +} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; export class VoiceEngineV2Controller { constructor(private readonly runtime: VoiceEngineV2Runtime) {} diff --git a/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.bench.ts b/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.bench.ts index cdba05838..3264ec2de 100644 --- a/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.bench.ts +++ b/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.bench.ts @@ -1,24 +1,24 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {bench, describe} from 'vitest'; -import basicSessionFixture from '../../fixtures/basic_session.json'; -import {availableVoiceEngineV2Capabilities} from '../core/state'; +import basicSessionFixture from '@fluxer/voice_engine_v2/fixtures/basic_session.json'; +import {availableVoiceEngineV2Capabilities} from '@fluxer/voice_engine_v2/src/core/state'; import type { VoiceEngineV2CommandResult, VoiceEngineV2ExternalEventListener, VoiceEngineV2Implementation, -} from '../implementations'; -import type {VoiceEngineV2Command} from '../protocol/commands'; -import type {VoiceEngineV2Event} from '../protocol/events'; +} from '@fluxer/voice_engine_v2/src/implementations'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2InboundVideoFrame, VoiceEngineV2MicrophoneOptions, VoiceEngineV2Participant, VoiceEngineV2ScreenOptions, VoiceEngineV2Stats, -} from '../protocol/types'; -import {createVoiceEngineV2MemoryEventLogSpillSink} from './eventLogRing'; -import {VoiceEngineV2Runtime} from './VoiceEngineV2Runtime'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import {createVoiceEngineV2MemoryEventLogSpillSink} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; +import {VoiceEngineV2Runtime} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; +import {bench, describe} from 'vitest'; interface VoiceEngineV2BenchFixture { events: Array; diff --git a/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.test.ts b/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.test.ts index 68bf94a29..a74bfde36 100644 --- a/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.test.ts +++ b/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.test.ts @@ -1,11 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {describe, expect, it} from 'vitest'; -import type {VoiceEngineV2CommandResult, VoiceEngineV2Implementation} from '../implementations'; -import type {VoiceEngineV2Command} from '../protocol/commands'; -import {FakeVoiceEngineV2Driver, VoiceEngineV2TestImplementation, waitForRuntime} from '../testing'; -import {createVoiceEngineV2MemoryEventLogSpillSink} from './eventLogRing'; +import type { + VoiceEngineV2CommandResult, + VoiceEngineV2Implementation, +} from '@fluxer/voice_engine_v2/src/implementations'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import {createVoiceEngineV2MemoryEventLogSpillSink} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; import { assertEventLogInvariants, isVoiceEngineV2ProgrammerError, @@ -16,7 +17,13 @@ import { VOICE_ENGINE_V2_RESOURCE_QUEUES_CAP, VoiceEngineV2Runtime, type VoiceEngineV2RuntimeDiagnostic, -} from './VoiceEngineV2Runtime'; +} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; +import { + FakeVoiceEngineV2Driver, + VoiceEngineV2TestImplementation, + waitForRuntime, +} from '@fluxer/voice_engine_v2/src/testing'; +import {describe, expect, it} from 'vitest'; class DeferredAllResolveImplementation implements VoiceEngineV2Implementation { readonly kind = 'js' as const; diff --git a/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.ts b/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.ts index a8f840519..c0b939a7f 100644 --- a/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.ts +++ b/packages/voice_engine_v2/src/runtime/VoiceEngineV2Runtime.ts @@ -1,42 +1,52 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {isVoiceEngineV2CommandCompletionStale, transitionVoiceEngineV2} from '../core/reducer'; +import {isVoiceEngineV2CommandCompletionStale, transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; import { availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot, type VoiceEngineV2Snapshot, type VoiceEngineV2Transition, -} from '../core/state'; +} from '@fluxer/voice_engine_v2/src/core/state'; import { errorToVoiceEngineV2Error, type VoiceEngineV2CommandResult, type VoiceEngineV2Implementation, -} from '../implementations'; -import {getVoiceEngineV2CommandResourceKey, type VoiceEngineV2Command} from '../protocol/commands'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import type {VoiceEngineV2Capabilities, VoiceEngineV2Error, VoiceEngineV2ResourceKey} from '../protocol/types'; -import {commandResultToEvent} from './commandEvents'; +} from '@fluxer/voice_engine_v2/src/implementations'; +import { + getVoiceEngineV2CommandResourceKey, + type VoiceEngineV2Command, +} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type { + VoiceEngineV2Capabilities, + VoiceEngineV2Error, + VoiceEngineV2ResourceKey, +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import {commandResultToEvent} from '@fluxer/voice_engine_v2/src/runtime/commandEvents'; import { assertEventLogRingInvariants, VOICE_ENGINE_V2_EVENT_LOG_CAP, type VoiceEngineV2EventLogEntry, VoiceEngineV2EventLogRing, type VoiceEngineV2EventLogSpillSink, -} from './eventLogRing'; +} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; import { canCoalesceVoiceEngineV2Events, isVoiceEngineV2FrameReceivedEvent, VOICE_ENGINE_V2_COALESCED_TRACKS_CAP, -} from './frameCoalescing'; +} from '@fluxer/voice_engine_v2/src/runtime/frameCoalescing'; import { createVoiceEngineV2SystemClockPort, createVoiceEngineV2SystemRandomPort, type VoiceEngineV2ClockPort, type VoiceEngineV2RandomPort, -} from './platformPort'; +} from '@fluxer/voice_engine_v2/src/runtime/platformPort'; -export type {VoiceEngineV2EventLogEntry, VoiceEngineV2EventLogSpillSink} from './eventLogRing'; +export type { + VoiceEngineV2EventLogEntry, + VoiceEngineV2EventLogSpillSink, +} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; export const VOICE_ENGINE_V2_QUEUED_COMMANDS_CAP = 4096; export const VOICE_ENGINE_V2_RESOURCE_QUEUES_CAP = 256; @@ -566,4 +576,4 @@ export function assertEventLogInvariants(runtime: VoiceEngineV2Runtime): void { runtime.verifyEventLogInvariants(); } -export {commandResultToEvent} from './commandEvents'; +export {commandResultToEvent} from '@fluxer/voice_engine_v2/src/runtime/commandEvents'; diff --git a/packages/voice_engine_v2/src/runtime/commandEvents.ts b/packages/voice_engine_v2/src/runtime/commandEvents.ts index 99507b40d..8b771765b 100644 --- a/packages/voice_engine_v2/src/runtime/commandEvents.ts +++ b/packages/voice_engine_v2/src/runtime/commandEvents.ts @@ -1,9 +1,9 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import type {VoiceEngineV2CommandResult} from '../implementations'; -import type {VoiceEngineV2Command} from '../protocol/commands'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import type {VoiceEngineV2Error} from '../protocol/types'; +import type {VoiceEngineV2CommandResult} from '@fluxer/voice_engine_v2/src/implementations'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type {VoiceEngineV2Error} from '@fluxer/voice_engine_v2/src/protocol/types'; type VoiceEngineV2CommandOfType = Extract< VoiceEngineV2Command, diff --git a/packages/voice_engine_v2/src/runtime/eventLogRing.test.ts b/packages/voice_engine_v2/src/runtime/eventLogRing.test.ts index 029dac86c..9ce1f26ce 100644 --- a/packages/voice_engine_v2/src/runtime/eventLogRing.test.ts +++ b/packages/voice_engine_v2/src/runtime/eventLogRing.test.ts @@ -1,16 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {describe, expect, it} from 'vitest'; -import {transitionVoiceEngineV2} from '../core/reducer'; +import {transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; import { availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot, type VoiceEngineV2Snapshot, -} from '../core/state'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import type {VoiceEngineV2InboundVideoFrame} from '../protocol/types'; -import {FakeVoiceEngineV2Driver, VoiceEngineV2TestImplementation} from '../testing'; +} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type {VoiceEngineV2InboundVideoFrame} from '@fluxer/voice_engine_v2/src/protocol/types'; import { assertEventLogRingInvariants, createVoiceEngineV2MemoryEventLogSpillSink, @@ -18,12 +16,14 @@ import { type VoiceEngineV2EventLogEntry, VoiceEngineV2EventLogRing, type VoiceEngineV2EventLogSpillSink, -} from './eventLogRing'; +} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; import { assertEventLogInvariants, type VoiceEngineV2EventLogEntry as RuntimeEventLogEntry, VoiceEngineV2Runtime, -} from './VoiceEngineV2Runtime'; +} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; +import {FakeVoiceEngineV2Driver, VoiceEngineV2TestImplementation} from '@fluxer/voice_engine_v2/src/testing'; +import {describe, expect, it} from 'vitest'; function makeInboundVideoFrameEvent(timestampUs: number): VoiceEngineV2Event { const frame: VoiceEngineV2InboundVideoFrame = { diff --git a/packages/voice_engine_v2/src/runtime/eventLogRing.ts b/packages/voice_engine_v2/src/runtime/eventLogRing.ts index e8d5f47e0..a7d563833 100644 --- a/packages/voice_engine_v2/src/runtime/eventLogRing.ts +++ b/packages/voice_engine_v2/src/runtime/eventLogRing.ts @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Command} from '../protocol/commands'; -import type {VoiceEngineV2Event} from '../protocol/events'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; export const VOICE_ENGINE_V2_EVENT_LOG_CAP = 4096; diff --git a/packages/voice_engine_v2/src/runtime/frameCoalescing.test.ts b/packages/voice_engine_v2/src/runtime/frameCoalescing.test.ts index 68d719a51..55132fbad 100644 --- a/packages/voice_engine_v2/src/runtime/frameCoalescing.test.ts +++ b/packages/voice_engine_v2/src/runtime/frameCoalescing.test.ts @@ -1,11 +1,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import {createVoiceEngineV2MemoryEventLogSpillSink} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; +import { + coalesceVoiceEngineV2EventSequence, + VOICE_ENGINE_V2_COALESCED_TRACKS_CAP, +} from '@fluxer/voice_engine_v2/src/runtime/frameCoalescing'; +import {VoiceEngineV2Runtime} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; +import {FakeVoiceEngineV2Driver, VoiceEngineV2TestImplementation} from '@fluxer/voice_engine_v2/src/testing'; import {describe, expect, it} from 'vitest'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import {FakeVoiceEngineV2Driver, VoiceEngineV2TestImplementation} from '../testing'; -import {createVoiceEngineV2MemoryEventLogSpillSink} from './eventLogRing'; -import {coalesceVoiceEngineV2EventSequence, VOICE_ENGINE_V2_COALESCED_TRACKS_CAP} from './frameCoalescing'; -import {VoiceEngineV2Runtime} from './VoiceEngineV2Runtime'; function makeRuntime(options?: {eventLogCap?: number}): VoiceEngineV2Runtime { const driver = new FakeVoiceEngineV2Driver(); diff --git a/packages/voice_engine_v2/src/runtime/frameCoalescing.ts b/packages/voice_engine_v2/src/runtime/frameCoalescing.ts index 8667cb890..fe2522ac9 100644 --- a/packages/voice_engine_v2/src/runtime/frameCoalescing.ts +++ b/packages/voice_engine_v2/src/runtime/frameCoalescing.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../protocol/events'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; export const VOICE_ENGINE_V2_COALESCED_TRACKS_CAP = 64; diff --git a/packages/voice_engine_v2/src/runtime/index.ts b/packages/voice_engine_v2/src/runtime/index.ts index 11e4d5a80..afe3203e3 100644 --- a/packages/voice_engine_v2/src/runtime/index.ts +++ b/packages/voice_engine_v2/src/runtime/index.ts @@ -1,20 +1,20 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -export type {VoiceEngineV2MemoryEventLogSpillSink} from './eventLogRing'; +export type {VoiceEngineV2MemoryEventLogSpillSink} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; export { assertEventLogRingInvariants, createVoiceEngineV2MemoryEventLogSpillSink, VOICE_ENGINE_V2_EVENT_LOG_CAP, VOICE_ENGINE_V2_MEMORY_EVENT_LOG_SPILL_SINK_CAP, VoiceEngineV2EventLogRing, -} from './eventLogRing'; -export type {VoiceEngineV2FrameReceivedEvent} from './frameCoalescing'; +} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; +export type {VoiceEngineV2FrameReceivedEvent} from '@fluxer/voice_engine_v2/src/runtime/frameCoalescing'; export { canCoalesceVoiceEngineV2Events, coalesceVoiceEngineV2EventSequence, isVoiceEngineV2FrameReceivedEvent, VOICE_ENGINE_V2_COALESCED_TRACKS_CAP, -} from './frameCoalescing'; +} from '@fluxer/voice_engine_v2/src/runtime/frameCoalescing'; export type { VoiceEngineV2ClockPort, VoiceEngineV2EntropySource, @@ -23,7 +23,7 @@ export type { VoiceEngineV2SystemClockPort, VoiceEngineV2SystemRandomPort, VoiceEngineV2WallClockSource, -} from './platformPort'; +} from '@fluxer/voice_engine_v2/src/runtime/platformPort'; export { createVoiceEngineV2DeterministicClockPort, createVoiceEngineV2DeterministicPlatformPort, @@ -31,8 +31,8 @@ export { createVoiceEngineV2SystemClockPort, createVoiceEngineV2SystemPlatformPort, createVoiceEngineV2SystemRandomPort, -} from './platformPort'; -export {VoiceEngineV2Controller} from './VoiceEngineV2Controller'; +} from '@fluxer/voice_engine_v2/src/runtime/platformPort'; +export {VoiceEngineV2Controller} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Controller'; export type { VoiceEngineV2EventLogEntry, VoiceEngineV2EventLogSpillSink, @@ -43,7 +43,7 @@ export type { VoiceEngineV2RuntimeListenerPayload, VoiceEngineV2RuntimeOptions, VoiceEngineV2RuntimeQueueKind, -} from './VoiceEngineV2Runtime'; +} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; export { assertEventLogInvariants, commandResultToEvent, @@ -54,4 +54,4 @@ export { VOICE_ENGINE_V2_QUEUED_COMMANDS_CAP, VOICE_ENGINE_V2_RESOURCE_QUEUES_CAP, VoiceEngineV2Runtime, -} from './VoiceEngineV2Runtime'; +} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; diff --git a/packages/voice_engine_v2/src/runtime/platformPort.test.ts b/packages/voice_engine_v2/src/runtime/platformPort.test.ts index bb1234bd9..13bd3afd5 100644 --- a/packages/voice_engine_v2/src/runtime/platformPort.test.ts +++ b/packages/voice_engine_v2/src/runtime/platformPort.test.ts @@ -1,11 +1,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {afterEach, describe, expect, it, vi} from 'vitest'; import { createVoiceEngineV2SeededRandomPort, createVoiceEngineV2SystemClockPort, createVoiceEngineV2SystemRandomPort, -} from './platformPort'; +} from '@fluxer/voice_engine_v2/src/runtime/platformPort'; +import {afterEach, describe, expect, it, vi} from 'vitest'; afterEach(() => { vi.restoreAllMocks(); diff --git a/packages/voice_engine_v2/src/runtime/snapshot.bench.ts b/packages/voice_engine_v2/src/runtime/snapshot.bench.ts index 89be4f1e9..c80dc3605 100644 --- a/packages/voice_engine_v2/src/runtime/snapshot.bench.ts +++ b/packages/voice_engine_v2/src/runtime/snapshot.bench.ts @@ -1,12 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {bench, describe} from 'vitest'; import { availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot, type VoiceEngineV2Snapshot, -} from '../core/state'; -import type {VoiceEngineV2Participant, VoiceEngineV2Track, VoiceEngineV2TrackSource} from '../protocol/types'; +} from '@fluxer/voice_engine_v2/src/core/state'; +import type { + VoiceEngineV2Participant, + VoiceEngineV2Track, + VoiceEngineV2TrackSource, +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import {bench, describe} from 'vitest'; const PARTICIPANT_COUNT = 8; const TRACKS_PER_PARTICIPANT = 4; diff --git a/packages/voice_engine_v2/src/simulation/FaultInjector.ts b/packages/voice_engine_v2/src/simulation/FaultInjector.ts index 18b0c8611..9e3b6ee47 100644 --- a/packages/voice_engine_v2/src/simulation/FaultInjector.ts +++ b/packages/voice_engine_v2/src/simulation/FaultInjector.ts @@ -1,7 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {createSimulatorRandom, type VoiceEngineV2SimulatorRandom} from './SimulatorPorts'; +import { + createSimulatorRandom, + type VoiceEngineV2SimulatorRandom, +} from '@fluxer/voice_engine_v2/src/simulation/SimulatorPorts'; const SIMULATOR_FAULTS_MAX = 128; const SIMULATOR_PEERS_PER_FAULT_MAX = 16; diff --git a/packages/voice_engine_v2/src/simulation/SafetyInvariants.ts b/packages/voice_engine_v2/src/simulation/SafetyInvariants.ts index 996ac0efd..09ccb895e 100644 --- a/packages/voice_engine_v2/src/simulation/SafetyInvariants.ts +++ b/packages/voice_engine_v2/src/simulation/SafetyInvariants.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2EventLogEntry} from '../runtime/VoiceEngineV2Runtime'; +import type {VoiceEngineV2EventLogEntry} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; const SIMULATOR_INVARIANT_LOG_MAX = 4096; diff --git a/packages/voice_engine_v2/src/simulation/Simulator.test.ts b/packages/voice_engine_v2/src/simulation/Simulator.test.ts index abbd49a15..71bded517 100644 --- a/packages/voice_engine_v2/src/simulation/Simulator.test.ts +++ b/packages/voice_engine_v2/src/simulation/Simulator.test.ts @@ -1,14 +1,21 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import {createVoiceEngineV2EmptyFaultPlan, createVoiceEngineV2FaultPlan} from './FaultInjector'; -import {STABLE_STRINGIFY_DEPTH_MAX, stableStringify, VoiceEngineV2Simulator} from './Simulator'; +import { + createVoiceEngineV2EmptyFaultPlan, + createVoiceEngineV2FaultPlan, +} from '@fluxer/voice_engine_v2/src/simulation/FaultInjector'; +import { + STABLE_STRINGIFY_DEPTH_MAX, + stableStringify, + VoiceEngineV2Simulator, +} from '@fluxer/voice_engine_v2/src/simulation/Simulator'; import { createVoiceEngineV2FiveParticipantConferenceWorkload, createVoiceEngineV2OneOnOneCallWorkload, createVoiceEngineV2ScreenShareWorkload, VoiceEngineV2WorkloadBuilder, -} from './Workload'; +} from '@fluxer/voice_engine_v2/src/simulation/Workload'; +import {describe, expect, it} from 'vitest'; describe('VoiceEngineV2Simulator determinism', () => { it('produces identical snapshot hashes for identical inputs', async () => { diff --git a/packages/voice_engine_v2/src/simulation/Simulator.ts b/packages/voice_engine_v2/src/simulation/Simulator.ts index 50a6987fd..22b5f3ac2 100644 --- a/packages/voice_engine_v2/src/simulation/Simulator.ts +++ b/packages/voice_engine_v2/src/simulation/Simulator.ts @@ -1,23 +1,29 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import {createVoiceEngineV2MemoryEventLogSpillSink} from '../runtime/eventLogRing'; -import {type VoiceEngineV2EventLogEntry, VoiceEngineV2Runtime} from '../runtime/VoiceEngineV2Runtime'; -import {VoiceEngineV2TestImplementation} from '../testing/VoiceEngineV2TestImplementation'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import {createVoiceEngineV2MemoryEventLogSpillSink} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; +import { + type VoiceEngineV2EventLogEntry, + VoiceEngineV2Runtime, +} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; import { type VoiceEngineV2FaultDecision, VoiceEngineV2FaultInjector, type VoiceEngineV2FaultPlan, -} from './FaultInjector'; -import {collectVoiceEngineV2SafetyViolations, type VoiceEngineV2SafetyViolation} from './SafetyInvariants'; +} from '@fluxer/voice_engine_v2/src/simulation/FaultInjector'; +import { + collectVoiceEngineV2SafetyViolations, + type VoiceEngineV2SafetyViolation, +} from '@fluxer/voice_engine_v2/src/simulation/SafetyInvariants'; import { createSimulatorClock, type SimulatorDriverDeviceInventory, type SimulatorDriverFaultPolicy, VoiceEngineV2SimulatorDriver, -} from './SimulatorPorts'; -import type {VoiceEngineV2Workload} from './Workload'; +} from '@fluxer/voice_engine_v2/src/simulation/SimulatorPorts'; +import type {VoiceEngineV2Workload} from '@fluxer/voice_engine_v2/src/simulation/Workload'; +import {VoiceEngineV2TestImplementation} from '@fluxer/voice_engine_v2/src/testing/VoiceEngineV2TestImplementation'; export const SIMULATOR_TICK_MAX = 4096; const SIMULATOR_TICK_NS_DEFAULT = 16_666_666; diff --git a/packages/voice_engine_v2/src/simulation/SimulatorPorts.ts b/packages/voice_engine_v2/src/simulation/SimulatorPorts.ts index 742519bc6..1465b0400 100644 --- a/packages/voice_engine_v2/src/simulation/SimulatorPorts.ts +++ b/packages/voice_engine_v2/src/simulation/SimulatorPorts.ts @@ -4,8 +4,8 @@ import assert from 'node:assert/strict'; import type { VoiceEngineV2Driver, VoiceEngineV2ExternalEventListener, -} from '../implementations/VoiceEngineV2ImplementationBase'; -import type {VoiceEngineV2Event} from '../protocol/events'; +} from '@fluxer/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2CameraEncodingOptions, VoiceEngineV2CameraOptions, @@ -29,8 +29,8 @@ import type { VoiceEngineV2ScreenEncodingOptions, VoiceEngineV2ScreenOptions, VoiceEngineV2Stats, -} from '../protocol/types'; -import type {VoiceEngineV2ClockPort, VoiceEngineV2RandomPort} from '../runtime/platformPort'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; +import type {VoiceEngineV2ClockPort, VoiceEngineV2RandomPort} from '@fluxer/voice_engine_v2/src/runtime/platformPort'; const SIMULATOR_CLOCK_MAX_NS = 1_000_000_000_000; const SIMULATOR_NS_PER_MS = 1_000_000; diff --git a/packages/voice_engine_v2/src/simulation/Workload.ts b/packages/voice_engine_v2/src/simulation/Workload.ts index b60095b89..c26d75b65 100644 --- a/packages/voice_engine_v2/src/simulation/Workload.ts +++ b/packages/voice_engine_v2/src/simulation/Workload.ts @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2Event} from '../protocol/events'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2CameraOptions, VoiceEngineV2ConnectOptions, @@ -10,7 +10,7 @@ import type { VoiceEngineV2NativeFrameSinkOptions, VoiceEngineV2Participant, VoiceEngineV2ScreenOptions, -} from '../protocol/types'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; const SIMULATOR_WORKLOAD_STEPS_MAX = 512; const SIMULATOR_PARTICIPANTS_MAX = 32; diff --git a/packages/voice_engine_v2/src/simulation/externalEstablishment.test.ts b/packages/voice_engine_v2/src/simulation/externalEstablishment.test.ts index 40a6650c3..449fd0746 100644 --- a/packages/voice_engine_v2/src/simulation/externalEstablishment.test.ts +++ b/packages/voice_engine_v2/src/simulation/externalEstablishment.test.ts @@ -1,13 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import {createVoiceEngineV2EmptyFaultPlan, createVoiceEngineV2FaultPlan} from './FaultInjector'; -import {VoiceEngineV2Simulator} from './Simulator'; +import { + createVoiceEngineV2EmptyFaultPlan, + createVoiceEngineV2FaultPlan, +} from '@fluxer/voice_engine_v2/src/simulation/FaultInjector'; +import {VoiceEngineV2Simulator} from '@fluxer/voice_engine_v2/src/simulation/Simulator'; import { createVoiceEngineV2ExternalEstablishmentCycleWorkload, SIMULATOR_EXTERNAL_ESTABLISH_CYCLES, VoiceEngineV2WorkloadBuilder, -} from './Workload'; +} from '@fluxer/voice_engine_v2/src/simulation/Workload'; +import {describe, expect, it} from 'vitest'; describe('external establishment workload shape', () => { it('emits an establish and a remote disconnect for every cycle', () => { diff --git a/packages/voice_engine_v2/src/simulation/scenarios/asymmetricNatAfterConnect.ts b/packages/voice_engine_v2/src/simulation/scenarios/asymmetricNatAfterConnect.ts index fb4837431..e245f395f 100644 --- a/packages/voice_engine_v2/src/simulation/scenarios/asymmetricNatAfterConnect.ts +++ b/packages/voice_engine_v2/src/simulation/scenarios/asymmetricNatAfterConnect.ts @@ -1,10 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {createVoiceEngineV2FaultPlan} from '../FaultInjector'; -import type {VoiceEngineV2SimulatorResult} from '../Simulator'; -import type {VoiceEngineV2Workload} from '../Workload'; -import {VoiceEngineV2WorkloadBuilder} from '../Workload'; +import {createVoiceEngineV2FaultPlan} from '@fluxer/voice_engine_v2/src/simulation/FaultInjector'; +import type {VoiceEngineV2SimulatorResult} from '@fluxer/voice_engine_v2/src/simulation/Simulator'; import { assertSeedWellFormed, combineVerdicts, @@ -12,7 +10,9 @@ import { passVerdict, type VoiceEngineV2AcceptanceVerdict, type VoiceEngineV2SimulationScenario, -} from './index'; +} from '@fluxer/voice_engine_v2/src/simulation/scenarios/index'; +import type {VoiceEngineV2Workload} from '@fluxer/voice_engine_v2/src/simulation/Workload'; +import {VoiceEngineV2WorkloadBuilder} from '@fluxer/voice_engine_v2/src/simulation/Workload'; const ASYM_PARTITION_FROM_TICK = 200; const ASYM_PARTITION_PEER_ID = 'B'; diff --git a/packages/voice_engine_v2/src/simulation/scenarios/captureDeviceDisconnect.ts b/packages/voice_engine_v2/src/simulation/scenarios/captureDeviceDisconnect.ts index 91bae7031..d3d755995 100644 --- a/packages/voice_engine_v2/src/simulation/scenarios/captureDeviceDisconnect.ts +++ b/packages/voice_engine_v2/src/simulation/scenarios/captureDeviceDisconnect.ts @@ -1,10 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {createVoiceEngineV2FaultPlan} from '../FaultInjector'; -import type {VoiceEngineV2SimulatorResult} from '../Simulator'; -import type {VoiceEngineV2Workload} from '../Workload'; -import {VoiceEngineV2WorkloadBuilder} from '../Workload'; +import {createVoiceEngineV2FaultPlan} from '@fluxer/voice_engine_v2/src/simulation/FaultInjector'; +import type {VoiceEngineV2SimulatorResult} from '@fluxer/voice_engine_v2/src/simulation/Simulator'; import { assertSeedWellFormed, combineVerdicts, @@ -12,7 +10,9 @@ import { passVerdict, type VoiceEngineV2AcceptanceVerdict, type VoiceEngineV2SimulationScenario, -} from './index'; +} from '@fluxer/voice_engine_v2/src/simulation/scenarios/index'; +import type {VoiceEngineV2Workload} from '@fluxer/voice_engine_v2/src/simulation/Workload'; +import {VoiceEngineV2WorkloadBuilder} from '@fluxer/voice_engine_v2/src/simulation/Workload'; const DEVICE_DISCONNECT_TICK = 100; const DEVICE_DISCONNECT_DEVICE_ID = 'mic-1'; diff --git a/packages/voice_engine_v2/src/simulation/scenarios/encoderFailUnderLoad.ts b/packages/voice_engine_v2/src/simulation/scenarios/encoderFailUnderLoad.ts index 2a18f1e54..9ae9a5c5d 100644 --- a/packages/voice_engine_v2/src/simulation/scenarios/encoderFailUnderLoad.ts +++ b/packages/voice_engine_v2/src/simulation/scenarios/encoderFailUnderLoad.ts @@ -1,10 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {createVoiceEngineV2FaultPlan} from '../FaultInjector'; -import type {VoiceEngineV2SimulatorResult} from '../Simulator'; -import type {VoiceEngineV2Workload} from '../Workload'; -import {VoiceEngineV2WorkloadBuilder} from '../Workload'; +import {createVoiceEngineV2FaultPlan} from '@fluxer/voice_engine_v2/src/simulation/FaultInjector'; +import type {VoiceEngineV2SimulatorResult} from '@fluxer/voice_engine_v2/src/simulation/Simulator'; import { assertSeedWellFormed, combineVerdicts, @@ -12,7 +10,9 @@ import { passVerdict, type VoiceEngineV2AcceptanceVerdict, type VoiceEngineV2SimulationScenario, -} from './index'; +} from '@fluxer/voice_engine_v2/src/simulation/scenarios/index'; +import type {VoiceEngineV2Workload} from '@fluxer/voice_engine_v2/src/simulation/Workload'; +import {VoiceEngineV2WorkloadBuilder} from '@fluxer/voice_engine_v2/src/simulation/Workload'; const ENCODER_FAIL_AT_TICK = 220; const ENCODER_FAIL_PARTICIPANT_COUNT = 4; diff --git a/packages/voice_engine_v2/src/simulation/scenarios/gpuTdrMidFrame.ts b/packages/voice_engine_v2/src/simulation/scenarios/gpuTdrMidFrame.ts index 90d9ee1da..dc33935c5 100644 --- a/packages/voice_engine_v2/src/simulation/scenarios/gpuTdrMidFrame.ts +++ b/packages/voice_engine_v2/src/simulation/scenarios/gpuTdrMidFrame.ts @@ -1,10 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {createVoiceEngineV2FaultPlan} from '../FaultInjector'; -import type {VoiceEngineV2SimulatorResult} from '../Simulator'; -import type {VoiceEngineV2Workload} from '../Workload'; -import {VoiceEngineV2WorkloadBuilder} from '../Workload'; +import {createVoiceEngineV2FaultPlan} from '@fluxer/voice_engine_v2/src/simulation/FaultInjector'; +import type {VoiceEngineV2SimulatorResult} from '@fluxer/voice_engine_v2/src/simulation/Simulator'; import { assertSeedWellFormed, combineVerdicts, @@ -12,7 +10,9 @@ import { passVerdict, type VoiceEngineV2AcceptanceVerdict, type VoiceEngineV2SimulationScenario, -} from './index'; +} from '@fluxer/voice_engine_v2/src/simulation/scenarios/index'; +import type {VoiceEngineV2Workload} from '@fluxer/voice_engine_v2/src/simulation/Workload'; +import {VoiceEngineV2WorkloadBuilder} from '@fluxer/voice_engine_v2/src/simulation/Workload'; const GPU_TDR_AT_TICK = 200; const GPU_TDR_RECONNECT_TICK = 215; diff --git a/packages/voice_engine_v2/src/simulation/scenarios/index.ts b/packages/voice_engine_v2/src/simulation/scenarios/index.ts index 3a8694cd8..64552ec0f 100644 --- a/packages/voice_engine_v2/src/simulation/scenarios/index.ts +++ b/packages/voice_engine_v2/src/simulation/scenarios/index.ts @@ -1,9 +1,12 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import type {VoiceEngineV2FaultPlan} from '../FaultInjector'; -import type {VoiceEngineV2SimulatorMode, VoiceEngineV2SimulatorResult} from '../Simulator'; -import type {VoiceEngineV2Workload} from '../Workload'; +import type {VoiceEngineV2FaultPlan} from '@fluxer/voice_engine_v2/src/simulation/FaultInjector'; +import type { + VoiceEngineV2SimulatorMode, + VoiceEngineV2SimulatorResult, +} from '@fluxer/voice_engine_v2/src/simulation/Simulator'; +import type {VoiceEngineV2Workload} from '@fluxer/voice_engine_v2/src/simulation/Workload'; const SCENARIO_SEED_MAX = 0x7fffffff; @@ -50,8 +53,8 @@ export function assertSeedWellFormed(seed: number): void { assert.ok(seed <= SCENARIO_SEED_MAX, 'scenario seed exceeds SCENARIO_SEED_MAX'); } -export {defineAsymmetricNatAfterConnectScenario} from './asymmetricNatAfterConnect'; -export {defineCaptureDeviceDisconnectScenario} from './captureDeviceDisconnect'; -export {defineEncoderFailUnderLoadScenario} from './encoderFailUnderLoad'; -export {defineGpuTdrMidFrameScenario} from './gpuTdrMidFrame'; -export {defineNetworkPartitionDuringScreenShareScenario} from './networkPartitionDuringScreenShare'; +export {defineAsymmetricNatAfterConnectScenario} from '@fluxer/voice_engine_v2/src/simulation/scenarios/asymmetricNatAfterConnect'; +export {defineCaptureDeviceDisconnectScenario} from '@fluxer/voice_engine_v2/src/simulation/scenarios/captureDeviceDisconnect'; +export {defineEncoderFailUnderLoadScenario} from '@fluxer/voice_engine_v2/src/simulation/scenarios/encoderFailUnderLoad'; +export {defineGpuTdrMidFrameScenario} from '@fluxer/voice_engine_v2/src/simulation/scenarios/gpuTdrMidFrame'; +export {defineNetworkPartitionDuringScreenShareScenario} from '@fluxer/voice_engine_v2/src/simulation/scenarios/networkPartitionDuringScreenShare'; diff --git a/packages/voice_engine_v2/src/simulation/scenarios/networkPartitionDuringScreenShare.ts b/packages/voice_engine_v2/src/simulation/scenarios/networkPartitionDuringScreenShare.ts index f7b0cc28a..5d83bc3b6 100644 --- a/packages/voice_engine_v2/src/simulation/scenarios/networkPartitionDuringScreenShare.ts +++ b/packages/voice_engine_v2/src/simulation/scenarios/networkPartitionDuringScreenShare.ts @@ -1,10 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {createVoiceEngineV2FaultPlan} from '../FaultInjector'; -import type {VoiceEngineV2SimulatorResult} from '../Simulator'; -import type {VoiceEngineV2Workload} from '../Workload'; -import {VoiceEngineV2WorkloadBuilder} from '../Workload'; +import {createVoiceEngineV2FaultPlan} from '@fluxer/voice_engine_v2/src/simulation/FaultInjector'; +import type {VoiceEngineV2SimulatorResult} from '@fluxer/voice_engine_v2/src/simulation/Simulator'; import { assertSeedWellFormed, combineVerdicts, @@ -12,7 +10,9 @@ import { passVerdict, type VoiceEngineV2AcceptanceVerdict, type VoiceEngineV2SimulationScenario, -} from './index'; +} from '@fluxer/voice_engine_v2/src/simulation/scenarios/index'; +import type {VoiceEngineV2Workload} from '@fluxer/voice_engine_v2/src/simulation/Workload'; +import {VoiceEngineV2WorkloadBuilder} from '@fluxer/voice_engine_v2/src/simulation/Workload'; const PARTITION_FROM_TICK = 150; const PARTITION_UNTIL_TICK = 350; diff --git a/packages/voice_engine_v2/src/simulation/scenarios/scenarios.test.ts b/packages/voice_engine_v2/src/simulation/scenarios/scenarios.test.ts index a2844780d..7af3ca9de 100644 --- a/packages/voice_engine_v2/src/simulation/scenarios/scenarios.test.ts +++ b/packages/voice_engine_v2/src/simulation/scenarios/scenarios.test.ts @@ -1,7 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import {SIMULATOR_TICK_MAX, VoiceEngineV2Simulator} from '../Simulator'; +import {SIMULATOR_TICK_MAX, VoiceEngineV2Simulator} from '@fluxer/voice_engine_v2/src/simulation/Simulator'; import { defineAsymmetricNatAfterConnectScenario, defineCaptureDeviceDisconnectScenario, @@ -9,7 +8,8 @@ import { defineGpuTdrMidFrameScenario, defineNetworkPartitionDuringScreenShareScenario, type VoiceEngineV2SimulationScenario, -} from './index'; +} from '@fluxer/voice_engine_v2/src/simulation/scenarios/index'; +import {describe, expect, it} from 'vitest'; const SCENARIO_FACTORIES: ReadonlyArray<(seed: number) => VoiceEngineV2SimulationScenario> = [ defineNetworkPartitionDuringScreenShareScenario, diff --git a/packages/voice_engine_v2/src/source_isolation/SourceLifecycleRegistry.ts b/packages/voice_engine_v2/src/source_isolation/SourceLifecycleRegistry.ts index e3289ce57..0894b215f 100644 --- a/packages/voice_engine_v2/src/source_isolation/SourceLifecycleRegistry.ts +++ b/packages/voice_engine_v2/src/source_isolation/SourceLifecycleRegistry.ts @@ -10,7 +10,7 @@ import { type SourceLifecycleEvent, type SourceLifecycleState, transitionSourceLifecycle, -} from './SourceLifecycleState'; +} from '@fluxer/voice_engine_v2/src/source_isolation/SourceLifecycleState'; export const MAX_TRACKED_SOURCES = 256; diff --git a/packages/voice_engine_v2/src/source_isolation/SourceLifecycleState.test.ts b/packages/voice_engine_v2/src/source_isolation/SourceLifecycleState.test.ts index c039b9ee6..10f3c495d 100644 --- a/packages/voice_engine_v2/src/source_isolation/SourceLifecycleState.test.ts +++ b/packages/voice_engine_v2/src/source_isolation/SourceLifecycleState.test.ts @@ -1,6 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; import { computeReconnectBackoffMs, createInitialActiveState, @@ -13,7 +12,8 @@ import { SourceLifecycleRegistry, type SourceLifecycleState, transitionSourceLifecycle, -} from './index'; +} from '@fluxer/voice_engine_v2/src/source_isolation/index'; +import {describe, expect, it} from 'vitest'; function makeClock(startNs: bigint = 1_000n, stepNs: bigint = 1_000n): SourceLifecycleClock { let value = startNs; diff --git a/packages/voice_engine_v2/src/source_isolation/index.ts b/packages/voice_engine_v2/src/source_isolation/index.ts index cd170ee96..10e8443a7 100644 --- a/packages/voice_engine_v2/src/source_isolation/index.ts +++ b/packages/voice_engine_v2/src/source_isolation/index.ts @@ -5,7 +5,7 @@ export { type SourceLifecycleDispatchResult, SourceLifecycleRegistry, type SourceLifecycleSnapshotEntry, -} from './SourceLifecycleRegistry'; +} from '@fluxer/voice_engine_v2/src/source_isolation/SourceLifecycleRegistry'; export { computeReconnectBackoffMs, createInitialActiveState, @@ -20,4 +20,4 @@ export { type SourceLifecycleState, type SourceLifecycleTransitionResult, transitionSourceLifecycle, -} from './SourceLifecycleState'; +} from '@fluxer/voice_engine_v2/src/source_isolation/SourceLifecycleState'; diff --git a/packages/voice_engine_v2/src/testing/FakeVoiceEngineV2Driver.ts b/packages/voice_engine_v2/src/testing/FakeVoiceEngineV2Driver.ts index ce9f94e70..1803a1697 100644 --- a/packages/voice_engine_v2/src/testing/FakeVoiceEngineV2Driver.ts +++ b/packages/voice_engine_v2/src/testing/FakeVoiceEngineV2Driver.ts @@ -3,8 +3,8 @@ import type { VoiceEngineV2Driver, VoiceEngineV2ExternalEventListener, -} from '../implementations/VoiceEngineV2ImplementationBase'; -import type {VoiceEngineV2Event} from '../protocol/events'; +} from '@fluxer/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; import type { VoiceEngineV2CameraEncodingOptions, VoiceEngineV2CameraOptions, @@ -22,7 +22,7 @@ import type { VoiceEngineV2ScreenEncodingOptions, VoiceEngineV2ScreenOptions, VoiceEngineV2Stats, -} from '../protocol/types'; +} from '@fluxer/voice_engine_v2/src/protocol/types'; export type FakeVoiceEngineV2DriverCall = | {type: 'prewarm'} diff --git a/packages/voice_engine_v2/src/testing/VoiceEngineV2TestImplementation.ts b/packages/voice_engine_v2/src/testing/VoiceEngineV2TestImplementation.ts index bc66f4ee5..9a324571f 100644 --- a/packages/voice_engine_v2/src/testing/VoiceEngineV2TestImplementation.ts +++ b/packages/voice_engine_v2/src/testing/VoiceEngineV2TestImplementation.ts @@ -3,7 +3,7 @@ import { type VoiceEngineV2Driver, VoiceEngineV2ImplementationBase, -} from '../implementations/VoiceEngineV2ImplementationBase'; +} from '@fluxer/voice_engine_v2/src/implementations/VoiceEngineV2ImplementationBase'; export interface VoiceEngineV2TestDriver extends VoiceEngineV2Driver {} diff --git a/packages/voice_engine_v2/src/testing/conformance.test.ts b/packages/voice_engine_v2/src/testing/conformance.test.ts index 4ba564751..39f48e905 100644 --- a/packages/voice_engine_v2/src/testing/conformance.test.ts +++ b/packages/voice_engine_v2/src/testing/conformance.test.ts @@ -1,13 +1,13 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {VoiceEngineV2HostPortImplementation} from '@fluxer/voice_engine_v2/src/implementations'; +import type {VoiceEngineV2HostPorts} from '@fluxer/voice_engine_v2/src/ports'; +import {createVoiceEngineV2MemoryEventLogSpillSink, VoiceEngineV2Runtime} from '@fluxer/voice_engine_v2/src/runtime'; +import type {VoiceEngineV2ConformanceSubject} from '@fluxer/voice_engine_v2/src/testing/conformance'; +import {runVoiceEngineV2ConformanceSuite, waitForRuntime} from '@fluxer/voice_engine_v2/src/testing/conformance'; +import {FakeVoiceEngineV2Driver} from '@fluxer/voice_engine_v2/src/testing/FakeVoiceEngineV2Driver'; +import {VoiceEngineV2TestImplementation} from '@fluxer/voice_engine_v2/src/testing/VoiceEngineV2TestImplementation'; import {describe, expect, it} from 'vitest'; -import {VoiceEngineV2HostPortImplementation} from '../implementations'; -import type {VoiceEngineV2HostPorts} from '../ports'; -import {createVoiceEngineV2MemoryEventLogSpillSink, VoiceEngineV2Runtime} from '../runtime'; -import type {VoiceEngineV2ConformanceSubject} from './conformance'; -import {runVoiceEngineV2ConformanceSuite, waitForRuntime} from './conformance'; -import {FakeVoiceEngineV2Driver} from './FakeVoiceEngineV2Driver'; -import {VoiceEngineV2TestImplementation} from './VoiceEngineV2TestImplementation'; function createConformanceHostPorts(driver: FakeVoiceEngineV2Driver): VoiceEngineV2HostPorts { return { diff --git a/packages/voice_engine_v2/src/testing/conformance.ts b/packages/voice_engine_v2/src/testing/conformance.ts index 12c3883d2..6d9fc6f8e 100644 --- a/packages/voice_engine_v2/src/testing/conformance.ts +++ b/packages/voice_engine_v2/src/testing/conformance.ts @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later +import {selectVoiceEngineV2Model} from '@fluxer/voice_engine_v2/src/core'; +import type {VoiceEngineV2Implementation} from '@fluxer/voice_engine_v2/src/implementations'; +import {createVoiceEngineV2MemoryEventLogSpillSink, VoiceEngineV2Runtime} from '@fluxer/voice_engine_v2/src/runtime'; +import type {FakeVoiceEngineV2Driver} from '@fluxer/voice_engine_v2/src/testing/FakeVoiceEngineV2Driver'; import {describe, expect, it} from 'vitest'; -import {selectVoiceEngineV2Model} from '../core'; -import type {VoiceEngineV2Implementation} from '../implementations'; -import {createVoiceEngineV2MemoryEventLogSpillSink, VoiceEngineV2Runtime} from '../runtime'; -import type {FakeVoiceEngineV2Driver} from './FakeVoiceEngineV2Driver'; export interface VoiceEngineV2ConformanceSubject { implementation: VoiceEngineV2Implementation; diff --git a/packages/voice_engine_v2/src/testing/determinism.test.ts b/packages/voice_engine_v2/src/testing/determinism.test.ts index 8726825e9..b4e48af8a 100644 --- a/packages/voice_engine_v2/src/testing/determinism.test.ts +++ b/packages/voice_engine_v2/src/testing/determinism.test.ts @@ -1,15 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import appVoiceSessionFixtureJson from '../../fixtures/event_logs/app_voice_session.json'; -import {coalesceVoiceEngineV2OutboundStats} from '../policies/voiceStats'; -import type {VoiceEngineV2OutboundStats} from '../protocol/types'; +import appVoiceSessionFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/app_voice_session.json'; +import {coalesceVoiceEngineV2OutboundStats} from '@fluxer/voice_engine_v2/src/policies/voiceStats'; +import type {VoiceEngineV2OutboundStats} from '@fluxer/voice_engine_v2/src/protocol/types'; import { createVoiceEngineV2DeterministicPlatformPort, createVoiceEngineV2SeededRandomPort, createVoiceEngineV2SystemClockPort, -} from '../runtime'; -import {replayVoiceEngineV2EventLogFixture, type VoiceEngineV2EventLogFixture} from './eventLogReplay'; +} from '@fluxer/voice_engine_v2/src/runtime'; +import { + replayVoiceEngineV2EventLogFixture, + type VoiceEngineV2EventLogFixture, +} from '@fluxer/voice_engine_v2/src/testing/eventLogReplay'; +import {describe, expect, it} from 'vitest'; const fixture = appVoiceSessionFixtureJson as unknown as VoiceEngineV2EventLogFixture; diff --git a/packages/voice_engine_v2/src/testing/eventLogReplay.test.ts b/packages/voice_engine_v2/src/testing/eventLogReplay.test.ts index aa16ffec1..33b7d8500 100644 --- a/packages/voice_engine_v2/src/testing/eventLogReplay.test.ts +++ b/packages/voice_engine_v2/src/testing/eventLogReplay.test.ts @@ -1,18 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -import {describe, expect, it} from 'vitest'; -import appVoiceSessionFixtureJson from '../../fixtures/event_logs/app_voice_session.json'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import {createVoiceEngineV2MemoryEventLogSpillSink} from '../runtime/eventLogRing'; -import {coalesceVoiceEngineV2EventSequence} from '../runtime/frameCoalescing'; -import {VoiceEngineV2Runtime} from '../runtime/VoiceEngineV2Runtime'; +import appVoiceSessionFixtureJson from '@fluxer/voice_engine_v2/fixtures/event_logs/app_voice_session.json'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import {createVoiceEngineV2MemoryEventLogSpillSink} from '@fluxer/voice_engine_v2/src/runtime/eventLogRing'; +import {coalesceVoiceEngineV2EventSequence} from '@fluxer/voice_engine_v2/src/runtime/frameCoalescing'; +import {VoiceEngineV2Runtime} from '@fluxer/voice_engine_v2/src/runtime/VoiceEngineV2Runtime'; import { replayVoiceEngineV2EventLogFixture, VOICE_ENGINE_V2_EVENT_LOG_FIXTURE_VERSION, type VoiceEngineV2EventLogFixture, -} from './eventLogReplay'; -import {FakeVoiceEngineV2Driver} from './FakeVoiceEngineV2Driver'; -import {VoiceEngineV2TestImplementation} from './VoiceEngineV2TestImplementation'; +} from '@fluxer/voice_engine_v2/src/testing/eventLogReplay'; +import {FakeVoiceEngineV2Driver} from '@fluxer/voice_engine_v2/src/testing/FakeVoiceEngineV2Driver'; +import {VoiceEngineV2TestImplementation} from '@fluxer/voice_engine_v2/src/testing/VoiceEngineV2TestImplementation'; +import {describe, expect, it} from 'vitest'; const appVoiceSessionFixture = appVoiceSessionFixtureJson as unknown as VoiceEngineV2EventLogFixture; diff --git a/packages/voice_engine_v2/src/testing/eventLogReplay.ts b/packages/voice_engine_v2/src/testing/eventLogReplay.ts index f62a27b04..78daf0fca 100644 --- a/packages/voice_engine_v2/src/testing/eventLogReplay.ts +++ b/packages/voice_engine_v2/src/testing/eventLogReplay.ts @@ -1,16 +1,16 @@ // SPDX-License-Identifier: AGPL-3.0-or-later import assert from 'node:assert/strict'; -import {transitionVoiceEngineV2} from '../core/reducer'; -import {selectVoiceEngineV2Model} from '../core/selectors'; +import {transitionVoiceEngineV2} from '@fluxer/voice_engine_v2/src/core/reducer'; +import {selectVoiceEngineV2Model} from '@fluxer/voice_engine_v2/src/core/selectors'; import { availableVoiceEngineV2Capabilities, createVoiceEngineV2InitialSnapshot, type VoiceEngineV2Snapshot, -} from '../core/state'; -import type {VoiceEngineV2Command} from '../protocol/commands'; -import type {VoiceEngineV2Event} from '../protocol/events'; -import type {VoiceEngineV2Capabilities, VoiceEngineV2Model} from '../protocol/types'; +} from '@fluxer/voice_engine_v2/src/core/state'; +import type {VoiceEngineV2Command} from '@fluxer/voice_engine_v2/src/protocol/commands'; +import type {VoiceEngineV2Event} from '@fluxer/voice_engine_v2/src/protocol/events'; +import type {VoiceEngineV2Capabilities, VoiceEngineV2Model} from '@fluxer/voice_engine_v2/src/protocol/types'; export const VOICE_ENGINE_V2_EVENT_LOG_FIXTURE_VERSION = 1; diff --git a/packages/voice_engine_v2/src/testing/implementationExportBoundary.test.ts b/packages/voice_engine_v2/src/testing/implementationExportBoundary.test.ts index 7db565479..996248539 100644 --- a/packages/voice_engine_v2/src/testing/implementationExportBoundary.test.ts +++ b/packages/voice_engine_v2/src/testing/implementationExportBoundary.test.ts @@ -4,16 +4,16 @@ import {readFileSync} from 'node:fs'; import path from 'node:path'; import {fileURLToPath} from 'node:url'; +import * as implementationsBarrel from '@fluxer/voice_engine_v2/src/implementations'; +import * as packageBarrel from '@fluxer/voice_engine_v2/src/index'; import {describe, expect, it} from 'vitest'; -import * as implementationsBarrel from '../implementations'; -import * as packageBarrel from '../index'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const PACKAGE_ROOT = path.resolve(__dirname, '..'); const PUBLIC_EXPORT_FILES = ['index.ts', 'implementations/index.ts']; const QUARANTINED_TESTING_EXPORTS = ['VoiceEngineV2TestImplementation', 'VoiceEngineV2TestDriver']; const LEGACY_TESTING_EXPORTS = ['JsVoiceEngineV2Implementation', 'VoiceEngineV2JsDriver']; -const TESTING_MODULE_REFERENCE_PATTERN = /from\s+['"][./]*testing(?:\/[^'"]*)?['"]/; +const TESTING_MODULE_REFERENCE_PATTERN = /from\s+['"](?:[./]*|@fluxer\/voice_engine_v2\/src\/)testing(?:\/[^'"]*)?['"]/; const PUBLIC_BARRELS: ReadonlyArray<[string, Record]> = [ ['src/index.ts', packageBarrel], diff --git a/packages/voice_engine_v2/src/testing/index.ts b/packages/voice_engine_v2/src/testing/index.ts index b29c32631..ef995651f 100644 --- a/packages/voice_engine_v2/src/testing/index.ts +++ b/packages/voice_engine_v2/src/testing/index.ts @@ -1,25 +1,28 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -export type {VoiceEngineV2ConformanceSubject, VoiceEngineV2ConformanceSubjectFactory} from './conformance'; -export {runVoiceEngineV2ConformanceSuite, waitForRuntime} from './conformance'; +export type { + VoiceEngineV2ConformanceSubject, + VoiceEngineV2ConformanceSubjectFactory, +} from '@fluxer/voice_engine_v2/src/testing/conformance'; +export {runVoiceEngineV2ConformanceSuite, waitForRuntime} from '@fluxer/voice_engine_v2/src/testing/conformance'; export type { VoiceEngineV2EventLogFixture, VoiceEngineV2EventLogFixtureExpected, VoiceEngineV2EventLogFixtureStep, VoiceEngineV2EventLogReplayResult, VoiceEngineV2EventLogReplayStepResult, -} from './eventLogReplay'; +} from '@fluxer/voice_engine_v2/src/testing/eventLogReplay'; export { assertVoiceEngineV2EventLogFixture, replayVoiceEngineV2EventLogFixture, VOICE_ENGINE_V2_EVENT_LOG_FIXTURE_VERSION, -} from './eventLogReplay'; +} from '@fluxer/voice_engine_v2/src/testing/eventLogReplay'; export type { FakeVoiceEngineV2DriverCall, FakeVoiceEngineV2DriverCallType, FakeVoiceEngineV2DriverOptions, FakeVoiceEngineV2FailureMap, -} from './FakeVoiceEngineV2Driver'; -export {FakeVoiceEngineV2Driver} from './FakeVoiceEngineV2Driver'; -export type {VoiceEngineV2TestDriver} from './VoiceEngineV2TestImplementation'; -export {VoiceEngineV2TestImplementation} from './VoiceEngineV2TestImplementation'; +} from '@fluxer/voice_engine_v2/src/testing/FakeVoiceEngineV2Driver'; +export {FakeVoiceEngineV2Driver} from '@fluxer/voice_engine_v2/src/testing/FakeVoiceEngineV2Driver'; +export type {VoiceEngineV2TestDriver} from '@fluxer/voice_engine_v2/src/testing/VoiceEngineV2TestImplementation'; +export {VoiceEngineV2TestImplementation} from '@fluxer/voice_engine_v2/src/testing/VoiceEngineV2TestImplementation';