Skip to content

Commit 7bce139

Browse files
committed
Refactor Mothership integration to use WebSocket-based UnraidServerClient
- Updated package.json scripts to remove MOTHERSHIP_GRAPHQL_LINK environment variable. - Changed MOTHERSHIP_GRAPHQL_LINK to MOTHERSHIP_BASE_URL in environment.ts. - Removed GraphQL code generation for Mothership types in codegen.ts. - Updated connection status services to use MOTHERSHIP_BASE_URL. - Refactored MothershipSubscriptionHandler to utilize UnraidServerClient instead of GraphQL client. - Implemented UnraidServerClient for WebSocket communication with Mothership. - Enhanced MothershipController to manage UnraidServerClient lifecycle. - Added reconnection logic and ping/pong handling in UnraidServerClient. - Simplified GraphQL execution logic in UnraidServerClient.
1 parent 1a8da6d commit 7bce139

File tree

17 files changed

+790
-627
lines changed

17 files changed

+790
-627
lines changed

.claude/settings.local.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
"Bash(mv:*)",
1515
"Bash(ls:*)",
1616
"mcp__ide__getDiagnostics",
17-
"Bash(pnpm --filter \"*connect*\" test connect-status-writer.service.spec)"
17+
"Bash(pnpm --filter \"*connect*\" test connect-status-writer.service.spec)",
18+
"Bash(npx tsc:*)",
19+
"Bash(npx eslint:*)",
20+
"Bash(rm:*)"
1821
]
1922
},
2023
"enableAllProjectMcpServers": false

api/.env.development

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ PATHS_ACTIVATION_BASE=./dev/activation
1515
PATHS_PASSWD=./dev/passwd
1616
PATHS_RCLONE_SOCKET=./dev/rclone-socket
1717
PATHS_LOG_BASE=./dev/log # Where we store logs
18+
PATHS_CONNECT_STATUS=./dev/states/connectStatus.json # Connect status file for development
1819
ENVIRONMENT="development"
1920
NODE_ENV="development"
2021
PORT="3001"
2122
PLAYGROUND=true
2223
INTROSPECTION=true
23-
MOTHERSHIP_GRAPHQL_LINK="http://authenticator:3000/graphql"
24+
MOTHERSHIP_BASE_URL="http://localhost:8787"
2425
NODE_TLS_REJECT_UNAUTHORIZED=0
2526
BYPASS_PERMISSION_CHECKS=false
2627
BYPASS_CORS_CHECKS=true

api/codegen.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,7 @@ const config: CodegenConfig = {
2727
},
2828
},
2929
generates: {
30-
// Generate Types for Mothership GraphQL Client
31-
'src/graphql/generated/client/': {
32-
documents: './src/graphql/mothership/*.ts',
33-
schema: {
34-
[process.env.MOTHERSHIP_GRAPHQL_LINK as string]: {
35-
headers: {
36-
origin: 'https://forums.unraid.net',
37-
},
38-
},
39-
},
40-
preset: 'client',
41-
presetConfig: {
42-
gqlTagName: 'graphql',
43-
},
44-
config: {
45-
useTypeImports: true,
46-
withObjectType: true,
47-
},
48-
plugins: [{ add: { content: '/* eslint-disable */' } }],
49-
},
50-
'src/graphql/generated/client/validators.ts': {
51-
schema: {
52-
[process.env.MOTHERSHIP_GRAPHQL_LINK as string]: {
53-
headers: {
54-
origin: 'https://forums.unraid.net',
55-
},
56-
},
57-
},
58-
plugins: ['typescript-validation-schema', { add: { content: '/* eslint-disable */' } }],
59-
config: {
60-
importFrom: '@app/graphql/generated/client/graphql.js',
61-
strictScalars: false,
62-
schema: 'zod',
63-
},
64-
},
30+
// No longer generating mothership GraphQL types since we switched to WebSocket-based UnraidServerClient
6531
},
6632
};
6733

api/dev/configs/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "4.9.5",
2+
"version": "4.10.0",
33
"extraOrigins": [
44
"https://google.com",
55
"https://test.com"

api/dev/configs/connect.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{
2-
"wanaccess": false,
3-
"wanport": 0,
2+
"wanaccess": true,
3+
"wanport": 8443,
44
"upnpEnabled": false,
5-
"apikey": "",
6-
"localApiKey": "",
7-
"email": "",
8-
"username": "",
9-
"avatar": "",
10-
"regWizTime": "",
5+
"apikey": "test-key-123",
6+
"localApiKey": "_______________________LOCAL_API_KEY_HERE_________________________",
7+
"email": "test@example.com",
8+
"username": "zspearmint",
9+
"avatar": "https://via.placeholder.com/200",
10+
"regWizTime": "1611175408732_0951-1653-3509-FBA155FA23C0",
11+
"dynamicRemoteAccessType": "DISABLED",
12+
"version": "4.4.1",
13+
"extraOrigins": "https://google.com,https://test.com",
14+
"sandbox": "yes",
1115
"accesstoken": "",
1216
"idtoken": "",
1317
"refreshtoken": "",
14-
"dynamicRemoteAccessType": "DISABLED",
15-
"ssoSubIds": []
18+
"ssoSubIds": ""
1619
}

api/dev/states/connectStatus.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"connectionStatus": "PRE_INIT",
3+
"error": null,
4+
"lastPing": null,
5+
"allowedOrigins": "",
6+
"timestamp": 1752935274494
7+
}

0 commit comments

Comments
 (0)