-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(core,docs,logstf): document all of logstf and add tests with ci (…
…#12)
- Loading branch information
Showing
22 changed files
with
716 additions
and
22 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: ci | ||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- "javascript-sdk/**" | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- "javascript-sdk/**" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Deno | ||
uses: denoland/setup-deno@v2 | ||
|
||
- name: Test | ||
working-directory: ./javascript-sdk | ||
run: deno task test | ||
|
||
publish-dry-run: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Deno | ||
uses: denoland/setup-deno@v2 | ||
|
||
- name: Dry Publish | ||
run: deno publish --dry-run --config javascript-sdk/deno.json |
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
docs/ | ||
.DS_Store | ||
deno.lock | ||
**/cov/ | ||
docs/ | ||
coverage/ |
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,7 +1,7 @@ | ||
{ | ||
"exclude": [".git", "coverage", "docs"], | ||
"exclude": [".git", "coverage", "docs", "tests"], | ||
"tasks": { | ||
"ok": "deno lint && deno fmt --check" | ||
"test": "deno test -A --clean" | ||
}, | ||
"workspace": ["./logstf"] | ||
} |
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,23 @@ | ||
# logs.tf | ||
|
||
The types and SDK that can interact with the (logs.tf api)[https://logs.tf/about]. | ||
|
||
## Install | ||
|
||
Checkout the [jsr page](https://jsr.io/@tf2software/logstf) for more details. | ||
|
||
### Examples | ||
|
||
A simple example that can request the log json of a particular game: | ||
|
||
```ts | ||
const logJson = await getById("3750052"); | ||
|
||
console.log(logJson); | ||
``` | ||
|
||
For more examples, see the [documentation on jsr](https://jsr.io/@tf2software/logstf/doc) | ||
|
||
## License | ||
|
||
Distributed under the MIT License. See [LICENSE](LICENSE) for more information. |
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
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,5 +6,5 @@ | |
* @module | ||
*/ | ||
|
||
export * from "./types/mod.ts"; | ||
export * from "./api/mod.ts"; | ||
export * from "./types/mod.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,44 @@ | ||
import { getById } from "../mod.ts"; | ||
import { assertEquals, assertExists, assertObjectMatch } from "jsr:@std/assert"; | ||
|
||
Deno.test("Getting a valid log succeeds", async () => { | ||
const log = await getById("3750052"); | ||
|
||
assertEquals(log.success, true); | ||
assertExists(log.chat); | ||
assertObjectMatch(log.info, { | ||
map: "cp_metalworks_f5", | ||
supplemental: true, | ||
total_length: 932, | ||
hasRealDamage: true, | ||
hasWeaponDamage: true, | ||
hasAccuracy: true, | ||
hasHP: true, | ||
hasHP_real: true, | ||
hasHS: false, | ||
hasHS_hit: false, | ||
hasBS: false, | ||
hasCP: true, | ||
hasSB: false, | ||
hasDT: true, | ||
hasAS: true, | ||
hasHR: true, | ||
hasIntel: false, | ||
AD_scoring: false, | ||
notifications: [], | ||
title: "na.serveme.tf #574912: RED vs BLU", | ||
date: 1731040571, | ||
uploader: { | ||
id: "76561197960497430", | ||
name: "Arie - VanillaTF2.org", | ||
info: "LogsTF 2.6.0", | ||
}, | ||
}); | ||
}); | ||
|
||
Deno.test("Getting an invalid log fails", async () => { | ||
const log = await getById("999999999999999"); | ||
|
||
assertEquals(log.success, false); | ||
assertEquals(log.error, "Log not found."); | ||
}); |
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,19 @@ | ||
/** | ||
* A chat message | ||
*/ | ||
export type ChatMessage = { | ||
/** | ||
* The steam id of the player that said the message | ||
*/ | ||
steamid: string; | ||
|
||
/** | ||
* The name of the player | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* The content of the message | ||
*/ | ||
msg: string; | ||
}; |
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,17 +1,66 @@ | ||
/** | ||
* Statistics for each type of class that the player played as | ||
*/ | ||
export type ClassStats = { | ||
/** | ||
* The class that was played | ||
*/ | ||
type: string; | ||
|
||
/** | ||
* The number of kills | ||
*/ | ||
kills: number; | ||
|
||
/** | ||
* The number of assists | ||
*/ | ||
assists: number; | ||
|
||
/** | ||
* The number of deaths | ||
*/ | ||
deaths: number; | ||
|
||
/** | ||
* The total damage dealt | ||
*/ | ||
dmg: number; | ||
|
||
/** | ||
* Statistics about the weapons used by the player | ||
*/ | ||
weapon: { | ||
[weaponName: string]: { | ||
/** | ||
* The number of kills with this weapon | ||
*/ | ||
kills: number; | ||
|
||
/** | ||
* The amount of damage dealt by the weapon | ||
*/ | ||
dmg: number; | ||
|
||
/** | ||
* The average damage with this weapon | ||
*/ | ||
avg_dmg: number; | ||
|
||
/** | ||
* The total number of shots with this weapon | ||
*/ | ||
shots: number; | ||
|
||
/** | ||
* The number of shots that hit another player | ||
*/ | ||
hits: number; | ||
}; | ||
}; | ||
|
||
/** | ||
* The amount of time on this class | ||
*/ | ||
total_time: number; | ||
}; |
Oops, something went wrong.