mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
refactor(addons): the transit-provider setting and photo-provider routes move into the shared kernel
AddonsService read the transit backend through transit/transit-provider.ts and built photo-provider endpoint paths with memories.helpers, so the addons domain, which nearly every domain imports for its gates, depended on transit and memories. Both are free functions over a repository or plain strings; they move unchanged to common/, where the transit and admin sides read them too.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { ADDON_IDS } from '../../addons';
|
||||
import { getPhotoProviderConfig } from '../memories/memories.helpers';
|
||||
import { readTransitProvider, writeTransitProvider } from '../transit/transit-provider';
|
||||
import { getPhotoProviderConfig } from '../common/photo-provider-config';
|
||||
import { readTransitProvider, writeTransitProvider } from '../common/transit-provider';
|
||||
import { resolveApiKey, type ApiKeySource } from '../settings/instance-api-keys';
|
||||
import { readEnv } from '../../app-config';
|
||||
import type { TransitProvider } from '@trek/shared';
|
||||
@@ -233,7 +233,7 @@ export class AddonsService {
|
||||
|
||||
// ── Transit backend (#1699) ────────────────────────────────────────────────
|
||||
// Not a flag: two named backends, so it stores the name rather than a
|
||||
// boolean. The read/write pair lives in transit/transit-provider.ts because
|
||||
// boolean. The read/write pair lives in common/transit-provider.ts because
|
||||
// TransitService reads the same row on every request — one key, one reader,
|
||||
// one writer. Neither that module nor instance-api-keys.ts (below) is one of
|
||||
// this plan's six domains, so they stay on DatabaseService until their own
|
||||
|
||||
@@ -18,7 +18,7 @@ import { maybe_encrypt_api_key, decrypt_api_key } from '../common/crypto/apiKeyC
|
||||
import { avatarUrl } from '../common/avatarUrl';
|
||||
import { DATABASE_BACKUP, type DatabaseBackupStrategy } from '../database/database-backup.interface';
|
||||
import { prepareLlmAddonConfigForWrite, maskLlmAddonConfig } from '../llm-parse/llm-config';
|
||||
import { getPhotoProviderConfig } from '../memories/memories.helpers';
|
||||
import { getPhotoProviderConfig } from '../common/photo-provider-config';
|
||||
import { validatePassword } from '../common/passwordPolicy';
|
||||
import { UserCleanupService } from '../auth/user-cleanup.service';
|
||||
import { UnitOfWork } from '../database/unit-of-work';
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Where the client finds a provider's settings/status/test endpoints. Pure
|
||||
* string building in the shared kernel: the admin and addons surfaces both
|
||||
* read it, and neither should have to import the memories domain to do so.
|
||||
*/
|
||||
export interface PhotoProviderConfig {
|
||||
settings_get: string;
|
||||
settings_put: string;
|
||||
status_get: string;
|
||||
test_post: string;
|
||||
}
|
||||
|
||||
export function getPhotoProviderConfig(providerId: string): PhotoProviderConfig {
|
||||
const prefix = `/integrations/memories/${providerId}`;
|
||||
return {
|
||||
settings_get: `${prefix}/settings`,
|
||||
settings_put: `${prefix}/settings`,
|
||||
status_get: `${prefix}/status`,
|
||||
test_post: `${prefix}/test`,
|
||||
};
|
||||
}
|
||||
@@ -360,28 +360,3 @@ export async function pipeAsset(url: string, response: Response, headers?: Recor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Route shape for the settings page ─────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Where the client finds a provider's settings/status/test endpoints. Pure
|
||||
* string building, so it stays here rather than on a service — the admin and
|
||||
* addons surfaces both read it and neither should have to import the memories
|
||||
* domain to do so.
|
||||
*/
|
||||
export interface PhotoProviderConfig {
|
||||
settings_get: string;
|
||||
settings_put: string;
|
||||
status_get: string;
|
||||
test_post: string;
|
||||
}
|
||||
|
||||
export function getPhotoProviderConfig(providerId: string): PhotoProviderConfig {
|
||||
const prefix = `/integrations/memories/${providerId}`;
|
||||
return {
|
||||
settings_get: `${prefix}/settings`,
|
||||
settings_put: `${prefix}/settings`,
|
||||
status_get: `${prefix}/status`,
|
||||
test_post: `${prefix}/test`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { AppSettingsRepository } from '../../db/repositories/AppSettings.re
|
||||
import { Users } from '../../db/entities/Users.entity';
|
||||
import type { UsersRepository } from '../../db/repositories/Users.repository';
|
||||
import { GoogleQuotaService } from '../google-quota/google-quota.service';
|
||||
import { readTransitProvider } from './transit-provider';
|
||||
import { readTransitProvider } from '../common/transit-provider';
|
||||
import {
|
||||
decodePolyline,
|
||||
deriveTransitStats,
|
||||
|
||||
Reference in New Issue
Block a user