-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into refactor/user-platform-accounts
- Loading branch information
Showing
197 changed files
with
8,336 additions
and
2,740 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,3 +120,5 @@ core/config/development.json.bak | |
core/config/main.json | ||
|
||
core/config/staging.json | ||
|
||
clients/web/schema.graphql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/zsh | ||
|
||
SESSIONNAME="sprocket" | ||
tmux has-session -t $SESSIONNAME &> /dev/null | ||
|
||
if [ $? != 0 ] | ||
then | ||
tmux new-session -s $SESSIONNAME -n script -d | ||
tmux split-window -h | ||
tmux selectp -t 0 | ||
tmux send-keys 'npm run build --workspaces --if-present' C-m | ||
tmux split-window -v | ||
tmux selectp -t 1 | ||
tmux send-keys 'cd $PWD/core' C-m | ||
tmux send-keys 'sleep 120; npm run dev;' C-m | ||
tmux selectp -t 2 | ||
tmux send-keys 'cd $PWD/clients/web' C-m 'reset' C-m | ||
tmux send-keys 'export PUBLIC_GQL_URL=http://localhost:3001; sleep 240; npm run dev' C-m | ||
tmux split-window -v | ||
tmux selectp -t 3 | ||
tmux send-keys 'cd $PWD/common' C-m 'reset' C-m | ||
tmux selectp -t 0 | ||
fi | ||
|
||
tmux attach -t $SESSIONNAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
clients/discord-bot/src/commands/administrator-commands/database-sync.marshal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {Logger} from "@nestjs/common"; | ||
import {CoreEndpoint, ResponseStatus} from "@sprocketbot/common"; | ||
import {Message} from "discord.js"; | ||
|
||
import {Command, Marshal} from "../../marshal"; | ||
|
||
export class DatabaseSyncMarshal extends Marshal { | ||
private readonly logger = new Logger(DatabaseSyncMarshal.name); | ||
|
||
@Command({ | ||
name: "syncNames", | ||
args: [], | ||
docs: "Sync all player names in the main MLE server.", | ||
}) | ||
async syncNames(m: Message): Promise<void> { | ||
if ( | ||
![ | ||
"353194025995730945", // Adi | ||
"105408136285818880", // Hyper | ||
"423850557334093827", // Hoos | ||
"470703275163779084", // Achilles | ||
"243430304319143936", // Kunics | ||
].includes(m.author.id) | ||
) | ||
return; | ||
|
||
await m.reply("Starting sync..."); | ||
|
||
const serverId = "172404472637685760"; // MLE Main | ||
const server = await this.botClient.guilds.fetch(serverId); | ||
await server.members.fetch(); | ||
|
||
for (const member of server.members.cache.values()) { | ||
const nicknameRequest = await this.coreService.send(CoreEndpoint.GetNicknameByDiscordUser, { | ||
discordId: member.id, | ||
}); | ||
if (nicknameRequest.status === ResponseStatus.ERROR) { | ||
this.logger.log(`Failed to get nickname for ${member.id}`); | ||
continue; | ||
} | ||
|
||
if (member.nickname === nicknameRequest.data) continue; | ||
|
||
await member.setNickname(nicknameRequest.data).catch(err => { | ||
this.logger.error(err); | ||
}); | ||
} | ||
|
||
await m.reply("Sync complete!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ node_modules | |
.env | ||
.env.* | ||
!.env.example | ||
|
||
$houdini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
projects: | ||
default: | ||
schema: | ||
- ./schema.graphql | ||
- ./$houdini/graphql/schema.graphql | ||
documents: | ||
- '**/*.gql' | ||
- '**/*.svelte' | ||
- ./$houdini/graphql/documents.gql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ARG BASE_IMAGE | ||
FROM $BASE_IMAGE AS test_image | ||
ENTRYPOINT npm run test --workspace=clients/web | ||
|
||
FROM $BASE_IMAGE AS app_image | ||
RUN DISABLE_CONFIG=true npm run gen-sdl --workspace=core | ||
RUN cp /app/core/schema.graphql /app/clients/web/schema.graphql | ||
RUN npm run build --workspace=clients/web | ||
ENTRYPOINT node /app/clients/web/build/index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// <references types="houdini-svelte"> | ||
|
||
/** @type {import('houdini').ConfigFile} */ | ||
const config = { | ||
"watchSchema": { | ||
url(env) { | ||
return `${env.PUBLIC_GQL_URL}/graphql` | ||
} | ||
}, | ||
"plugins": { | ||
"houdini-svelte": {}, | ||
}, | ||
scalars: { | ||
DateTime: { type: Date.name } | ||
} | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,63 @@ | ||
{ | ||
"name": "web", | ||
"version": "0.0.1", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite dev", | ||
"build": "vite build", | ||
"preview": "vite preview", | ||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", | ||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", | ||
"lint": "eslint src --fix", | ||
"format": "prettier src --write", | ||
"story:dev": "histoire dev", | ||
"story:build": "histoire build", | ||
"story:preview": "histoire preview" | ||
}, | ||
"devDependencies": { | ||
"@histoire/plugin-svelte": "^0.12.4", | ||
"@steeze-ui/heroicons": "^2.1.0", | ||
"@steeze-ui/svelte-icon": "^1.3.2", | ||
"@sveltejs/adapter-auto": "^1.0.1", | ||
"@sveltejs/kit": "^1.1.1", | ||
"@types/lodash.times": "^4.3.7", | ||
"@typescript-eslint/eslint-plugin": "^5.27.0", | ||
"@typescript-eslint/parser": "^5.27.0", | ||
"autoprefixer": "^10.4.7", | ||
"date-fns": "^2.29.3", | ||
"date-picker-svelte": "^2.2.5", | ||
"eslint": "^8.16.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-svelte3": "^4.0.0", | ||
"filedrop-svelte": "^0.1.2", | ||
"histoire": "^0.12.4", | ||
"lodash.times": "^4.3.2", | ||
"nanoid": "^4.0.0", | ||
"postcss": "^8.4.14", | ||
"postcss-load-config": "^4.0.1", | ||
"prettier-plugin-svelte": "^2.9.0", | ||
"svelte": "^3.44.0", | ||
"svelte-check": "^2.7.1", | ||
"svelte-preprocess": "^4.10.7", | ||
"tailwindcss": "^3.1.5", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.7.4", | ||
"vite": "^4.0.4" | ||
}, | ||
"type": "module", | ||
"dependencies": { | ||
"@faker-js/faker": "^7.6.0", | ||
"echarts": "^5.4.1" | ||
} | ||
"name": "web", | ||
"version": "0.0.1", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite dev", | ||
"build": "vite build", | ||
"preview": "vite preview", | ||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", | ||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", | ||
"lint": "eslint src --fix", | ||
"format": "prettier src --write", | ||
"story:dev": "histoire dev", | ||
"story:build": "histoire build", | ||
"story:preview": "histoire preview" | ||
}, | ||
"devDependencies": { | ||
"@histoire/plugin-svelte": "^0.15.4", | ||
"@steeze-ui/heroicons": "^2.1.0", | ||
"@steeze-ui/simple-icons": "^1.4.0", | ||
"@steeze-ui/svelte-icon": "^1.3.2", | ||
"@sveltejs/adapter-auto": "^1.0.1", | ||
"@sveltejs/kit": "^1.15.2", | ||
"@types/lodash.startcase": "^4.4.7", | ||
"@types/lodash.times": "^4.3.7", | ||
"@typescript-eslint/eslint-plugin": "^5.27.0", | ||
"@typescript-eslint/parser": "^5.27.0", | ||
"autoprefixer": "^10.4.7", | ||
"date-fns": "^2.29.3", | ||
"date-picker-svelte": "^2.2.5", | ||
"eslint": "^8.16.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-svelte3": "^4.0.0", | ||
"filedrop-svelte": "^0.1.2", | ||
"histoire": "^0.15.4", | ||
"houdini": "^1.0.9", | ||
"houdini-svelte": "^1.0.9", | ||
"lodash.times": "^4.3.2", | ||
"nanoid": "^4.0.0", | ||
"postcss": "^8.4.14", | ||
"postcss-load-config": "^4.0.1", | ||
"prettier-plugin-svelte": "^2.9.0", | ||
"svelte": "^3.44.0", | ||
"svelte-check": "^2.7.1", | ||
"svelte-preprocess": "^4.10.7", | ||
"tailwindcss": "^3.1.5", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.7.4", | ||
"vite": "^4.1.5" | ||
}, | ||
"type": "module", | ||
"dependencies": { | ||
"@faker-js/faker": "^7.6.0", | ||
"@fontsource/montserrat": "^4.5.14", | ||
"@sveltejs/adapter-node": "^1.0.0-next.106", | ||
"@tanstack/svelte-table": "^8.9.3", | ||
"echarts": "^5.4.1", | ||
"jwt-decode": "^3.1.2", | ||
"lodash.startcase": "^4.4.0", | ||
"subscriptions-transport-ws": "^0.11.0", | ||
"typescript-cookie": "^1.0.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
body { | ||
font-family: "Montserrat"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import {env} from "$env/dynamic/public"; | ||
import {HoudiniClient} from "$houdini"; | ||
import {SubscriptionClient} from "subscriptions-transport-ws"; | ||
import {subscription} from "$houdini/plugins"; | ||
import {goto} from "$app/navigation"; | ||
import {getAuthCookies, clearAuthCookies} from "$lib/api"; | ||
import {redirect} from "@sveltejs/kit"; | ||
import {refreshAuthPlugin} from "./houdini/refresh-auth.plugin"; | ||
|
||
const getAuthToken = ({ | ||
session, | ||
metadata, | ||
useRefresh, | ||
}: {session?: App.Session; metadata?: App.Metadata; useRefresh?: boolean} = {}) => { | ||
if (metadata?.accessTokenOverride) return metadata.accessTokenOverride; | ||
if (useRefresh && session?.refresh) return session.refresh; | ||
if (session?.access) return session.access; | ||
const cookies = getAuthCookies(); | ||
if (cookies.access) return cookies.access; | ||
return ""; | ||
}; | ||
|
||
export default new HoudiniClient({ | ||
url: `${env.PUBLIC_GQL_URL}/graphql`, | ||
|
||
// uncomment this to configure the network call (for things like authentication) | ||
// for more information, please visit here: https://www.houdinigraphql.com/guides/authentication | ||
fetchParams({session, metadata, document}) { | ||
const authToken = getAuthToken({ | ||
session: session ?? undefined, | ||
metadata: metadata ?? undefined, | ||
useRefresh: false, | ||
}); | ||
return { | ||
headers: { | ||
authorization: `Bearer ${authToken}`, | ||
}, | ||
}; | ||
}, | ||
throwOnError: { | ||
operations: ["all"], | ||
error: errors => { | ||
if (errors.some(e => e.message === "Unauthorized")) { | ||
// TODO: Check if JWT is actually expired, or if this is an authorization issue, not authentication | ||
// TODO: Check to see if we can use the refresh token, and then reload the page | ||
// (e.g. goto with invalidateAll on current path). | ||
// This would create a choppy-ish UX (e.g. page would "soft reload") | ||
// But it would also prevent a user having to log in when they don't need to. | ||
clearAuthCookies(); | ||
|
||
if (typeof window !== "undefined") goto(`/auth/login?next=${encodeURI(window.location.pathname)}`); | ||
else { | ||
throw redirect(307, "/auth/login"); | ||
} | ||
} else { | ||
console.error(errors); | ||
} | ||
}, | ||
}, | ||
plugins: [ | ||
refreshAuthPlugin, | ||
subscription(ctx => { | ||
const c = new SubscriptionClient(`${env.PUBLIC_GQL_URL.replace("http", "ws")}/graphql`, { | ||
reconnect: true, | ||
lazy: true, | ||
}); | ||
return { | ||
subscribe(payload, handlers) { | ||
const {unsubscribe} = c | ||
.request({ | ||
...payload, | ||
context: {authorization: getAuthToken() ? `Bearer ${getAuthToken()}` : undefined}, | ||
}) | ||
.subscribe(handlers); | ||
return unsubscribe; | ||
}, | ||
}; | ||
}), | ||
], | ||
}); |
Oops, something went wrong.