@cs2dak/contract 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/analysis.ts +222 -0
- package/src/cohort.ts +59 -0
- package/src/contract.test.ts +559 -0
- package/src/demo-package.ts +38 -0
- package/src/index.ts +11 -599
- package/src/leaderboard.ts +102 -0
- package/src/player.ts +96 -0
- package/src/qa.ts +21 -0
- package/src/scoring.ts +79 -0
- package/src/series.ts +77 -0
- package/src/team.ts +72 -0
- package/src/upstream.ts +90 -0
- package/src/workspace.ts +167 -0
package/src/workspace.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { teamKeySchema, sideSchema, grenadeTypeSchema, teamEconomySchema } from "cs2-demo-format";
|
|
3
|
+
import { qaReportSchema } from "./qa.js";
|
|
4
|
+
import {
|
|
5
|
+
analysisBundleSchema,
|
|
6
|
+
timelineEventSchema,
|
|
7
|
+
economyPointSchema,
|
|
8
|
+
heatmapPointSchema,
|
|
9
|
+
playerScoreboardRowSchema,
|
|
10
|
+
playerRoundFactSchema,
|
|
11
|
+
mapViewSchema,
|
|
12
|
+
} from "./analysis.js";
|
|
13
|
+
|
|
14
|
+
export const workspaceTabSchema = z.object({
|
|
15
|
+
key: z.enum(["overview", "rounds", "players", "economy", "map", "replay"]),
|
|
16
|
+
label: z.string()
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const workspaceKpiSchema = z.object({
|
|
20
|
+
key: z.string(),
|
|
21
|
+
label: z.string(),
|
|
22
|
+
value: z.string(),
|
|
23
|
+
detail: z.string()
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const workspaceOverviewSchema = z.object({
|
|
27
|
+
kpis: z.array(workspaceKpiSchema),
|
|
28
|
+
story: z.array(z.string())
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const workspaceRoundSchema = z.object({
|
|
32
|
+
roundNumber: z.number().int().positive(),
|
|
33
|
+
scoreBefore: z.string(),
|
|
34
|
+
winnerTeamKey: teamKeySchema,
|
|
35
|
+
winnerSide: sideSchema,
|
|
36
|
+
endReason: z.string(),
|
|
37
|
+
teamAEconomy: teamEconomySchema,
|
|
38
|
+
teamBEconomy: teamEconomySchema,
|
|
39
|
+
events: z.array(timelineEventSchema),
|
|
40
|
+
playerFacts: z.array(playerRoundFactSchema)
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const workspacePlayerSchema = z.object({
|
|
44
|
+
row: playerScoreboardRowSchema,
|
|
45
|
+
teamName: z.string(),
|
|
46
|
+
summary: z.array(z.string()),
|
|
47
|
+
rrBreakdown: z.array(z.object({
|
|
48
|
+
key: z.enum(["combat", "trade", "clutch", "objective", "utility"]),
|
|
49
|
+
label: z.string(),
|
|
50
|
+
value: z.number()
|
|
51
|
+
})),
|
|
52
|
+
roundFacts: z.array(playerRoundFactSchema)
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const workspaceMapModeSchema = z.object({
|
|
56
|
+
key: z.enum(["death", "kill", "grenade", "bomb", "position"]),
|
|
57
|
+
label: z.string(),
|
|
58
|
+
count: z.number().int().nonnegative()
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const workspaceSpatialPointSchema = z.object({
|
|
62
|
+
x: z.number(),
|
|
63
|
+
y: z.number(),
|
|
64
|
+
z: z.number(),
|
|
65
|
+
roundNumber: z.number().int().positive(),
|
|
66
|
+
teamKey: teamKeySchema.nullable(),
|
|
67
|
+
steamId64: z.string().nullable(),
|
|
68
|
+
side: sideSchema.nullable(),
|
|
69
|
+
kind: z.enum(["kill", "death", "grenade", "bomb", "position"]),
|
|
70
|
+
grenadeType: grenadeTypeSchema.nullable()
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export const workspaceMapSchema = z.object({
|
|
74
|
+
view: mapViewSchema,
|
|
75
|
+
modes: z.array(workspaceMapModeSchema),
|
|
76
|
+
points: z.array(workspaceSpatialPointSchema),
|
|
77
|
+
status: z.object({
|
|
78
|
+
hasRadar: z.boolean(),
|
|
79
|
+
hasPositionData: z.boolean(),
|
|
80
|
+
message: z.string().nullable()
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const workspaceReplayFrameSchema = z.object({
|
|
85
|
+
tick: z.number().int().positive(),
|
|
86
|
+
x: z.number(),
|
|
87
|
+
y: z.number(),
|
|
88
|
+
z: z.number(),
|
|
89
|
+
yaw: z.number(),
|
|
90
|
+
hp: z.number().int().nonnegative().max(100),
|
|
91
|
+
weapon: z.string().nullable(),
|
|
92
|
+
alive: z.boolean(),
|
|
93
|
+
flashed: z.boolean(),
|
|
94
|
+
hasDefuseKit: z.boolean()
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export const workspaceReplayPlayerSchema = z.object({
|
|
98
|
+
steamId64: z.string(),
|
|
99
|
+
name: z.string(),
|
|
100
|
+
teamKey: teamKeySchema,
|
|
101
|
+
side: sideSchema,
|
|
102
|
+
frames: z.array(workspaceReplayFrameSchema)
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export const workspaceKillEventSchema = z.object({
|
|
106
|
+
id: z.string(),
|
|
107
|
+
tick: z.number().int().positive(),
|
|
108
|
+
killerName: z.string().nullable(),
|
|
109
|
+
killerTeamKey: teamKeySchema.nullable(),
|
|
110
|
+
victimName: z.string(),
|
|
111
|
+
weapon: z.string(),
|
|
112
|
+
headshot: z.boolean(),
|
|
113
|
+
throughSmoke: z.boolean(),
|
|
114
|
+
noScope: z.boolean(),
|
|
115
|
+
flashAssist: z.boolean(),
|
|
116
|
+
tradeKill: z.boolean()
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
export const workspaceReplayRoundSchema = z.object({
|
|
120
|
+
roundNumber: z.number().int().positive(),
|
|
121
|
+
startTick: z.number().int().positive(),
|
|
122
|
+
tickStep: z.number().int().positive(),
|
|
123
|
+
frameCount: z.number().int().nonnegative(),
|
|
124
|
+
players: z.array(workspaceReplayPlayerSchema),
|
|
125
|
+
kills: z.array(workspaceKillEventSchema)
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export const workspaceReplaySchema = z.object({
|
|
129
|
+
available: z.boolean(),
|
|
130
|
+
sampleRate: z.number().int().positive().nullable(),
|
|
131
|
+
tickrate: z.number().int().positive().nullable(),
|
|
132
|
+
rounds: z.array(workspaceReplayRoundSchema),
|
|
133
|
+
capabilities: z.object({
|
|
134
|
+
hasDefuseKit: z.boolean(),
|
|
135
|
+
hasBombPosition: z.boolean()
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export const matchWorkspaceModelSchema = z.object({
|
|
140
|
+
version: z.literal("cs2-demo-analysis-kit/workspace-0.1"),
|
|
141
|
+
sourceSchemaVersion: z.literal("cs2-demo-format/2.0"),
|
|
142
|
+
title: z.string(),
|
|
143
|
+
subtitle: z.string(),
|
|
144
|
+
scoreline: z.string(),
|
|
145
|
+
mapName: z.string(),
|
|
146
|
+
teams: analysisBundleSchema.shape.teams,
|
|
147
|
+
tabs: z.array(workspaceTabSchema),
|
|
148
|
+
overview: workspaceOverviewSchema,
|
|
149
|
+
scoreboard: z.array(playerScoreboardRowSchema),
|
|
150
|
+
rounds: z.array(workspaceRoundSchema),
|
|
151
|
+
players: z.array(workspacePlayerSchema),
|
|
152
|
+
economy: z.array(economyPointSchema),
|
|
153
|
+
map: workspaceMapSchema,
|
|
154
|
+
replay: workspaceReplaySchema,
|
|
155
|
+
adminQa: qaReportSchema
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
export type WorkspaceTab = z.infer<typeof workspaceTabSchema>;
|
|
159
|
+
export type WorkspaceKpi = z.infer<typeof workspaceKpiSchema>;
|
|
160
|
+
export type WorkspaceRound = z.infer<typeof workspaceRoundSchema>;
|
|
161
|
+
export type WorkspacePlayer = z.infer<typeof workspacePlayerSchema>;
|
|
162
|
+
export type WorkspaceSpatialPoint = z.infer<typeof workspaceSpatialPointSchema>;
|
|
163
|
+
export type WorkspaceReplayFrame = z.infer<typeof workspaceReplayFrameSchema>;
|
|
164
|
+
export type WorkspaceReplayPlayer = z.infer<typeof workspaceReplayPlayerSchema>;
|
|
165
|
+
export type WorkspaceKillEvent = z.infer<typeof workspaceKillEventSchema>;
|
|
166
|
+
export type WorkspaceReplayRound = z.infer<typeof workspaceReplayRoundSchema>;
|
|
167
|
+
export type MatchWorkspaceModel = z.infer<typeof matchWorkspaceModelSchema>;
|