diff --git a/src/app/core/services/auth.service.ts b/src/app/core/services/auth.service.ts index 492bfc3f0..833c2752e 100644 --- a/src/app/core/services/auth.service.ts +++ b/src/app/core/services/auth.service.ts @@ -19,18 +19,20 @@ export class AuthService { private readonly jsonApiService = inject(JsonApiService); private readonly cookieService = inject(CookieService); private readonly loaderService = inject(LoaderService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2/users/`; + private readonly webUrl = environment.webUrl; private readonly actions = createDispatchMap({ clearCurrentUser: ClearCurrentUser }); navigateToSignIn(): void { this.loaderService.show(); - const loginUrl = `${environment.casUrl}/login?${urlParam({ service: `${environment.webUrl}/login` })}`; + const loginUrl = `${environment.casUrl}/login?${urlParam({ service: `${this.webUrl}/login` })}`; window.location.href = loginUrl; } navigateToOrcidSingIn(): void { const loginUrl = `${environment.casUrl}/login?${urlParam({ redirectOrcid: 'true', - service: `${environment.webUrl}/login/?next=${encodeURIComponent(environment.webUrl)}`, + service: `${this.webUrl}/login/?next=${encodeURIComponent(this.webUrl)}`, })}`; window.location.href = loginUrl; } @@ -38,7 +40,7 @@ export class AuthService { navigateToInstitutionSignIn(): void { const loginUrl = `${environment.casUrl}/login?${urlParam({ campaign: 'institution', - service: `${environment.webUrl}/login/?next=${encodeURIComponent(environment.webUrl)}`, + service: `${this.webUrl}/login/?next=${encodeURIComponent(this.webUrl)}`, })}`; window.location.href = loginUrl; } @@ -47,25 +49,25 @@ export class AuthService { this.loaderService.show(); this.cookieService.deleteAll(); this.actions.clearCurrentUser(); - window.location.href = `${environment.webUrl}/logout/?next=${encodeURIComponent('/')}`; + window.location.href = `${this.webUrl}/logout/?next=${encodeURIComponent('/')}`; } register(payload: SignUpModel) { - const baseUrl = `${environment.apiUrlV1}/register/`; + const baseUrl = `${this.webUrl}/api/v1/register/`; const body = { ...payload, 'g-recaptcha-response': payload.recaptcha, campaign: null }; return this.jsonApiService.post(baseUrl, body); } forgotPassword(email: string) { - const baseUrl = `${environment.apiUrl}/users/reset_password/`; + const baseUrl = `${this.apiUrl}/reset_password/`; const params: Record = { email }; return this.jsonApiService.get(baseUrl, params); } resetPassword(userId: string, token: string, newPassword: string) { - const baseUrl = `${environment.apiUrl}/users/reset_password/`; + const baseUrl = `${this.apiUrl}/reset_password/`; const body = { data: { attributes: { diff --git a/src/app/core/services/request-access.service.ts b/src/app/core/services/request-access.service.ts index 86e60e493..d996283eb 100644 --- a/src/app/core/services/request-access.service.ts +++ b/src/app/core/services/request-access.service.ts @@ -2,7 +2,7 @@ import { Observable } from 'rxjs'; import { inject, Injectable } from '@angular/core'; -import { JsonApiService } from '../../shared/services/json-api.service'; +import { JsonApiService } from '@osf/shared/services'; import { environment } from 'src/environments/environment'; @@ -10,7 +10,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class RequestAccessService { - jsonApiService = inject(JsonApiService); + private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; requestAccessToProject(projectId: string, comment = ''): Observable { const payload = { @@ -23,6 +24,6 @@ export class RequestAccessService { }, }; - return this.jsonApiService.post(`${environment.apiUrl}/nodes/${projectId}/requests/`, payload); + return this.jsonApiService.post(`${this.apiUrl}/nodes/${projectId}/requests/`, payload); } } diff --git a/src/app/core/services/user-emails.service.ts b/src/app/core/services/user-emails.service.ts index 3a55fe78c..89697e10d 100644 --- a/src/app/core/services/user-emails.service.ts +++ b/src/app/core/services/user-emails.service.ts @@ -13,7 +13,7 @@ import { environment } from 'src/environments/environment'; }) export class UserEmailsService { private readonly jsonApiService = inject(JsonApiService); - private readonly baseUrl = `${environment.apiUrl}/users`; + private readonly baseUrl = `${environment.apiDomainUrl}/v2/users`; getEmails(): Observable { const params: Record = { diff --git a/src/app/core/services/user.service.ts b/src/app/core/services/user.service.ts index 4a1af083b..ddff1e871 100644 --- a/src/app/core/services/user.service.ts +++ b/src/app/core/services/user.service.ts @@ -23,23 +23,24 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class UserService { - jsonApiService = inject(JsonApiService); + private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getUserById(userId: string): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/users/${userId}/`) + .get(`${this.apiUrl}/users/${userId}/`) .pipe(map((response) => UserMapper.fromUserGetResponse(response.data))); } getCurrentUser(): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/`) + .get(`${this.apiUrl}/`) .pipe(map((response) => UserMapper.fromUserDataGetResponse(response))); } getCurrentUserSettings(): Observable { return this.jsonApiService - .get>(`${environment.apiUrl}/users/me/settings/`) + .get>(`${this.apiUrl}/users/me/settings/`) .pipe(map((response) => UserMapper.fromUserSettingsGetResponse(response.data))); } @@ -47,7 +48,7 @@ export class UserService { const request = UserMapper.toUpdateUserSettingsRequest(userId, userSettings); return this.jsonApiService - .patch(`${environment.apiUrl}/users/${userId}/settings/`, request) + .patch(`${this.apiUrl}/users/${userId}/settings/`, request) .pipe(map((response) => UserMapper.fromUserSettingsGetResponse(response))); } @@ -55,7 +56,7 @@ export class UserService { const patchedData = key === ProfileSettingsKey.User ? data : { [key]: data }; return this.jsonApiService - .patch(`${environment.apiUrl}/users/${userId}/`, { + .patch(`${this.apiUrl}/users/${userId}/`, { data: { type: 'users', id: userId, attributes: patchedData }, }) .pipe(map((response) => UserMapper.fromUserGetResponse(response))); diff --git a/src/app/features/admin-institutions/services/institutions-admin.service.ts b/src/app/features/admin-institutions/services/institutions-admin.service.ts index b2b7a466f..b73ab02e9 100644 --- a/src/app/features/admin-institutions/services/institutions-admin.service.ts +++ b/src/app/features/admin-institutions/services/institutions-admin.service.ts @@ -42,17 +42,18 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class InstitutionsAdminService { - private jsonApiService = inject(JsonApiService); + private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; fetchDepartments(institutionId: string): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/institutions/${institutionId}/metrics/departments/`) + .get(`${this.apiUrl}/institutions/${institutionId}/metrics/departments/`) .pipe(map((res) => mapInstitutionDepartments(res))); } fetchSummary(institutionId: string): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/institutions/${institutionId}/metrics/summary/`) + .get(`${this.apiUrl}/institutions/${institutionId}/metrics/summary/`) .pipe(map((result) => mapInstitutionSummaryMetrics(result.data.attributes))); } @@ -71,7 +72,7 @@ export class InstitutionsAdminService { }; return this.jsonApiService - .get(`${environment.apiUrl}/institutions/${institutionId}/metrics/users/`, params) + .get(`${this.apiUrl}/institutions/${institutionId}/metrics/users/`, params) .pipe( map((response) => ({ users: mapInstitutionUsers(response as InstitutionUsersJsonApi), @@ -105,7 +106,7 @@ export class InstitutionsAdminService { }; return this.jsonApiService - .get(`${environment.shareDomainUrl}/index-value-search`, params) + .get(`${environment.shareTroveUrl}/index-value-search`, params) .pipe(map((response) => mapIndexCardResults(response?.included))); } @@ -113,7 +114,7 @@ export class InstitutionsAdminService { const payload = sendMessageRequestMapper(request); return this.jsonApiService.post( - `${environment.apiUrl}/users/${request.userId}/messages/`, + `${this.apiUrl}/users/${request.userId}/messages/`, payload ); } @@ -121,7 +122,7 @@ export class InstitutionsAdminService { requestProjectAccess(request: RequestProjectAccessData): Observable { const payload = requestProjectAccessMapper(request); - return this.jsonApiService.post(`${environment.apiUrl}/nodes/${request.projectId}/requests/`, payload); + return this.jsonApiService.post(`${this.apiUrl}/nodes/${request.projectId}/requests/`, payload); } private fetchIndexCards( @@ -131,7 +132,7 @@ export class InstitutionsAdminService { sort = '-dateModified', cursor = '' ): Observable { - const url = `${environment.shareDomainUrl}/index-card-search`; + const url = `${environment.shareTroveUrl}/index-card-search`; const affiliationParam = institutionIris.join(','); const params: Record = { diff --git a/src/app/features/analytics/services/analytics.service.ts b/src/app/features/analytics/services/analytics.service.ts index b9f358ae2..b0a180c4a 100644 --- a/src/app/features/analytics/services/analytics.service.ts +++ b/src/app/features/analytics/services/analytics.service.ts @@ -16,6 +16,7 @@ import { environment } from 'src/environments/environment'; }) export class AnalyticsService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiDomainUrl = environment.apiDomainUrl; private readonly urlMap = new Map([ [ResourceType.Project, 'nodes'], @@ -23,7 +24,7 @@ export class AnalyticsService { ]); getMetrics(resourceId: string, dateRange: string): Observable { - const baseUrl = `${environment.apiDomainUrl}/_/metrics/query/node_analytics`; + const baseUrl = `${this.apiDomainUrl}/_/metrics/query/node_analytics`; return this.jsonApiService .get>(`${baseUrl}/${resourceId}/${dateRange}/`) @@ -32,7 +33,7 @@ export class AnalyticsService { getRelatedCounts(resourceId: string, resourceType: ResourceType) { const resourcePath = this.urlMap.get(resourceType); - const url = `${environment.apiUrl}/${resourcePath}/${resourceId}/?related_counts=true`; + const url = `${this.apiDomainUrl}/v2/${resourcePath}/${resourceId}/?related_counts=true`; return this.jsonApiService .get(url) diff --git a/src/app/features/collections/services/add-to-collection.service.ts b/src/app/features/collections/services/add-to-collection.service.ts index 6e4afe441..8893a4718 100644 --- a/src/app/features/collections/services/add-to-collection.service.ts +++ b/src/app/features/collections/services/add-to-collection.service.ts @@ -12,8 +12,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class AddToCollectionService { - private apiUrl = environment.apiUrl; private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; fetchCollectionLicenses(providerId: string): Observable { return this.jsonApiService diff --git a/src/app/features/files/components/file-revisions/file-revisions.component.ts b/src/app/features/files/components/file-revisions/file-revisions.component.ts index 2fc72a763..eb802f4ab 100644 --- a/src/app/features/files/components/file-revisions/file-revisions.component.ts +++ b/src/app/features/files/components/file-revisions/file-revisions.component.ts @@ -47,7 +47,7 @@ export class FileRevisionsComponent { downloadRevision(version: string): void { if (this.fileGuid()) { - window.open(`${environment.downloadUrl}/${this.fileGuid()}/?revision=${version}`)?.focus(); + window.open(`${environment.webUrl}/download/${this.fileGuid()}/?revision=${version}`)?.focus(); } } } diff --git a/src/app/features/files/pages/files/files.component.ts b/src/app/features/files/pages/files/files.component.ts index 67eb41cc7..e0d819218 100644 --- a/src/app/features/files/pages/files/files.component.ts +++ b/src/app/features/files/pages/files/files.component.ts @@ -208,7 +208,7 @@ export class FilesComponent { const resourceId = this.resourceId(); const resourcePath = this.urlMap.get(this.resourceType()!); - const folderLink = `${environment.apiUrl}/${resourcePath}/${resourceId}/files/`; + const folderLink = `${environment.apiDomainUrl}/v2/${resourcePath}/${resourceId}/files/`; const iriLink = `${environment.webUrl}/${resourceId}`; this.actions.getRootFolders(folderLink); this.actions.getConfiguredStorageAddons(iriLink); diff --git a/src/app/features/metadata/services/metadata.service.ts b/src/app/features/metadata/services/metadata.service.ts index 015adee1c..86fa1a76d 100644 --- a/src/app/features/metadata/services/metadata.service.ts +++ b/src/app/features/metadata/services/metadata.service.ts @@ -28,7 +28,8 @@ import { environment } from 'src/environments/environment'; }) export class MetadataService { private readonly jsonApiService = inject(JsonApiService); - private readonly apiUrl = environment.apiUrl; + private readonly apiDomainUrl = environment.apiDomainUrl; + private readonly apiUrl = `${this.apiDomainUrl}/v2`; private readonly urlMap = new Map([ [ResourceType.Project, 'nodes'], [ResourceType.Registration, 'registrations'], @@ -77,7 +78,7 @@ export class MetadataService { getMetadataCedarTemplates(url?: string): Observable { return this.jsonApiService.get( - url || `${environment.apiDomainUrl}/_/cedar_metadata_templates/` + url || `${this.apiDomainUrl}/_/cedar_metadata_templates/` ); } @@ -99,10 +100,7 @@ export class MetadataService { resourceType: ResourceType ): Observable { const payload = CedarRecordsMapper.toCedarRecordsPayload(data, resourceId, this.urlMap.get(resourceType) as string); - return this.jsonApiService.post( - `${environment.apiDomainUrl}/_/cedar_metadata_records/`, - payload - ); + return this.jsonApiService.post(`${this.apiDomainUrl}/_/cedar_metadata_records/`, payload); } updateMetadataCedarRecord( @@ -114,7 +112,7 @@ export class MetadataService { const payload = CedarRecordsMapper.toCedarRecordsPayload(data, resourceId, this.urlMap.get(resourceType) as string); return this.jsonApiService.patch( - `${environment.apiDomainUrl}/_/cedar_metadata_records/${recordId}/`, + `${this.apiDomainUrl}/_/cedar_metadata_records/${recordId}/`, payload ); } diff --git a/src/app/features/moderation/services/moderators.service.ts b/src/app/features/moderation/services/moderators.service.ts index 74ed8d130..df6558f2f 100644 --- a/src/app/features/moderation/services/moderators.service.ts +++ b/src/app/features/moderation/services/moderators.service.ts @@ -17,6 +17,7 @@ import { environment } from 'src/environments/environment'; }) export class ModeratorsService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; private readonly urlMap = new Map([ [ResourceType.Collection, 'providers/collections'], @@ -25,7 +26,7 @@ export class ModeratorsService { ]); getModerators(resourceId: string, resourceType: ResourceType): Observable { - const baseUrl = `${environment.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/moderators`; + const baseUrl = `${this.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/moderators`; return this.jsonApiService .get(baseUrl) @@ -33,7 +34,7 @@ export class ModeratorsService { } addModerator(resourceId: string, resourceType: ResourceType, data: ModeratorAddModel): Observable { - const baseUrl = `${environment.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/moderators/`; + const baseUrl = `${this.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/moderators/`; const type = data.id ? AddModeratorType.Search : AddModeratorType.Invite; const moderatorData = { data: ModerationMapper.toModeratorAddRequest(data, type) }; @@ -44,7 +45,7 @@ export class ModeratorsService { } updateModerator(resourceId: string, resourceType: ResourceType, data: ModeratorAddModel): Observable { - const baseUrl = `${environment.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/moderators/${data.id}`; + const baseUrl = `${this.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/moderators/${data.id}`; const moderatorData = { data: ModerationMapper.toModeratorAddRequest(data) }; return this.jsonApiService @@ -53,13 +54,13 @@ export class ModeratorsService { } deleteModerator(resourceId: string, resourceType: ResourceType, userId: string): Observable { - const baseUrl = `${environment.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/moderators/${userId}`; + const baseUrl = `${this.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/moderators/${userId}`; return this.jsonApiService.delete(baseUrl); } searchUsers(value: string, page = 1): Observable> { - const baseUrl = `${environment.apiUrl}/users/?filter[full_name]=${value}&page=${page}`; + const baseUrl = `${this.apiUrl}/users/?filter[full_name]=${value}&page=${page}`; return this.jsonApiService .get>(baseUrl) diff --git a/src/app/features/moderation/services/preprint-moderation.service.ts b/src/app/features/moderation/services/preprint-moderation.service.ts index 2e827bb68..3756a094b 100644 --- a/src/app/features/moderation/services/preprint-moderation.service.ts +++ b/src/app/features/moderation/services/preprint-moderation.service.ts @@ -27,9 +27,10 @@ import { environment } from 'src/environments/environment'; }) export class PreprintModerationService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getPreprintProviders(): Observable { - const baseUrl = `${environment.apiUrl}/providers/preprints/?filter[permissions]=view_actions,set_up_moderation`; + const baseUrl = `${this.apiUrl}/providers/preprints/?filter[permissions]=view_actions,set_up_moderation`; return this.jsonApiService .get>(baseUrl) @@ -37,7 +38,7 @@ export class PreprintModerationService { } getPreprintProvider(id: string): Observable { - const baseUrl = `${environment.apiUrl}/providers/preprints/${id}/?related_counts=true`; + const baseUrl = `${this.apiUrl}/providers/preprints/${id}/?related_counts=true`; return this.jsonApiService .get>(baseUrl) @@ -45,7 +46,7 @@ export class PreprintModerationService { } getPreprintReviews(page = 1): Observable> { - const baseUrl = `${environment.apiUrl}/actions/reviews/?embed=provider&embed=target&page=${page}`; + const baseUrl = `${this.apiUrl}/actions/reviews/?embed=provider&embed=target&page=${page}`; return this.jsonApiService .get>(baseUrl) @@ -60,7 +61,7 @@ export class PreprintModerationService { ): Observable { const filters = `filter[reviews_state]=${status}`; - const baseUrl = `${environment.apiUrl}/providers/preprints/${provider}/preprints/?page=${page}&meta[reviews_state_counts]=true&${filters}&sort=${sort}`; + const baseUrl = `${this.apiUrl}/providers/preprints/${provider}/preprints/?page=${page}&meta[reviews_state_counts]=true&${filters}&sort=${sort}`; return this.jsonApiService .get(baseUrl) @@ -75,7 +76,7 @@ export class PreprintModerationService { ): Observable { const params = `?embed=target&embed=creator&filter[machine_state]=${status}&meta[requests_state_counts]=true&page=${page}&sort=${sort}`; - const baseUrl = `${environment.apiUrl}/providers/preprints/${provider}/withdraw_requests/${params}`; + const baseUrl = `${this.apiUrl}/providers/preprints/${provider}/withdraw_requests/${params}`; return this.jsonApiService .get(baseUrl) @@ -83,7 +84,7 @@ export class PreprintModerationService { } getPreprintSubmissionReviewAction(id: string): Observable { - const baseUrl = `${environment.apiUrl}/preprints/${id}/review_actions/`; + const baseUrl = `${this.apiUrl}/preprints/${id}/review_actions/`; return this.jsonApiService .get(baseUrl) @@ -91,7 +92,7 @@ export class PreprintModerationService { } getPreprintWithdrawalSubmissionReviewAction(id: string): Observable { - const baseUrl = `${environment.apiUrl}/requests/${id}/actions/`; + const baseUrl = `${this.apiUrl}/requests/${id}/actions/`; return this.jsonApiService .get(baseUrl) diff --git a/src/app/features/moderation/services/registry-moderation.service.ts b/src/app/features/moderation/services/registry-moderation.service.ts index 6b5f8bb9e..30068c4cd 100644 --- a/src/app/features/moderation/services/registry-moderation.service.ts +++ b/src/app/features/moderation/services/registry-moderation.service.ts @@ -16,6 +16,7 @@ import { environment } from 'src/environments/environment'; }) export class RegistryModerationService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getRegistrySubmissions( provider: string, @@ -28,7 +29,7 @@ export class RegistryModerationService { ? `filter[reviews_state]=embargo,accepted&filter[revision_state]=pending_moderation` : `filter[reviews_state]=${status}`; - const baseUrl = `${environment.apiUrl}/providers/registrations/${provider}/registrations/?page=${page}&page[size]=10&${filters}&sort=${sort}`; + const baseUrl = `${this.apiUrl}/providers/registrations/${provider}/registrations/?page=${page}&page[size]=10&${filters}&sort=${sort}`; const params = { 'embed[]': ['schema_responses'], }; @@ -38,7 +39,7 @@ export class RegistryModerationService { } getRegistrySubmissionHistory(id: string): Observable { - const baseUrl = `${environment.apiUrl}/registrations/${id}/actions/`; + const baseUrl = `${this.apiUrl}/registrations/${id}/actions/`; return this.jsonApiService .get(baseUrl) diff --git a/src/app/features/preprints/services/preprint-files.service.ts b/src/app/features/preprints/services/preprint-files.service.ts index 75e715f59..bd1c697fd 100644 --- a/src/app/features/preprints/services/preprint-files.service.ts +++ b/src/app/features/preprints/services/preprint-files.service.ts @@ -21,11 +21,12 @@ import { environment } from 'src/environments/environment'; export class PreprintFilesService { private filesService = inject(FilesService); private jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; updateFileRelationship(preprintId: string, fileId: string): Observable { return this.jsonApiService .patch>( - `${environment.apiUrl}/preprints/${preprintId}/`, + `${this.apiUrl}/preprints/${preprintId}/`, { data: { type: 'preprints', @@ -46,7 +47,7 @@ export class PreprintFilesService { } getPreprintFilesLinks(id: string): Observable { - return this.jsonApiService.get(`${environment.apiUrl}/preprints/${id}/files/`).pipe( + return this.jsonApiService.get(`${this.apiUrl}/preprints/${id}/files/`).pipe( map((response) => { const rel = response.data[0].relationships; const links = response.data[0].links; @@ -60,7 +61,7 @@ export class PreprintFilesService { } getProjectFiles(projectId: string): Observable { - return this.jsonApiService.get(`${environment.apiUrl}/nodes/${projectId}/files/`).pipe( + return this.jsonApiService.get(`${this.apiUrl}/nodes/${projectId}/files/`).pipe( switchMap((response: GetFilesResponse) => { return this.jsonApiService .get(response.data[0].relationships.root_folder.links.related.href) diff --git a/src/app/features/preprints/services/preprint-licenses.service.ts b/src/app/features/preprints/services/preprint-licenses.service.ts index d69c7da83..02171b35f 100644 --- a/src/app/features/preprints/services/preprint-licenses.service.ts +++ b/src/app/features/preprints/services/preprint-licenses.service.ts @@ -19,8 +19,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class PreprintLicensesService { - private apiUrl = environment.apiUrl; private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getLicenses(providerId: string): Observable { return this.jsonApiService diff --git a/src/app/features/preprints/services/preprint-providers.service.ts b/src/app/features/preprints/services/preprint-providers.service.ts index d67ebfe0c..51172864e 100644 --- a/src/app/features/preprints/services/preprint-providers.service.ts +++ b/src/app/features/preprints/services/preprint-providers.service.ts @@ -17,8 +17,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class PreprintProvidersService { - private jsonApiService = inject(JsonApiService); - private baseUrl = `${environment.apiUrl}/providers/preprints/`; + private readonly jsonApiService = inject(JsonApiService); + private readonly baseUrl = `${environment.apiDomainUrl}/v2/providers/preprints/`; getPreprintProviderById(id: string): Observable { return this.jsonApiService diff --git a/src/app/features/preprints/services/preprints-projects.service.ts b/src/app/features/preprints/services/preprints-projects.service.ts index b888fa2b9..3abe096cb 100644 --- a/src/app/features/preprints/services/preprints-projects.service.ts +++ b/src/app/features/preprints/services/preprints-projects.service.ts @@ -15,7 +15,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class PreprintsProjectsService { - private jsonApiService = inject(JsonApiService); + private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getAvailableProjects(searchTerm: StringOrNull): Observable { const params: Record = {}; @@ -24,20 +25,18 @@ export class PreprintsProjectsService { params['filter[title]'] = searchTerm; } - return this.jsonApiService - .get>(`${environment.apiUrl}/users/me/nodes/`, params) - .pipe( - map((response) => { - return response.data.map((item) => ({ - id: item.id, - name: item.attributes.title, - })); - }) - ); + return this.jsonApiService.get>(`${this.apiUrl}/users/me/nodes/`, params).pipe( + map((response) => { + return response.data.map((item) => ({ + id: item.id, + name: item.attributes.title, + })); + }) + ); } getProjectById(projectId: string): Observable { - return this.jsonApiService.get>(`${environment.apiUrl}/nodes/${projectId}/`).pipe( + return this.jsonApiService.get>(`${this.apiUrl}/nodes/${projectId}/`).pipe( map((response) => { return { id: response.data.id, @@ -48,7 +47,7 @@ export class PreprintsProjectsService { } removePreprintProjectRelationship(preprintId: string) { - return this.jsonApiService.patch(`${environment.apiUrl}/preprints/${preprintId}/relationships/node/`, { + return this.jsonApiService.patch(`${this.apiUrl}/preprints/${preprintId}/relationships/node/`, { data: [], }); } @@ -56,7 +55,7 @@ export class PreprintsProjectsService { updatePreprintProjectRelationship(preprintId: string, projectId: string): Observable { return this.jsonApiService .patch>( - `${environment.apiUrl}/preprints/${preprintId}/`, + `${this.apiUrl}/preprints/${preprintId}/`, { data: { type: 'preprints', @@ -111,7 +110,7 @@ export class PreprintsProjectsService { }, }; - return this.jsonApiService.post>(`${environment.apiUrl}/nodes/`, payload).pipe( + return this.jsonApiService.post>(`${this.apiUrl}/nodes/`, payload).pipe( map((response) => { return { id: response.data.id, diff --git a/src/app/features/preprints/services/preprints.service.ts b/src/app/features/preprints/services/preprints.service.ts index d52fde721..30fe8ca1a 100644 --- a/src/app/features/preprints/services/preprints.service.ts +++ b/src/app/features/preprints/services/preprints.service.ts @@ -30,7 +30,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class PreprintsService { - private jsonApiService = inject(JsonApiService); + private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; private domainToApiFieldMap: Record = { title: 'title', @@ -58,7 +59,7 @@ export class PreprintsService { ApiData, null > - >(`${environment.apiUrl}/preprints/`, payload) + >(`${this.apiUrl}/preprints/`, payload) .pipe(map((response) => PreprintsMapper.fromPreprintJsonApi(response.data))); } @@ -69,7 +70,7 @@ export class PreprintsService { ApiData, null > - >(`${environment.apiUrl}/preprints/${id}/`) + >(`${this.apiUrl}/preprints/${id}/`) .pipe(map((response) => PreprintsMapper.fromPreprintJsonApi(response.data))); } @@ -86,12 +87,12 @@ export class PreprintsService { PreprintMetaJsonApi, null > - >(`${environment.apiUrl}/preprints/${id}/`, params) + >(`${this.apiUrl}/preprints/${id}/`, params) .pipe(map((response) => PreprintsMapper.fromPreprintWithEmbedsJsonApi(response))); } deletePreprint(id: string) { - return this.jsonApiService.delete(`${environment.apiUrl}/preprints/${id}/`); + return this.jsonApiService.delete(`${this.apiUrl}/preprints/${id}/`); } updatePreprint(id: string, payload: Partial): Observable { @@ -99,7 +100,7 @@ export class PreprintsService { return this.jsonApiService .patch>( - `${environment.apiUrl}/preprints/${id}/`, + `${this.apiUrl}/preprints/${id}/`, { data: { type: 'preprints', @@ -113,7 +114,7 @@ export class PreprintsService { submitPreprint(preprintId: string) { const payload = PreprintsMapper.toReviewActionPayload(preprintId, 'submit'); - return this.jsonApiService.post(`${environment.apiUrl}/preprints/${preprintId}/review_actions/`, payload); + return this.jsonApiService.post(`${this.apiUrl}/preprints/${preprintId}/review_actions/`, payload); } createNewVersion(prevVersionPreprintId: string) { @@ -123,7 +124,7 @@ export class PreprintsService { ApiData, null > - >(`${environment.apiUrl}/preprints/${prevVersionPreprintId}/versions/?version=2.20`) + >(`${this.apiUrl}/preprints/${prevVersionPreprintId}/versions/?version=2.20`) .pipe(map((response) => PreprintsMapper.fromPreprintJsonApi(response.data))); } @@ -141,7 +142,7 @@ export class PreprintsService { return this.jsonApiService .get< ResponseJsonApi[]> - >(`${environment.apiUrl}/preprints/${preprintId}/versions/`) + >(`${this.apiUrl}/preprints/${preprintId}/versions/`) .pipe(map((response) => response.data.map((data) => data.id))); } @@ -157,12 +158,12 @@ export class PreprintsService { return this.jsonApiService .get< ResponseJsonApi[]> - >(`${environment.apiUrl}/users/me/preprints/`, params) + >(`${this.apiUrl}/users/me/preprints/`, params) .pipe(map((response) => PreprintsMapper.fromMyPreprintJsonApi(response))); } getPreprintReviewActions(preprintId: string) { - const baseUrl = `${environment.apiUrl}/preprints/${preprintId}/review_actions/`; + const baseUrl = `${this.apiUrl}/preprints/${preprintId}/review_actions/`; return this.jsonApiService .get(baseUrl) @@ -170,7 +171,7 @@ export class PreprintsService { } getPreprintRequests(preprintId: string): Observable { - const baseUrl = `${environment.apiUrl}/preprints/${preprintId}/requests/?embed=creator`; + const baseUrl = `${this.apiUrl}/preprints/${preprintId}/requests/?embed=creator`; return this.jsonApiService .get(baseUrl) @@ -178,7 +179,7 @@ export class PreprintsService { } getPreprintRequestActions(requestId: string): Observable { - const baseUrl = `${environment.apiUrl}/requests/${requestId}/actions/`; + const baseUrl = `${this.apiUrl}/requests/${requestId}/actions/`; return this.jsonApiService .get(baseUrl) @@ -188,16 +189,16 @@ export class PreprintsService { withdrawPreprint(preprintId: string, justification: string) { const payload = PreprintRequestMapper.toWithdrawPreprintPayload(preprintId, justification); - return this.jsonApiService.post(`${environment.apiUrl}/preprints/${preprintId}/requests/`, payload); + return this.jsonApiService.post(`${this.apiUrl}/preprints/${preprintId}/requests/`, payload); } submitReviewsDecision(preprintId: string, trigger: string, comment: StringOrNull) { const payload = PreprintsMapper.toReviewActionPayload(preprintId, trigger, comment); - return this.jsonApiService.post(`${environment.apiUrl}/actions/reviews/`, payload); + return this.jsonApiService.post(`${this.apiUrl}/actions/reviews/`, payload); } submitRequestsDecision(requestId: string, trigger: string, comment: StringOrNull) { const payload = PreprintRequestActionsMapper.toRequestActionPayload(requestId, trigger, comment); - return this.jsonApiService.post(`${environment.apiUrl}/actions/requests/preprints/`, payload); + return this.jsonApiService.post(`${this.apiUrl}/actions/requests/preprints/`, payload); } } diff --git a/src/app/features/project/overview/components/files-widget/files-widget.component.ts b/src/app/features/project/overview/components/files-widget/files-widget.component.ts index 8a0afd8ab..6fa3518d3 100644 --- a/src/app/features/project/overview/components/files-widget/files-widget.component.ts +++ b/src/app/features/project/overview/components/files-widget/files-widget.component.ts @@ -154,7 +154,7 @@ export class FilesWidgetComponent { private getStorageAddons(projectId: string) { const resourcePath = 'nodes'; - const folderLink = `${environment.apiUrl}/${resourcePath}/${projectId}/files/`; + const folderLink = `${environment.apiDomainUrl}/v2/${resourcePath}/${projectId}/files/`; const iriLink = `${environment.webUrl}/${projectId}`; this.actions.getRootFolders(folderLink); this.actions.getConfiguredStorageAddons(iriLink); diff --git a/src/app/features/project/overview/services/project-overview.service.ts b/src/app/features/project/overview/services/project-overview.service.ts index b1cc7d779..7c2bfce27 100644 --- a/src/app/features/project/overview/services/project-overview.service.ts +++ b/src/app/features/project/overview/services/project-overview.service.ts @@ -17,6 +17,7 @@ import { environment } from 'src/environments/environment'; }) export class ProjectOverviewService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getProjectById(projectId: string): Observable { const params: Record = { @@ -34,14 +35,12 @@ export class ProjectOverviewService { related_counts: 'forks,view_only_links', }; - return this.jsonApiService - .get(`${environment.apiUrl}/nodes/${projectId}/`, params) - .pipe( - map((response) => ({ - project: ProjectOverviewMapper.fromGetProjectResponse(response.data), - meta: response.meta, - })) - ); + return this.jsonApiService.get(`${this.apiUrl}/nodes/${projectId}/`, params).pipe( + map((response) => ({ + project: ProjectOverviewMapper.fromGetProjectResponse(response.data), + meta: response.meta, + })) + ); } updateProjectPublicStatus(projectId: string, isPublic: boolean): Observable { @@ -55,7 +54,7 @@ export class ProjectOverviewService { }, }; - return this.jsonApiService.patch(`${environment.apiUrl}/nodes/${projectId}/`, payload); + return this.jsonApiService.patch(`${this.apiUrl}/nodes/${projectId}/`, payload); } forkResource(projectId: string, resourceType: string): Observable { @@ -65,7 +64,7 @@ export class ProjectOverviewService { }, }; - return this.jsonApiService.post(`${environment.apiUrl}/${resourceType}/${projectId}/forks/`, payload); + return this.jsonApiService.post(`${this.apiUrl}/${resourceType}/${projectId}/forks/`, payload); } duplicateProject(projectId: string, title: string): Observable { @@ -80,7 +79,7 @@ export class ProjectOverviewService { }, }; - return this.jsonApiService.post(`${environment.apiUrl}/nodes/`, payload); + return this.jsonApiService.post(`${this.apiUrl}/nodes/`, payload); } createComponent( @@ -116,11 +115,11 @@ export class ProjectOverviewService { params['affiliated_institutions'] = affiliatedInstitutions; } - return this.jsonApiService.post(`${environment.apiUrl}/nodes/${projectId}/children/`, payload, params); + return this.jsonApiService.post(`${this.apiUrl}/nodes/${projectId}/children/`, payload, params); } deleteComponent(componentId: string): Observable { - return this.jsonApiService.delete(`${environment.apiUrl}/nodes/${componentId}/`); + return this.jsonApiService.delete(`${this.apiUrl}/nodes/${componentId}/`); } getComponents(projectId: string): Observable { @@ -130,9 +129,7 @@ export class ProjectOverviewService { }; return this.jsonApiService - .get< - JsonApiResponse - >(`${environment.apiUrl}/nodes/${projectId}/children/`, params) + .get>(`${this.apiUrl}/nodes/${projectId}/children/`, params) .pipe(map((response) => response.data.map((item) => ComponentsMapper.fromGetComponentResponse(item)))); } } diff --git a/src/app/features/project/registrations/services/registrations.service.ts b/src/app/features/project/registrations/services/registrations.service.ts index b41f388e5..c222b575d 100644 --- a/src/app/features/project/registrations/services/registrations.service.ts +++ b/src/app/features/project/registrations/services/registrations.service.ts @@ -13,11 +13,12 @@ import { environment } from 'src/environments/environment'; }) export class RegistrationsService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getRegistrations(projectId: string): Observable> { const params: Record = { embed: 'contributors' }; - const url = `${environment.apiUrl}/nodes/${projectId}/linked_by_registrations/`; + const url = `${this.apiUrl}/nodes/${projectId}/linked_by_registrations/`; return this.jsonApiService.get>(url, params).pipe( map((response) => { diff --git a/src/app/features/project/settings/services/settings.service.ts b/src/app/features/project/settings/services/settings.service.ts index 85f121369..90cc2efde 100644 --- a/src/app/features/project/settings/services/settings.service.ts +++ b/src/app/features/project/settings/services/settings.service.ts @@ -28,19 +28,18 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class SettingsService { - private readonly baseUrl = environment.apiUrl; - private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getProjectSettings(nodeId: string): Observable { return this.jsonApiService - .get(`${this.baseUrl}/nodes/${nodeId}/settings/`) + .get(`${this.apiUrl}/nodes/${nodeId}/settings/`) .pipe(map((response) => SettingsMapper.fromResponse(response, nodeId))); } updateProjectSettings(model: ProjectSettingsData): Observable { return this.jsonApiService - .patch(`${this.baseUrl}/nodes/${model.id}/settings/`, { data: model }) + .patch(`${this.apiUrl}/nodes/${model.id}/settings/`, { data: model }) .pipe(map((response) => SettingsMapper.fromResponse(response, model.id))); } @@ -50,7 +49,7 @@ export class SettingsService { }; return this.jsonApiService - .get>(`${this.baseUrl}/subscriptions/`, params) + .get>(`${this.apiUrl}/subscriptions/`, params) .pipe( map((responses) => responses.data.map((response) => NotificationSubscriptionMapper.fromGetResponse(response))) ); @@ -60,7 +59,7 @@ export class SettingsService { const request = NotificationSubscriptionMapper.toUpdateRequest(id, frequency, false); return this.jsonApiService - .patch(`${this.baseUrl}/subscriptions/${id}/`, request) + .patch(`${this.apiUrl}/subscriptions/${id}/`, request) .pipe(map((response) => NotificationSubscriptionMapper.fromGetResponse(response))); } @@ -69,18 +68,18 @@ export class SettingsService { 'embed[]': ['affiliated_institutions', 'region'], }; return this.jsonApiService - .get(`${this.baseUrl}/nodes/${projectId}/`, params) + .get(`${this.apiUrl}/nodes/${projectId}/`, params) .pipe(map((response) => SettingsMapper.fromNodeResponse(response.data))); } updateProjectById(model: UpdateNodeRequestModel): Observable { return this.jsonApiService - .patch(`${this.baseUrl}/nodes/${model?.data?.id}/`, model) + .patch(`${this.apiUrl}/nodes/${model?.data?.id}/`, model) .pipe(map((response) => SettingsMapper.fromNodeResponse(response))); } deleteProject(projectId: string): Observable { - return this.jsonApiService.delete(`${this.baseUrl}/nodes/${projectId}/`); + return this.jsonApiService.delete(`${this.apiUrl}/nodes/${projectId}/`); } deleteInstitution(institutionId: string, projectId: string): Observable { @@ -93,6 +92,6 @@ export class SettingsService { ], }; - return this.jsonApiService.delete(`${this.baseUrl}/institutions/${institutionId}/relationships/nodes/`, data); + return this.jsonApiService.delete(`${this.apiUrl}/institutions/${institutionId}/relationships/nodes/`, data); } } diff --git a/src/app/features/registries/services/licenses.service.ts b/src/app/features/registries/services/licenses.service.ts index 50091bd4a..8d4652844 100644 --- a/src/app/features/registries/services/licenses.service.ts +++ b/src/app/features/registries/services/licenses.service.ts @@ -21,8 +21,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class LicensesService { - private apiUrl = environment.apiUrl; private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getLicenses(providerId: string): Observable { return this.jsonApiService @@ -31,11 +31,7 @@ export class LicensesService { 'page[size]': 100, }, }) - .pipe( - map((licenses) => { - return LicensesMapper.fromLicensesResponse(licenses); - }) - ); + .pipe(map((licenses) => LicensesMapper.fromLicensesResponse(licenses))); } updateLicense( diff --git a/src/app/features/registries/services/projects.service.ts b/src/app/features/registries/services/projects.service.ts index 457641c87..f33232e1f 100644 --- a/src/app/features/registries/services/projects.service.ts +++ b/src/app/features/registries/services/projects.service.ts @@ -14,8 +14,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class ProjectsService { - private apiUrl = environment.apiUrl; private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getProjects(): Observable { const params: Record = { diff --git a/src/app/features/registries/services/providers.service.ts b/src/app/features/registries/services/providers.service.ts index 88c02b1e5..978251eb0 100644 --- a/src/app/features/registries/services/providers.service.ts +++ b/src/app/features/registries/services/providers.service.ts @@ -17,8 +17,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class ProvidersService { - private apiUrl = environment.apiUrl; private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getProviderSchemas(providerId: string): Observable { return this.jsonApiService diff --git a/src/app/features/registries/services/registries.service.ts b/src/app/features/registries/services/registries.service.ts index 89db221f8..1cbff264e 100644 --- a/src/app/features/registries/services/registries.service.ts +++ b/src/app/features/registries/services/registries.service.ts @@ -31,8 +31,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class RegistriesService { - private apiUrl = environment.apiUrl; private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; createDraft( registrationSchemaId: string, diff --git a/src/app/features/registry/services/registry-components.service.ts b/src/app/features/registry/services/registry-components.service.ts index e81cc0d2b..65292f889 100644 --- a/src/app/features/registry/services/registry-components.service.ts +++ b/src/app/features/registry/services/registry-components.service.ts @@ -15,7 +15,7 @@ import { environment } from 'src/environments/environment'; }) export class RegistryComponentsService { private readonly jsonApiService = inject(JsonApiService); - private readonly apiUrl = environment.apiUrl; + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getRegistryComponents(registryId: string, page = 1, pageSize = 10): Observable { const params: Record = { diff --git a/src/app/features/registry/services/registry-links.service.ts b/src/app/features/registry/services/registry-links.service.ts index 5659d5855..4a4175be0 100644 --- a/src/app/features/registry/services/registry-links.service.ts +++ b/src/app/features/registry/services/registry-links.service.ts @@ -22,7 +22,7 @@ import { environment } from 'src/environments/environment'; }) export class RegistryLinksService { private readonly jsonApiService = inject(JsonApiService); - private readonly apiUrl = environment.apiUrl; + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getLinkedNodes(registryId: string, page = 1, pageSize = 10): Observable { const params: Record = { diff --git a/src/app/features/registry/services/registry-overview.service.ts b/src/app/features/registry/services/registry-overview.service.ts index 8465e7980..3d7b12a01 100644 --- a/src/app/features/registry/services/registry-overview.service.ts +++ b/src/app/features/registry/services/registry-overview.service.ts @@ -25,7 +25,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class RegistryOverviewService { - private jsonApiService = inject(JsonApiService); + private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getRegistrationById(id: string): Observable { const params = { @@ -43,7 +44,7 @@ export class RegistryOverviewService { }; return this.jsonApiService - .get(`${environment.apiUrl}/registrations/${id}/`, params) + .get(`${this.apiUrl}/registrations/${id}/`, params) .pipe(map((response) => ({ registry: MapRegistryOverview(response.data), meta: response.meta }))); } @@ -54,7 +55,7 @@ export class RegistryOverviewService { }; return this.jsonApiService - .get(`${environment.apiUrl}/registrations/${registryId}/subjects/`, params) + .get(`${this.apiUrl}/registrations/${registryId}/subjects/`, params) .pipe(map((response) => response.data.map((subject) => ({ id: subject.id, text: subject.attributes.text })))); } @@ -64,7 +65,7 @@ export class RegistryOverviewService { }; return this.jsonApiService - .get(`${environment.apiUrl}/registrations/${registryId}/institutions/`, params) + .get(`${this.apiUrl}/registrations/${registryId}/institutions/`, params) .pipe(map((response) => InstitutionsMapper.fromInstitutionsResponse(response))); } @@ -101,7 +102,7 @@ export class RegistryOverviewService { }; return this.jsonApiService - .patch(`${environment.apiUrl}/registrations/${registryId}`, payload) + .patch(`${this.apiUrl}/registrations/${registryId}`, payload) .pipe(map((response) => MapRegistryOverview(response))); } @@ -118,12 +119,12 @@ export class RegistryOverviewService { }; return this.jsonApiService - .patch(`${environment.apiUrl}/registrations/${registryId}`, payload) + .patch(`${this.apiUrl}/registrations/${registryId}`, payload) .pipe(map((response) => MapRegistryOverview(response))); } getRegistryReviewActions(id: string): Observable { - const baseUrl = `${environment.apiUrl}/registrations/${id}/actions/`; + const baseUrl = `${this.apiUrl}/registrations/${id}/actions/`; return this.jsonApiService .get(baseUrl) @@ -132,7 +133,7 @@ export class RegistryOverviewService { submitDecision(payload: ReviewActionPayload, isRevision: boolean): Observable { const path = isRevision ? 'schema_responses' : 'registrations'; - const baseUrl = `${environment.apiUrl}/${path}/${payload.targetId}/actions/`; + const baseUrl = `${this.apiUrl}/${path}/${payload.targetId}/actions/`; const actionType = isRevision ? 'schema_response_actions' : 'review_actions'; const targetType = isRevision ? 'schema-responses' : 'registrations'; diff --git a/src/app/features/registry/services/registry-resources.service.ts b/src/app/features/registry/services/registry-resources.service.ts index 112a73425..f2f49b837 100644 --- a/src/app/features/registry/services/registry-resources.service.ts +++ b/src/app/features/registry/services/registry-resources.service.ts @@ -18,7 +18,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class RegistryResourcesService { - private jsonApiService = inject(JsonApiService); + private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getResources(registryId: string): Observable { const params = { @@ -26,14 +27,14 @@ export class RegistryResourcesService { }; return this.jsonApiService - .get(`${environment.apiUrl}/registrations/${registryId}/resources/?page=1`, params) + .get(`${this.apiUrl}/registrations/${registryId}/resources/?page=1`, params) .pipe(map((response) => response.data.map((resource) => MapRegistryResource(resource)))); } addRegistryResource(registryId: string): Observable { const body = toAddResourceRequestBody(registryId); - return this.jsonApiService.post(`${environment.apiUrl}/resources/`, body).pipe( + return this.jsonApiService.post(`${this.apiUrl}/resources/`, body).pipe( map((response) => { return MapRegistryResource(response.data); }) @@ -44,7 +45,7 @@ export class RegistryResourcesService { const payload = MapAddResourceRequest(resourceId, resource); return this.jsonApiService - .patch(`${environment.apiUrl}/resources/${resourceId}/`, payload) + .patch(`${this.apiUrl}/resources/${resourceId}/`, payload) .pipe( map((response) => { return MapRegistryResource(response); @@ -56,7 +57,7 @@ export class RegistryResourcesService { const payload = MapAddResourceRequest(resourceId, resource); return this.jsonApiService - .patch(`${environment.apiUrl}/resources/${resourceId}/`, payload) + .patch(`${this.apiUrl}/resources/${resourceId}/`, payload) .pipe( map((response) => { return MapRegistryResource(response); @@ -65,12 +66,12 @@ export class RegistryResourcesService { } deleteResource(resourceId: string): Observable { - return this.jsonApiService.delete(`${environment.apiUrl}/resources/${resourceId}/`); + return this.jsonApiService.delete(`${this.apiUrl}/resources/${resourceId}/`); } updateResource(resourceId: string, resource: AddResource) { const payload = MapAddResourceRequest(resourceId, resource); - return this.jsonApiService.patch(`${environment.apiUrl}/resources/${resourceId}/`, payload); + return this.jsonApiService.patch(`${this.apiUrl}/resources/${resourceId}/`, payload); } } diff --git a/src/app/features/settings/account-settings/services/account-settings.service.ts b/src/app/features/settings/account-settings/services/account-settings.service.ts index 2ca71e3c4..a64e5aaa3 100644 --- a/src/app/features/settings/account-settings/services/account-settings.service.ts +++ b/src/app/features/settings/account-settings/services/account-settings.service.ts @@ -22,10 +22,11 @@ import { environment } from 'src/environments/environment'; }) export class AccountSettingsService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getRegions(): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/regions/`) + .get(`${this.apiUrl}/regions/`) .pipe(map((response) => MapRegions(response.data))); } @@ -47,7 +48,7 @@ export class AccountSettingsService { }; return this.jsonApiService - .patch(`${environment.apiUrl}/users/${userId}/`, body) + .patch(`${this.apiUrl}/users/${userId}/`, body) .pipe(map((user) => UserMapper.fromUserGetResponse(user))); } @@ -64,7 +65,7 @@ export class AccountSettingsService { }; return this.jsonApiService - .patch(`${environment.apiUrl}/users/${userId}/`, body) + .patch(`${this.apiUrl}/users/${userId}/`, body) .pipe(map((user) => UserMapper.fromUserGetResponse(user))); } @@ -79,7 +80,7 @@ export class AccountSettingsService { }, }; - return this.jsonApiService.post(`${environment.apiUrl}/users/me/settings/password/`, body); + return this.jsonApiService.post(`${this.apiUrl}/users/me/settings/password/`, body); } getExternalIdentities(): Observable { @@ -89,17 +90,17 @@ export class AccountSettingsService { }; return this.jsonApiService - .get(`${environment.apiUrl}/users/me/settings/identities/`, params) + .get(`${this.apiUrl}/users/me/settings/identities/`, params) .pipe(map((response) => MapExternalIdentities(response.data))); } deleteExternalIdentity(id: string): Observable { - return this.jsonApiService.delete(`${environment.apiUrl}/users/me/settings/identities/${id}/`); + return this.jsonApiService.delete(`${this.apiUrl}/users/me/settings/identities/${id}/`); } getSettings(): Observable { return this.jsonApiService - .get>(`${environment.apiUrl}/users/me/settings/`) + .get>(`${this.apiUrl}/users/me/settings/`) .pipe(map((response) => MapAccountSettings(response.data))); } @@ -113,7 +114,7 @@ export class AccountSettingsService { }; return this.jsonApiService - .patch(`${environment.apiUrl}/users/${userId}/settings`, body) + .patch(`${this.apiUrl}/users/${userId}/settings`, body) .pipe(map((response) => MapAccountSettings(response))); } } diff --git a/src/app/features/settings/developer-apps/services/developer-apps.service.ts b/src/app/features/settings/developer-apps/services/developer-apps.service.ts index 200e3a8fa..7f552f211 100644 --- a/src/app/features/settings/developer-apps/services/developer-apps.service.ts +++ b/src/app/features/settings/developer-apps/services/developer-apps.service.ts @@ -15,7 +15,7 @@ import { environment } from 'src/environments/environment'; }) export class DeveloperApplicationsService { private readonly jsonApiService = inject(JsonApiService); - private readonly baseUrl = `${environment.apiUrl}/applications/`; + private readonly baseUrl = `${environment.apiDomainUrl}/v2/applications/`; getApplications(): Observable { return this.jsonApiService diff --git a/src/app/features/settings/notifications/services/notification-subscription.service.ts b/src/app/features/settings/notifications/services/notification-subscription.service.ts index 576e1a775..494185463 100644 --- a/src/app/features/settings/notifications/services/notification-subscription.service.ts +++ b/src/app/features/settings/notifications/services/notification-subscription.service.ts @@ -18,7 +18,7 @@ import { environment } from 'src/environments/environment'; }) export class NotificationSubscriptionService { private readonly jsonApiService = inject(JsonApiService); - private readonly baseUrl = `${environment.apiUrl}/subscriptions/`; + private readonly baseUrl = `${environment.apiDomainUrl}/v2/subscriptions/`; getAllGlobalNotificationSubscriptions(): Observable { const params: Record = { diff --git a/src/app/features/settings/tokens/services/tokens.service.spec.ts b/src/app/features/settings/tokens/services/tokens.service.spec.ts index 7d14565e0..d8aa7b31b 100644 --- a/src/app/features/settings/tokens/services/tokens.service.spec.ts +++ b/src/app/features/settings/tokens/services/tokens.service.spec.ts @@ -42,7 +42,7 @@ describe('TokensService', () => { jsonApiServiceMock.get.mockReturnValue(of(mockResponse)); service.getScopes().subscribe((result) => { - expect(jsonApiServiceMock.get).toHaveBeenCalledWith(`${environment.apiUrl}/scopes/`); + expect(jsonApiServiceMock.get).toHaveBeenCalledWith(`${environment.apiDomainUrl}/v2/scopes/`); expect(result).toBe(mappedScopes); done(); }); @@ -75,7 +75,7 @@ describe('TokensService', () => { jsonApiServiceMock.get.mockReturnValue(of(mockApiResponse)); service.getTokenById(tokenId).subscribe((token) => { - expect(jsonApiServiceMock.get).toHaveBeenCalledWith(`${environment.apiUrl}/tokens/${tokenId}/`); + expect(jsonApiServiceMock.get).toHaveBeenCalledWith(`${environment.apiDomainUrl}/v2/tokens/${tokenId}/`); expect(token).toBe(mappedToken); done(); }); @@ -94,7 +94,7 @@ describe('TokensService', () => { jsonApiServiceMock.post.mockReturnValue(of(apiResponse)); service.createToken(name, scopes).subscribe((token) => { - expect(jsonApiServiceMock.post).toHaveBeenCalledWith(`${environment.apiUrl}/tokens/`, requestBody); + expect(jsonApiServiceMock.post).toHaveBeenCalledWith(`${environment.apiDomainUrl}/v2/tokens/`, requestBody); expect(token).toEqual(mapped); done(); }); @@ -114,7 +114,10 @@ describe('TokensService', () => { jsonApiServiceMock.patch.mockReturnValue(of(apiResponse)); service.updateToken(tokenId, name, scopes).subscribe((token) => { - expect(jsonApiServiceMock.patch).toHaveBeenCalledWith(`${environment.apiUrl}/tokens/${tokenId}/`, requestBody); + expect(jsonApiServiceMock.patch).toHaveBeenCalledWith( + `${environment.apiDomainUrl}/v2/tokens/${tokenId}/`, + requestBody + ); expect(token).toEqual(mapped); done(); }); @@ -125,7 +128,7 @@ describe('TokensService', () => { jsonApiServiceMock.delete.mockReturnValue(of(void 0)); service.deleteToken(tokenId).subscribe((result) => { - expect(jsonApiServiceMock.delete).toHaveBeenCalledWith(`${environment.apiUrl}/tokens/${tokenId}/`); + expect(jsonApiServiceMock.delete).toHaveBeenCalledWith(`${environment.apiDomainUrl}/v2/tokens/${tokenId}/`); expect(result).toBeUndefined(); done(); }); diff --git a/src/app/features/settings/tokens/services/tokens.service.ts b/src/app/features/settings/tokens/services/tokens.service.ts index 2735c5bad..90ff66a49 100644 --- a/src/app/features/settings/tokens/services/tokens.service.ts +++ b/src/app/features/settings/tokens/services/tokens.service.ts @@ -16,22 +16,23 @@ import { environment } from 'src/environments/environment'; }) export class TokensService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getScopes(): Observable { return this.jsonApiService - .get>(`${environment.apiUrl}/scopes/`) + .get>(`${this.apiUrl}/scopes/`) .pipe(map((responses) => ScopeMapper.fromResponse(responses.data))); } getTokens(): Observable { return this.jsonApiService - .get>(`${environment.apiUrl}/tokens/`) + .get>(`${this.apiUrl}/tokens/`) .pipe(map((responses) => responses.data.map((response) => TokenMapper.fromGetResponse(response)))); } getTokenById(tokenId: string): Observable { return this.jsonApiService - .get>(`${environment.apiUrl}/tokens/${tokenId}/`) + .get>(`${this.apiUrl}/tokens/${tokenId}/`) .pipe(map((response) => TokenMapper.fromGetResponse(response.data))); } @@ -39,7 +40,7 @@ export class TokensService { const request = TokenMapper.toRequest(name, scopes); return this.jsonApiService - .post>(environment.apiUrl + '/tokens/', request) + .post>(environment.apiDomainUrl + '/tokens/', request) .pipe(map((response) => TokenMapper.fromGetResponse(response.data))); } @@ -47,11 +48,11 @@ export class TokensService { const request = TokenMapper.toRequest(name, scopes); return this.jsonApiService - .patch(`${environment.apiUrl}/tokens/${tokenId}/`, request) + .patch(`${this.apiUrl}/tokens/${tokenId}/`, request) .pipe(map((response) => TokenMapper.fromGetResponse(response))); } deleteToken(tokenId: string): Observable { - return this.jsonApiService.delete(`${environment.apiUrl}/tokens/${tokenId}/`); + return this.jsonApiService.delete(`${this.apiUrl}/tokens/${tokenId}/`); } } diff --git a/src/app/shared/services/activity-logs/activity-logs.service.ts b/src/app/shared/services/activity-logs/activity-logs.service.ts index a8f847498..a36b4dd2c 100644 --- a/src/app/shared/services/activity-logs/activity-logs.service.ts +++ b/src/app/shared/services/activity-logs/activity-logs.service.ts @@ -20,9 +20,10 @@ import { environment } from 'src/environments/environment'; }) export class ActivityLogsService { private jsonApiService = inject(JsonApiService); + private apiUrl = `${environment.apiDomainUrl}/v2`; fetchLogs(projectId: string, page = '1', pageSize: string): Observable> { - const url = `${environment.apiUrl}/nodes/${projectId}/logs/`; + const url = `${this.apiUrl}/nodes/${projectId}/logs/`; const params: Record = { 'embed[]': ['original_node', 'user', 'linked_node', 'linked_registration', 'template_node', 'group'], page, diff --git a/src/app/shared/services/addons/addon-form.service.ts b/src/app/shared/services/addons/addon-form.service.ts index 365aba3db..d4ad7f373 100644 --- a/src/app/shared/services/addons/addon-form.service.ts +++ b/src/app/shared/services/addons/addon-form.service.ts @@ -16,7 +16,7 @@ import { providedIn: 'root', }) export class AddonFormService { - protected formBuilder: FormBuilder = inject(FormBuilder); + formBuilder: FormBuilder = inject(FormBuilder); initializeForm(addon: AddonModel | AuthorizedAccountModel): FormGroup { if (!addon) { diff --git a/src/app/shared/services/addons/addons.service.ts b/src/app/shared/services/addons/addons.service.ts index 8246587e5..4e0d4baf1 100644 --- a/src/app/shared/services/addons/addons.service.ts +++ b/src/app/shared/services/addons/addons.service.ts @@ -49,6 +49,7 @@ export class AddonsService { * This service handles standardized JSON:API request and response formatting. */ private jsonApiService = inject(JsonApiService); + private apiUrl = environment.addonsApiUrl; /** * Signal holding the current authenticated user from the global NGXS store. @@ -65,9 +66,7 @@ export class AddonsService { */ getAddons(addonType: string): Observable { return this.jsonApiService - .get< - JsonApiResponse - >(`${environment.addonsApiUrl}/external-${addonType}-services`) + .get>(`${this.apiUrl}/external-${addonType}-services`) .pipe(map((response) => response.data.map((item) => AddonMapper.fromResponse(item)))); } @@ -76,36 +75,29 @@ export class AddonsService { if (!currentUser) throw new Error('Current user not found'); const userUri = `${environment.webUrl}/${currentUser.id}`; - const params = { - 'filter[user_uri]': userUri, - }; + const params = { 'filter[user_uri]': userUri }; return this.jsonApiService - .get>(environment.addonsApiUrl + '/user-references/', params) + .get>(this.apiUrl + '/user-references/', params) .pipe(map((response) => response.data)); } getAddonsResourceReference(resourceId: string): Observable { const resourceUri = `${environment.webUrl}/${resourceId}`; - const params = { - 'filter[resource_uri]': resourceUri, - }; + const params = { 'filter[resource_uri]': resourceUri }; return this.jsonApiService - .get< - JsonApiResponse - >(environment.addonsApiUrl + '/resource-references/', params) + .get>(this.apiUrl + '/resource-references/', params) .pipe(map((response) => response.data)); } getAuthorizedStorageAddons(addonType: string, referenceId: string): Observable { - const params = { - [`fields[external-${addonType}-services]`]: 'external_service_name', - }; + const params = { [`fields[external-${addonType}-services]`]: 'external_service_name' }; + return this.jsonApiService .get< JsonApiResponse - >(`${environment.addonsApiUrl}/user-references/${referenceId}/authorized_${addonType}_accounts/?include=external-${addonType}-service`, params) + >(`${this.apiUrl}/user-references/${referenceId}/authorized_${addonType}_accounts/?include=external-${addonType}-service`, params) .pipe( map((response) => response.data.map((item) => AddonMapper.fromAuthorizedAddonResponse(item, response.included))) ); @@ -113,23 +105,14 @@ export class AddonsService { getAuthorizedStorageOauthToken(accountId: string): Observable { return this.jsonApiService - .patch( - `${environment.addonsApiUrl}/authorized-storage-accounts/${accountId}`, - { - data: { - id: accountId, - type: 'authorized-storage-accounts', - attributes: { - serialize_oauth_token: 'true', - }, - }, - } - ) - .pipe( - map((response) => { - return AddonMapper.fromAuthorizedAddonResponse(response as AuthorizedAddonGetResponseJsonApi); - }) - ); + .patch(`${this.apiUrl}/authorized-storage-accounts/${accountId}`, { + data: { + id: accountId, + type: 'authorized-storage-accounts', + attributes: { serialize_oauth_token: 'true' }, + }, + }) + .pipe(map((response) => AddonMapper.fromAuthorizedAddonResponse(response as AuthorizedAddonGetResponseJsonApi))); } /** @@ -144,12 +127,8 @@ export class AddonsService { return this.jsonApiService .get< JsonApiResponse - >(`${environment.addonsApiUrl}/resource-references/${referenceId}/configured_${addonType}_addons/`) - .pipe( - map((response) => { - return response.data.map((item) => AddonMapper.fromConfiguredAddonResponse(item)); - }) - ); + >(`${this.apiUrl}/resource-references/${referenceId}/configured_${addonType}_addons/`) + .pipe(map((response) => response.data.map((item) => AddonMapper.fromConfiguredAddonResponse(item)))); } createAuthorizedAddon( @@ -159,7 +138,7 @@ export class AddonsService { return this.jsonApiService .post< JsonApiResponse - >(`${environment.addonsApiUrl}/authorized-${addonType}-accounts/`, addonRequestPayload) + >(`${this.apiUrl}/authorized-${addonType}-accounts/`, addonRequestPayload) .pipe(map((response) => response.data)); } @@ -169,7 +148,7 @@ export class AddonsService { addonId: string ): Observable { return this.jsonApiService.patch( - `${environment.addonsApiUrl}/authorized-${addonType}-accounts/${addonId}/`, + `${this.apiUrl}/authorized-${addonType}-accounts/${addonId}/`, addonRequestPayload ); } @@ -181,7 +160,7 @@ export class AddonsService { return this.jsonApiService .post< JsonApiResponse - >(`${environment.addonsApiUrl}/configured-${addonType}-addons/`, addonRequestPayload) + >(`${this.apiUrl}/configured-${addonType}-addons/`, addonRequestPayload) .pipe(map((response) => response.data)); } @@ -191,7 +170,7 @@ export class AddonsService { addonId: string ): Observable { return this.jsonApiService.patch( - `${environment.addonsApiUrl}/configured-${addonType}-addons/${addonId}/`, + `${this.apiUrl}/configured-${addonType}-addons/${addonId}/`, addonRequestPayload ); } @@ -202,19 +181,15 @@ export class AddonsService { return this.jsonApiService .post< JsonApiResponse - >(`${environment.addonsApiUrl}/addon-operation-invocations/`, invocationRequestPayload) - .pipe( - map((response) => { - return AddonMapper.fromOperationInvocationResponse(response.data); - }) - ); + >(`${this.apiUrl}/addon-operation-invocations/`, invocationRequestPayload) + .pipe(map((response) => AddonMapper.fromOperationInvocationResponse(response.data))); } deleteAuthorizedAddon(id: string, addonType: string): Observable { - return this.jsonApiService.delete(`${environment.addonsApiUrl}/authorized-${addonType}-accounts/${id}/`); + return this.jsonApiService.delete(`${this.apiUrl}/authorized-${addonType}-accounts/${id}/`); } deleteConfiguredAddon(id: string, addonType: string): Observable { - return this.jsonApiService.delete(`${environment.addonsApiUrl}/${addonType}/${id}/`); + return this.jsonApiService.delete(`${this.apiUrl}/${addonType}/${id}/`); } } diff --git a/src/app/shared/services/bookmarks.service.ts b/src/app/shared/services/bookmarks.service.ts index e4f03586e..90bba2d84 100644 --- a/src/app/shared/services/bookmarks.service.ts +++ b/src/app/shared/services/bookmarks.service.ts @@ -13,7 +13,9 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class BookmarksService { - private jsonApiService = inject(JsonApiService); + private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; + private readonly urlMap = new Map([ [ResourceType.Project, 'linked_nodes'], [ResourceType.Registration, 'linked_registrations'], @@ -29,7 +31,7 @@ export class BookmarksService { 'fields[collections]': 'title,bookmarks', }; - return this.jsonApiService.get(environment.apiUrl + '/collections/', params).pipe( + return this.jsonApiService.get(`${this.apiUrl}/collections/`, params).pipe( map((response: SparseCollectionsResponseJsonApi) => { const bookmarksCollection = response.data.find( (collection) => collection.attributes.title === 'Bookmarks' && collection.attributes.bookmarks @@ -40,14 +42,14 @@ export class BookmarksService { } addResourceToBookmarks(bookmarksId: string, resourceId: string, resourceType: ResourceType): Observable { - const url = `${environment.apiUrl}/collections/${bookmarksId}/relationships/${this.urlMap.get(resourceType)}/`; + const url = `${this.apiUrl}/collections/${bookmarksId}/relationships/${this.urlMap.get(resourceType)}/`; const payload = { data: [{ type: this.resourceMap.get(resourceType), id: resourceId }] }; return this.jsonApiService.post(url, payload); } removeResourceFromBookmarks(bookmarksId: string, resourceId: string, resourceType: ResourceType): Observable { - const url = `${environment.apiUrl}/collections/${bookmarksId}/relationships/${this.urlMap.get(resourceType)}/`; + const url = `${this.apiUrl}/collections/${bookmarksId}/relationships/${this.urlMap.get(resourceType)}/`; const payload = { data: [{ type: this.resourceMap.get(resourceType), id: resourceId }] }; return this.jsonApiService.delete(url, payload); diff --git a/src/app/shared/services/citations.service.ts b/src/app/shared/services/citations.service.ts index 4abf218ee..a729f308f 100644 --- a/src/app/shared/services/citations.service.ts +++ b/src/app/shared/services/citations.service.ts @@ -25,6 +25,7 @@ import { environment } from 'src/environments/environment'; }) export class CitationsService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; private readonly urlMap = new Map([[ResourceType.Preprint, 'preprints']]); @@ -40,20 +41,17 @@ export class CitationsService { } fetchCitationStyles(searchQuery?: string): Observable { - const baseUrl = environment.apiUrl; - const params = new HttpParams().set('filter[title,short_title]', searchQuery || '').set('page[size]', '100'); return this.jsonApiService - .get>(`${baseUrl}/citations/styles/`, { params }) + .get>(`${this.apiUrl}/citations/styles/`, { params }) .pipe(map((response) => CitationsMapper.fromGetCitationStylesResponse(response.data))); } updateCustomCitation(payload: CustomCitationPayload): Observable { - const baseUrl = environment.apiUrl; const citationData = CitationsMapper.toUpdateCustomCitationRequest(payload); - return this.jsonApiService.patch(`${baseUrl}/${payload.type}/${payload.id}/`, citationData); + return this.jsonApiService.patch(`${this.apiUrl}/${payload.type}/${payload.id}/`, citationData); } fetchStyledCitation( @@ -69,7 +67,6 @@ export class CitationsService { } private getBaseCitationUrl(resourceType: ResourceType | string, resourceId: string): string { - const baseUrl = `${environment.apiUrl}`; let resourceTypeString; if (typeof resourceType === 'string') { @@ -78,6 +75,6 @@ export class CitationsService { resourceTypeString = this.urlMap.get(resourceType); } - return `${baseUrl}/${resourceTypeString}/${resourceId}/citation`; + return `${this.apiUrl}/${resourceTypeString}/${resourceId}/citation`; } } diff --git a/src/app/shared/services/collections.service.ts b/src/app/shared/services/collections.service.ts index 809d56e74..bd75d9d01 100644 --- a/src/app/shared/services/collections.service.ts +++ b/src/app/shared/services/collections.service.ts @@ -41,12 +41,11 @@ import { environment } from 'src/environments/environment'; }) export class CollectionsService { private jsonApiService = inject(JsonApiService); - private actions = createDispatchMap({ - setTotalSubmissions: SetTotalSubmissions, - }); + private apiUrl = `${environment.apiDomainUrl}/v2`; + private actions = createDispatchMap({ setTotalSubmissions: SetTotalSubmissions }); getCollectionProvider(collectionName: string): Observable { - const url = `${environment.apiUrl}/providers/collections/${collectionName}/?embed=brand`; + const url = `${this.apiUrl}/providers/collections/${collectionName}/?embed=brand`; return this.jsonApiService .get>(url) @@ -54,7 +53,7 @@ export class CollectionsService { } getCollectionDetails(collectionId: string): Observable { - const url = `${environment.apiUrl}/collections/${collectionId}/`; + const url = `${this.apiUrl}/collections/${collectionId}/`; return this.jsonApiService .get(url) @@ -68,7 +67,7 @@ export class CollectionsService { page = '1', sortBy: string ): Observable { - const url = `${environment.apiUrl}/search/collections/`; + const url = `${this.apiUrl}/search/collections/`; const params: Record = { page, }; @@ -130,15 +129,13 @@ export class CollectionsService { return this.jsonApiService .get< ResponseJsonApi - >(`${environment.apiUrl}/collections/${collectionId}/collection_submissions/`, params) + >(`${this.apiUrl}/collections/${collectionId}/collection_submissions/`, params) .pipe(map((response) => CollectionsMapper.fromGetCollectionSubmissionsResponse(response))); } fetchProjectCollections(projectId: string): Observable { return this.jsonApiService - .get< - JsonApiResponse - >(`${environment.apiUrl}/nodes/${projectId}/collections/`) + .get>(`${this.apiUrl}/nodes/${projectId}/collections/`) .pipe( map((response) => response.data.map((collection) => CollectionsMapper.fromGetCollectionDetailsResponse(collection)) @@ -155,7 +152,7 @@ export class CollectionsService { return this.jsonApiService .get< JsonApiResponse - >(`${environment.apiUrl}/collections/${collectionId}/collection_submissions/`, params) + >(`${this.apiUrl}/collections/${collectionId}/collection_submissions/`, params) .pipe(map((response) => CollectionsMapper.fromCurrentSubmissionResponse(response.data[0]))); } @@ -170,7 +167,7 @@ export class CollectionsService { return this.jsonApiService .get< JsonApiResponse - >(`${environment.apiUrl}/collection_submissions/${projectId}-${collectionId}/actions/?sort=-date_modified`, params) + >(`${this.apiUrl}/collection_submissions/${projectId}-${collectionId}/actions/?sort=-date_modified`, params) .pipe(map((response) => CollectionsMapper.fromGetCollectionSubmissionsActionsResponse(response.data))); } @@ -197,7 +194,7 @@ export class CollectionsService { return this.jsonApiService.post< ReviewActionPayloadJsonApi - >(`${environment.apiUrl}/collection_submission_actions/`, params); + >(`${this.apiUrl}/collection_submission_actions/`, params); } private getCollectionContributors(contributorsUrl: string): Observable { @@ -227,7 +224,7 @@ export class CollectionsService { return this.jsonApiService .get< ResponseJsonApi - >(`${environment.apiUrl}/collections/${providerId}/collection_submissions/`, params) + >(`${this.apiUrl}/collections/${providerId}/collection_submissions/`, params) .pipe(map((response) => CollectionsMapper.fromGetCollectionSubmissionsResponse(response))); } } diff --git a/src/app/shared/services/contributors.service.ts b/src/app/shared/services/contributors.service.ts index 88bd13327..3f491113d 100644 --- a/src/app/shared/services/contributors.service.ts +++ b/src/app/shared/services/contributors.service.ts @@ -23,6 +23,7 @@ import { environment } from 'src/environments/environment'; }) export class ContributorsService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; private readonly urlMap = new Map([ [ResourceType.Project, 'nodes'], @@ -32,14 +33,13 @@ export class ContributorsService { ]); private getBaseUrl(resourceType: ResourceType, resourceId: string): string { - const baseUrl = `${environment.apiUrl}`; const resourcePath = this.urlMap.get(resourceType); if (!resourcePath) { throw new Error(`Unsupported resource type: ${resourceType}`); } - return `${baseUrl}/${resourcePath}/${resourceId}/contributors`; + return `${this.apiUrl}/${resourcePath}/${resourceId}/contributors`; } getAllContributors(resourceType: ResourceType, resourceId: string): Observable { @@ -51,7 +51,7 @@ export class ContributorsService { } searchUsers(value: string, page = 1): Observable> { - const baseUrl = `${environment.apiUrl}/users/?filter[full_name]=${value}&page=${page}`; + const baseUrl = `${this.apiUrl}/users/?filter[full_name]=${value}&page=${page}`; return this.jsonApiService .get>(baseUrl) diff --git a/src/app/shared/services/duplicates.service.ts b/src/app/shared/services/duplicates.service.ts index 2e74271e4..fcf381446 100644 --- a/src/app/shared/services/duplicates.service.ts +++ b/src/app/shared/services/duplicates.service.ts @@ -15,6 +15,7 @@ import { environment } from 'src/environments/environment'; }) export class DuplicatesService { private jsonApiService = inject(JsonApiService); + private apiUrl = `${environment.apiDomainUrl}/v2`; fetchAllDuplicates( resourceId: string, @@ -36,7 +37,7 @@ export class DuplicatesService { } return this.jsonApiService - .get>(`${environment.apiUrl}/${resourceType}/${resourceId}/forks/`, params) + .get>(`${this.apiUrl}/${resourceType}/${resourceId}/forks/`, params) .pipe(map((res) => DuplicatesMapper.fromDuplicatesJsonApiResponse(res))); } } diff --git a/src/app/shared/services/files.service.ts b/src/app/shared/services/files.service.ts index 9c195db49..205faef92 100644 --- a/src/app/shared/services/files.service.ts +++ b/src/app/shared/services/files.service.ts @@ -51,6 +51,8 @@ import { environment } from 'src/environments/environment'; export class FilesService { readonly jsonApiService = inject(JsonApiService); readonly toastService = inject(ToastService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; + filesFields = 'name,guid,kind,extra,size,path,materialized_path,date_modified,parent_folder,files'; private readonly urlMap = new Map([ @@ -172,7 +174,7 @@ export class FilesService { getFileTarget(fileGuid: string): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/files/${fileGuid}/?embed=target`) + .get(`${this.apiUrl}/files/${fileGuid}/?embed=target`) .pipe(map((response) => MapFile(response.data))); } @@ -182,13 +184,13 @@ export class FilesService { }; return this.jsonApiService - .get(`${environment.apiUrl}/files/${id}/`, params) + .get(`${this.apiUrl}/files/${id}/`, params) .pipe(map((response) => MapFile(response.data))); } getFileById(fileGuid: string): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/files/${fileGuid}/`) + .get(`${this.apiUrl}/files/${fileGuid}/`) .pipe(map((response) => MapFile(response.data))); } @@ -199,13 +201,13 @@ export class FilesService { }; return this.jsonApiService - .get(`${environment.apiUrl}/files/${fileGuid}/versions/`, params) + .get(`${this.apiUrl}/files/${fileGuid}/versions/`, params) .pipe(map((response) => MapFileVersions(response))); } getFileMetadata(fileGuid: string): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/custom_file_metadata_records/${fileGuid}/`) + .get(`${this.apiUrl}/custom_file_metadata_records/${fileGuid}/`) .pipe(map((response) => MapFileCustomMetadata(response.data))); } @@ -213,15 +215,12 @@ export class FilesService { const params = { 'fields[nodes]': 'title,description,date_created,date_modified', }; - return this.jsonApiService.get( - `${environment.apiUrl}/${resourceType}/${resourceId}/`, - params - ); + return this.jsonApiService.get(`${this.apiUrl}/${resourceType}/${resourceId}/`, params); } getCustomMetadata(resourceId: string): Observable { return this.jsonApiService.get( - `${environment.apiUrl}/guids/${resourceId}/?embed=custom_metadata&resolve=false` + `${this.apiUrl}/guids/${resourceId}/?embed=custom_metadata&resolve=false` ); } @@ -229,7 +228,7 @@ export class FilesService { return this.jsonApiService .get< JsonApiResponse - >(`${environment.apiUrl}/${resourceType}/${resourceId}/bibliographic_contributors/`) + >(`${this.apiUrl}/${resourceType}/${resourceId}/bibliographic_contributors/`) .pipe(map((response) => ContributorsMapper.fromResponse(response.data))); } @@ -245,7 +244,7 @@ export class FilesService { return this.jsonApiService .patch< ApiData - >(`${environment.apiUrl}/custom_file_metadata_records/${fileGuid}/`, payload) + >(`${this.apiUrl}/custom_file_metadata_records/${fileGuid}/`, payload) .pipe(map((response) => MapFileCustomMetadata(response))); } @@ -272,7 +271,7 @@ export class FilesService { return this.jsonApiService .patch< ApiData - >(`${environment.apiUrl}/files/${fileGuid}/`, payload) + >(`${this.apiUrl}/files/${fileGuid}/`, payload) .pipe(map((response) => MapFile(response))); } @@ -284,6 +283,7 @@ export class FilesService { provider, resource: resourceId, }; + return this.jsonApiService .post< JsonApiResponse, null> @@ -299,7 +299,7 @@ export class FilesService { return this.jsonApiService .get< JsonApiResponse[], null> - >(`${environment.addonsV1Url}/resource-references`, params) + >(`${environment.addonsApiUrl}/resource-references`, params) .pipe(map((response) => response.data?.[0]?.links?.self ?? '')); } diff --git a/src/app/shared/services/global-search.service.ts b/src/app/shared/services/global-search.service.ts index 6d4cd896f..a1e391fad 100644 --- a/src/app/shared/services/global-search.service.ts +++ b/src/app/shared/services/global-search.service.ts @@ -25,25 +25,19 @@ export class GlobalSearchService { getResources(params: Record): Observable { return this.jsonApiService - .get(`${environment.shareDomainUrl}/index-card-search`, params) - .pipe( - map((response) => { - return this.handleResourcesRawResponse(response); - }) - ); + .get(`${environment.shareTroveUrl}/index-card-search`, params) + .pipe(map((response) => this.handleResourcesRawResponse(response))); } getResourcesByLink(link: string): Observable { - return this.jsonApiService.get(link).pipe( - map((response) => { - return this.handleResourcesRawResponse(response); - }) - ); + return this.jsonApiService + .get(link) + .pipe(map((response) => this.handleResourcesRawResponse(response))); } getFilterOptions(params: Record): Observable<{ options: SelectOption[]; nextUrl?: string }> { return this.jsonApiService - .get(`${environment.shareDomainUrl}/index-value-search`, params) + .get(`${environment.shareTroveUrl}/index-value-search`, params) .pipe(map((response) => this.handleFilterOptionsRawResponse(response))); } diff --git a/src/app/shared/services/institutions.service.ts b/src/app/shared/services/institutions.service.ts index d3cec04a1..b75a762bb 100644 --- a/src/app/shared/services/institutions.service.ts +++ b/src/app/shared/services/institutions.service.ts @@ -21,6 +21,7 @@ import { environment } from 'src/environments/environment'; }) export class InstitutionsService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; private readonly urlMap = new Map([ [ResourceType.Preprint, 'preprints'], [ResourceType.Agent, 'users'], @@ -44,12 +45,12 @@ export class InstitutionsService { } return this.jsonApiService - .get(`${environment.apiUrl}/institutions/`, params) + .get(`${this.apiUrl}/institutions/`, params) .pipe(map((response) => InstitutionsMapper.fromResponseWithMeta(response))); } getUserInstitutions(): Observable { - const url = `${environment.apiUrl}/users/me/institutions/`; + const url = `${this.apiUrl}/users/me/institutions/`; return this.jsonApiService .get(url) @@ -58,7 +59,7 @@ export class InstitutionsService { getInstitutionById(institutionId: string): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/institutions/${institutionId}/`) + .get(`${this.apiUrl}/institutions/${institutionId}/`) .pipe(map((response) => InstitutionsMapper.fromInstitutionData(response.data))); } @@ -66,11 +67,12 @@ export class InstitutionsService { const payload = { data: [{ id: id, type: 'institutions' }], }; - return this.jsonApiService.delete(`${environment.apiUrl}/users/${userId}/relationships/institutions/`, payload); + + return this.jsonApiService.delete(`${this.apiUrl}/users/${userId}/relationships/institutions/`, payload); } getResourceInstitutions(resourceId: string, resourceType: ResourceType): Observable { - const url = `${environment.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/institutions/`; + const url = `${this.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/institutions/`; return this.jsonApiService .get(url) @@ -82,7 +84,7 @@ export class InstitutionsService { resourceType: ResourceType, institutions: Institution[] ): Observable { - const baseUrl = `${environment.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/relationships/institutions/`; + const baseUrl = `${this.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/relationships/institutions/`; const payload = { data: institutions.map((item) => ({ id: item.id, type: 'institutions' })), }; diff --git a/src/app/shared/services/licenses.service.ts b/src/app/shared/services/licenses.service.ts index b17f176e2..50d0e3c39 100644 --- a/src/app/shared/services/licenses.service.ts +++ b/src/app/shared/services/licenses.service.ts @@ -13,7 +13,7 @@ import { environment } from 'src/environments/environment'; }) export class LicensesService { private readonly http = inject(HttpClient); - private readonly baseUrl = environment.apiUrl; + private readonly baseUrl = environment.apiDomainUrl; getAllLicenses(): Observable { return this.http diff --git a/src/app/shared/services/my-resources.service.ts b/src/app/shared/services/my-resources.service.ts index a8bd35b3f..a638c19b3 100644 --- a/src/app/shared/services/my-resources.service.ts +++ b/src/app/shared/services/my-resources.service.ts @@ -30,6 +30,7 @@ export class MyResourcesService { }; private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; private buildCommonParams( filters?: MyResourcesSearchFilters, @@ -88,11 +89,9 @@ export class MyResourcesService { let url; if (searchMode === ResourceSearchMode.All) { - url = environment.apiUrl + '/' + endpoint + '/'; + url = `${this.apiUrl}/${endpoint}/`; } else { - url = endpoint.startsWith('collections/') - ? environment.apiUrl + '/' + endpoint - : environment.apiUrl + '/users/me/' + endpoint; + url = endpoint.startsWith('collections/') ? `${this.apiUrl}/${endpoint}` : `${this.apiUrl}/users/me/${endpoint}`; } return this.jsonApiService.get(url, params).pipe( @@ -204,7 +203,7 @@ export class MyResourcesService { }; return this.jsonApiService - .post>(`${environment.apiUrl}/nodes/`, payload, params) + .post>(`${this.apiUrl}/nodes/`, payload, params) .pipe(map((response) => MyResourcesMapper.fromResponse(response.data))); } } diff --git a/src/app/shared/services/node-links.service.ts b/src/app/shared/services/node-links.service.ts index b4e895474..54bdb320d 100644 --- a/src/app/shared/services/node-links.service.ts +++ b/src/app/shared/services/node-links.service.ts @@ -14,7 +14,8 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class NodeLinksService { - jsonApiService = inject(JsonApiService); + private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; createNodeLink( currentProjectId: string, @@ -30,7 +31,7 @@ export class NodeLinksService { }; return this.jsonApiService.post>( - `${environment.apiUrl}/nodes/${currentProjectId}/relationships/linked_${resource.type}/`, + `${this.apiUrl}/nodes/${currentProjectId}/relationships/linked_${resource.type}/`, payload ); } @@ -46,7 +47,7 @@ export class NodeLinksService { }; return this.jsonApiService.delete( - `${environment.apiUrl}/nodes/${projectId}/relationships/linked_${resource.type}/`, + `${this.apiUrl}/nodes/${projectId}/relationships/linked_${resource.type}/`, payload ); } @@ -60,12 +61,8 @@ export class NodeLinksService { return this.jsonApiService .get< JsonApiResponse - >(`${environment.apiUrl}/nodes/${projectId}/linked_nodes/`, params) - .pipe( - map((response) => { - return response.data.map((item) => ComponentsMapper.fromGetComponentResponse(item)); - }) - ); + >(`${this.apiUrl}/nodes/${projectId}/linked_nodes/`, params) + .pipe(map((response) => response.data.map((item) => ComponentsMapper.fromGetComponentResponse(item)))); } fetchLinkedRegistrations(projectId: string): Observable { @@ -77,11 +74,7 @@ export class NodeLinksService { return this.jsonApiService .get< JsonApiResponse - >(`${environment.apiUrl}/nodes/${projectId}/linked_registrations/`, params) - .pipe( - map((response) => { - return response.data.map((item) => ComponentsMapper.fromGetComponentResponse(item)); - }) - ); + >(`${this.apiUrl}/nodes/${projectId}/linked_registrations/`, params) + .pipe(map((response) => response.data.map((item) => ComponentsMapper.fromGetComponentResponse(item)))); } } diff --git a/src/app/shared/services/projects.service.ts b/src/app/shared/services/projects.service.ts index 96d3e6249..ae135a51a 100644 --- a/src/app/shared/services/projects.service.ts +++ b/src/app/shared/services/projects.service.ts @@ -14,10 +14,11 @@ import { environment } from 'src/environments/environment'; }) export class ProjectsService { private jsonApiService = inject(JsonApiService); + private apiUrl = `${environment.apiDomainUrl}/v2`; fetchProjects(userId: string, params?: Record): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/users/${userId}/nodes/`, params) + .get(`${this.apiUrl}/users/${userId}/nodes/`, params) .pipe(map((response) => ProjectsMapper.fromGetAllProjectsResponse(response))); } @@ -25,13 +26,13 @@ export class ProjectsService { const payload = ProjectsMapper.toUpdateProjectRequest(metadata); return this.jsonApiService - .patch(`${environment.apiUrl}/nodes/${metadata.id}/`, payload) + .patch(`${this.apiUrl}/nodes/${metadata.id}/`, payload) .pipe(map((response) => ProjectsMapper.fromProjectResponse(response))); } getProjectChildren(id: string): Observable { return this.jsonApiService - .get(`${environment.apiUrl}/nodes/${id}/children/`) + .get(`${this.apiUrl}/nodes/${id}/children/`) .pipe(map((response) => ProjectsMapper.fromGetAllProjectsResponse(response))); } diff --git a/src/app/shared/services/regions.service.ts b/src/app/shared/services/regions.service.ts index 4fb836929..613585b1e 100644 --- a/src/app/shared/services/regions.service.ts +++ b/src/app/shared/services/regions.service.ts @@ -14,11 +14,11 @@ import { environment } from 'src/environments/environment'; }) export class RegionsService { private readonly http = inject(HttpClient); - private readonly baseUrl = environment.apiUrl; + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; getAllRegions(): Observable { return this.http - .get(`${this.baseUrl}/regions/`) + .get(`${this.apiUrl}/regions/`) .pipe(map((regions) => RegionsMapper.fromRegionsResponseJsonApi(regions))); } } diff --git a/src/app/shared/services/resource-card.service.ts b/src/app/shared/services/resource-card.service.ts index b018cb700..8a11abf23 100644 --- a/src/app/shared/services/resource-card.service.ts +++ b/src/app/shared/services/resource-card.service.ts @@ -13,6 +13,7 @@ import { environment } from 'src/environments/environment'; }) export class ResourceCardService { private jsonApiService = inject(JsonApiService); + private apiUrl = `${environment.apiDomainUrl}/v2`; getUserRelatedCounts(userId: string): Observable { const params: Record = { @@ -20,7 +21,7 @@ export class ResourceCardService { }; return this.jsonApiService - .get(`${environment.apiUrl}/users/${userId}/`, params) + .get(`${this.apiUrl}/users/${userId}/`, params) .pipe(map((response) => MapUserCounts(response))); } } diff --git a/src/app/shared/services/resource.service.ts b/src/app/shared/services/resource.service.ts index 2ae735cef..ea775f0f6 100644 --- a/src/app/shared/services/resource.service.ts +++ b/src/app/shared/services/resource.service.ts @@ -26,6 +26,7 @@ import { environment } from 'src/environments/environment'; export class ResourceGuidService { private jsonApiService = inject(JsonApiService); private loaderService = inject(LoaderService); + private apiUrl = `${environment.apiDomainUrl}/v2`; private readonly urlMap = new Map([ [ResourceType.Project, 'nodes'], @@ -33,7 +34,7 @@ export class ResourceGuidService { ]); getResourceById(id: string): Observable { - const baseUrl = `${environment.apiUrl}/guids/${id}/`; + const baseUrl = `${this.apiUrl}/guids/${id}/`; this.loaderService.show(); @@ -61,7 +62,7 @@ export class ResourceGuidService { const resourcePath = this.urlMap.get(resourceType); return this.jsonApiService - .get>(`${environment.apiUrl}/${resourcePath}/${resourceId}/`) + .get>(`${this.apiUrl}/${resourcePath}/${resourceId}/`) .pipe(map((response) => BaseNodeMapper.getNodeData(response.data))); } @@ -69,7 +70,7 @@ export class ResourceGuidService { const resourcePath = this.urlMap.get(resourceType); return this.jsonApiService - .get>(`${environment.apiUrl}/${resourcePath}/?filter[root]=${resourceId}`) + .get>(`${this.apiUrl}/${resourcePath}/?filter[root]=${resourceId}`) .pipe(map((response) => BaseNodeMapper.getNodesWithChildren(response.data.reverse()))); } } diff --git a/src/app/shared/services/subjects.service.ts b/src/app/shared/services/subjects.service.ts index 9cea2b7fd..d567681ad 100644 --- a/src/app/shared/services/subjects.service.ts +++ b/src/app/shared/services/subjects.service.ts @@ -16,7 +16,7 @@ import { environment } from 'src/environments/environment'; }) export class SubjectsService { private readonly jsonApiService = inject(JsonApiService); - private readonly apiUrl = environment.apiUrl; + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; defaultProvider = environment.defaultProvider; diff --git a/src/app/shared/services/view-only-links.service.ts b/src/app/shared/services/view-only-links.service.ts index 229bb3910..ef595590a 100644 --- a/src/app/shared/services/view-only-links.service.ts +++ b/src/app/shared/services/view-only-links.service.ts @@ -20,6 +20,7 @@ import { environment } from 'src/environments/environment'; }) export class ViewOnlyLinksService { private readonly jsonApiService = inject(JsonApiService); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; private readonly urlMap = new Map([ [ResourceType.Project, 'nodes'], @@ -31,7 +32,7 @@ export class ViewOnlyLinksService { const params: Record = { 'embed[]': ['creator', 'nodes'] }; return this.jsonApiService - .get(`${environment.apiUrl}/${resourcePath}/${projectId}/view_only_links/`, params) + .get(`${this.apiUrl}/${resourcePath}/${projectId}/view_only_links/`, params) .pipe(map((response) => ViewOnlyLinksMapper.fromResponse(response, projectId))); } @@ -47,12 +48,13 @@ export class ViewOnlyLinksService { return this.jsonApiService .post< JsonApiResponse - >(`${environment.apiUrl}/${resourcePath}/${projectId}/view_only_links/`, data, params) + >(`${this.apiUrl}/${resourcePath}/${projectId}/view_only_links/`, data, params) .pipe(map((response) => ViewOnlyLinksMapper.fromSingleResponse(response.data, projectId))); } deleteLink(projectId: string, resourceType: ResourceType, linkId: string): Observable { const resourcePath = this.urlMap.get(resourceType); - return this.jsonApiService.delete(`${environment.apiUrl}/${resourcePath}/${projectId}/view_only_links/${linkId}`); + + return this.jsonApiService.delete(`${this.apiUrl}/${resourcePath}/${projectId}/view_only_links/${linkId}`); } } diff --git a/src/app/shared/services/wiki.service.ts b/src/app/shared/services/wiki.service.ts index 55ebdc89a..d84428b16 100644 --- a/src/app/shared/services/wiki.service.ts +++ b/src/app/shared/services/wiki.service.ts @@ -27,7 +27,8 @@ import { environment } from 'src/environments/environment'; }) export class WikiService { private readonly jsonApiService = inject(JsonApiService); - readonly http = inject(HttpClient); + private readonly http = inject(HttpClient); + private readonly apiUrl = `${environment.apiDomainUrl}/v2`; private readonly urlMap = new Map([ [ResourceType.Project, 'nodes'], @@ -35,14 +36,13 @@ export class WikiService { ]); private getBaseUrl(resourceType: ResourceType, resourceId: string): string { - const baseUrl = `${environment.apiUrl}`; const resourcePath = this.urlMap.get(resourceType); if (!resourcePath) { throw new Error(`Unsupported resource type: ${resourceType}`); } - return `${baseUrl}/${resourcePath}/${resourceId}/wikis/`; + return `${this.apiUrl}/${resourcePath}/${resourceId}/wikis/`; } createWiki(projectId: string, name: string): Observable { @@ -55,16 +55,12 @@ export class WikiService { }, }; return this.jsonApiService - .post>(environment.apiUrl + `/nodes/${projectId}/wikis/`, body) - .pipe( - map((response) => { - return WikiMapper.fromCreateWikiResponse(response.data); - }) - ); + .post>(`${this.apiUrl}/nodes/${projectId}/wikis/`, body) + .pipe(map((response) => WikiMapper.fromCreateWikiResponse(response.data))); } deleteWiki(wikiId: string): Observable { - return this.jsonApiService.delete(environment.apiUrl + `/wikis/${wikiId}/`); + return this.jsonApiService.delete(`${this.apiUrl}/wikis/${wikiId}/`); } getHomeWiki(resourceType: ResourceType, resourceId: string): Observable { @@ -72,6 +68,7 @@ export class WikiService { const params: Record = { 'filter[name]': 'home', }; + return this.jsonApiService.get(baseUrl, params).pipe( map((response) => { const homeWiki = response.data.find((wiki) => wiki.attributes.name.toLocaleLowerCase() === 'home'); @@ -92,6 +89,7 @@ export class WikiService { getWikiList(resourceType: ResourceType, resourceId: string): Observable { const baseUrl = this.getBaseUrl(resourceType, resourceId); + return this.jsonApiService.get(baseUrl).pipe( map((response) => ({ wikis: response.data.map((wiki) => WikiMapper.fromGetWikiResponse(wiki)), @@ -103,7 +101,7 @@ export class WikiService { getComponentsWikiList(resourceType: ResourceType, resourceId: string): Observable { const resourcePath = this.urlMap.get(resourceType); return this.jsonApiService - .get(environment.apiUrl + `/${resourcePath}/${resourceId}/children/?embed=wikis`) + .get(`${this.apiUrl}/${resourcePath}/${resourceId}/children/?embed=wikis`) .pipe(map((response) => response.data.map((component) => WikiMapper.fromGetComponentsWikiResponse(component)))); } @@ -112,13 +110,10 @@ export class WikiService { embed: 'user', 'fields[users]': 'full_name', }; + return this.jsonApiService - .get(environment.apiUrl + `/wikis/${wikiId}/versions/`, params) - .pipe( - map((response) => { - return response.data.map((version) => WikiMapper.fromGetWikiVersionResponse(version)); - }) - ); + .get(`${this.apiUrl}/wikis/${wikiId}/versions/`, params) + .pipe(map((response) => response.data.map((version) => WikiMapper.fromGetWikiVersionResponse(version)))); } createWikiVersion(wikiId: string, content: string): Observable { @@ -130,18 +125,13 @@ export class WikiService { }, }, }; + return this.jsonApiService - .post>(environment.apiUrl + `/wikis/${wikiId}/versions/`, body) - .pipe( - map((response) => { - return WikiMapper.fromCreateWikiResponse(response.data); - }) - ); + .post>(`${this.apiUrl}/wikis/${wikiId}/versions/`, body) + .pipe(map((response) => WikiMapper.fromCreateWikiResponse(response.data))); } getWikiVersionContent(wikiId: string, versionId: string): Observable { - return this.http.get(environment.apiUrl + `/wikis/${wikiId}/versions/${versionId}/content/`, { - responseType: 'text', - }); + return this.http.get(`${this.apiUrl}/wikis/${wikiId}/versions/${versionId}/content/`, { responseType: 'text' }); } } diff --git a/src/environments/environment.development.ts b/src/environments/environment.development.ts index 685b90a2c..fef1c37a5 100644 --- a/src/environments/environment.development.ts +++ b/src/environments/environment.development.ts @@ -14,18 +14,6 @@ export const environment = { * Base URL of the OSF web application. */ webUrl: 'https://staging4.osf.io', - /** - * URL used for file downloads from OSF. - */ - downloadUrl: 'https://staging4.osf.io/download', - /** - * Base URL for the OSF JSON:API v2 endpoints. - */ - apiUrl: 'https://api.staging4.osf.io/v2', - /** - * Legacy v1 API endpoint used by some older services. - */ - apiUrlV1: 'https://staging4.osf.io/api/v1', /** * Domain URL used for JSON:API v2 services. */ @@ -33,7 +21,7 @@ export const environment = { /** * Base URL for SHARE discovery search (Trove). */ - shareDomainUrl: 'https://staging-share.osf.io/trove', + shareTroveUrl: 'https://staging-share.osf.io/trove', /** * URL for the OSF Addons API (v1). */ @@ -46,10 +34,6 @@ export const environment = { * API endpoint for funder metadata resolution via Crossref. */ funderApiUrl: 'https://api.crossref.org/', - /** - * Duplicate of `addonsApiUrl`, retained for backwards compatibility. - */ - addonsV1Url: 'https://addons.staging4.osf.io/v1', /** * URL for OSF Central Authentication Service (CAS). */ diff --git a/src/environments/environment.local.ts b/src/environments/environment.local.ts index 19c5638ce..05ff0cb9e 100644 --- a/src/environments/environment.local.ts +++ b/src/environments/environment.local.ts @@ -1,15 +1,11 @@ export const environment = { production: false, webUrl: 'http://localhost:5000', - downloadUrl: 'http://localhost:5000/download', - apiUrl: 'http://localhost:8000/v2', - apiUrlV1: 'http://localhost:5000/api/v1', apiDomainUrl: 'http://localhost:8000', - shareDomainUrl: 'https://localhost:8003/trove', + shareTroveUrl: 'https://localhost:8003/trove', addonsApiUrl: 'http://localhost:8004/v1', fileApiUrl: 'http://localhost:7777/v1', funderApiUrl: 'https://api.crossref.org/', - addonsV1Url: 'http://localhost:8004/v1', casUrl: 'http://localhost:8080', recaptchaSiteKey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', twitterHandle: 'OSFramework', diff --git a/src/environments/environment.test-osf.ts b/src/environments/environment.test-osf.ts index 47efc1648..f4867f106 100644 --- a/src/environments/environment.test-osf.ts +++ b/src/environments/environment.test-osf.ts @@ -3,16 +3,12 @@ */ export const environment = { production: false, - webUrl: 'https://test.osf.io/', - downloadUrl: 'https://test.osf.io/download', - apiUrl: 'https://api.test.osf.io/v2', - apiUrlV1: 'https://test.osf.io/api/v1', + webUrl: 'https://test.osf.io', apiDomainUrl: 'https://api.test.osf.io', - shareDomainUrl: 'https://test-share.osf.io/trove', + shareTroveUrl: 'https://test-share.osf.io/trove', addonsApiUrl: 'https://addons.test.osf.io/v1', fileApiUrl: 'https://files.us.test.osf.io/v1', funderApiUrl: 'https://api.crossref.org/', - addonsV1Url: 'https://addons.test.osf.io/v1', casUrl: 'https://accounts.test.osf.io', recaptchaSiteKey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', twitterHandle: 'OSFramework', diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 504cc1b5c..901305e6f 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -14,18 +14,6 @@ export const environment = { * Base URL of the OSF web application. */ webUrl: 'https://staging4.osf.io', - /** - * URL used for file downloads from OSF. - */ - downloadUrl: 'https://staging4.osf.io/download', - /** - * Base URL for the OSF JSON:API v2 endpoints. - */ - apiUrl: 'https://api.staging4.osf.io/v2', - /** - * Legacy v1 API endpoint used by some older services. - */ - apiUrlV1: 'https://staging4.osf.io/api/v1', /** * Domain URL used for JSON:API v2 services. */ @@ -33,7 +21,7 @@ export const environment = { /** * Base URL for SHARE discovery search (Trove). */ - shareDomainUrl: 'https://staging-share.osf.io/trove', + shareTroveUrl: 'https://staging-share.osf.io/trove', /** * URL for the OSF Addons API (v1). */ @@ -46,10 +34,6 @@ export const environment = { * API endpoint for funder metadata resolution via Crossref. */ funderApiUrl: 'https://api.crossref.org/', - /** - * Duplicate of `addonsApiUrl`, retained for backwards compatibility. - */ - addonsV1Url: 'https://addons.staging4.osf.io/v1', /** * URL for OSF Central Authentication Service (CAS). */