1- import { Injectable , computed , effect , inject , signal , Signal , WritableSignal } from '@angular/core' ;
2- import { HttpClient , HttpHeaders } from '@angular/common/http' ;
1+ import { Injectable , computed , effect , inject , signal , Signal } from '@angular/core' ;
2+ import { HttpClient } from '@angular/common/http' ;
33import { firstValueFrom } from 'rxjs' ;
44
55import { AppDetailPrefs } from './app-detail-prefs.service' ;
66import { AppLifecycleStateService } from './app-lifecycle-state.service' ;
77import { ApplicationStateService , ApplicationStateData } from '../../shared/services/application-state.service' ;
8- import { IApp , IAppSummary , IDomain , IOrganization , ISpace } from '../../cf-api.types' ;
8+ import { IApp , IAppSummary } from '../../cf-api.types' ;
99import { APIResource } from '@stratosui/store' ;
1010import { EnvVarStratosProject } from './application/application-tabs-base/tabs/build-tab/application-env-vars.service' ;
1111import {
1212 StAppDetail ,
1313 StAppRoutesResponse ,
1414 StAppStat ,
15+ StDomain ,
16+ StratosPagedResponse ,
1517 StEnvVars ,
18+ StOrg ,
1619 StRoute ,
1720 StServiceCredentialBinding ,
1821 StServiceCredentialBindingsResponse ,
22+ StSpace ,
1923 StratosError ,
2024} from '../../services/endpoint-data/stratos-types' ;
2125import { stToLegacy } from '../../services/v3-to-legacy-adapter' ;
@@ -36,8 +40,8 @@ interface StAppStatsResponse {
3640 * signals via the `stToLegacy` adapter so unmigrated cards/tabs keep
3741 * reading their familiar shape during the migration.
3842 *
39- * Space / org / domains stay v2-shaped for now — those are addressed in
40- * a later slice when the org/space detail pages migrate .
43+ * Space / org / domains are sourced from Jetstream native handlers and
44+ * exposed as Stratos-native shapes (`StSpace`, `StOrg`, `StDomain[]`) .
4145 *
4246 * Provide at application-base.component so signals are torn down when the
4347 * user navigates away from the app detail page. DO NOT add `providedIn:'root'`.
@@ -59,11 +63,12 @@ export class AppDetailDataService {
5963 private readonly _envVars = signal < StEnvVars | undefined > ( undefined ) ;
6064 private readonly _stats = signal < StAppStat [ ] > ( [ ] ) ;
6165
62- // Space / org / domains stay V2-shaped — out of scope for slice 1 commit 4.
63- // These switch to V3 native handlers when the org/space detail pages migrate.
64- private readonly _space = signal < APIResource < ISpace > | undefined > ( undefined ) ;
65- private readonly _org = signal < APIResource < IOrganization > | undefined > ( undefined ) ;
66- private readonly _domains = signal < IDomain [ ] > ( [ ] ) ;
66+ // Space / org / domains — Stratos-native shapes from Jetstream native
67+ // handlers. Backend translates v2/v3 under the hood; the frontend never
68+ // touches `/pp/v1/proxy/v2/...` directly.
69+ private readonly _space = signal < StSpace | undefined > ( undefined ) ;
70+ private readonly _org = signal < StOrg | undefined > ( undefined ) ;
71+ private readonly _domains = signal < StDomain [ ] > ( [ ] ) ;
6772
6873 // Per-app routes — V3-shaped via the native handler. Null until first load
6974 // so consumers can distinguish "haven't fetched yet" from "fetched, empty".
@@ -117,9 +122,9 @@ export class AppDetailDataService {
117122 /** Trimmed V3 stats — one row per running instance with `{ index, state }`. */
118123 readonly stats : Signal < StAppStat [ ] > = this . _stats . asReadonly ( ) ;
119124
120- readonly space : Signal < APIResource < ISpace > | undefined > = this . _space . asReadonly ( ) ;
121- readonly org : Signal < APIResource < IOrganization > | undefined > = this . _org . asReadonly ( ) ;
122- readonly domains : Signal < IDomain [ ] > = this . _domains . asReadonly ( ) ;
125+ readonly space : Signal < StSpace | undefined > = this . _space . asReadonly ( ) ;
126+ readonly org : Signal < StOrg | undefined > = this . _org . asReadonly ( ) ;
127+ readonly domains : Signal < StDomain [ ] > = this . _domains . asReadonly ( ) ;
123128 readonly loading : Signal < Record < EntityKind , boolean > > = this . _loading . asReadonly ( ) ;
124129 readonly errors : Signal < Record < EntityKind , StratosError | null > > = this . _errors . asReadonly ( ) ;
125130 readonly lastPolledAt : Signal < Date | null > = this . _lastPolledAt . asReadonly ( ) ;
@@ -302,7 +307,7 @@ export class AppDetailDataService {
302307 * Phase 1b (conditional): stats — only when state is STARTED to avoid
303308 * a noisy 400 from CF's CF-AppStoppedStatsError on stopped apps.
304309 * Phase 2 (sequential): space (needs app.spaceGuid), then org (needs
305- * space.organization_guid ), then domains (needs org.guid).
310+ * space.orgGuid ), then domains (needs org.guid).
306311 */
307312 async refresh ( scope : EntityKind | 'all' = 'all' ) : Promise < void > {
308313 if ( scope === 'all' ) {
@@ -340,9 +345,9 @@ export class AppDetailDataService {
340345 // ---------------------------------------------------------------------------
341346 // URL helpers
342347 //
343- // App detail / env / stats now hit Jetstream native handlers — the cnsi
344- // is in the path, no x-cap-passthrough header needed. Space / org /
345- // domains still hit the V2 proxy until those pages migrate (slice 2+) .
348+ // All entity fetches hit Jetstream native handlers — cnsi is in the
349+ // path and responses come back as Stratos-native shapes. No
350+ // `x-cap-passthrough` header needed; the frontend never talks v2 wire .
346351 // ---------------------------------------------------------------------------
347352
348353 private nativeAppDetailUrl ( ) : string {
@@ -362,29 +367,15 @@ export class AppDetailDataService {
362367 }
363368
364369 private spaceUrl ( spaceGuid : string ) : string {
365- return `/pp/v1/proxy/v2/ spaces/${ spaceGuid } ` ;
370+ return `/pp/v1/cf/ spaces/ ${ this . cnsiGuid } /${ spaceGuid } ` ;
366371 }
367372
368373 private orgUrl ( orgGuid : string ) : string {
369- return `/pp/v1/proxy/v2/organizations /${ orgGuid } ` ;
374+ return `/pp/v1/cf/org/ ${ this . cnsiGuid } /${ orgGuid } ` ;
370375 }
371376
372377 private orgDomainsUrl ( orgGuid : string ) : string {
373- return `/pp/v1/proxy/v2/organizations/${ orgGuid } /domains` ;
374- }
375-
376- /**
377- * Headers required by the V2 proxy paths (space / org / domains). Native
378- * handlers don't need these — cnsi is in the path and the response is
379- * the raw shape, no envelope.
380- */
381- private v2ProxyHeaders ( ) : { headers : HttpHeaders } {
382- return {
383- headers : new HttpHeaders ( {
384- 'x-cap-cnsi-list' : this . cnsiGuid ,
385- 'x-cap-passthrough' : 'true' ,
386- } ) ,
387- } ;
378+ return `/pp/v1/cf/org/${ this . cnsiGuid } /${ orgGuid } /private_domains` ;
388379 }
389380
390381 // ---------------------------------------------------------------------------
@@ -478,7 +469,7 @@ export class AppDetailDataService {
478469 this . _errors . update ( m => ( { ...m , space : null } ) ) ;
479470 try {
480471 const value = await firstValueFrom (
481- this . http . get < APIResource < ISpace > > ( this . spaceUrl ( spaceGuid ) , this . v2ProxyHeaders ( ) )
472+ this . http . get < StSpace > ( this . spaceUrl ( spaceGuid ) )
482473 ) ;
483474 this . _space . set ( value ) ;
484475 } catch ( err : unknown ) {
@@ -489,15 +480,15 @@ export class AppDetailDataService {
489480 }
490481
491482 private async fetchOrg ( ) : Promise < void > {
492- const orgGuid = this . _space ( ) ?. entity ?. organization_guid ;
483+ const orgGuid = this . _space ( ) ?. orgGuid ;
493484 if ( ! orgGuid ) {
494485 return ;
495486 }
496487 this . _loading . update ( m => ( { ...m , org : true } ) ) ;
497488 this . _errors . update ( m => ( { ...m , org : null } ) ) ;
498489 try {
499490 const value = await firstValueFrom (
500- this . http . get < APIResource < IOrganization > > ( this . orgUrl ( orgGuid ) , this . v2ProxyHeaders ( ) )
491+ this . http . get < StOrg > ( this . orgUrl ( orgGuid ) )
501492 ) ;
502493 this . _org . set ( value ) ;
503494 } catch ( err : unknown ) {
@@ -613,15 +604,15 @@ export class AppDetailDataService {
613604 }
614605
615606 private async fetchDomains ( ) : Promise < void > {
616- const orgGuid = this . _org ( ) ?. metadata ?. guid ;
607+ const orgGuid = this . _org ( ) ?. guid ;
617608 if ( ! orgGuid ) {
618609 return ;
619610 }
620611 this . _loading . update ( m => ( { ...m , domains : true } ) ) ;
621612 this . _errors . update ( m => ( { ...m , domains : null } ) ) ;
622613 try {
623614 const result = await firstValueFrom (
624- this . http . get < { resources : IDomain [ ] } > ( this . orgDomainsUrl ( orgGuid ) , this . v2ProxyHeaders ( ) )
615+ this . http . get < StratosPagedResponse < StDomain > > ( this . orgDomainsUrl ( orgGuid ) )
625616 ) ;
626617 this . _domains . set ( result ?. resources ?? [ ] ) ;
627618 } catch ( err : unknown ) {
0 commit comments