Remove api keys from old world (#2548)
* Use apiKeyV2 for getApiKeys * Use apiKeyV2 for createApiKey * Use apiKeyV2 for getApiKey * Use apiKeyV2 to deleteapikey * Filter null revokedAt -> not working * Use apiKeyV2 to regenerate * Fix default values injected * Remove useless stuff * Fix type
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { useOptimisticEffect } from '@/apollo/optimistic-effect/hooks/useOptimisticEffect';
|
||||
import { useFindOneObjectMetadataItem } from '@/object-metadata/hooks/useFindOneObjectMetadataItem';
|
||||
@ -41,16 +42,7 @@ export const useCreateOneObjectRecord = ({
|
||||
? async (input: Record<string, any>) => {
|
||||
const createdObject = await mutate({
|
||||
variables: {
|
||||
input: {
|
||||
...foundObjectMetadataItem.fields.reduce(
|
||||
(result, field) => ({
|
||||
...result,
|
||||
[field.name]: defaultFieldValues[field.type],
|
||||
}),
|
||||
{},
|
||||
),
|
||||
...input,
|
||||
},
|
||||
input: { ...input, id: v4() },
|
||||
},
|
||||
});
|
||||
|
||||
@ -60,6 +52,7 @@ export const useCreateOneObjectRecord = ({
|
||||
`create${capitalize(foundObjectMetadataItem.nameSingular)}`
|
||||
],
|
||||
);
|
||||
return createdObject.data;
|
||||
}
|
||||
: undefined;
|
||||
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const GENERATE_ONE_API_KEY_TOKEN = gql`
|
||||
mutation GenerateOneApiKeyToken($data: ApiKeyCreateInput!) {
|
||||
generateApiKeyV2Token(data: $data) {
|
||||
token
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -1,5 +1,5 @@
|
||||
import { ApiFieldItem } from '@/settings/developers/types/ApiFieldItem';
|
||||
import { GetApiKeysQuery } from '~/generated/graphql';
|
||||
import { ApiKey } from '~/generated/graphql';
|
||||
import { beautifyDateDiff } from '~/utils/date-utils';
|
||||
|
||||
export const formatExpiration = (
|
||||
@ -18,9 +18,9 @@ export const formatExpiration = (
|
||||
};
|
||||
|
||||
export const formatExpirations = (
|
||||
apiKeysQuery: GetApiKeysQuery,
|
||||
apiKeys: Array<Pick<ApiKey, 'id' | 'name' | 'expiresAt'>>,
|
||||
): ApiFieldItem[] => {
|
||||
return apiKeysQuery.findManyApiKey.map(({ id, name, expiresAt }) => {
|
||||
return apiKeys.map(({ id, name, expiresAt }) => {
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
|
||||
Reference in New Issue
Block a user