Skip to content

Commit 75829b1

Browse files
committed
feat: use bigint instead of long
1 parent 7067e9e commit 75829b1

File tree

8 files changed

+36
-61
lines changed

8 files changed

+36
-61
lines changed

api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
"ini": "^5.0.0",
116116
"ip": "^2.0.1",
117117
"jose": "^6.0.0",
118+
"json-bigint-patch": "^0.0.8",
118119
"lodash-es": "^4.17.21",
119120
"multi-ini": "^2.3.2",
120121
"mustache": "^4.2.0",

api/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import '@app/dotenv.js';
2+
import 'json-bigint-patch';
23

34
import { execa } from 'execa';
45
import { CommandFactory } from 'nest-commander';

api/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'reflect-metadata';
22
import 'global-agent/bootstrap.js';
3+
import 'json-bigint-patch';
34
import '@app/dotenv.js';
45

56
import { type NestFastifyApplication } from '@nestjs/platform-fastify';

api/src/unraid-api/graph/graph.module.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Module } from '@nestjs/common';
44
import { GraphQLModule } from '@nestjs/graphql';
55

66
import { NoUnusedVariablesRule } from 'graphql';
7-
import { JSONResolver, URLResolver } from 'graphql-scalars';
7+
import { GraphQLBigInt, JSONResolver, URLResolver } from 'graphql-scalars';
88

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

@@ -50,7 +49,7 @@ import { PluginModule } from '@app/unraid-api/plugin/plugin.module.js';
5049
},
5150
resolvers: {
5251
JSON: JSONResolver,
53-
Long: GraphQLLong,
52+
Long: GraphQLBigInt,
5453
URL: URLResolver,
5554
},
5655
buildSchemaOptions: {

api/src/unraid-api/graph/resolvers/array/array.model.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Field, InputType, Int, ObjectType, registerEnumType } from '@nestjs/graphql';
22

33
import { IsEnum } from 'class-validator';
4+
import { GraphQLBigInt } from 'graphql-scalars';
45

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

99
@ObjectType()
@@ -43,7 +43,7 @@ export class ArrayDisk extends Node {
4343
@Field(() => String, { nullable: true })
4444
device?: string;
4545

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

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

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

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

75-
@Field(() => GraphQLLong, {
75+
@Field(() => GraphQLBigInt, {
7676
nullable: true,
7777
description:
7878
'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.',
7979
})
8080
numErrors?: number | null;
8181

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

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

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

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

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

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

255255
@Field(() => [String], { description: 'Disks that are included in this share', nullable: true })

api/src/unraid-api/graph/resolvers/info/info.model.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
registerEnumType,
99
} from '@nestjs/graphql';
1010

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

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

291291
@ObjectType({ implements: () => Node })
292292
export class MemoryLayout extends Node {
293-
@Field(() => Int)
293+
@Field(() => GraphQLBigInt)
294294
size!: number;
295295

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

327327
@ObjectType({ implements: () => Node })
328328
export class InfoMemory extends Node {
329-
@Field(() => Int)
329+
@Field(() => GraphQLBigInt)
330330
max!: number;
331331

332-
@Field(() => Int)
332+
@Field(() => GraphQLBigInt)
333333
total!: number;
334334

335-
@Field(() => Int)
335+
@Field(() => GraphQLBigInt)
336336
free!: number;
337337

338-
@Field(() => Int)
338+
@Field(() => GraphQLBigInt)
339339
used!: number;
340340

341-
@Field(() => Int)
341+
@Field(() => GraphQLBigInt)
342342
active!: number;
343343

344-
@Field(() => Int)
344+
@Field(() => GraphQLBigInt)
345345
available!: number;
346346

347-
@Field(() => Int)
347+
@Field(() => GraphQLBigInt)
348348
buffcache!: number;
349349

350-
@Field(() => Int)
350+
@Field(() => GraphQLBigInt)
351351
swaptotal!: number;
352352

353-
@Field(() => Int)
353+
@Field(() => GraphQLBigInt)
354354
swapused!: number;
355355

356-
@Field(() => Int)
356+
@Field(() => GraphQLBigInt)
357357
swapfree!: number;
358358

359359
@Field(() => [MemoryLayout])

api/src/unraid-api/graph/scalars/graphql-type-long.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)