@rustrak/client 0.3.6 → 0.3.8
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/dist/index.cjs +99 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -2
- package/dist/index.d.ts +61 -2
- package/dist/index.js +99 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -608,6 +608,42 @@ var sourceMapFileSchema = zod.z.object({
|
|
|
608
608
|
var listSourceMapsResponseSchema = zod.z.object({
|
|
609
609
|
data: zod.z.array(sourceMapFileSchema)
|
|
610
610
|
});
|
|
611
|
+
var sourceMapStorageSchema = zod.z.object({
|
|
612
|
+
chunk_bytes: zod.z.number(),
|
|
613
|
+
source_file_bytes: zod.z.number(),
|
|
614
|
+
total_bytes: zod.z.number(),
|
|
615
|
+
file_count: zod.z.number()
|
|
616
|
+
});
|
|
617
|
+
var storageSummarySchema = zod.z.object({
|
|
618
|
+
total_db_size_bytes: zod.z.number(),
|
|
619
|
+
events_count: zod.z.number(),
|
|
620
|
+
transactions_count: zod.z.number(),
|
|
621
|
+
spans_count: zod.z.number(),
|
|
622
|
+
source_maps: sourceMapStorageSchema
|
|
623
|
+
});
|
|
624
|
+
var projectStorageSchema = zod.z.object({
|
|
625
|
+
project_id: zod.z.number(),
|
|
626
|
+
project_name: zod.z.string(),
|
|
627
|
+
events_count: zod.z.number(),
|
|
628
|
+
transactions_count: zod.z.number(),
|
|
629
|
+
spans_count: zod.z.number(),
|
|
630
|
+
source_maps_count: zod.z.number(),
|
|
631
|
+
estimated_bytes: zod.z.number()
|
|
632
|
+
});
|
|
633
|
+
var cleanupCountsSchema = zod.z.object({
|
|
634
|
+
events: zod.z.number(),
|
|
635
|
+
transactions: zod.z.number(),
|
|
636
|
+
spans: zod.z.number(),
|
|
637
|
+
issues_removed: zod.z.number()
|
|
638
|
+
});
|
|
639
|
+
var sourceMapGcResultSchema = zod.z.object({
|
|
640
|
+
files_removed: zod.z.number(),
|
|
641
|
+
bytes_freed: zod.z.number()
|
|
642
|
+
});
|
|
643
|
+
var cleanupOptionsSchema = zod.z.object({
|
|
644
|
+
older_than_days: zod.z.number().int().min(1),
|
|
645
|
+
project_id: zod.z.number().int().optional()
|
|
646
|
+
});
|
|
611
647
|
var authTokenSchema = zod.z.object({
|
|
612
648
|
id: zod.z.number().int(),
|
|
613
649
|
token_prefix: zod.z.string(),
|
|
@@ -941,6 +977,59 @@ var SourceMapsResource = class extends BaseResource {
|
|
|
941
977
|
return this.validate(data, listSourceMapsResponseSchema);
|
|
942
978
|
}
|
|
943
979
|
};
|
|
980
|
+
var StorageResource = class extends BaseResource {
|
|
981
|
+
/**
|
|
982
|
+
* Get the instance-wide storage summary: row counts per data category, the
|
|
983
|
+
* whole-DB size, and exact source-map weight.
|
|
984
|
+
*/
|
|
985
|
+
async getSummary() {
|
|
986
|
+
const data = await this.http.get("api/storage/summary").json();
|
|
987
|
+
return this.validate(data, storageSummarySchema);
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Get the per-project storage breakdown (one row per project, including
|
|
991
|
+
* empty ones).
|
|
992
|
+
*/
|
|
993
|
+
async getProjects() {
|
|
994
|
+
const data = await this.http.get("api/storage/projects").json();
|
|
995
|
+
return this.validate(data, zod.z.array(projectStorageSchema));
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Dry-run: count the rows a cleanup would remove. Mutates nothing — use it to
|
|
999
|
+
* confirm impact before {@link executeCleanup}.
|
|
1000
|
+
*/
|
|
1001
|
+
async previewCleanup(options) {
|
|
1002
|
+
const json = cleanupOptionsSchema.parse(options);
|
|
1003
|
+
const data = await this.http.post("api/storage/cleanup/preview", { json }).json();
|
|
1004
|
+
return this.validate(data, cleanupCountsSchema);
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Execute a cleanup: delete data older than `older_than_days` (optionally
|
|
1008
|
+
* scoped to one project) and remove any issue left with zero events.
|
|
1009
|
+
*/
|
|
1010
|
+
async executeCleanup(options) {
|
|
1011
|
+
const json = cleanupOptionsSchema.parse(options);
|
|
1012
|
+
const data = await this.http.post("api/storage/cleanup", { json }).json();
|
|
1013
|
+
return this.validate(data, cleanupCountsSchema);
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Dry-run for {@link gcSourceMaps}: count the orphaned source-map files and
|
|
1017
|
+
* bytes a GC would reclaim. Mutates nothing.
|
|
1018
|
+
*/
|
|
1019
|
+
async previewGcSourceMaps() {
|
|
1020
|
+
const data = await this.http.post("api/storage/source-maps/gc/preview").json();
|
|
1021
|
+
return this.validate(data, sourceMapGcResultSchema);
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Garbage-collect orphaned source maps: files no longer referenced by any
|
|
1025
|
+
* upload, removed from the DB and unlinked from disk. Safe — never touches
|
|
1026
|
+
* referenced files.
|
|
1027
|
+
*/
|
|
1028
|
+
async gcSourceMaps() {
|
|
1029
|
+
const data = await this.http.post("api/storage/source-maps/gc").json();
|
|
1030
|
+
return this.validate(data, sourceMapGcResultSchema);
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
944
1033
|
|
|
945
1034
|
// src/resources/team.ts
|
|
946
1035
|
var TeamResource = class extends BaseResource {
|
|
@@ -979,11 +1068,14 @@ var TokensResource = class extends BaseResource {
|
|
|
979
1068
|
return this.validate(data, authTokenSchema.array());
|
|
980
1069
|
}
|
|
981
1070
|
/**
|
|
982
|
-
* Get a single auth token by ID (
|
|
1071
|
+
* Get a single auth token by ID (full token value).
|
|
1072
|
+
*
|
|
1073
|
+
* Previously returned a masked version, but the server now returns the
|
|
1074
|
+
* complete token for GET /api/tokens/{id}.
|
|
983
1075
|
*/
|
|
984
1076
|
async get(id) {
|
|
985
1077
|
const data = await this.http.get(`api/tokens/${id}`).json();
|
|
986
|
-
return this.validate(data,
|
|
1078
|
+
return this.validate(data, authTokenCreatedSchema);
|
|
987
1079
|
}
|
|
988
1080
|
/**
|
|
989
1081
|
* Create a new auth token
|
|
@@ -1205,6 +1297,10 @@ var RustrakClient = class {
|
|
|
1205
1297
|
* Transactions API resource (performance monitoring)
|
|
1206
1298
|
*/
|
|
1207
1299
|
transactions;
|
|
1300
|
+
/**
|
|
1301
|
+
* Storage API resource (usage + retention cleanup, admin only)
|
|
1302
|
+
*/
|
|
1303
|
+
storage;
|
|
1208
1304
|
/**
|
|
1209
1305
|
* Health API resource (version info)
|
|
1210
1306
|
*/
|
|
@@ -1229,6 +1325,7 @@ var RustrakClient = class {
|
|
|
1229
1325
|
this.members = new MembersResource(this.http);
|
|
1230
1326
|
this.sessions = new SessionsResource(this.http);
|
|
1231
1327
|
this.transactions = new TransactionsResource(this.http);
|
|
1328
|
+
this.storage = new StorageResource(this.http);
|
|
1232
1329
|
this.health = new HealthResource(this.http);
|
|
1233
1330
|
}
|
|
1234
1331
|
};
|