@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.d.ts
CHANGED
|
@@ -516,6 +516,55 @@ interface AssembleInput {
|
|
|
516
516
|
projects: string[];
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
+
declare const sourceMapStorageSchema: z.ZodObject<{
|
|
520
|
+
chunk_bytes: z.ZodNumber;
|
|
521
|
+
source_file_bytes: z.ZodNumber;
|
|
522
|
+
total_bytes: z.ZodNumber;
|
|
523
|
+
file_count: z.ZodNumber;
|
|
524
|
+
}, z.core.$strip>;
|
|
525
|
+
declare const storageSummarySchema: z.ZodObject<{
|
|
526
|
+
total_db_size_bytes: z.ZodNumber;
|
|
527
|
+
events_count: z.ZodNumber;
|
|
528
|
+
transactions_count: z.ZodNumber;
|
|
529
|
+
spans_count: z.ZodNumber;
|
|
530
|
+
source_maps: z.ZodObject<{
|
|
531
|
+
chunk_bytes: z.ZodNumber;
|
|
532
|
+
source_file_bytes: z.ZodNumber;
|
|
533
|
+
total_bytes: z.ZodNumber;
|
|
534
|
+
file_count: z.ZodNumber;
|
|
535
|
+
}, z.core.$strip>;
|
|
536
|
+
}, z.core.$strip>;
|
|
537
|
+
declare const projectStorageSchema: z.ZodObject<{
|
|
538
|
+
project_id: z.ZodNumber;
|
|
539
|
+
project_name: z.ZodString;
|
|
540
|
+
events_count: z.ZodNumber;
|
|
541
|
+
transactions_count: z.ZodNumber;
|
|
542
|
+
spans_count: z.ZodNumber;
|
|
543
|
+
source_maps_count: z.ZodNumber;
|
|
544
|
+
estimated_bytes: z.ZodNumber;
|
|
545
|
+
}, z.core.$strip>;
|
|
546
|
+
declare const cleanupCountsSchema: z.ZodObject<{
|
|
547
|
+
events: z.ZodNumber;
|
|
548
|
+
transactions: z.ZodNumber;
|
|
549
|
+
spans: z.ZodNumber;
|
|
550
|
+
issues_removed: z.ZodNumber;
|
|
551
|
+
}, z.core.$strip>;
|
|
552
|
+
declare const sourceMapGcResultSchema: z.ZodObject<{
|
|
553
|
+
files_removed: z.ZodNumber;
|
|
554
|
+
bytes_freed: z.ZodNumber;
|
|
555
|
+
}, z.core.$strip>;
|
|
556
|
+
declare const cleanupOptionsSchema: z.ZodObject<{
|
|
557
|
+
older_than_days: z.ZodNumber;
|
|
558
|
+
project_id: z.ZodOptional<z.ZodNumber>;
|
|
559
|
+
}, z.core.$strip>;
|
|
560
|
+
|
|
561
|
+
type SourceMapStorage = z.infer<typeof sourceMapStorageSchema>;
|
|
562
|
+
type StorageSummary = z.infer<typeof storageSummarySchema>;
|
|
563
|
+
type ProjectStorage = z.infer<typeof projectStorageSchema>;
|
|
564
|
+
type CleanupCounts = z.infer<typeof cleanupCountsSchema>;
|
|
565
|
+
type SourceMapGcResult = z.infer<typeof sourceMapGcResultSchema>;
|
|
566
|
+
type CleanupOptions = z.infer<typeof cleanupOptionsSchema>;
|
|
567
|
+
|
|
519
568
|
declare const globalRoleSchema: z.ZodEnum<{
|
|
520
569
|
admin: "admin";
|
|
521
570
|
member: "member";
|
|
@@ -669,6 +718,15 @@ declare class SourceMapsResource extends BaseResource {
|
|
|
669
718
|
list(orgSlug: string, projectSlug: string): Promise<ListSourceMapsResponse>;
|
|
670
719
|
}
|
|
671
720
|
|
|
721
|
+
declare class StorageResource extends BaseResource {
|
|
722
|
+
getSummary(): Promise<StorageSummary>;
|
|
723
|
+
getProjects(): Promise<ProjectStorage[]>;
|
|
724
|
+
previewCleanup(options: CleanupOptions): Promise<CleanupCounts>;
|
|
725
|
+
executeCleanup(options: CleanupOptions): Promise<CleanupCounts>;
|
|
726
|
+
previewGcSourceMaps(): Promise<SourceMapGcResult>;
|
|
727
|
+
gcSourceMaps(): Promise<SourceMapGcResult>;
|
|
728
|
+
}
|
|
729
|
+
|
|
672
730
|
declare class TeamResource extends BaseResource {
|
|
673
731
|
list(): Promise<TeamMember[]>;
|
|
674
732
|
updateRole(userId: number, role: GlobalRole): Promise<void>;
|
|
@@ -677,7 +735,7 @@ declare class TeamResource extends BaseResource {
|
|
|
677
735
|
|
|
678
736
|
declare class TokensResource extends BaseResource {
|
|
679
737
|
list(): Promise<AuthToken[]>;
|
|
680
|
-
get(id: number): Promise<
|
|
738
|
+
get(id: number): Promise<AuthTokenCreated>;
|
|
681
739
|
create(input: CreateAuthToken): Promise<AuthTokenCreated>;
|
|
682
740
|
delete(id: number): Promise<void>;
|
|
683
741
|
}
|
|
@@ -708,6 +766,7 @@ declare class RustrakClient {
|
|
|
708
766
|
readonly members: MembersResource;
|
|
709
767
|
readonly sessions: SessionsResource;
|
|
710
768
|
readonly transactions: TransactionsResource;
|
|
769
|
+
readonly storage: StorageResource;
|
|
711
770
|
readonly health: HealthResource;
|
|
712
771
|
constructor(config: ClientConfig);
|
|
713
772
|
}
|
|
@@ -752,4 +811,4 @@ declare class ValidationError extends RustrakError {
|
|
|
752
811
|
getValidationDetails(): string;
|
|
753
812
|
}
|
|
754
813
|
|
|
755
|
-
export { type AcceptInvitation, type AlertHistory, type AlertIntegration, type AlertRule, type AlertRuleChannelInput, type AlertStatus, type AlertType, type ApiError, type AssembleInput, type AssembleResponse, type AuthResponse, type AuthToken, type AuthTokenCreated, AuthenticationError, AuthorizationError, BadRequestError, type ChannelType, type ChunkUploadCapability, type ClientConfig, type CreateAlertIntegration, type CreateAlertRule, type CreateAuthToken, type CreateInvitation, type CreateNotificationChannel, type CreateProject, type Event, type EventDetail, type GlobalRole, type Invitation, type InvitationInfo, type Issue, type IssueFilter, type IssueSort, type ListAlertHistoryOptions, type ListEventsOptions, type ListIssuesOptions, type ListProjectsOptions, type ListSourceMapsResponse, type ListTransactionsOptions, type LoginRequest, type LoginResult, NetworkError, NotFoundError, type NotificationChannel, type OffsetPaginatedResponse, type PaginatedResponse, type Project, type ProjectMember, type ProjectRole, type ProviderType, RateLimitError, type RegisterRequest, type ReleaseHealth, type ReleaseHealthRow, type RoutingOverride, RustrakClient, RustrakError, ServerError, type ServerVersion, type SortOrder, type SourceMapFile, type Span, type TeamMember, type TestChannelResponse, type TestIntegrationBody, type Transaction, type TransactionDetail, type TransactionStats, type UpdateAlertIntegration, type UpdateAlertRule, type UpdateIssueState, type UpdateNotificationChannel, type UpdateProject, type UpdateUserRole, type UpsertProjectMember, type User, ValidationError };
|
|
814
|
+
export { type AcceptInvitation, type AlertHistory, type AlertIntegration, type AlertRule, type AlertRuleChannelInput, type AlertStatus, type AlertType, type ApiError, type AssembleInput, type AssembleResponse, type AuthResponse, type AuthToken, type AuthTokenCreated, AuthenticationError, AuthorizationError, BadRequestError, type ChannelType, type ChunkUploadCapability, type CleanupCounts, type CleanupOptions, type ClientConfig, type CreateAlertIntegration, type CreateAlertRule, type CreateAuthToken, type CreateInvitation, type CreateNotificationChannel, type CreateProject, type Event, type EventDetail, type GlobalRole, type Invitation, type InvitationInfo, type Issue, type IssueFilter, type IssueSort, type ListAlertHistoryOptions, type ListEventsOptions, type ListIssuesOptions, type ListProjectsOptions, type ListSourceMapsResponse, type ListTransactionsOptions, type LoginRequest, type LoginResult, NetworkError, NotFoundError, type NotificationChannel, type OffsetPaginatedResponse, type PaginatedResponse, type Project, type ProjectMember, type ProjectRole, type ProjectStorage, type ProviderType, RateLimitError, type RegisterRequest, type ReleaseHealth, type ReleaseHealthRow, type RoutingOverride, RustrakClient, RustrakError, ServerError, type ServerVersion, type SortOrder, type SourceMapFile, type SourceMapGcResult, type SourceMapStorage, type Span, type StorageSummary, type TeamMember, type TestChannelResponse, type TestIntegrationBody, type Transaction, type TransactionDetail, type TransactionStats, type UpdateAlertIntegration, type UpdateAlertRule, type UpdateIssueState, type UpdateNotificationChannel, type UpdateProject, type UpdateUserRole, type UpsertProjectMember, type User, ValidationError };
|
package/dist/index.js
CHANGED
|
@@ -602,6 +602,42 @@ var sourceMapFileSchema = z.object({
|
|
|
602
602
|
var listSourceMapsResponseSchema = z.object({
|
|
603
603
|
data: z.array(sourceMapFileSchema)
|
|
604
604
|
});
|
|
605
|
+
var sourceMapStorageSchema = z.object({
|
|
606
|
+
chunk_bytes: z.number(),
|
|
607
|
+
source_file_bytes: z.number(),
|
|
608
|
+
total_bytes: z.number(),
|
|
609
|
+
file_count: z.number()
|
|
610
|
+
});
|
|
611
|
+
var storageSummarySchema = z.object({
|
|
612
|
+
total_db_size_bytes: z.number(),
|
|
613
|
+
events_count: z.number(),
|
|
614
|
+
transactions_count: z.number(),
|
|
615
|
+
spans_count: z.number(),
|
|
616
|
+
source_maps: sourceMapStorageSchema
|
|
617
|
+
});
|
|
618
|
+
var projectStorageSchema = z.object({
|
|
619
|
+
project_id: z.number(),
|
|
620
|
+
project_name: z.string(),
|
|
621
|
+
events_count: z.number(),
|
|
622
|
+
transactions_count: z.number(),
|
|
623
|
+
spans_count: z.number(),
|
|
624
|
+
source_maps_count: z.number(),
|
|
625
|
+
estimated_bytes: z.number()
|
|
626
|
+
});
|
|
627
|
+
var cleanupCountsSchema = z.object({
|
|
628
|
+
events: z.number(),
|
|
629
|
+
transactions: z.number(),
|
|
630
|
+
spans: z.number(),
|
|
631
|
+
issues_removed: z.number()
|
|
632
|
+
});
|
|
633
|
+
var sourceMapGcResultSchema = z.object({
|
|
634
|
+
files_removed: z.number(),
|
|
635
|
+
bytes_freed: z.number()
|
|
636
|
+
});
|
|
637
|
+
var cleanupOptionsSchema = z.object({
|
|
638
|
+
older_than_days: z.number().int().min(1),
|
|
639
|
+
project_id: z.number().int().optional()
|
|
640
|
+
});
|
|
605
641
|
var authTokenSchema = z.object({
|
|
606
642
|
id: z.number().int(),
|
|
607
643
|
token_prefix: z.string(),
|
|
@@ -935,6 +971,59 @@ var SourceMapsResource = class extends BaseResource {
|
|
|
935
971
|
return this.validate(data, listSourceMapsResponseSchema);
|
|
936
972
|
}
|
|
937
973
|
};
|
|
974
|
+
var StorageResource = class extends BaseResource {
|
|
975
|
+
/**
|
|
976
|
+
* Get the instance-wide storage summary: row counts per data category, the
|
|
977
|
+
* whole-DB size, and exact source-map weight.
|
|
978
|
+
*/
|
|
979
|
+
async getSummary() {
|
|
980
|
+
const data = await this.http.get("api/storage/summary").json();
|
|
981
|
+
return this.validate(data, storageSummarySchema);
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Get the per-project storage breakdown (one row per project, including
|
|
985
|
+
* empty ones).
|
|
986
|
+
*/
|
|
987
|
+
async getProjects() {
|
|
988
|
+
const data = await this.http.get("api/storage/projects").json();
|
|
989
|
+
return this.validate(data, z.array(projectStorageSchema));
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Dry-run: count the rows a cleanup would remove. Mutates nothing — use it to
|
|
993
|
+
* confirm impact before {@link executeCleanup}.
|
|
994
|
+
*/
|
|
995
|
+
async previewCleanup(options) {
|
|
996
|
+
const json = cleanupOptionsSchema.parse(options);
|
|
997
|
+
const data = await this.http.post("api/storage/cleanup/preview", { json }).json();
|
|
998
|
+
return this.validate(data, cleanupCountsSchema);
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Execute a cleanup: delete data older than `older_than_days` (optionally
|
|
1002
|
+
* scoped to one project) and remove any issue left with zero events.
|
|
1003
|
+
*/
|
|
1004
|
+
async executeCleanup(options) {
|
|
1005
|
+
const json = cleanupOptionsSchema.parse(options);
|
|
1006
|
+
const data = await this.http.post("api/storage/cleanup", { json }).json();
|
|
1007
|
+
return this.validate(data, cleanupCountsSchema);
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Dry-run for {@link gcSourceMaps}: count the orphaned source-map files and
|
|
1011
|
+
* bytes a GC would reclaim. Mutates nothing.
|
|
1012
|
+
*/
|
|
1013
|
+
async previewGcSourceMaps() {
|
|
1014
|
+
const data = await this.http.post("api/storage/source-maps/gc/preview").json();
|
|
1015
|
+
return this.validate(data, sourceMapGcResultSchema);
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Garbage-collect orphaned source maps: files no longer referenced by any
|
|
1019
|
+
* upload, removed from the DB and unlinked from disk. Safe — never touches
|
|
1020
|
+
* referenced files.
|
|
1021
|
+
*/
|
|
1022
|
+
async gcSourceMaps() {
|
|
1023
|
+
const data = await this.http.post("api/storage/source-maps/gc").json();
|
|
1024
|
+
return this.validate(data, sourceMapGcResultSchema);
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
938
1027
|
|
|
939
1028
|
// src/resources/team.ts
|
|
940
1029
|
var TeamResource = class extends BaseResource {
|
|
@@ -973,11 +1062,14 @@ var TokensResource = class extends BaseResource {
|
|
|
973
1062
|
return this.validate(data, authTokenSchema.array());
|
|
974
1063
|
}
|
|
975
1064
|
/**
|
|
976
|
-
* Get a single auth token by ID (
|
|
1065
|
+
* Get a single auth token by ID (full token value).
|
|
1066
|
+
*
|
|
1067
|
+
* Previously returned a masked version, but the server now returns the
|
|
1068
|
+
* complete token for GET /api/tokens/{id}.
|
|
977
1069
|
*/
|
|
978
1070
|
async get(id) {
|
|
979
1071
|
const data = await this.http.get(`api/tokens/${id}`).json();
|
|
980
|
-
return this.validate(data,
|
|
1072
|
+
return this.validate(data, authTokenCreatedSchema);
|
|
981
1073
|
}
|
|
982
1074
|
/**
|
|
983
1075
|
* Create a new auth token
|
|
@@ -1199,6 +1291,10 @@ var RustrakClient = class {
|
|
|
1199
1291
|
* Transactions API resource (performance monitoring)
|
|
1200
1292
|
*/
|
|
1201
1293
|
transactions;
|
|
1294
|
+
/**
|
|
1295
|
+
* Storage API resource (usage + retention cleanup, admin only)
|
|
1296
|
+
*/
|
|
1297
|
+
storage;
|
|
1202
1298
|
/**
|
|
1203
1299
|
* Health API resource (version info)
|
|
1204
1300
|
*/
|
|
@@ -1223,6 +1319,7 @@ var RustrakClient = class {
|
|
|
1223
1319
|
this.members = new MembersResource(this.http);
|
|
1224
1320
|
this.sessions = new SessionsResource(this.http);
|
|
1225
1321
|
this.transactions = new TransactionsResource(this.http);
|
|
1322
|
+
this.storage = new StorageResource(this.http);
|
|
1226
1323
|
this.health = new HealthResource(this.http);
|
|
1227
1324
|
}
|
|
1228
1325
|
};
|