-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
306 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | ||
fragment RankedResultBaseFragment on RankedResult { | ||
id | ||
versionName | ||
versionType | ||
competitionEventId | ||
maxEntryLockedAt | ||
results | ||
} |
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,21 @@ | ||
query Leaderboard ($groupId: ID!, $limit: Int, $maxVisibility: ResultVersionType) { | ||
group (groupId: $groupId) { | ||
id | ||
name | ||
|
||
categories { | ||
id | ||
name | ||
type | ||
|
||
participants { | ||
...AthleteFragment | ||
...TeamFragment | ||
} | ||
|
||
rankedResults (limit: $limit, maxVisibility: $maxVisibility) { | ||
...RankedResultBaseFragment | ||
} | ||
} | ||
} | ||
} |
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,32 @@ | ||
import { unref, watch, isRef, ref } from 'vue' | ||
import { importPreconfiguredCompetitionEvent } from '../import-helpers' | ||
import type { MaybeRef } from '@vueuse/core' | ||
import { type CompetitionEvent } from '@ropescore/rulesets' | ||
|
||
export function useCompetitionEvent (competitionEventId: MaybeRef<string | undefined>) { | ||
const competitionEvent = ref<CompetitionEvent>() | ||
|
||
const key = unref(competitionEventId) | ||
if (key != null) { | ||
importPreconfiguredCompetitionEvent(key) | ||
.then(ce => { competitionEvent.value = ce }) | ||
.catch(err => { | ||
console.error(err) | ||
}) | ||
} | ||
|
||
if (isRef(competitionEventId)) { | ||
watch(competitionEventId, id => { | ||
if (id == null) competitionEvent.value = undefined | ||
else { | ||
importPreconfiguredCompetitionEvent(id) | ||
.then(ce => { competitionEvent.value = ce }) | ||
.catch(err => { | ||
console.error(err) | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
return competitionEvent | ||
} |
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,53 @@ | ||
import { RSUnsupported } from '@ropescore/rulesets' | ||
import type { CompetitionEventModel, OverallModel, CompetitionEvent, Overall, Ruleset } from '@ropescore/rulesets' | ||
|
||
const modelRegex = /^[a-z0-9-.]+@(?<version>[a-z0-9-.]+)$/ | ||
const evtDefRegex = /^e\.(?<org>[a-z]+)(?:\.(?:[a-z0-9-]+)){5}@(?<version>[a-z0-9-.]+)$/ | ||
const rulesetRegex = /^[a-z0-9-]+@(?<version>[a-z0-9-.]+)$/ | ||
|
||
export async function importCompetitionEventModel (modelId: string): Promise<CompetitionEventModel> { | ||
if (!modelRegex.test(modelId)) throw new TypeError('Invalid competitionEvent provided must be in the form of <model id>@<version>') | ||
try { | ||
return (await import(`../node_modules/@ropescore/rulesets/dist/esm/lib/models/competition-events/${modelId}.js`)).default | ||
} catch { | ||
throw new RSUnsupported('competition-event-model', modelId) | ||
} | ||
} | ||
export async function importOverallModel (modelId: string): Promise<OverallModel> { | ||
if (!modelRegex.test(modelId)) throw new TypeError('Invalid competitionEvent provided must be in the form of <model id>@<version>') | ||
try { | ||
return (await import(`../node_modules/@ropescore/rulesets/dist/esm/lib/models/overalls/${modelId}.js`)).default | ||
} catch { | ||
throw new RSUnsupported('overall-model', modelId) | ||
} | ||
} | ||
|
||
export async function importPreconfiguredCompetitionEvent (competitionEvent: string): Promise<CompetitionEvent> { | ||
const match = evtDefRegex.exec(competitionEvent) | ||
if (match?.groups?.org == null || match.groups?.version == null) throw new TypeError('Invalid competitionEvent provided must be in the form of <event definition lookup code>@<version>') | ||
try { | ||
return (await import(`../node_modules/@ropescore/rulesets/dist/esm/lib/preconfigured/competition-events/${match.groups.org}/${match.groups.version}/${competitionEvent}.js`)).default | ||
} catch { | ||
throw new RSUnsupported('competition-event-preconfigured', competitionEvent) | ||
} | ||
} | ||
export async function importPreconfiguredOverall (competitionEvent: string): Promise<Overall> { | ||
const match = evtDefRegex.exec(competitionEvent) | ||
if (match?.groups?.org == null || match.groups?.version == null) throw new TypeError('Invalid competitionEvent provided must be in the form of <event definition lookup code>@<version>') | ||
try { | ||
return (await import(`../node_modules/@ropescore/rulesets/dist/esm/lib/preconfigured/overalls/${match.groups.org}/${match.groups.version}/${competitionEvent}.js`)).default | ||
} catch { | ||
throw new RSUnsupported('overall-preconfigured', competitionEvent) | ||
} | ||
} | ||
|
||
export async function importRuleset (rulesetId: string): Promise<Ruleset> { | ||
if (!rulesetRegex.test(rulesetId)) throw new TypeError('Invalid competitionEvent provided must be in the form of <ruleset id>@<version>') | ||
if (rulesetId === 'types') throw new RSUnsupported('ruleset', rulesetId) | ||
try { | ||
return (await import(`../node_modules/@ropescore/rulesets/dist/esm/lib/rulesets/${rulesetId}.js`)).default | ||
} catch (err) { | ||
console.error(err) | ||
throw new RSUnsupported('ruleset', rulesetId) | ||
} | ||
} |
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
Oops, something went wrong.