chore: run prettier

This commit is contained in:
Matthew Penner 2023-01-12 12:31:47 -07:00
parent 9cdbbc3a00
commit 155d7bb876
No known key found for this signature in database
76 changed files with 788 additions and 550 deletions

View file

@ -16,7 +16,7 @@ export interface CreateServerRequest {
cpu: number;
threads: string;
oomDisabled: boolean;
}
};
featureLimits: {
allocations: number;
@ -39,41 +39,45 @@ export interface CreateServerRequest {
export default (r: CreateServerRequest, include: string[] = []): Promise<Server> => {
return new Promise((resolve, reject) => {
http.post('/api/application/servers', {
externalId: r.externalId,
name: r.name,
description: r.description,
owner_id: r.ownerId,
node_id: r.nodeId,
http.post(
'/api/application/servers',
{
externalId: r.externalId,
name: r.name,
description: r.description,
owner_id: r.ownerId,
node_id: r.nodeId,
limits: {
cpu: r.limits.cpu,
disk: r.limits.disk,
io: r.limits.io,
memory: r.limits.memory,
swap: r.limits.swap,
threads: r.limits.threads,
oom_killer: r.limits.oomDisabled,
limits: {
cpu: r.limits.cpu,
disk: r.limits.disk,
io: r.limits.io,
memory: r.limits.memory,
swap: r.limits.swap,
threads: r.limits.threads,
oom_killer: r.limits.oomDisabled,
},
feature_limits: {
allocations: r.featureLimits.allocations,
backups: r.featureLimits.backups,
databases: r.featureLimits.databases,
},
allocation: {
default: r.allocation.default,
additional: r.allocation.additional,
},
startup: r.startup,
environment: r.environment,
egg_id: r.eggId,
image: r.image,
skip_scripts: r.skipScripts,
start_on_completion: r.startOnCompletion,
},
feature_limits: {
allocations: r.featureLimits.allocations,
backups: r.featureLimits.backups,
databases: r.featureLimits.databases,
},
allocation: {
default: r.allocation.default,
additional: r.allocation.additional,
},
startup: r.startup,
environment: r.environment,
egg_id: r.eggId,
image: r.image,
skip_scripts: r.skipScripts,
start_on_completion: r.startOnCompletion,
}, { params: { include: include.join(',') } })
{ params: { include: include.join(',') } },
)
.then(({ data }) => resolve(rawDataToServer(data)))
.catch(reject);
});

View file

@ -41,7 +41,7 @@ export const rawDataToServerVariable = ({ attributes }: FractalResponseData): Se
export interface Server {
id: number;
externalId: string | null
externalId: string | null;
uuid: string;
identifier: string;
name: string;
@ -56,13 +56,13 @@ export interface Server {
cpu: number;
threads: string | null;
oomDisabled: boolean;
}
};
featureLimits: {
databases: number;
allocations: number;
backups: number;
}
};
ownerId: number;
nodeId: number;
@ -74,7 +74,7 @@ export interface Server {
startup: string;
image: string;
environment: Map<string, string>;
}
};
createdAt: Date;
updatedAt: Date;
@ -85,57 +85,71 @@ export interface Server {
node?: Node;
user?: User;
variables: ServerVariable[];
}
};
}
export const rawDataToServer = ({ attributes }: FractalResponseData): Server => ({
id: attributes.id,
externalId: attributes.external_id,
uuid: attributes.uuid,
identifier: attributes.identifier,
name: attributes.name,
description: attributes.description,
status: attributes.status,
export const rawDataToServer = ({ attributes }: FractalResponseData): Server =>
({
id: attributes.id,
externalId: attributes.external_id,
uuid: attributes.uuid,
identifier: attributes.identifier,
name: attributes.name,
description: attributes.description,
status: attributes.status,
limits: {
memory: attributes.limits.memory,
swap: attributes.limits.swap,
disk: attributes.limits.disk,
io: attributes.limits.io,
cpu: attributes.limits.cpu,
threads: attributes.limits.threads,
oomDisabled: attributes.limits.oom_disabled,
},
limits: {
memory: attributes.limits.memory,
swap: attributes.limits.swap,
disk: attributes.limits.disk,
io: attributes.limits.io,
cpu: attributes.limits.cpu,
threads: attributes.limits.threads,
oomDisabled: attributes.limits.oom_disabled,
},
featureLimits: {
databases: attributes.feature_limits.databases,
allocations: attributes.feature_limits.allocations,
backups: attributes.feature_limits.backups,
},
featureLimits: {
databases: attributes.feature_limits.databases,
allocations: attributes.feature_limits.allocations,
backups: attributes.feature_limits.backups,
},
ownerId: attributes.owner_id,
nodeId: attributes.node_id,
allocationId: attributes.allocation_id,
nestId: attributes.nest_id,
eggId: attributes.egg_id,
ownerId: attributes.owner_id,
nodeId: attributes.node_id,
allocationId: attributes.allocation_id,
nestId: attributes.nest_id,
eggId: attributes.egg_id,
container: {
startup: attributes.container.startup,
image: attributes.container.image,
environment: attributes.container.environment,
},
container: {
startup: attributes.container.startup,
image: attributes.container.image,
environment: attributes.container.environment,
},
createdAt: new Date(attributes.created_at),
updatedAt: new Date(attributes.updated_at),
createdAt: new Date(attributes.created_at),
updatedAt: new Date(attributes.updated_at),
relations: {
allocations: ((attributes.relationships?.allocations as FractalResponseList | undefined)?.data || []).map(rawDataToAllocation),
egg: attributes.relationships?.egg?.object === 'egg' ? rawDataToEgg(attributes.relationships.egg as FractalResponseData) : undefined,
node: attributes.relationships?.node?.object === 'node' ? rawDataToNode(attributes.relationships.node as FractalResponseData) : undefined,
user: attributes.relationships?.user?.object === 'user' ? Transformers.toUser(attributes.relationships.user as FractalResponseData) : undefined,
variables: ((attributes.relationships?.variables as FractalResponseList | undefined)?.data || []).map(rawDataToServerVariable),
},
}) as Server;
relations: {
allocations: ((attributes.relationships?.allocations as FractalResponseList | undefined)?.data || []).map(
rawDataToAllocation,
),
egg:
attributes.relationships?.egg?.object === 'egg'
? rawDataToEgg(attributes.relationships.egg as FractalResponseData)
: undefined,
node:
attributes.relationships?.node?.object === 'node'
? rawDataToNode(attributes.relationships.node as FractalResponseData)
: undefined,
user:
attributes.relationships?.user?.object === 'user'
? Transformers.toUser(attributes.relationships.user as FractalResponseData)
: undefined,
variables: ((attributes.relationships?.variables as FractalResponseList | undefined)?.data || []).map(
rawDataToServerVariable,
),
},
} as Server);
export interface Filters {
id?: string;
@ -166,12 +180,14 @@ export default (include: string[] = []) => {
params.sort = (sortDirection ? '-' : '') + sort;
}
return useSWR<PaginatedResult<Server>>([ 'servers', page, filters, sort, sortDirection ], async () => {
const { data } = await http.get('/api/application/servers', { params: { include: include.join(','), page, ...params } });
return useSWR<PaginatedResult<Server>>(['servers', page, filters, sort, sortDirection], async () => {
const { data } = await http.get('/api/application/servers', {
params: { include: include.join(','), page, ...params },
});
return ({
return {
items: (data.data || []).map(rawDataToServer),
pagination: getPaginationSet(data.meta.pagination),
});
};
});
};

View file

@ -14,13 +14,13 @@ export interface Values {
cpu: number;
threads: string;
oomDisabled: boolean;
}
};
featureLimits: {
allocations: number;
backups: number;
databases: number;
}
};
allocationId: number;
addAllocations: number[];
@ -56,7 +56,7 @@ export default (id: number, server: Partial<Values>, include: string[] = []): Pr
add_allocations: server.addAllocations,
remove_allocations: server.removeAllocations,
},
{ params: { include: include.join(',') } }
{ params: { include: include.join(',') } },
)
.then(({ data }) => resolve(rawDataToServer(data)))
.catch(reject);

View file

@ -20,7 +20,7 @@ export default (id: number, values: Partial<Values>, include: string[] = []): Pr
image: values.image,
skip_scripts: values.skipScripts,
},
{ params: { include: include.join(',') } }
{ params: { include: include.join(',') } },
)
.then(({ data }) => resolve(rawDataToServer(data)))
.catch(reject);