mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
feat: use connected instances api with orval type (#6352)
This commit is contained in:
parent
ed44de6c94
commit
d6e0bea2f0
@ -30,7 +30,7 @@
|
||||
"gen:api": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" orval --config orval.config.js",
|
||||
"gen:api:demo": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" UNLEASH_OPENAPI_URL=https://app.unleash-hosted.com/demo/docs/openapi.json yarn run gen:api",
|
||||
"gen:api:sandbox": "NODE_OPTIONS=\"${NODE_OPTIONS} --no-experimental-fetch\" UNLEASH_OPENAPI_URL=https://sandbox.getunleash.io/demo2/docs/openapi.json yarn run gen:api",
|
||||
"gen:api:clean": "yarn gen:api && rm -rf src/openapi/apis && sed -i '1q' src/openapi/index.ts"
|
||||
"gen:api:clean": "yarn gen:api && rm -rf src/openapi/apis && sed -i.bak '1q' src/openapi/index.ts && rm src/openapi/index.ts.bak"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.5.1",
|
||||
|
@ -1,17 +1,15 @@
|
||||
import { FC, useEffect, useMemo, useState } from 'react';
|
||||
import useApplication from 'hooks/api/getters/useApplication/useApplication';
|
||||
import { formatDateYMDHMS } from 'utils/formatDate';
|
||||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
||||
import { useConnectedInstancesTable } from './useConnectedInstancesTable';
|
||||
import { ConnectedInstancesTable } from './ConnectedInstancesTable';
|
||||
import { IApplication } from 'interfaces/application';
|
||||
import { Box, ToggleButton, ToggleButtonGroup } from '@mui/material';
|
||||
import { useApplicationOverview } from 'hooks/api/getters/useApplicationOverview/useApplicationOverview';
|
||||
import { useConnectedInstances } from 'hooks/api/getters/useConnectedInstances/useConnectedInstances';
|
||||
import { ApplicationEnvironmentInstancesSchemaInstancesItem } from '../../../openapi';
|
||||
|
||||
export const ConnectedInstances: FC = () => {
|
||||
const name = useRequiredPathParam('name');
|
||||
const { application } = useApplication(name);
|
||||
const { data: applicationOverview } = useApplicationOverview(name);
|
||||
|
||||
const availableEnvironments = applicationOverview.environments.map(
|
||||
@ -40,23 +38,17 @@ export const ConnectedInstances: FC = () => {
|
||||
sdkVersion,
|
||||
clientIp,
|
||||
lastSeen,
|
||||
}: IApplication['instances'][number]) => ({
|
||||
}: ApplicationEnvironmentInstancesSchemaInstancesItem) => ({
|
||||
instanceId,
|
||||
ip: clientIp,
|
||||
sdkVersion,
|
||||
lastSeen: formatDateYMDHMS(lastSeen),
|
||||
ip: clientIp || '',
|
||||
sdkVersion: sdkVersion || '',
|
||||
lastSeen: lastSeen ? formatDateYMDHMS(lastSeen) : '',
|
||||
});
|
||||
if (!currentEnvironment) {
|
||||
return application.instances.map(map);
|
||||
return [];
|
||||
}
|
||||
return application.instances
|
||||
.filter(
|
||||
// @ts-expect-error: the type definition here is incomplete. It
|
||||
// should be updated as part of this project.
|
||||
(instance) => instance.environment === currentEnvironment,
|
||||
)
|
||||
.map(map);
|
||||
}, [application, currentEnvironment]);
|
||||
return connectedInstances.instances.map(map);
|
||||
}, [JSON.stringify(connectedInstances), currentEnvironment]);
|
||||
|
||||
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } =
|
||||
useConnectedInstancesTable(tableData);
|
||||
|
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
import type { ApplicationEnvironmentInstancesSchemaInstancesItem } from './applicationEnvironmentInstancesSchemaInstancesItem';
|
||||
|
||||
/**
|
||||
* Data about an application environment instances that are connected to Unleash via an SDK.
|
||||
*/
|
||||
export interface ApplicationEnvironmentInstancesSchema {
|
||||
/** A list of instances */
|
||||
instances: ApplicationEnvironmentInstancesSchemaInstancesItem[];
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
export type ApplicationEnvironmentInstancesSchemaInstancesItem = {
|
||||
/** An IP address identifying the instance of the application running the SDK */
|
||||
clientIp?: string;
|
||||
/** A unique identifier identifying the instance of the application running the SDK. Often changes based on execution environment. For instance: two pods in Kubernetes will have two different instanceIds */
|
||||
instanceId: string;
|
||||
/** The last time the application environment instance was seen */
|
||||
lastSeen?: string;
|
||||
/** An SDK version identifier. Usually formatted as "unleash-client-<language>:<version>" */
|
||||
sdkVersion?: string;
|
||||
};
|
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
export type GetApplicationEnvironmentInstances404 = {
|
||||
/** The ID of the error instance */
|
||||
id?: string;
|
||||
/** A description of what went wrong. */
|
||||
message?: string;
|
||||
/** The name of the error kind */
|
||||
name?: string;
|
||||
};
|
@ -90,6 +90,8 @@ export * from './advancedPlaygroundResponseSchema';
|
||||
export * from './apiTokenSchema';
|
||||
export * from './apiTokenSchemaType';
|
||||
export * from './apiTokensSchema';
|
||||
export * from './applicationEnvironmentInstancesSchema';
|
||||
export * from './applicationEnvironmentInstancesSchemaInstancesItem';
|
||||
export * from './applicationOverviewEnvironmentSchema';
|
||||
export * from './applicationOverviewIssuesSchema';
|
||||
export * from './applicationOverviewIssuesSchemaType';
|
||||
@ -573,6 +575,7 @@ export * from './getAllToggles403';
|
||||
export * from './getApiTokensByName401';
|
||||
export * from './getApiTokensByName403';
|
||||
export * from './getApplication404';
|
||||
export * from './getApplicationEnvironmentInstances404';
|
||||
export * from './getApplicationOverview404';
|
||||
export * from './getApplicationsParams';
|
||||
export * from './getArchivedFeatures401';
|
||||
|
Loading…
Reference in New Issue
Block a user