Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"ini": "^5.0.0",
"ip": "^2.0.1",
"jose": "^6.0.0",
"json-bigint-patch": "^0.0.8",
"lodash-es": "^4.17.21",
"multi-ini": "^2.3.2",
"mustache": "^4.2.0",
Expand Down
1 change: 1 addition & 0 deletions api/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '@app/dotenv.js';
import 'json-bigint-patch';

import { execa } from 'execa';
import { CommandFactory } from 'nest-commander';
Expand Down
1 change: 1 addition & 0 deletions api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'reflect-metadata';
import 'global-agent/bootstrap.js';
import 'json-bigint-patch';
import '@app/dotenv.js';

import { type NestFastifyApplication } from '@nestjs/platform-fastify';
Expand Down
5 changes: 2 additions & 3 deletions api/src/unraid-api/graph/graph.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';

import { NoUnusedVariablesRule } from 'graphql';
import { JSONResolver, URLResolver } from 'graphql-scalars';
import { GraphQLBigInt, JSONResolver, URLResolver } from 'graphql-scalars';

import { ENVIRONMENT } from '@app/environment.js';
import { getters } from '@app/store/index.js';
Expand All @@ -14,7 +14,6 @@ import {
} from '@app/unraid-api/graph/directives/use-permissions.directive.js';
import { ResolversModule } from '@app/unraid-api/graph/resolvers/resolvers.module.js';
import { sandboxPlugin } from '@app/unraid-api/graph/sandbox-plugin.js';
import { GraphQLLong } from '@app/unraid-api/graph/scalars/graphql-type-long.js';
import { PrefixedID as PrefixedIDScalar } from '@app/unraid-api/graph/scalars/graphql-type-prefixed-id.js';
import { PluginModule } from '@app/unraid-api/plugin/plugin.module.js';

Expand Down Expand Up @@ -50,7 +49,7 @@ import { PluginModule } from '@app/unraid-api/plugin/plugin.module.js';
},
resolvers: {
JSON: JSONResolver,
Long: GraphQLLong,
Long: GraphQLBigInt,
URL: URLResolver,
},
buildSchemaOptions: {
Expand Down
22 changes: 11 additions & 11 deletions api/src/unraid-api/graph/resolvers/array/array.model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Field, InputType, Int, ObjectType, registerEnumType } from '@nestjs/graphql';

import { IsEnum } from 'class-validator';
import { GraphQLBigInt } from 'graphql-scalars';

import { Node } from '@app/unraid-api/graph/resolvers/base.model.js';
import { GraphQLLong } from '@app/unraid-api/graph/scalars/graphql-type-long.js';
import { PrefixedID } from '@app/unraid-api/graph/scalars/graphql-type-prefixed-id.js';

@ObjectType()
Expand Down Expand Up @@ -43,7 +43,7 @@ export class ArrayDisk extends Node {
@Field(() => String, { nullable: true })
device?: string;

@Field(() => GraphQLLong, { description: '(KB) Disk Size total', nullable: true })
@Field(() => GraphQLBigInt, { description: '(KB) Disk Size total', nullable: true })
size?: number | null;

Comment on lines +46 to 48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Mismatch between GraphQLBigInt and TS number type
GraphQLBigInt returns a JS BigInt, but the field is typed as number | null, risking precision loss. Update the TypeScript type to bigint | null.

Apply this diff:

-    @Field(() => GraphQLBigInt, { description: '(KB) Disk Size total', nullable: true })
-    size?: number | null;
+    @Field(() => GraphQLBigInt, { description: '(KB) Disk Size total', nullable: true })
+    size?: bigint | null;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Field(() => GraphQLBigInt, { description: '(KB) Disk Size total', nullable: true })
size?: number | null;
@Field(() => GraphQLBigInt, { description: '(KB) Disk Size total', nullable: true })
size?: bigint | null;
🤖 Prompt for AI Agents
In api/src/unraid-api/graph/resolvers/array/array.model.ts around lines 46 to
48, the TypeScript type for the size field is incorrectly set as number | null
while the GraphQL type is GraphQLBigInt, which returns a JS BigInt. Change the
TypeScript type of the size field from number | null to bigint | null to match
the GraphQLBigInt type and avoid precision loss.

@Field(() => ArrayDiskStatus, { nullable: true })
Expand All @@ -58,40 +58,40 @@ export class ArrayDisk extends Node {
})
temp?: number | null;

@Field(() => GraphQLLong, {
@Field(() => GraphQLBigInt, {
nullable: true,
description:
'Count of I/O read requests sent to the device I/O drivers. These statistics may be cleared at any time.',
})
numReads?: number | null;

@Field(() => GraphQLLong, {
@Field(() => GraphQLBigInt, {
nullable: true,
description:
'Count of I/O writes requests sent to the device I/O drivers. These statistics may be cleared at any time.',
})
numWrites?: number | null;

@Field(() => GraphQLLong, {
@Field(() => GraphQLBigInt, {
nullable: true,
description:
'Number of unrecoverable errors reported by the device I/O drivers. Missing data due to unrecoverable array read errors is filled in on-the-fly using parity reconstruct (and we attempt to write this data back to the sector(s) which failed). Any unrecoverable write error results in disabling the disk.',
})
numErrors?: number | null;

@Field(() => GraphQLLong, {
@Field(() => GraphQLBigInt, {
nullable: true,
description: '(KB) Total Size of the FS (Not present on Parity type drive)',
})
fsSize?: number | null;

@Field(() => GraphQLLong, {
@Field(() => GraphQLBigInt, {
nullable: true,
description: '(KB) Free Size on the FS (Not present on Parity type drive)',
})
fsFree?: number | null;

@Field(() => GraphQLLong, {
@Field(() => GraphQLBigInt, {
nullable: true,
description: '(KB) Used Size on the FS (Not present on Parity type drive)',
})
Expand Down Expand Up @@ -243,13 +243,13 @@ export class Share extends Node {
@Field(() => String, { description: 'Display name', nullable: true })
name?: string | null;

@Field(() => GraphQLLong, { description: '(KB) Free space', nullable: true })
@Field(() => GraphQLBigInt, { description: '(KB) Free space', nullable: true })
free?: number | null;

@Field(() => GraphQLLong, { description: '(KB) Used Size', nullable: true })
@Field(() => GraphQLBigInt, { description: '(KB) Used Size', nullable: true })
used?: number | null;

@Field(() => GraphQLLong, { description: '(KB) Total size', nullable: true })
@Field(() => GraphQLBigInt, { description: '(KB) Total size', nullable: true })
size?: number | null;

@Field(() => [String], { description: 'Disks that are included in this share', nullable: true })
Expand Down
24 changes: 12 additions & 12 deletions api/src/unraid-api/graph/resolvers/info/info.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
registerEnumType,
} from '@nestjs/graphql';

import { GraphQLJSON } from 'graphql-scalars';
import { GraphQLBigInt, GraphQLJSON } from 'graphql-scalars';

import { Node } from '@app/unraid-api/graph/resolvers/base.model.js';
import { ThemeName } from '@app/unraid-api/graph/resolvers/customization/theme.model.js';
Expand Down Expand Up @@ -290,7 +290,7 @@ export class Display extends Node {

@ObjectType({ implements: () => Node })
export class MemoryLayout extends Node {
@Field(() => Int)
@Field(() => GraphQLBigInt)
size!: number;

@Field(() => String, { nullable: true })
Expand Down Expand Up @@ -326,34 +326,34 @@ export class MemoryLayout extends Node {

@ObjectType({ implements: () => Node })
export class InfoMemory extends Node {
@Field(() => Int)
@Field(() => GraphQLBigInt)
max!: number;

@Field(() => Int)
@Field(() => GraphQLBigInt)
total!: number;

@Field(() => Int)
@Field(() => GraphQLBigInt)
free!: number;

@Field(() => Int)
@Field(() => GraphQLBigInt)
used!: number;

@Field(() => Int)
@Field(() => GraphQLBigInt)
active!: number;

@Field(() => Int)
@Field(() => GraphQLBigInt)
available!: number;

@Field(() => Int)
@Field(() => GraphQLBigInt)
buffcache!: number;

@Field(() => Int)
@Field(() => GraphQLBigInt)
swaptotal!: number;

@Field(() => Int)
@Field(() => GraphQLBigInt)
swapused!: number;

@Field(() => Int)
@Field(() => GraphQLBigInt)
swapfree!: number;

@Field(() => [MemoryLayout])
Expand Down
35 changes: 0 additions & 35 deletions api/src/unraid-api/graph/scalars/graphql-type-long.ts

This file was deleted.

8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading