@authhero/adapter-interfaces 4.7.0 → 4.8.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/dist/adapter-interfaces.cjs +1 -1
- package/dist/adapter-interfaces.d.ts +62 -2
- package/dist/adapter-interfaces.mjs +69 -47
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/adapters/Analytics.d.ts +10 -1
- package/dist/types/types/Analytics.d.ts +45 -0
- package/dist/types/utils/session-retention.d.ts +7 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalyticsQueryParams, AnalyticsQueryResponse, AnalyticsResource, SessionRetentionParams, SessionRetentionResponse } from "../types/Analytics";
|
|
1
|
+
import { AnalyticsQueryParams, AnalyticsQueryResponse, AnalyticsResource, RefreshTokenRetentionParams, RefreshTokenRetentionResponse, SessionRetentionParams, SessionRetentionResponse } from "../types/Analytics";
|
|
2
2
|
export interface AnalyticsAdapter {
|
|
3
3
|
/**
|
|
4
4
|
* Run an analytics query for a tenant. The adapter is responsible for
|
|
@@ -13,4 +13,13 @@ export interface AnalyticsAdapter {
|
|
|
13
13
|
* route responds 501 when it is absent.
|
|
14
14
|
*/
|
|
15
15
|
sessionRetention?(tenantId: string, params: SessionRetentionParams): Promise<SessionRetentionResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Weekly refresh-token cohort retention, computed from the refresh_tokens
|
|
18
|
+
* table. Rotating tokens mint a new row per exchange, so rows are grouped
|
|
19
|
+
* into rotation families before folding: a family's cohort week comes from
|
|
20
|
+
* its first token's created_at_ts and its last-active week from the max of
|
|
21
|
+
* last_exchanged_at_ts/created_at_ts across the family. Optional for the
|
|
22
|
+
* same reason as sessionRetention.
|
|
23
|
+
*/
|
|
24
|
+
refreshTokenRetention?(tenantId: string, params: RefreshTokenRetentionParams): Promise<RefreshTokenRetentionResponse>;
|
|
16
25
|
}
|
|
@@ -96,6 +96,36 @@ export interface SessionRetentionResponse {
|
|
|
96
96
|
to: string;
|
|
97
97
|
cohorts: SessionRetentionCohort[];
|
|
98
98
|
}
|
|
99
|
+
export interface RefreshTokenRetentionParams {
|
|
100
|
+
/** Number of weekly cohorts to include, counting back from the current week */
|
|
101
|
+
weeks: number;
|
|
102
|
+
/** Optional filter to one or more client IDs */
|
|
103
|
+
client_id?: string[];
|
|
104
|
+
}
|
|
105
|
+
export interface RefreshTokenRetentionCohort {
|
|
106
|
+
/** ISO date (UTC Monday) the cohort week starts on */
|
|
107
|
+
cohort: string;
|
|
108
|
+
/**
|
|
109
|
+
* Refresh-token families created during the cohort week. Rotating tokens
|
|
110
|
+
* mint a new row on every exchange, so the retention unit is the rotation
|
|
111
|
+
* family (a non-rotating token is a family of one).
|
|
112
|
+
*/
|
|
113
|
+
tokens: number;
|
|
114
|
+
/**
|
|
115
|
+
* active[k] = token families still active k weeks after the cohort week,
|
|
116
|
+
* i.e. last exchanged during week k or later. active[0] === tokens. The
|
|
117
|
+
* array is truncated at the current week.
|
|
118
|
+
*/
|
|
119
|
+
active: number[];
|
|
120
|
+
}
|
|
121
|
+
export interface RefreshTokenRetentionResponse {
|
|
122
|
+
interval: "week";
|
|
123
|
+
/** Inclusive lower bound of the first cohort week */
|
|
124
|
+
from: string;
|
|
125
|
+
/** Timestamp the query ran at; the last cohort week is still in progress */
|
|
126
|
+
to: string;
|
|
127
|
+
cohorts: RefreshTokenRetentionCohort[];
|
|
128
|
+
}
|
|
99
129
|
export declare const sessionRetentionCohortSchema: z.ZodObject<{
|
|
100
130
|
cohort: z.ZodString;
|
|
101
131
|
sessions: z.ZodNumber;
|
|
@@ -111,6 +141,21 @@ export declare const sessionRetentionResponseSchema: z.ZodObject<{
|
|
|
111
141
|
active: z.ZodArray<z.ZodNumber>;
|
|
112
142
|
}, z.core.$strip>>;
|
|
113
143
|
}, z.core.$strip>;
|
|
144
|
+
export declare const refreshTokenRetentionCohortSchema: z.ZodObject<{
|
|
145
|
+
cohort: z.ZodString;
|
|
146
|
+
tokens: z.ZodNumber;
|
|
147
|
+
active: z.ZodArray<z.ZodNumber>;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
export declare const refreshTokenRetentionResponseSchema: z.ZodObject<{
|
|
150
|
+
interval: z.ZodLiteral<"week">;
|
|
151
|
+
from: z.ZodString;
|
|
152
|
+
to: z.ZodString;
|
|
153
|
+
cohorts: z.ZodArray<z.ZodObject<{
|
|
154
|
+
cohort: z.ZodString;
|
|
155
|
+
tokens: z.ZodNumber;
|
|
156
|
+
active: z.ZodArray<z.ZodNumber>;
|
|
157
|
+
}, z.core.$strip>>;
|
|
158
|
+
}, z.core.$strip>;
|
|
114
159
|
export declare const analyticsColumnMetaSchema: z.ZodObject<{
|
|
115
160
|
name: z.ZodString;
|
|
116
161
|
type: z.ZodString;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SessionRetentionResponse } from "../types/Analytics";
|
|
1
|
+
import { RefreshTokenRetentionResponse, SessionRetentionResponse } from "../types/Analytics";
|
|
2
2
|
export declare const WEEK_MS: number;
|
|
3
3
|
/**
|
|
4
4
|
* The Unix epoch (1970-01-01) was a Thursday; adding 3 days before dividing
|
|
@@ -30,3 +30,9 @@ export interface SessionRetentionRawRow {
|
|
|
30
30
|
* enough to reconstruct the whole retention triangle.
|
|
31
31
|
*/
|
|
32
32
|
export declare function buildSessionRetention(rows: SessionRetentionRawRow[], weeks: number, now?: number): SessionRetentionResponse;
|
|
33
|
+
/**
|
|
34
|
+
* Same fold as {@link buildSessionRetention}, but the rows count refresh-token
|
|
35
|
+
* families (created-week = the family's first token, used-week = its last
|
|
36
|
+
* exchange) and the per-cohort total is reported as `tokens`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildRefreshTokenRetention(rows: SessionRetentionRawRow[], weeks: number, now?: number): RefreshTokenRetentionResponse;
|