|
| 1 | +import { |
| 2 | + useComposeBlueprintMutation, |
| 3 | + useCreateBlueprintMutation, |
| 4 | + useDeleteBlueprintMutation, |
| 5 | + useGetArchitecturesQuery, |
| 6 | + useGetBlueprintComposesQuery, |
| 7 | + useGetBlueprintQuery, |
| 8 | + useGetBlueprintsQuery, |
| 9 | + useGetComposesQuery, |
| 10 | + useGetComposeStatusQuery, |
| 11 | + useGetDistributionsQuery, |
| 12 | + useGetOscapCustomizationsQuery, |
| 13 | + useGetOscapProfilesQuery, |
| 14 | + useLazyGetBlueprintsQuery, |
| 15 | + useLazyGetOscapCustomizationsQuery, |
| 16 | + useUpdateBlueprintMutation, |
| 17 | +} from '@/store/api/backend/onprem/composerApi'; |
| 18 | +import { composerApi } from '@/store/api/backend/onprem/enhancedComposerApi'; |
| 19 | +import { |
| 20 | + contentSourcesApi, |
| 21 | + useListSnapshotsByDateMutation, |
| 22 | + useSearchRpmMutation, |
| 23 | +} from '@/store/api/contentSources/onprem'; |
| 24 | + |
| 25 | +import type { PlatformHooks } from './types'; |
| 26 | + |
| 27 | +// Feature flag defaults for on-premises — Unleash is not available. |
| 28 | +// All flags default to false (default-deny). Add cases here when a |
| 29 | +// flag-gated feature needs to be enabled for on-prem users. |
| 30 | +export const onPremFlag = (_flag: string): boolean => { |
| 31 | + return false; |
| 32 | +}; |
| 33 | + |
| 34 | +// On-prem environment is static — hoist to avoid allocations per call |
| 35 | +const onPremEnv = { isBeta: () => false, isProd: () => true }; |
| 36 | + |
| 37 | +// The on-prem hooks use OnPremBaseQuery which is structurally different from |
| 38 | +// the hosted FetchBaseQueryError used in PlatformHooks type definitions. |
| 39 | +// The runtime behavior is identical, so we cast individual hooks that diverge. |
| 40 | +export const onPremPlatform: PlatformHooks = { |
| 41 | + queries: { |
| 42 | + useGetArchitecturesQuery: |
| 43 | + useGetArchitecturesQuery as unknown as PlatformHooks['queries']['useGetArchitecturesQuery'], |
| 44 | + useGetDistributionsQuery: |
| 45 | + useGetDistributionsQuery as unknown as PlatformHooks['queries']['useGetDistributionsQuery'], |
| 46 | + useGetBlueprintQuery: |
| 47 | + useGetBlueprintQuery as unknown as PlatformHooks['queries']['useGetBlueprintQuery'], |
| 48 | + useGetBlueprintsQuery: |
| 49 | + useGetBlueprintsQuery as unknown as PlatformHooks['queries']['useGetBlueprintsQuery'], |
| 50 | + useLazyGetBlueprintsQuery: |
| 51 | + useLazyGetBlueprintsQuery as unknown as PlatformHooks['queries']['useLazyGetBlueprintsQuery'], |
| 52 | + useGetOscapProfilesQuery: |
| 53 | + useGetOscapProfilesQuery as unknown as PlatformHooks['queries']['useGetOscapProfilesQuery'], |
| 54 | + useGetOscapCustomizationsQuery: |
| 55 | + useGetOscapCustomizationsQuery as unknown as PlatformHooks['queries']['useGetOscapCustomizationsQuery'], |
| 56 | + useLazyGetOscapCustomizationsQuery: |
| 57 | + useLazyGetOscapCustomizationsQuery as unknown as PlatformHooks['queries']['useLazyGetOscapCustomizationsQuery'], |
| 58 | + useGetComposesQuery: |
| 59 | + useGetComposesQuery as unknown as PlatformHooks['queries']['useGetComposesQuery'], |
| 60 | + useGetBlueprintComposesQuery: |
| 61 | + useGetBlueprintComposesQuery as unknown as PlatformHooks['queries']['useGetBlueprintComposesQuery'], |
| 62 | + useGetComposeStatusQuery: |
| 63 | + useGetComposeStatusQuery as unknown as PlatformHooks['queries']['useGetComposeStatusQuery'], |
| 64 | + }, |
| 65 | + mutations: { |
| 66 | + useCreateBlueprintMutation: |
| 67 | + useCreateBlueprintMutation as unknown as PlatformHooks['mutations']['useCreateBlueprintMutation'], |
| 68 | + useUpdateBlueprintMutation: |
| 69 | + useUpdateBlueprintMutation as unknown as PlatformHooks['mutations']['useUpdateBlueprintMutation'], |
| 70 | + useDeleteBlueprintMutation: |
| 71 | + useDeleteBlueprintMutation as unknown as PlatformHooks['mutations']['useDeleteBlueprintMutation'], |
| 72 | + useComposeBlueprintMutation: |
| 73 | + useComposeBlueprintMutation as unknown as PlatformHooks['mutations']['useComposeBlueprintMutation'], |
| 74 | + useSearchRpmMutation: |
| 75 | + useSearchRpmMutation as unknown as PlatformHooks['mutations']['useSearchRpmMutation'], |
| 76 | + useListSnapshotsByDateMutation: |
| 77 | + useListSnapshotsByDateMutation as unknown as PlatformHooks['mutations']['useListSnapshotsByDateMutation'], |
| 78 | + }, |
| 79 | + env: { |
| 80 | + useFlag: onPremFlag, |
| 81 | + useGetEnvironment: () => onPremEnv, |
| 82 | + }, |
| 83 | + api: { |
| 84 | + backendApi: composerApi as unknown as PlatformHooks['api']['backendApi'], |
| 85 | + contentSourcesApi: |
| 86 | + contentSourcesApi as unknown as PlatformHooks['api']['contentSourcesApi'], |
| 87 | + useBackendPrefetch: |
| 88 | + composerApi.usePrefetch as unknown as PlatformHooks['api']['useBackendPrefetch'], |
| 89 | + }, |
| 90 | +}; |
0 commit comments