checkly 9.2.0 → 9.3.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.
@@ -0,0 +1,130 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ export declare const USAGE_INTERVALS: readonly ["total", "day", "week", "month"];
3
+ export type UsageInterval = typeof USAGE_INTERVALS[number];
4
+ export declare const USAGE_GROUP_BY: readonly ["account", "checkType", "account,checkType"];
5
+ export type UsageGroupBy = typeof USAGE_GROUP_BY[number];
6
+ export type UsageWarningCode = 'PARTIAL_WINDOW' | 'USAGE_TERMS_FLAGGED' | 'UNKNOWN_BUDGET';
7
+ export type UsageErrorCode = 'ACCOUNT_NOT_IN_USAGE_TERMS' | 'INVALID_CURSOR' | 'INVALID_RANGE' | 'NO_USAGE_TERMS' | 'USAGE_STORE_UNAVAILABLE' | 'USAGE_TERMS_CONFLICT';
8
+ export interface UsageTermsParams {
9
+ /** YYYY-MM-DD, inclusive. Resolves the usage terms that cover this date. Defaults to today. */
10
+ to?: string;
11
+ }
12
+ export interface UsageRangeParams extends UsageTermsParams {
13
+ /** YYYY-MM-DD, inclusive. */
14
+ from?: string;
15
+ accountIds?: string[];
16
+ checkTypes?: string[];
17
+ }
18
+ export interface UsageSeriesParams extends UsageRangeParams {
19
+ interval?: UsageInterval;
20
+ groupBy?: UsageGroupBy;
21
+ limit?: number;
22
+ nextId?: string;
23
+ }
24
+ export interface UsageAccount {
25
+ id: string;
26
+ name: string;
27
+ }
28
+ export interface UsageTerms {
29
+ id: string;
30
+ name: string;
31
+ accounts: UsageAccount[];
32
+ contractStartDate: string;
33
+ contractEndDate: string;
34
+ usageStartDate: string;
35
+ creditBudget: number | null;
36
+ standardCreditsPerUnit: number | null;
37
+ premiumCreditsPerUnit: number | null;
38
+ }
39
+ export interface UsageCredits {
40
+ used: number | null;
41
+ percentOfBudget: number | null;
42
+ }
43
+ export interface CheckRunMeasures {
44
+ totalRuns: number;
45
+ finalRuns: number;
46
+ retryRuns: number;
47
+ cancelledRuns: number;
48
+ multiStepRequests: number;
49
+ playwrightBillableDurationMs: number;
50
+ degradedRuns: number;
51
+ failedRuns: number;
52
+ errorRuns: number;
53
+ abortedRuns: number;
54
+ overMaxResponseTimeRuns: number;
55
+ standardBillableUnits: number;
56
+ premiumBillableUnits: number;
57
+ }
58
+ export interface AiInvocationMeasures {
59
+ invocations: number;
60
+ durationMs: number;
61
+ }
62
+ export type UsageMeter = {
63
+ meterType: 'CHECK_RUN';
64
+ measures: CheckRunMeasures;
65
+ } | {
66
+ meterType: 'AI_INVOCATION';
67
+ measures: AiInvocationMeasures;
68
+ };
69
+ export interface UsageMetrics {
70
+ credits: UsageCredits;
71
+ meters: UsageMeter[];
72
+ }
73
+ export interface UsageWarning {
74
+ code: UsageWarningCode;
75
+ message: string;
76
+ }
77
+ export interface UsageProjectionWindow {
78
+ usage: UsageMetrics;
79
+ projectedAnnualPercentOfBudget: number | null;
80
+ projectedCreditsAtContractEnd: number | null;
81
+ projectedPercentAtContractEnd: number | null;
82
+ projectedWeeksUntilExhausted: number | null;
83
+ }
84
+ export interface UsageProjections {
85
+ weeksSinceStart: number;
86
+ weeksRemaining: number;
87
+ remainingCredits: number | null;
88
+ windows: {
89
+ sinceStart: UsageProjectionWindow;
90
+ last30Days: UsageProjectionWindow;
91
+ last7Days: UsageProjectionWindow;
92
+ last1Day: UsageProjectionWindow;
93
+ };
94
+ }
95
+ export interface UsageSummary {
96
+ usageTermsId: string;
97
+ period: {
98
+ from: string;
99
+ to: string;
100
+ };
101
+ totals: UsageMetrics;
102
+ projections: UsageProjections;
103
+ }
104
+ export interface UsageRow extends UsageMetrics {
105
+ periodStart: string;
106
+ periodEnd: string;
107
+ accountId?: string;
108
+ checkType?: string;
109
+ }
110
+ export interface UsageSeries {
111
+ usageTermsId: string;
112
+ period: {
113
+ from: string;
114
+ to: string;
115
+ interval: UsageInterval;
116
+ groupBy: UsageGroupBy;
117
+ };
118
+ data: UsageRow[];
119
+ length: number;
120
+ nextId: string | null;
121
+ warnings: UsageWarning[];
122
+ }
123
+ declare class Usage {
124
+ api: AxiosInstance;
125
+ constructor(api: AxiosInstance);
126
+ getTerms(params?: UsageTermsParams): Promise<import("axios").AxiosResponse<UsageTerms, any, {}, any>>;
127
+ getSummary(params?: UsageRangeParams): Promise<import("axios").AxiosResponse<UsageSummary, any, {}, any>>;
128
+ getSeries(params?: UsageSeriesParams): Promise<import("axios").AxiosResponse<UsageSeries, any, {}, any>>;
129
+ }
130
+ export default Usage;
@@ -0,0 +1,38 @@
1
+ export const USAGE_INTERVALS = ['total', 'day', 'week', 'month'];
2
+ export const USAGE_GROUP_BY = ['account', 'checkType', 'account,checkType'];
3
+ // The API accepts repeated or comma-separated values. Axios would serialize
4
+ // arrays as `accountIds[]=...`, which the API does not parse as a list, so join them.
5
+ function toQuery(params) {
6
+ const query = {};
7
+ const set = (key, value) => {
8
+ if (value !== undefined)
9
+ query[key] = value;
10
+ };
11
+ const joined = (values) => (values?.length ? values.join(',') : undefined);
12
+ set('from', params.from);
13
+ set('to', params.to);
14
+ set('accountIds', joined(params.accountIds));
15
+ set('checkTypes', joined(params.checkTypes));
16
+ set('interval', params.interval);
17
+ set('groupBy', params.groupBy);
18
+ set('limit', params.limit);
19
+ set('nextId', params.nextId);
20
+ return query;
21
+ }
22
+ class Usage {
23
+ api;
24
+ constructor(api) {
25
+ this.api = api;
26
+ }
27
+ getTerms(params = {}) {
28
+ return this.api.get('/v1/usage/terms', { params: toQuery(params) });
29
+ }
30
+ getSummary(params = {}) {
31
+ return this.api.get('/v1/usage/summary', { params: toQuery(params) });
32
+ }
33
+ getSeries(params = {}) {
34
+ return this.api.get('/v1/usage/series', { params: toQuery(params) });
35
+ }
36
+ }
37
+ export default Usage;
38
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/rest/usage.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,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