@crowdedkingdoms/crowdyjs 8.8.0 → 8.10.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/MIGRATION.md +59 -0
- package/README.md +5 -1
- package/dist/domains/compute.d.ts +13 -2
- package/dist/domains/compute.d.ts.map +1 -1
- package/dist/domains/compute.js +19 -2
- package/dist/generated/graphql.d.ts +60 -0
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/kit/abilities.d.ts +66 -0
- package/dist/kit/abilities.d.ts.map +1 -0
- package/dist/kit/abilities.js +71 -0
- package/dist/kit/blueprints/index.d.ts +3 -1
- package/dist/kit/blueprints/index.d.ts.map +1 -1
- package/dist/kit/blueprints/index.js +3 -1
- package/dist/kit/blueprints/inventory.d.ts +47 -1
- package/dist/kit/blueprints/inventory.d.ts.map +1 -1
- package/dist/kit/blueprints/inventory.js +112 -12
- package/dist/kit/blueprints/liveops.d.ts +42 -0
- package/dist/kit/blueprints/liveops.d.ts.map +1 -0
- package/dist/kit/blueprints/liveops.js +170 -0
- package/dist/kit/blueprints/moderation.d.ts +32 -0
- package/dist/kit/blueprints/moderation.d.ts.map +1 -0
- package/dist/kit/blueprints/moderation.js +140 -0
- package/dist/kit/combat.d.ts +4 -3
- package/dist/kit/combat.d.ts.map +1 -1
- package/dist/kit/combat.js +4 -3
- package/dist/kit/index.d.ts +9 -2
- package/dist/kit/index.d.ts.map +1 -1
- package/dist/kit/index.js +9 -2
- package/dist/kit/inventory.d.ts +13 -0
- package/dist/kit/inventory.d.ts.map +1 -1
- package/dist/kit/inventory.js +33 -4
- package/dist/kit/kit.d.ts +44 -0
- package/dist/kit/kit.d.ts.map +1 -1
- package/dist/kit/kit.js +35 -1
- package/dist/kit/liveops.d.ts +112 -0
- package/dist/kit/liveops.d.ts.map +1 -0
- package/dist/kit/liveops.js +183 -0
- package/dist/kit/loot.d.ts +22 -1
- package/dist/kit/loot.d.ts.map +1 -1
- package/dist/kit/loot.js +41 -1
- package/dist/kit/moderation.d.ts +73 -0
- package/dist/kit/moderation.d.ts.map +1 -0
- package/dist/kit/moderation.js +103 -0
- package/dist/kit/movement.d.ts +78 -0
- package/dist/kit/movement.d.ts.map +1 -0
- package/dist/kit/movement.js +103 -0
- package/dist/kit/npcs.d.ts.map +1 -1
- package/dist/kit/quests.d.ts +4 -0
- package/dist/kit/quests.d.ts.map +1 -1
- package/dist/kit/quests.js +9 -2
- package/dist/kit/racing.d.ts +85 -0
- package/dist/kit/racing.d.ts.map +1 -0
- package/dist/kit/racing.js +99 -0
- package/dist/kit/social.d.ts.map +1 -1
- package/dist/kit/telemetry.d.ts +66 -0
- package/dist/kit/telemetry.d.ts.map +1 -0
- package/dist/kit/telemetry.js +133 -0
- package/dist/kit/territory.d.ts +97 -0
- package/dist/kit/territory.d.ts.map +1 -0
- package/dist/kit/territory.js +114 -0
- package/dist/kit/wire.d.ts +51 -0
- package/dist/kit/wire.d.ts.map +1 -1
- package/dist/kit/wire.js +60 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moderation.d.ts","sourceRoot":"","sources":["../../src/kit/moderation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIvD,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,2BAA2B;AAC3B,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;I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|
+
/**
|
|
4
|
+
* Runtime helpers for the moderation blueprint: file reports, read the
|
|
5
|
+
* admin escalation queue, resolve reports, and manage the caller's personal
|
|
6
|
+
* mute list (client-enforced chat filtering). Enforcement stays on platform
|
|
7
|
+
* surfaces — tier revocation and grid permissions.
|
|
8
|
+
*
|
|
9
|
+
* Obtained via `client.kit(appId).moderation`.
|
|
10
|
+
*/
|
|
11
|
+
export class ModerationKit {
|
|
12
|
+
constructor(appId, gameModel, options = {}) {
|
|
13
|
+
this.appId = appId;
|
|
14
|
+
this.gameModel = gameModel;
|
|
15
|
+
this.names = moderationNames(options.typePrefix ?? '');
|
|
16
|
+
}
|
|
17
|
+
/** File a report (creates the caller's report row in the queue). */
|
|
18
|
+
async report(input) {
|
|
19
|
+
return this.gameModel.createContainer({
|
|
20
|
+
appId: this.appId,
|
|
21
|
+
typeName: this.names.reportType,
|
|
22
|
+
displayName: `report ${input.reason} vs ${input.subjectUserId}`,
|
|
23
|
+
properties: [
|
|
24
|
+
{ key: 'reporter_user_id', valueType: 'string', valueJson: JSON.stringify(input.reporterUserId) },
|
|
25
|
+
{ key: 'subject_user_id', valueType: 'string', valueJson: JSON.stringify(input.subjectUserId) },
|
|
26
|
+
{ key: 'reason', valueType: 'string', valueJson: JSON.stringify(input.reason) },
|
|
27
|
+
{ key: 'detail', valueType: 'string', valueJson: JSON.stringify((input.detail ?? '').slice(0, 500)) },
|
|
28
|
+
{ key: 'filed_at_ms', valueType: 'int', valueJson: String(Date.now()) },
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** The escalation queue (admins; filter by status, default `'open'`). */
|
|
33
|
+
async queue(status = 'open') {
|
|
34
|
+
const containers = await this.gameModel.containers({
|
|
35
|
+
appId: this.appId,
|
|
36
|
+
typeName: this.names.reportType,
|
|
37
|
+
});
|
|
38
|
+
const rows = await Promise.all(containers.map(async (c) => {
|
|
39
|
+
const props = await kitContainerProperties(this.gameModel, String(this.appId), c.containerId);
|
|
40
|
+
return {
|
|
41
|
+
containerId: c.containerId,
|
|
42
|
+
reporterUserId: String(props.reporter_user_id ?? ''),
|
|
43
|
+
subjectUserId: String(props.subject_user_id ?? ''),
|
|
44
|
+
reason: String(props.reason ?? ''),
|
|
45
|
+
detail: String(props.detail ?? ''),
|
|
46
|
+
status: String(props.status ?? 'open'),
|
|
47
|
+
resolution: String(props.resolution ?? ''),
|
|
48
|
+
filedAtMs: Number(props.filed_at_ms ?? 0),
|
|
49
|
+
};
|
|
50
|
+
}));
|
|
51
|
+
return rows
|
|
52
|
+
.filter((r) => !status || r.status === status)
|
|
53
|
+
.sort((a, b) => a.filedAtMs - b.filedAtMs);
|
|
54
|
+
}
|
|
55
|
+
/** ADMIN — resolve a report with a disposition. */
|
|
56
|
+
async resolve(reportContainerId, status, resolution) {
|
|
57
|
+
return kitInvoke(this.gameModel, {
|
|
58
|
+
appId: String(this.appId),
|
|
59
|
+
functionName: this.names.resolveReportFn,
|
|
60
|
+
selfContainerId: reportContainerId,
|
|
61
|
+
params: { status, resolution },
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** Mute a player (adds to YOUR client-enforced mute list). */
|
|
65
|
+
async mute(ownerUserId, mutedUserId) {
|
|
66
|
+
return this.gameModel.createContainer({
|
|
67
|
+
appId: this.appId,
|
|
68
|
+
typeName: this.names.muteType,
|
|
69
|
+
displayName: `mute ${mutedUserId}`,
|
|
70
|
+
properties: [
|
|
71
|
+
{ key: 'owner_user_id', valueType: 'string', valueJson: JSON.stringify(ownerUserId) },
|
|
72
|
+
{ key: 'muted_user_id', valueType: 'string', valueJson: JSON.stringify(mutedUserId) },
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** Unmute: delete the matching mute row. */
|
|
77
|
+
async unmute(ownerUserId, mutedUserId) {
|
|
78
|
+
const mutes = await this.mutes(ownerUserId);
|
|
79
|
+
const row = mutes.find((m) => m.mutedUserId === mutedUserId);
|
|
80
|
+
if (!row)
|
|
81
|
+
return false;
|
|
82
|
+
await this.gameModel.deleteContainer({ appId: this.appId, containerId: row.containerId });
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
/** The caller's mute list (feed it to your chat renderer). */
|
|
86
|
+
async mutes(ownerUserId) {
|
|
87
|
+
const containers = await this.gameModel.containers({
|
|
88
|
+
appId: this.appId,
|
|
89
|
+
typeName: this.names.muteType,
|
|
90
|
+
});
|
|
91
|
+
const rows = await Promise.all(containers.map(async (c) => {
|
|
92
|
+
const props = await kitContainerProperties(this.gameModel, String(this.appId), c.containerId);
|
|
93
|
+
return {
|
|
94
|
+
containerId: c.containerId,
|
|
95
|
+
ownerUserId: String(props.owner_user_id ?? ''),
|
|
96
|
+
mutedUserId: String(props.muted_user_id ?? ''),
|
|
97
|
+
};
|
|
98
|
+
}));
|
|
99
|
+
return rows
|
|
100
|
+
.filter((r) => r.ownerUserId === String(ownerUserId))
|
|
101
|
+
.map(({ containerId, mutedUserId }) => ({ containerId, mutedUserId }));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { GameModelAPI } from '../domains/gameModel.js';
|
|
2
|
+
import type { Scalars } from '../generated/graphql.js';
|
|
3
|
+
import type { EngineDetector } from './engine.js';
|
|
4
|
+
import { type MovementViolationEvent } from './wire.js';
|
|
5
|
+
/** Options for {@link MovementKit}. */
|
|
6
|
+
export interface MovementKitOptions {
|
|
7
|
+
/** The warden module name. Defaults to `'movement-warden'`. */
|
|
8
|
+
moduleName?: string;
|
|
9
|
+
/** The warden-config container type. Defaults to `'WardenConfig'`. */
|
|
10
|
+
configTypeName?: string;
|
|
11
|
+
}
|
|
12
|
+
/** A user's violation book as the warden reports it. */
|
|
13
|
+
export interface KitViolations {
|
|
14
|
+
userId: string;
|
|
15
|
+
speed: number;
|
|
16
|
+
teleport: number;
|
|
17
|
+
bounds: number;
|
|
18
|
+
log: Array<{
|
|
19
|
+
atMs: number;
|
|
20
|
+
kind: string;
|
|
21
|
+
detail: string;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Runtime helpers for the movement-warden (Wave 3, observe/flag posture):
|
|
26
|
+
* read violation books, inspect the live envelope config, and parse type-95
|
|
27
|
+
* violation events. The warden never corrects or kicks — client prediction
|
|
28
|
+
* stays exactly as it is; games decide what flags mean (scoreboard shame,
|
|
29
|
+
* moderation reports, tournament DQs).
|
|
30
|
+
*
|
|
31
|
+
* Client-prediction guidance: keep your movement client-authoritative and
|
|
32
|
+
* SMOOTH — the envelopes are generous (speed tolerance + one-sample jitter
|
|
33
|
+
* forgiveness) so honest clients never flag; teleports (fast travel,
|
|
34
|
+
* respawns) should be paired with game-known context you can correlate
|
|
35
|
+
* against the violation log.
|
|
36
|
+
*
|
|
37
|
+
* Obtained via `client.kit(appId).movement`.
|
|
38
|
+
*/
|
|
39
|
+
export declare class MovementKit {
|
|
40
|
+
private readonly appId;
|
|
41
|
+
private readonly gameModel;
|
|
42
|
+
private readonly engines;
|
|
43
|
+
private readonly moduleName;
|
|
44
|
+
private readonly configTypeName;
|
|
45
|
+
constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, engines: EngineDetector, options?: MovementKitOptions);
|
|
46
|
+
/** Is the warden deployed + enabled (cached per session)? */
|
|
47
|
+
engineAvailable(): Promise<boolean>;
|
|
48
|
+
/** A user's violation book (your own without an argument). */
|
|
49
|
+
violations(userId?: string): Promise<KitViolations>;
|
|
50
|
+
/** The live envelope configuration (posture is always `'observe'` v1). */
|
|
51
|
+
config(): Promise<Record<string, unknown>>;
|
|
52
|
+
/** Warden totals (watched actors, flagged users, samples). */
|
|
53
|
+
status(): Promise<Record<string, unknown>>;
|
|
54
|
+
/** STUDIO (admin) — create/adjust the WardenConfig container. */
|
|
55
|
+
defineConfig(input: {
|
|
56
|
+
displayName?: string;
|
|
57
|
+
chunk?: [number, number, number];
|
|
58
|
+
radiusXz?: number;
|
|
59
|
+
maxSpeed?: number;
|
|
60
|
+
maxTeleport?: number;
|
|
61
|
+
bounds?: [number, number, number, number];
|
|
62
|
+
tolerancePct?: number;
|
|
63
|
+
}): Promise<{
|
|
64
|
+
__typename?: "GmContainer";
|
|
65
|
+
containerId: string;
|
|
66
|
+
appId: string;
|
|
67
|
+
sessionId: string | null;
|
|
68
|
+
typeName: string;
|
|
69
|
+
displayName: string;
|
|
70
|
+
description: string | null;
|
|
71
|
+
ownerUserId: string | null;
|
|
72
|
+
metadataJson: string;
|
|
73
|
+
}>;
|
|
74
|
+
/** Parse a type-95 movement-violation server event. */
|
|
75
|
+
parseViolation(bytes: Uint8Array): MovementViolationEvent | null;
|
|
76
|
+
private invoke;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=movement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"movement.d.ts","sourceRoot":"","sources":["../../src/kit/movement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAA0B,KAAK,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEhF,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,C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Wave 3, observe/flag posture):
|
|
4
|
+
* read violation books, inspect the live envelope config, and parse type-95
|
|
5
|
+
* violation events. The warden never corrects or kicks — client prediction
|
|
6
|
+
* stays exactly as it is; games decide what flags mean (scoreboard shame,
|
|
7
|
+
* moderation reports, tournament DQs).
|
|
8
|
+
*
|
|
9
|
+
* Client-prediction guidance: keep your movement client-authoritative and
|
|
10
|
+
* SMOOTH — the envelopes are generous (speed tolerance + one-sample jitter
|
|
11
|
+
* forgiveness) so honest clients never flag; teleports (fast travel,
|
|
12
|
+
* respawns) should be paired with game-known context you can correlate
|
|
13
|
+
* against the violation log.
|
|
14
|
+
*
|
|
15
|
+
* Obtained via `client.kit(appId).movement`.
|
|
16
|
+
*/
|
|
17
|
+
export class MovementKit {
|
|
18
|
+
constructor(appId, gameModel, engines, options = {}) {
|
|
19
|
+
this.appId = appId;
|
|
20
|
+
this.gameModel = gameModel;
|
|
21
|
+
this.engines = engines;
|
|
22
|
+
this.moduleName = options.moduleName ?? 'movement-warden';
|
|
23
|
+
this.configTypeName = options.configTypeName ?? 'WardenConfig';
|
|
24
|
+
}
|
|
25
|
+
/** Is the warden deployed + enabled (cached per session)? */
|
|
26
|
+
engineAvailable() {
|
|
27
|
+
return this.engines.has(this.moduleName);
|
|
28
|
+
}
|
|
29
|
+
/** A user's violation book (your own without an argument). */
|
|
30
|
+
async violations(userId) {
|
|
31
|
+
const body = await this.invoke('violations', userId ? { userId } : {});
|
|
32
|
+
return {
|
|
33
|
+
userId: String(body.userId ?? ''),
|
|
34
|
+
speed: Number(body.speed ?? 0),
|
|
35
|
+
teleport: Number(body.teleport ?? 0),
|
|
36
|
+
bounds: Number(body.bounds ?? 0),
|
|
37
|
+
log: Array.isArray(body.log)
|
|
38
|
+
? body.log.map((entry) => ({
|
|
39
|
+
atMs: Number(entry.atMs ?? 0),
|
|
40
|
+
kind: String(entry.kind ?? ''),
|
|
41
|
+
detail: String(entry.detail ?? ''),
|
|
42
|
+
}))
|
|
43
|
+
: [],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** The live envelope configuration (posture is always `'observe'` v1). */
|
|
47
|
+
async config() {
|
|
48
|
+
return this.invoke('config', {});
|
|
49
|
+
}
|
|
50
|
+
/** Warden totals (watched actors, flagged users, samples). */
|
|
51
|
+
async status() {
|
|
52
|
+
return this.invoke('status', {});
|
|
53
|
+
}
|
|
54
|
+
/** STUDIO (admin) — create/adjust the WardenConfig container. */
|
|
55
|
+
async defineConfig(input) {
|
|
56
|
+
const properties = [
|
|
57
|
+
...(input.chunk
|
|
58
|
+
? [
|
|
59
|
+
{ key: 'chunk_x', valueType: 'int', valueJson: String(input.chunk[0]) },
|
|
60
|
+
{ key: 'chunk_y', valueType: 'int', valueJson: String(input.chunk[1]) },
|
|
61
|
+
{ key: 'chunk_z', valueType: 'int', valueJson: String(input.chunk[2]) },
|
|
62
|
+
]
|
|
63
|
+
: []),
|
|
64
|
+
...(input.radiusXz !== undefined
|
|
65
|
+
? [{ key: 'radius_xz', valueType: 'int', valueJson: String(input.radiusXz) }]
|
|
66
|
+
: []),
|
|
67
|
+
...(input.maxSpeed !== undefined
|
|
68
|
+
? [{ key: 'max_speed', valueType: 'int', valueJson: String(input.maxSpeed) }]
|
|
69
|
+
: []),
|
|
70
|
+
...(input.maxTeleport !== undefined
|
|
71
|
+
? [{ key: 'max_teleport', valueType: 'int', valueJson: String(input.maxTeleport) }]
|
|
72
|
+
: []),
|
|
73
|
+
...(input.bounds
|
|
74
|
+
? [
|
|
75
|
+
{ key: 'min_x', valueType: 'int', valueJson: String(input.bounds[0]) },
|
|
76
|
+
{ key: 'max_x', valueType: 'int', valueJson: String(input.bounds[1]) },
|
|
77
|
+
{ key: 'min_z', valueType: 'int', valueJson: String(input.bounds[2]) },
|
|
78
|
+
{ key: 'max_z', valueType: 'int', valueJson: String(input.bounds[3]) },
|
|
79
|
+
]
|
|
80
|
+
: []),
|
|
81
|
+
...(input.tolerancePct !== undefined
|
|
82
|
+
? [{ key: 'tolerance_pct', valueType: 'int', valueJson: String(input.tolerancePct) }]
|
|
83
|
+
: []),
|
|
84
|
+
];
|
|
85
|
+
return this.gameModel.createContainer({
|
|
86
|
+
appId: this.appId,
|
|
87
|
+
typeName: this.configTypeName,
|
|
88
|
+
displayName: input.displayName ?? 'warden-config',
|
|
89
|
+
properties,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** Parse a type-95 movement-violation server event. */
|
|
93
|
+
parseViolation(bytes) {
|
|
94
|
+
return parseMovementViolation(bytes);
|
|
95
|
+
}
|
|
96
|
+
async invoke(exportName, params) {
|
|
97
|
+
const result = await this.engines.invoke(this.moduleName, exportName, params);
|
|
98
|
+
if (!result.success) {
|
|
99
|
+
throw new Error(`movement.${exportName} failed: ${result.reason ?? 'unknown'}`);
|
|
100
|
+
}
|
|
101
|
+
return result.body;
|
|
102
|
+
}
|
|
103
|
+
}
|
package/dist/kit/npcs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npcs.d.ts","sourceRoot":"","sources":["../../src/kit/npcs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC7B,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;IACzC,U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;KACpB;;;;;;;;;;;IAuBD;;;;OAIG;IACG,IAAI,CAAC,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAclF,gDAAgD;IAC1C,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ3C,8EAA8E;IACxE,MAAM,CAAC,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;IAInC;;;OAGG;IACG,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAQzD,6EAA6E;IACvE,KAAK,CAAC,aAAa,CAAC,EAAE,MAAM;;;;;;;;;;;;sBA+Bg5le,CAAC;;;;;;;;;;IAxBn7le,2DAA2D;IACrD,IAAI,CAAC,OAAO,GAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO;;;;;;;;;;;;;;;;;;;;;;YAIzE,KAAK;CAkBpB"}
|
package/dist/kit/quests.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { GameModelAPI } from '../domains/gameModel.js';
|
|
2
2
|
import type { Scalars, SeedPropertyInput } from '../generated/graphql.js';
|
|
3
|
+
import { type KitOwnerIdKind } from './blueprints/index.js';
|
|
3
4
|
import { type KitInvokeResult } from './shared.js';
|
|
4
5
|
/** Options for {@link QuestsKit}. Must match the deployed quests blueprint. */
|
|
5
6
|
export interface QuestsKitOptions {
|
|
6
7
|
/** The `typePrefix` the quests blueprint was deployed with. */
|
|
7
8
|
typePrefix?: string;
|
|
9
|
+
/** Must match questsBlueprint.ownerIdKind. Defaults to `int`. */
|
|
10
|
+
ownerIdKind?: KitOwnerIdKind;
|
|
8
11
|
}
|
|
9
12
|
/** A parsed view of one quest catalog row. */
|
|
10
13
|
export interface KitQuestDef {
|
|
@@ -42,6 +45,7 @@ export declare class QuestsKit {
|
|
|
42
45
|
private readonly appId;
|
|
43
46
|
private readonly gameModel;
|
|
44
47
|
private readonly names;
|
|
48
|
+
private readonly ownerIdKind;
|
|
45
49
|
constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, options?: QuestsKitOptions);
|
|
46
50
|
/** List the quest catalog (admin-seeded QuestDef containers). */
|
|
47
51
|
catalog(): Promise<KitQuestDef[]>;
|
package/dist/kit/quests.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quests.d.ts","sourceRoot":"","sources":["../../src/kit/quests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"quests.d.ts","sourceRoot":"","sources":["../../src/kit/quests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAErB,+EAA+E;AAC/E,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,8CAA8C;AAC9C,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,M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CvB,MAAM;aACZ,WAAW;kBACN,gBAAgB,GAAG,IAAI;gBACzB,QAAQ,GAAG,QAAQ,GAAG,UAAU;;IA4C5C,6BAA6B;IACvB,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAuB1D;;;;OAIG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAS/E;;;;OAIG;IACG,KAAK,CAAC,KAAK,EAAE;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;CAYrC"}
|
package/dist/kit/quests.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { questsNames } from './blueprints/index.js';
|
|
1
|
+
import { questsNames, } from './blueprints/index.js';
|
|
2
2
|
import { kitContainerProperties, kitInvoke, } from './shared.js';
|
|
3
3
|
/**
|
|
4
4
|
* Runtime helpers for the {@link questsBlueprint} conventions: browse the
|
|
@@ -13,6 +13,7 @@ export class QuestsKit {
|
|
|
13
13
|
this.appId = appId;
|
|
14
14
|
this.gameModel = gameModel;
|
|
15
15
|
this.names = questsNames(options.typePrefix ?? '');
|
|
16
|
+
this.ownerIdKind = options.ownerIdKind ?? 'int';
|
|
16
17
|
}
|
|
17
18
|
/** List the quest catalog (admin-seeded QuestDef containers). */
|
|
18
19
|
async catalog() {
|
|
@@ -82,7 +83,13 @@ export class QuestsKit {
|
|
|
82
83
|
displayName: options.displayName ?? `Quest ${questId} ${ownerUserId}`,
|
|
83
84
|
...(options.sessionId !== undefined ? { sessionId: options.sessionId } : {}),
|
|
84
85
|
properties: [
|
|
85
|
-
{
|
|
86
|
+
{
|
|
87
|
+
key: 'owner_user_id',
|
|
88
|
+
valueType: this.ownerIdKind,
|
|
89
|
+
valueJson: this.ownerIdKind === 'string'
|
|
90
|
+
? JSON.stringify(String(ownerUserId))
|
|
91
|
+
: String(ownerUserId),
|
|
92
|
+
},
|
|
86
93
|
{ key: 'quest_id', valueType: 'string', valueJson: JSON.stringify(questId) },
|
|
87
94
|
{
|
|
88
95
|
key: 'target',
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { GameModelAPI } from '../domains/gameModel.js';
|
|
2
|
+
import type { Scalars } from '../generated/graphql.js';
|
|
3
|
+
import type { EngineDetector } from './engine.js';
|
|
4
|
+
import { type RaceTimingEvent } from './wire.js';
|
|
5
|
+
/** Options for {@link RacingKit}. */
|
|
6
|
+
export interface RacingKitOptions {
|
|
7
|
+
/** The racing engine module name. Defaults to `'racing'`. */
|
|
8
|
+
moduleName?: string;
|
|
9
|
+
/** The possession (ball) engine module name. Defaults to `'possession'`. */
|
|
10
|
+
possessionModuleName?: string;
|
|
11
|
+
/** The course container type. Defaults to `'Course'`. */
|
|
12
|
+
courseTypeName?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Your live run as the engine reports it. */
|
|
15
|
+
export interface KitRaceRun {
|
|
16
|
+
courseId: string;
|
|
17
|
+
started: boolean;
|
|
18
|
+
lap: number;
|
|
19
|
+
nextGate: number;
|
|
20
|
+
splitsMs: number[];
|
|
21
|
+
bestLapMs: number;
|
|
22
|
+
finished: boolean;
|
|
23
|
+
totalMs: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Runtime helpers for the racing engine (Wave 3, G16) and its possession
|
|
27
|
+
* sub-template (G17 sports-lite): server-timed gates/laps from the pose
|
|
28
|
+
* stream (type-97 events), course records with ghost replays on the actor
|
|
29
|
+
* lane (suffix `ghost:<courseId>`, FLAG_RESERVED3), and the authoritative
|
|
30
|
+
* ball (claim/steal/pass/shoot; lane suffix `ball`).
|
|
31
|
+
*
|
|
32
|
+
* Obtained via `client.kit(appId).racing`.
|
|
33
|
+
*/
|
|
34
|
+
export declare class RacingKit {
|
|
35
|
+
private readonly appId;
|
|
36
|
+
private readonly gameModel;
|
|
37
|
+
private readonly engines;
|
|
38
|
+
private readonly moduleName;
|
|
39
|
+
private readonly possessionModuleName;
|
|
40
|
+
private readonly courseTypeName;
|
|
41
|
+
constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, engines: EngineDetector, options?: RacingKitOptions);
|
|
42
|
+
/** Is the racing engine deployed + enabled (cached per session)? */
|
|
43
|
+
engineAvailable(): Promise<boolean>;
|
|
44
|
+
/** Is the possession (ball) engine deployed + enabled? */
|
|
45
|
+
possessionAvailable(): Promise<boolean>;
|
|
46
|
+
/** STUDIO (admin) — create a course (`gates` = [[x, z, radius], ...]). */
|
|
47
|
+
defineCourse(input: {
|
|
48
|
+
courseId: string;
|
|
49
|
+
gates: Array<[number, number, number]>;
|
|
50
|
+
laps?: number;
|
|
51
|
+
displayName?: string;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
__typename?: "GmContainer";
|
|
54
|
+
containerId: string;
|
|
55
|
+
appId: string;
|
|
56
|
+
sessionId: string | null;
|
|
57
|
+
typeName: string;
|
|
58
|
+
displayName: string;
|
|
59
|
+
description: string | null;
|
|
60
|
+
ownerUserId: string | null;
|
|
61
|
+
metadataJson: string;
|
|
62
|
+
}>;
|
|
63
|
+
/** Enter a course: your next pose through gate 0 starts the clock. */
|
|
64
|
+
enter(courseId: string): Promise<Record<string, unknown>>;
|
|
65
|
+
/** Your live run (splits, lap, next gate). */
|
|
66
|
+
raceStatus(): Promise<KitRaceRun>;
|
|
67
|
+
/** The course record (holder, time, ghost length). */
|
|
68
|
+
best(courseId: string): Promise<Record<string, unknown>>;
|
|
69
|
+
/** Replay the course-record ghost onto the actor lane. */
|
|
70
|
+
ghostPlay(courseId: string): Promise<Record<string, unknown>>;
|
|
71
|
+
/** Parse a type-97 race-timing server event. */
|
|
72
|
+
parseRaceTiming(bytes: Uint8Array): RaceTimingEvent | null;
|
|
73
|
+
/** Join the ball match (teams fill by join order). */
|
|
74
|
+
joinMatch(): Promise<Record<string, unknown>>;
|
|
75
|
+
/** Claim the free ball (or steal after the protection window). */
|
|
76
|
+
claim(): Promise<Record<string, unknown>>;
|
|
77
|
+
/** Pass along a direction (holder only). */
|
|
78
|
+
pass(dirX: number, dirZ: number): Promise<Record<string, unknown>>;
|
|
79
|
+
/** Shoot at the opposing goal (holder only; the server aims). */
|
|
80
|
+
shoot(): Promise<Record<string, unknown>>;
|
|
81
|
+
/** The live ball match (teams, ball, standings, summary). */
|
|
82
|
+
matchState(): Promise<Record<string, unknown>>;
|
|
83
|
+
private invoke;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=racing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"racing.d.ts","sourceRoot":"","sources":["../../src/kit/racing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEvE,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yDAAyD;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,8CAA8C;AAC9C,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO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,EAAE,IAAI,EAAE,MAAM;IAIrC,iEAAiE;IAC3D,KAAK;IAIX,6DAA6D;IACvD,UAAU;YAIF,MAAM;CAOrB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { parseRaceTimingEvent } from './wire.js';
|
|
2
|
+
/**
|
|
3
|
+
* Runtime helpers for the racing engine (Wave 3, G16) and its possession
|
|
4
|
+
* sub-template (G17 sports-lite): server-timed gates/laps from the pose
|
|
5
|
+
* stream (type-97 events), course records with ghost replays on the actor
|
|
6
|
+
* lane (suffix `ghost:<courseId>`, FLAG_RESERVED3), and the authoritative
|
|
7
|
+
* ball (claim/steal/pass/shoot; lane suffix `ball`).
|
|
8
|
+
*
|
|
9
|
+
* Obtained via `client.kit(appId).racing`.
|
|
10
|
+
*/
|
|
11
|
+
export class RacingKit {
|
|
12
|
+
constructor(appId, gameModel, engines, options = {}) {
|
|
13
|
+
this.appId = appId;
|
|
14
|
+
this.gameModel = gameModel;
|
|
15
|
+
this.engines = engines;
|
|
16
|
+
this.moduleName = options.moduleName ?? 'racing';
|
|
17
|
+
this.possessionModuleName = options.possessionModuleName ?? 'possession';
|
|
18
|
+
this.courseTypeName = options.courseTypeName ?? 'Course';
|
|
19
|
+
}
|
|
20
|
+
/** Is the racing engine deployed + enabled (cached per session)? */
|
|
21
|
+
engineAvailable() {
|
|
22
|
+
return this.engines.has(this.moduleName);
|
|
23
|
+
}
|
|
24
|
+
/** Is the possession (ball) engine deployed + enabled? */
|
|
25
|
+
possessionAvailable() {
|
|
26
|
+
return this.engines.has(this.possessionModuleName);
|
|
27
|
+
}
|
|
28
|
+
/** STUDIO (admin) — create a course (`gates` = [[x, z, radius], ...]). */
|
|
29
|
+
async defineCourse(input) {
|
|
30
|
+
return this.gameModel.createContainer({
|
|
31
|
+
appId: this.appId,
|
|
32
|
+
typeName: this.courseTypeName,
|
|
33
|
+
displayName: input.displayName ?? `course-${input.courseId}`,
|
|
34
|
+
properties: [
|
|
35
|
+
{ key: 'course_id', valueType: 'string', valueJson: JSON.stringify(input.courseId) },
|
|
36
|
+
{ key: 'gates', valueType: 'string', valueJson: JSON.stringify(JSON.stringify(input.gates)) },
|
|
37
|
+
{ key: 'laps', valueType: 'int', valueJson: String(input.laps ?? 1) },
|
|
38
|
+
],
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** Enter a course: your next pose through gate 0 starts the clock. */
|
|
42
|
+
async enter(courseId) {
|
|
43
|
+
return this.invoke(this.moduleName, 'enter', { courseId });
|
|
44
|
+
}
|
|
45
|
+
/** Your live run (splits, lap, next gate). */
|
|
46
|
+
async raceStatus() {
|
|
47
|
+
const body = await this.invoke(this.moduleName, 'race_status', {});
|
|
48
|
+
return {
|
|
49
|
+
courseId: String(body.courseId ?? ''),
|
|
50
|
+
started: body.started === true,
|
|
51
|
+
lap: Number(body.lap ?? 0),
|
|
52
|
+
nextGate: Number(body.nextGate ?? 0),
|
|
53
|
+
splitsMs: Array.isArray(body.splitsMs) ? body.splitsMs.map(Number) : [],
|
|
54
|
+
bestLapMs: Number(body.bestLapMs ?? 0),
|
|
55
|
+
finished: body.finished === true,
|
|
56
|
+
totalMs: Number(body.totalMs ?? 0),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** The course record (holder, time, ghost length). */
|
|
60
|
+
async best(courseId) {
|
|
61
|
+
return this.invoke(this.moduleName, 'best', { courseId });
|
|
62
|
+
}
|
|
63
|
+
/** Replay the course-record ghost onto the actor lane. */
|
|
64
|
+
async ghostPlay(courseId) {
|
|
65
|
+
return this.invoke(this.moduleName, 'ghost_play', { courseId });
|
|
66
|
+
}
|
|
67
|
+
/** Parse a type-97 race-timing server event. */
|
|
68
|
+
parseRaceTiming(bytes) {
|
|
69
|
+
return parseRaceTimingEvent(bytes);
|
|
70
|
+
}
|
|
71
|
+
// -- possession (sports-lite ball) ----------------------------------------
|
|
72
|
+
/** Join the ball match (teams fill by join order). */
|
|
73
|
+
async joinMatch() {
|
|
74
|
+
return this.invoke(this.possessionModuleName, 'join_match', {});
|
|
75
|
+
}
|
|
76
|
+
/** Claim the free ball (or steal after the protection window). */
|
|
77
|
+
async claim() {
|
|
78
|
+
return this.invoke(this.possessionModuleName, 'claim', {});
|
|
79
|
+
}
|
|
80
|
+
/** Pass along a direction (holder only). */
|
|
81
|
+
async pass(dirX, dirZ) {
|
|
82
|
+
return this.invoke(this.possessionModuleName, 'pass', { dirX, dirZ });
|
|
83
|
+
}
|
|
84
|
+
/** Shoot at the opposing goal (holder only; the server aims). */
|
|
85
|
+
async shoot() {
|
|
86
|
+
return this.invoke(this.possessionModuleName, 'shoot', {});
|
|
87
|
+
}
|
|
88
|
+
/** The live ball match (teams, ball, standings, summary). */
|
|
89
|
+
async matchState() {
|
|
90
|
+
return this.invoke(this.possessionModuleName, 'match_state', {});
|
|
91
|
+
}
|
|
92
|
+
async invoke(moduleName, exportName, params) {
|
|
93
|
+
const result = await this.engines.invoke(moduleName, exportName, params);
|
|
94
|
+
if (!result.success) {
|
|
95
|
+
throw new Error(`racing.${exportName} failed: ${result.reason ?? 'unknown'}`);
|
|
96
|
+
}
|
|
97
|
+
return result.body;
|
|
98
|
+
}
|
|
99
|
+
}
|
package/dist/kit/social.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"social.d.ts","sourceRoot":"","sources":["../../src/kit/social.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGvD,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM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el.js';
|
|
2
|
+
import type { Scalars } from '../generated/graphql.js';
|
|
3
|
+
/** Options for {@link TelemetryKit}. */
|
|
4
|
+
export interface TelemetryKitOptions {
|
|
5
|
+
/** The counter container type name. Defaults to `'TelemetryCounter'`. */
|
|
6
|
+
counterTypeName?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Sample rate for `track()` in [0, 1] — the client-side budget knob.
|
|
9
|
+
* Defaults to 1 (every event).
|
|
10
|
+
*/
|
|
11
|
+
sampleRate?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Game analytics events (matrix P7) — MODEL-THIN by design: `track()`
|
|
15
|
+
* writes a naming-convention row into the existing model event log via a
|
|
16
|
+
* fire-and-forget container property bump, and sampled counters live in
|
|
17
|
+
* ordinary `TelemetryCounter` containers (`event_name` + `count`). Export
|
|
18
|
+
* and BI are platform concerns, deliberately out of scope; the convention
|
|
19
|
+
* is the abstraction.
|
|
20
|
+
*
|
|
21
|
+
* Naming convention: `<area>.<action>` (e.g. `ftue.step_completed`,
|
|
22
|
+
* `shop.purchase`). Keep cardinality low — counters are containers.
|
|
23
|
+
*
|
|
24
|
+
* Obtained via `client.kit(appId).telemetry`.
|
|
25
|
+
*/
|
|
26
|
+
export declare class TelemetryKit {
|
|
27
|
+
private readonly appId;
|
|
28
|
+
private readonly gameModel;
|
|
29
|
+
private readonly counterTypeName;
|
|
30
|
+
private readonly sampleRate;
|
|
31
|
+
/** event name -> counter container id (cached per session). */
|
|
32
|
+
private readonly counterIds;
|
|
33
|
+
constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, options?: TelemetryKitOptions);
|
|
34
|
+
/**
|
|
35
|
+
* Track one event — fire-and-forget (never throws, never blocks
|
|
36
|
+
* gameplay): bumps the event's sampled counter. `props` ride the
|
|
37
|
+
* container's last-props snapshot for spot-debugging (NOT a warehouse).
|
|
38
|
+
*/
|
|
39
|
+
track(name: string, props?: Record<string, unknown>): void;
|
|
40
|
+
/** The awaitable form of {@link track} for tests/backfills. */
|
|
41
|
+
bump(name: string, props?: Record<string, unknown>): Promise<void>;
|
|
42
|
+
/** Read the sampled counters (dashboards, tests). */
|
|
43
|
+
counters(): Promise<Array<{
|
|
44
|
+
eventName: string;
|
|
45
|
+
count: number;
|
|
46
|
+
lastProps: string;
|
|
47
|
+
}>>;
|
|
48
|
+
private ensureCounter;
|
|
49
|
+
}
|
|
50
|
+
/** The telemetry blueprint: one counter type; the convention is the point. */
|
|
51
|
+
export declare function telemetryBlueprint(counterTypeName?: string): {
|
|
52
|
+
name: string;
|
|
53
|
+
containerTypes: {
|
|
54
|
+
typeName: string;
|
|
55
|
+
displayName: string;
|
|
56
|
+
description: string;
|
|
57
|
+
}[];
|
|
58
|
+
propertyDefinitions: {
|
|
59
|
+
containerTypeName: string;
|
|
60
|
+
key: string;
|
|
61
|
+
valueType: string;
|
|
62
|
+
defaultValueJson: string;
|
|
63
|
+
description: string;
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=telemetry.d.ts.map
|