From b7445429ce1916418497710bda0ff1f39943d024 Mon Sep 17 00:00:00 2001 From: c43721 Date: Fri, 8 Nov 2024 13:45:58 -0600 Subject: [PATCH 1/7] chore(docs): document all of logs --- javascript-sdk/logstf/README.md | 23 ++ javascript-sdk/logstf/api/logstf.ts | 3 + javascript-sdk/logstf/mod.ts | 2 +- javascript-sdk/logstf/types/chat.ts | 19 ++ javascript-sdk/logstf/types/classStats.ts | 49 +++++ .../logstf/types/endpoints/logById.ts | 205 ++++++++++++++++-- .../logstf/types/endpoints/logSearch.ts | 23 ++ javascript-sdk/logstf/types/killstreak.ts | 19 ++ javascript-sdk/logstf/types/medicStats.ts | 33 +++ .../logstf/types/playerInformation.ts | 122 +++++++++++ javascript-sdk/logstf/types/roundEvent.ts | 32 ++- .../logstf/types/teamInformation.ts | 34 +++ javascript-sdk/logstf/types/teamRoundInfo.ts | 18 ++ javascript-sdk/logstf/types/tf2ClassMap.ts | 38 ++++ 14 files changed, 603 insertions(+), 17 deletions(-) create mode 100644 javascript-sdk/logstf/README.md create mode 100644 javascript-sdk/logstf/types/chat.ts create mode 100644 javascript-sdk/logstf/types/killstreak.ts diff --git a/javascript-sdk/logstf/README.md b/javascript-sdk/logstf/README.md new file mode 100644 index 0000000..e11d5ac --- /dev/null +++ b/javascript-sdk/logstf/README.md @@ -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. diff --git a/javascript-sdk/logstf/api/logstf.ts b/javascript-sdk/logstf/api/logstf.ts index 0ccf3fc..580818a 100644 --- a/javascript-sdk/logstf/api/logstf.ts +++ b/javascript-sdk/logstf/api/logstf.ts @@ -17,18 +17,21 @@ const getRawLogUrl = (id: string) => `http://logs.tf/logs/log_${id}.log.zip`; /** * The base URL of the for logs.tf + * * @internal */ const logsBaseUrl = "https://logs.tf"; /** * The logs API url + * * @internal */ const logsApiUrl = `${logsBaseUrl}/api/v1`; /** * The logs upload url + * * @internal */ const logsUploadUrl = `${logsBaseUrl}/upload`; diff --git a/javascript-sdk/logstf/mod.ts b/javascript-sdk/logstf/mod.ts index 1c80305..a60e4a5 100644 --- a/javascript-sdk/logstf/mod.ts +++ b/javascript-sdk/logstf/mod.ts @@ -6,5 +6,5 @@ * @module */ -export * from "./types/mod.ts"; export * from "./api/mod.ts"; +export * from "./types/mod.ts"; diff --git a/javascript-sdk/logstf/types/chat.ts b/javascript-sdk/logstf/types/chat.ts new file mode 100644 index 0000000..69bfe2e --- /dev/null +++ b/javascript-sdk/logstf/types/chat.ts @@ -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; +}; diff --git a/javascript-sdk/logstf/types/classStats.ts b/javascript-sdk/logstf/types/classStats.ts index 7e3f6c6..77b5185 100644 --- a/javascript-sdk/logstf/types/classStats.ts +++ b/javascript-sdk/logstf/types/classStats.ts @@ -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; }; diff --git a/javascript-sdk/logstf/types/endpoints/logById.ts b/javascript-sdk/logstf/types/endpoints/logById.ts index 46a9b70..ef3bce5 100644 --- a/javascript-sdk/logstf/types/endpoints/logById.ts +++ b/javascript-sdk/logstf/types/endpoints/logById.ts @@ -1,3 +1,5 @@ +import type { ChatMessage } from "../chat.ts"; +import type { Killstreak } from "../killstreak.ts"; import type { TeamType } from "../mod.ts"; import type { PlayerInformation } from "../playerInformation.ts"; import type { RoundEvent } from "../roundEvent.ts"; @@ -5,89 +7,264 @@ import type { TeamInformation } from "../teamInformation.ts"; import type { TeamRoundInfo } from "../teamRoundInfo.ts"; import type { Tf2ClassMap } from "../tf2ClassMap.ts"; +/** + * The information for a given log + */ export type LogById = { + /** + * Gets the version of the parser used + */ version: string; + + /** + * Gets the length of the log + */ length: number; + + /** + * Gets a flag that determines if the request was successful + */ success: boolean; + + /** + * Gets the aggregated information for each team + */ teams: { Red: TeamInformation; Blue: TeamInformation }; + + /** + * Gets a list of the players to their stats + */ players: { [steamIdThree: string]: PlayerInformation; }; + + /** + * Gets the list of the players and their aliases used in the game + */ names: { [steamIdThree: string]: string; }; + + /** + * Gets information about the round + */ rounds: [ { + /** + * Gets the start date of the round + */ start_time: number; + /** + * Gets the winner of the round + */ winner: TeamType; + /** + * Gets the stats of the round + */ team: { Blue: TeamRoundInfo; Red: TeamRoundInfo; }; + /** + * Gets the events of the round + */ events: RoundEvent[]; + + /** + * Gets the player's stats of the round + */ players: { [steamIdThree: string]: { + /** + * Gets the number of kills the player had this round + */ kills: number; + + /** + * Gets the amount of damage the player dealt + */ dmg: number; }; }; + + /** + * Gets the team who had first cap + */ firstcap: TeamType; + + /** + * Gets the length of the round + */ length: number; } ]; + + /** + * Gets the stats of the healspread to each team member + */ healspread: { [steamIdThree: string]: { + /** + * The number of heals the player received + */ [steamIdThree: string]: number; }; }; + + /** + * Gets the stats of each player and the type of kills they got + */ classkills: { [steamIdThree: string]: Tf2ClassMap; }; + + /** + * Gets the stats of each player and how many times they died to that class + */ classdeaths: { [steamIdThree: string]: Tf2ClassMap; }; + + /** + * Gets the stats of each player and how assists of kills they had to that class + */ classkillassists: { [steamIdThree: string]: Tf2ClassMap; }; - chat: [ - { - steamId: string; - name: string; - msg: string; - } - ]; + + /** + * Gets the chat messages + */ + chat: ChatMessage[]; + + /** + * Gets additional information about the log + */ info: { + /** + * Gets the map that was played + */ map: string; + + /** + * Gets whether supplemental information is available + */ + supplemental: boolean; + /** + * Gets the total length of the log + */ total_length: number; + + /** + * Gets whether real damage is enabled + */ hasRealDamage: boolean; + + /** + * Gets whether the log has weapon damage + */ hasWeaponDamage: boolean; + + /** + * whether the log has accuracy reports + */ hasAccuracy: boolean; + + /** + * Gets whether the log has HTP enabled + */ hasHP: boolean; + + /** + * Gets whether the log has real HP enabled + */ hasHP_real: boolean; + + /** + * whether the log has headshots + */ hasHS: boolean; + + /** + * Gets whether the log has headshots + */ hasHS_hit: boolean; + + /** + * whether the log has backstabs + */ hasBS: boolean; + + /** + * whether the log has captures + */ hasCP: boolean; + + /** + * whether the log has SB + */ hasSB: boolean; + + /** + * Gets whether the log has DT + */ hasDT: boolean; + + /** + * Gets whether the log has airshots + */ hasAS: boolean; + + /** + * Gets whether HR enabled + */ hasHR: boolean; + + /** + * Gets whether intelligence was present + */ hasIntel: boolean; + + /** + * Gets the list of notifications + * + * This is currently unused + */ notifications: []; + + /** + * Gets the title of the log + */ title: string; + /** + * Gets the date the log was uploaded + */ date: number; + + /** + * Information about the uploader + */ uploader: { + /** + * Gets the steam id of the uploader + */ id: string; + + /** + * Gets the name of the uploader + */ name: string; + + /** + * Gets information about how the log was uploaded + */ info: string; }; }; - killstreaks: [ - { - steamid: string; - streak: number; - time: number; - } - ]; + + /** + * Gets the killstreak information + */ + killstreaks: Killstreak[]; }; diff --git a/javascript-sdk/logstf/types/endpoints/logSearch.ts b/javascript-sdk/logstf/types/endpoints/logSearch.ts index 8b18161..8bc8c95 100644 --- a/javascript-sdk/logstf/types/endpoints/logSearch.ts +++ b/javascript-sdk/logstf/types/endpoints/logSearch.ts @@ -27,11 +27,34 @@ export type LogSearchResponse = { */ logs: [ { + /** + * The id of the log + */ id: number; + + /** + * The title of the log + */ title: string; + + /** + * The map that was played + */ map: string; + + /** + * The date the game was played on + */ date: number; + + /** + * The number of views the log has + */ views: number; + + /** + * The number of players in the log + */ players: number; } ]; diff --git a/javascript-sdk/logstf/types/killstreak.ts b/javascript-sdk/logstf/types/killstreak.ts new file mode 100644 index 0000000..491c0c0 --- /dev/null +++ b/javascript-sdk/logstf/types/killstreak.ts @@ -0,0 +1,19 @@ +/** + * Represents a killstreak during the game + */ +export type Killstreak = { + /** + * The steam id that got the killstreak + */ + steamid: string; + /** + * The number of kills in the killstreak + * + */ + streak: number; + + /** + * The time which the killstreak occurred + */ + time: number; +}; diff --git a/javascript-sdk/logstf/types/medicStats.ts b/javascript-sdk/logstf/types/medicStats.ts index 8a34bda..87a3813 100644 --- a/javascript-sdk/logstf/types/medicStats.ts +++ b/javascript-sdk/logstf/types/medicStats.ts @@ -1,10 +1,43 @@ +/** + * The stats of the medic player + */ export type MedicStats = { + /** + * The number of uber charge advantages that were lost + */ advantages_lost: number; + + /** + * The largest advantage lost + */ biggest_advantage_lost: number; + + /** + * The number of deaths that the medic was close to uber + */ deaths_with_95_99_uber: number; + /** + * The number of deaths that occurred within 20 seconds after ubering + */ deaths_within_20s_after_uber: number; + + /** + * The average time before healint + */ avg_time_before_healing: number; + + /** + * The average time to build uber charge + */ avg_time_to_build: number; + + /** + * The average time before the uber was used + */ avg_time_before_using: number; + + /** + * The average number of seconds the uber laster + */ avg_uber_length: number; }; diff --git a/javascript-sdk/logstf/types/playerInformation.ts b/javascript-sdk/logstf/types/playerInformation.ts index 6f7f3ab..ebe89ea 100644 --- a/javascript-sdk/logstf/types/playerInformation.ts +++ b/javascript-sdk/logstf/types/playerInformation.ts @@ -2,36 +2,158 @@ import type { ClassStats } from "./classStats.ts"; import type { TeamType } from "./enums/teamType.ts"; import type { MedicStats } from "./medicStats.ts"; +/** + * The general information for a given player + */ export type PlayerInformation = { + /** + * The team the player was on + */ team: TeamType; + + /** + * The number of kills the player got + */ kills: number; + + /** + * The number of deaths + */ deaths: number; + + /** + * The number of assists + */ assists: number; + + /** + * The number of times the player suicided + */ suicides: number; + + /** + * The kills and assists per death + */ kapd: string; + + /** + * The kills per death + */ kpd: string; + + /** + * The amount of damage dealt + */ dmg: number; + + /** + * The real number of damage dealt + */ dmg_real: number; + + /** + * The damage taken + */ dt: number; + + /** + * The real amount of damage taken + */ dt_real: number; + + /** + * The number of heals received + */ hr: number; + + /** + * The number of health packs picked up + */ lks: number; + + /** + * The number of airshots + */ as: number; + + /** + * The damage per death + */ dapd: number; + + /** + * The damage per death averaged by minute + */ dapm: number; + + /** + * The amount of ubers + */ ubers: number; + + /** + * The amount of drops + */ drops: number; + + /** + * The amount of medkits used + */ medkits: number; + + /** + * The total health recovered with medkits + */ medkits_hp: number; + + /** + * The number of backstabs + */ backstabs: number; + + /** + * The number of headshots + */ headshots: number; + + /** + * The number of headshots hit + */ headshots_hit: number; + + /** + * The number of sentries built + */ sentries: number; + + /** + * The amount that was healed + */ heal: number; + + /** + * The CPC + */ cpc: number; + + /** + * The IC + */ ic: number; + + /** + * The medic specific stats + */ medicstats: MedicStats; + + /** + * The stats of each class + */ class_stats: ClassStats[]; + + /** + * The types of medigun charges the player used + */ ubertypes: { [medigunType: string]: number; }; diff --git a/javascript-sdk/logstf/types/roundEvent.ts b/javascript-sdk/logstf/types/roundEvent.ts index 3e68f86..c57db92 100644 --- a/javascript-sdk/logstf/types/roundEvent.ts +++ b/javascript-sdk/logstf/types/roundEvent.ts @@ -1,8 +1,36 @@ import type { TeamType } from "./enums/teamType.ts"; +/** + * The event that happens in a round + */ export type RoundEvent = { + /** + * The parsed event that happened + */ type: string; + + /** + * The tick the event occurred at + */ time: number; - team: TeamType; - point: number; + + /** + * The team the event belongs to + */ + team?: TeamType; + + /** + * The point that was captured + */ + point?: number; + + /** + * The id of the player who died + */ + steamid?: string; + + /** + * The id of the player that got the kill + */ + killer?: string; }; diff --git a/javascript-sdk/logstf/types/teamInformation.ts b/javascript-sdk/logstf/types/teamInformation.ts index 10f4878..2dd60d0 100644 --- a/javascript-sdk/logstf/types/teamInformation.ts +++ b/javascript-sdk/logstf/types/teamInformation.ts @@ -1,10 +1,44 @@ +/** + * General information about how a team played during the game + */ export type TeamInformation = { + /** + * The amount of points the team earned + */ score: number; + + /** + * The number of kills the team got + */ kills: number; + + /** + * The number of deaths + */ deaths: number; + + /** + * The amount of damage that was dealth + */ dmg: number; + + /** + * The number of uber charges + */ charges: number; + + /** + * The amount of ubers dropped by the team + */ drops: number; + + /** + * The number of captures by the team that were done when the point was neutral + */ firstcaps: number; + + /** + * The number of caps the team had overall + */ caps: number; }; diff --git a/javascript-sdk/logstf/types/teamRoundInfo.ts b/javascript-sdk/logstf/types/teamRoundInfo.ts index 4135add..56d12d7 100644 --- a/javascript-sdk/logstf/types/teamRoundInfo.ts +++ b/javascript-sdk/logstf/types/teamRoundInfo.ts @@ -1,6 +1,24 @@ +/** + * The team round info + */ export type TeamRoundInfo = { + /** + * The score of the round + */ score: number; + + /** + * The number of kills in this round + */ kills: number; + + /** + * The damage dealt this round + */ dmg: number; + + /** + * The number of ubers this round + */ ubers: number; }; diff --git a/javascript-sdk/logstf/types/tf2ClassMap.ts b/javascript-sdk/logstf/types/tf2ClassMap.ts index d790953..139a453 100644 --- a/javascript-sdk/logstf/types/tf2ClassMap.ts +++ b/javascript-sdk/logstf/types/tf2ClassMap.ts @@ -1,11 +1,49 @@ +/** + * The lookup of a class to a number of an action + */ export type Tf2ClassMap = { + /** + * The number of actions on scout + */ scout?: number; + + /** + * The number of actions on soldier + */ solider?: number; + + /** + * The number of actions on pyro + */ pyro?: number; + + /** + * The number of actions on demoman + */ demoman?: number; + + /** + * The number of actions on heavy + */ heavyweapons?: number; + + /** + * The number of actions on engineer + */ engineer?: number; + + /** + * The number of actions on medic + */ medic?: number; + + /** + * The number of actions on sniper + */ sniper?: number; + + /** + * The number of actions on spy + */ spy?: number; }; From 6fe671b211f5329a8328fdc04b22c57e34b21b74 Mon Sep 17 00:00:00 2001 From: c43721 Date: Fri, 8 Nov 2024 13:49:43 -0600 Subject: [PATCH 2/7] chore: module docs --- javascript-sdk/logstf/api/mod.ts | 6 ++++++ javascript-sdk/logstf/types/mod.ts | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/javascript-sdk/logstf/api/mod.ts b/javascript-sdk/logstf/api/mod.ts index 7afdf0e..66d75ed 100644 --- a/javascript-sdk/logstf/api/mod.ts +++ b/javascript-sdk/logstf/api/mod.ts @@ -1,6 +1,12 @@ /** * Provides methods used to interact with the [logs.tf api](https://logs.tf/about) * + * @example Fetching the JSON for a log + * ```ts + * const logJson = await getById("3750052"); + * + * console.log(logJson); + * ``` * @module */ diff --git a/javascript-sdk/logstf/types/mod.ts b/javascript-sdk/logstf/types/mod.ts index a04a5c5..db7e85d 100644 --- a/javascript-sdk/logstf/types/mod.ts +++ b/javascript-sdk/logstf/types/mod.ts @@ -1,5 +1,5 @@ /** - * Provides types used when interacting with the [logs.tf api](https://logs.tf/about) + * Provides the types used when interacting with the [logs.tf api](https://logs.tf/about) and its responses * * @module */ @@ -9,6 +9,8 @@ export * from "./enums/mod.ts"; export * from "./classStats.ts"; export * from "./medicStats.ts"; +export * from "./chat.ts"; +export * from "./killstreak.ts"; export * from "./playerInformation.ts"; export * from "./roundEvent.ts"; export * from "./teamInformation.ts"; From d4750562f14cb0cb3aaa21428caf8c530fdb70c0 Mon Sep 17 00:00:00 2001 From: c43721 Date: Fri, 8 Nov 2024 14:00:17 -0600 Subject: [PATCH 3/7] chore: add test --- javascript-sdk/deno.json | 2 +- javascript-sdk/deno.lock | 18 +++++++++++ javascript-sdk/logstf/deno.json | 2 +- javascript-sdk/logstf/tests/api.test.ts | 43 +++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 javascript-sdk/deno.lock create mode 100644 javascript-sdk/logstf/tests/api.test.ts diff --git a/javascript-sdk/deno.json b/javascript-sdk/deno.json index 82e7f0a..17516f5 100644 --- a/javascript-sdk/deno.json +++ b/javascript-sdk/deno.json @@ -1,5 +1,5 @@ { - "exclude": [".git", "coverage", "docs"], + "exclude": [".git", "coverage", "docs", "tests"], "tasks": { "ok": "deno lint && deno fmt --check" }, diff --git a/javascript-sdk/deno.lock b/javascript-sdk/deno.lock new file mode 100644 index 0000000..cec0cb3 --- /dev/null +++ b/javascript-sdk/deno.lock @@ -0,0 +1,18 @@ +{ + "version": "4", + "specifiers": { + "jsr:@std/assert@*": "1.0.7", + "jsr:@std/internal@^1.0.5": "1.0.5" + }, + "jsr": { + "@std/assert@1.0.7": { + "integrity": "64ce9fac879e0b9f3042a89b3c3f8ccfc9c984391af19e2087513a79d73e28c3", + "dependencies": [ + "jsr:@std/internal" + ] + }, + "@std/internal@1.0.5": { + "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba" + } + } +} diff --git a/javascript-sdk/logstf/deno.json b/javascript-sdk/logstf/deno.json index 04834c6..057d5f8 100644 --- a/javascript-sdk/logstf/deno.json +++ b/javascript-sdk/logstf/deno.json @@ -1,6 +1,6 @@ { "name": "@tf2software/logstf", - "version": "0.0.1", + "version": "0.0.2", "exports": { ".": "./mod.ts", "./api": "./mod.ts", diff --git a/javascript-sdk/logstf/tests/api.test.ts b/javascript-sdk/logstf/tests/api.test.ts new file mode 100644 index 0000000..a910d8e --- /dev/null +++ b/javascript-sdk/logstf/tests/api.test.ts @@ -0,0 +1,43 @@ +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("-99999"); + + assertEquals(log.success, false); +}); From 5a682696507b639bfedf71598def20d8a8093254 Mon Sep 17 00:00:00 2001 From: c43721 Date: Fri, 8 Nov 2024 14:07:37 -0600 Subject: [PATCH 4/7] chore: some modifications --- .github/workflows/publish-javscript-sdk.yml | 3 +++ .gitignore | 6 +++++- javascript-sdk/deno.json | 2 +- javascript-sdk/deno.lock | 18 ------------------ javascript-sdk/logstf/tests/api.test.ts | 3 ++- .../logstf/types/endpoints/logById.ts | 5 +++++ 6 files changed, 16 insertions(+), 21 deletions(-) delete mode 100644 javascript-sdk/deno.lock diff --git a/.github/workflows/publish-javscript-sdk.yml b/.github/workflows/publish-javscript-sdk.yml index a7c4214..b83380b 100644 --- a/.github/workflows/publish-javscript-sdk.yml +++ b/.github/workflows/publish-javscript-sdk.yml @@ -21,5 +21,8 @@ jobs: - name: Set up Deno uses: denoland/setup-deno@v2 + - name: Test + run: deno task test + - name: Publish to JSR run: deno publish --config javascript-sdk/deno.json diff --git a/.gitignore b/.gitignore index 96c0ecc..837724e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -docs/ \ No newline at end of file +.DS_Store +deno.lock +**/cov/ +docs/ +coverage/ \ No newline at end of file diff --git a/javascript-sdk/deno.json b/javascript-sdk/deno.json index 17516f5..a65c09d 100644 --- a/javascript-sdk/deno.json +++ b/javascript-sdk/deno.json @@ -1,7 +1,7 @@ { "exclude": [".git", "coverage", "docs", "tests"], "tasks": { - "ok": "deno lint && deno fmt --check" + "test": "deno test -A --clean" }, "workspace": ["./logstf"] } diff --git a/javascript-sdk/deno.lock b/javascript-sdk/deno.lock deleted file mode 100644 index cec0cb3..0000000 --- a/javascript-sdk/deno.lock +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": "4", - "specifiers": { - "jsr:@std/assert@*": "1.0.7", - "jsr:@std/internal@^1.0.5": "1.0.5" - }, - "jsr": { - "@std/assert@1.0.7": { - "integrity": "64ce9fac879e0b9f3042a89b3c3f8ccfc9c984391af19e2087513a79d73e28c3", - "dependencies": [ - "jsr:@std/internal" - ] - }, - "@std/internal@1.0.5": { - "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba" - } - } -} diff --git a/javascript-sdk/logstf/tests/api.test.ts b/javascript-sdk/logstf/tests/api.test.ts index a910d8e..a025ca7 100644 --- a/javascript-sdk/logstf/tests/api.test.ts +++ b/javascript-sdk/logstf/tests/api.test.ts @@ -37,7 +37,8 @@ Deno.test("Getting a valid log succeeds", async () => { }); Deno.test("Getting an invalid log fails", async () => { - const log = await getById("-99999"); + const log = await getById("999999999999999"); assertEquals(log.success, false); + assertEquals(log.error, "Log not found."); }); diff --git a/javascript-sdk/logstf/types/endpoints/logById.ts b/javascript-sdk/logstf/types/endpoints/logById.ts index ef3bce5..0bbfb44 100644 --- a/javascript-sdk/logstf/types/endpoints/logById.ts +++ b/javascript-sdk/logstf/types/endpoints/logById.ts @@ -16,6 +16,11 @@ export type LogById = { */ version: string; + /** + * Gets the error that occurred + */ + error?: string; + /** * Gets the length of the log */ From 093c52c33a5cfce62ff1324b81be6b640999238e Mon Sep 17 00:00:00 2001 From: c43721 Date: Fri, 8 Nov 2024 14:11:18 -0600 Subject: [PATCH 5/7] chore: add test to ci --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..daa113f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +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 + 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 From 890b68eb73914784121ea40b0cdd4e680e52910d Mon Sep 17 00:00:00 2001 From: c43721 Date: Fri, 8 Nov 2024 14:12:16 -0600 Subject: [PATCH 6/7] fix: fix ci config paths --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index daa113f..f85b8c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: uses: denoland/setup-deno@v2 - name: Test - run: deno task test + run: deno task test --config javascript-sdk/deno.json publish-dry-run: runs-on: ubuntu-latest @@ -40,4 +40,4 @@ jobs: uses: denoland/setup-deno@v2 - name: Dry Publish - run: deno publish --dry-run + run: deno publish --dry-run --config javascript-sdk/deno.json From 85ac12373f44a777cedecc895c7c45f7fd343e9d Mon Sep 17 00:00:00 2001 From: c43721 Date: Fri, 8 Nov 2024 14:13:41 -0600 Subject: [PATCH 7/7] fix: working directory --- .github/workflows/{ci.yml => javascript-ci.yml} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename .github/workflows/{ci.yml => javascript-ci.yml} (91%) diff --git a/.github/workflows/ci.yml b/.github/workflows/javascript-ci.yml similarity index 91% rename from .github/workflows/ci.yml rename to .github/workflows/javascript-ci.yml index f85b8c3..2433734 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/javascript-ci.yml @@ -24,7 +24,8 @@ jobs: uses: denoland/setup-deno@v2 - name: Test - run: deno task test --config javascript-sdk/deno.json + working-directory: ./javascript-sdk + run: deno task test publish-dry-run: runs-on: ubuntu-latest