@authhero/adapter-interfaces 4.4.0 → 4.6.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 +158 -2
- package/dist/adapter-interfaces.mjs +646 -578
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/adapters/ActionExecutions.d.ts +8 -0
- package/dist/types/adapters/Analytics.d.ts +8 -1
- package/dist/types/types/Analytics.d.ts +39 -0
- package/dist/types/types/Forms.d.ts +32 -0
- package/dist/types/types/Hook.d.ts +38 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/session-retention.d.ts +32 -0
- package/package.json +1 -1
|
@@ -2,4 +2,12 @@ import { ActionExecution, ActionExecutionInsert } from "../types";
|
|
|
2
2
|
export interface ActionExecutionsAdapter {
|
|
3
3
|
create: (tenant_id: string, execution: ActionExecutionInsert) => Promise<ActionExecution>;
|
|
4
4
|
get: (tenant_id: string, execution_id: string) => Promise<ActionExecution | null>;
|
|
5
|
+
/**
|
|
6
|
+
* Delete executions created before `olderThan` (ISO-8601), across all
|
|
7
|
+
* tenants. Returns the number of rows deleted.
|
|
8
|
+
*
|
|
9
|
+
* Optional because some backends expire rows themselves (DynamoDB TTL,
|
|
10
|
+
* Analytics Engine dataset retention) and have nothing to sweep.
|
|
11
|
+
*/
|
|
12
|
+
cleanup?: (olderThan: string) => Promise<number>;
|
|
5
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalyticsQueryParams, AnalyticsQueryResponse, AnalyticsResource } from "../types/Analytics";
|
|
1
|
+
import { AnalyticsQueryParams, AnalyticsQueryResponse, AnalyticsResource, 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
|
|
@@ -6,4 +6,11 @@ export interface AnalyticsAdapter {
|
|
|
6
6
|
* tenant value from a client-controlled source.
|
|
7
7
|
*/
|
|
8
8
|
query(tenantId: string, resource: AnalyticsResource, params: AnalyticsQueryParams): Promise<AnalyticsQueryResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Weekly session cohort retention, computed from the sessions table
|
|
11
|
+
* (created_at_ts × used_at_ts) rather than logs. Optional: adapters that
|
|
12
|
+
* only see log events (e.g. Analytics Engine) cannot implement it, and the
|
|
13
|
+
* route responds 501 when it is absent.
|
|
14
|
+
*/
|
|
15
|
+
sessionRetention?(tenantId: string, params: SessionRetentionParams): Promise<SessionRetentionResponse>;
|
|
9
16
|
}
|
|
@@ -72,6 +72,45 @@ export interface AnalyticsQueryResponse {
|
|
|
72
72
|
bytes_read?: number;
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
+
export interface SessionRetentionParams {
|
|
76
|
+
/** Number of weekly cohorts to include, counting back from the current week */
|
|
77
|
+
weeks: number;
|
|
78
|
+
}
|
|
79
|
+
export interface SessionRetentionCohort {
|
|
80
|
+
/** ISO date (UTC Monday) the cohort week starts on */
|
|
81
|
+
cohort: string;
|
|
82
|
+
/** Sessions created during the cohort week */
|
|
83
|
+
sessions: number;
|
|
84
|
+
/**
|
|
85
|
+
* active[k] = sessions still active k weeks after the cohort week, i.e.
|
|
86
|
+
* last used during week k or later. active[0] === sessions. The array is
|
|
87
|
+
* truncated at the current week, so recent cohorts have fewer entries.
|
|
88
|
+
*/
|
|
89
|
+
active: number[];
|
|
90
|
+
}
|
|
91
|
+
export interface SessionRetentionResponse {
|
|
92
|
+
interval: "week";
|
|
93
|
+
/** Inclusive lower bound of the first cohort week */
|
|
94
|
+
from: string;
|
|
95
|
+
/** Timestamp the query ran at; the last cohort week is still in progress */
|
|
96
|
+
to: string;
|
|
97
|
+
cohorts: SessionRetentionCohort[];
|
|
98
|
+
}
|
|
99
|
+
export declare const sessionRetentionCohortSchema: z.ZodObject<{
|
|
100
|
+
cohort: z.ZodString;
|
|
101
|
+
sessions: z.ZodNumber;
|
|
102
|
+
active: z.ZodArray<z.ZodNumber>;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
export declare const sessionRetentionResponseSchema: z.ZodObject<{
|
|
105
|
+
interval: z.ZodLiteral<"week">;
|
|
106
|
+
from: z.ZodString;
|
|
107
|
+
to: z.ZodString;
|
|
108
|
+
cohorts: z.ZodArray<z.ZodObject<{
|
|
109
|
+
cohort: z.ZodString;
|
|
110
|
+
sessions: z.ZodNumber;
|
|
111
|
+
active: z.ZodArray<z.ZodNumber>;
|
|
112
|
+
}, z.core.$strip>>;
|
|
113
|
+
}, z.core.$strip>;
|
|
75
114
|
export declare const analyticsColumnMetaSchema: z.ZodObject<{
|
|
76
115
|
name: z.ZodString;
|
|
77
116
|
type: z.ZodString;
|
|
@@ -354,6 +354,8 @@ declare const emailField: z.ZodObject<{
|
|
|
354
354
|
config: z.ZodOptional<z.ZodObject<{
|
|
355
355
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
356
356
|
default_value: z.ZodOptional<z.ZodString>;
|
|
357
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
358
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
357
359
|
}, z.core.$strip>>;
|
|
358
360
|
}, z.core.$strip>;
|
|
359
361
|
declare const fileField: z.ZodObject<{
|
|
@@ -573,6 +575,8 @@ declare const textField: z.ZodObject<{
|
|
|
573
575
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
574
576
|
max_length: z.ZodOptional<z.ZodNumber>;
|
|
575
577
|
default_value: z.ZodOptional<z.ZodString>;
|
|
578
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
579
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
576
580
|
}, z.core.$strip>>;
|
|
577
581
|
}, z.core.$strip>;
|
|
578
582
|
declare const countryField: z.ZodObject<{
|
|
@@ -997,6 +1001,8 @@ export declare const fieldComponentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
997
1001
|
config: z.ZodOptional<z.ZodObject<{
|
|
998
1002
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
999
1003
|
default_value: z.ZodOptional<z.ZodString>;
|
|
1004
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
1005
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
1000
1006
|
}, z.core.$strip>>;
|
|
1001
1007
|
}, z.core.$strip>, z.ZodObject<{
|
|
1002
1008
|
id: z.ZodString;
|
|
@@ -1208,6 +1214,8 @@ export declare const fieldComponentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
1208
1214
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
1209
1215
|
max_length: z.ZodOptional<z.ZodNumber>;
|
|
1210
1216
|
default_value: z.ZodOptional<z.ZodString>;
|
|
1217
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
1218
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
1211
1219
|
}, z.core.$strip>>;
|
|
1212
1220
|
}, z.core.$strip>, z.ZodObject<{
|
|
1213
1221
|
id: z.ZodString;
|
|
@@ -1598,6 +1606,8 @@ export declare const formNodeComponentDefinition: z.ZodUnion<readonly [z.ZodDisc
|
|
|
1598
1606
|
config: z.ZodOptional<z.ZodObject<{
|
|
1599
1607
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
1600
1608
|
default_value: z.ZodOptional<z.ZodString>;
|
|
1609
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
1610
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
1601
1611
|
}, z.core.$strip>>;
|
|
1602
1612
|
}, z.core.$strip>, z.ZodObject<{
|
|
1603
1613
|
id: z.ZodString;
|
|
@@ -1809,6 +1819,8 @@ export declare const formNodeComponentDefinition: z.ZodUnion<readonly [z.ZodDisc
|
|
|
1809
1819
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
1810
1820
|
max_length: z.ZodOptional<z.ZodNumber>;
|
|
1811
1821
|
default_value: z.ZodOptional<z.ZodString>;
|
|
1822
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
1823
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
1812
1824
|
}, z.core.$strip>>;
|
|
1813
1825
|
}, z.core.$strip>, z.ZodObject<{
|
|
1814
1826
|
id: z.ZodString;
|
|
@@ -2290,6 +2302,8 @@ declare const stepNodeSchema: z.ZodObject<{
|
|
|
2290
2302
|
config: z.ZodOptional<z.ZodObject<{
|
|
2291
2303
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
2292
2304
|
default_value: z.ZodOptional<z.ZodString>;
|
|
2305
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
2306
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
2293
2307
|
}, z.core.$strip>>;
|
|
2294
2308
|
}, z.core.$strip>, z.ZodObject<{
|
|
2295
2309
|
id: z.ZodString;
|
|
@@ -2501,6 +2515,8 @@ declare const stepNodeSchema: z.ZodObject<{
|
|
|
2501
2515
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
2502
2516
|
max_length: z.ZodOptional<z.ZodNumber>;
|
|
2503
2517
|
default_value: z.ZodOptional<z.ZodString>;
|
|
2518
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
2519
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
2504
2520
|
}, z.core.$strip>>;
|
|
2505
2521
|
}, z.core.$strip>, z.ZodObject<{
|
|
2506
2522
|
id: z.ZodString;
|
|
@@ -2929,6 +2945,8 @@ export declare const formNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
2929
2945
|
config: z.ZodOptional<z.ZodObject<{
|
|
2930
2946
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
2931
2947
|
default_value: z.ZodOptional<z.ZodString>;
|
|
2948
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
2949
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
2932
2950
|
}, z.core.$strip>>;
|
|
2933
2951
|
}, z.core.$strip>, z.ZodObject<{
|
|
2934
2952
|
id: z.ZodString;
|
|
@@ -3140,6 +3158,8 @@ export declare const formNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
3140
3158
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
3141
3159
|
max_length: z.ZodOptional<z.ZodNumber>;
|
|
3142
3160
|
default_value: z.ZodOptional<z.ZodString>;
|
|
3161
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
3162
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
3143
3163
|
}, z.core.$strip>>;
|
|
3144
3164
|
}, z.core.$strip>, z.ZodObject<{
|
|
3145
3165
|
id: z.ZodString;
|
|
@@ -3586,6 +3606,8 @@ export declare const formInsertSchema: z.ZodObject<{
|
|
|
3586
3606
|
config: z.ZodOptional<z.ZodObject<{
|
|
3587
3607
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
3588
3608
|
default_value: z.ZodOptional<z.ZodString>;
|
|
3609
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
3610
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
3589
3611
|
}, z.core.$strip>>;
|
|
3590
3612
|
}, z.core.$strip>, z.ZodObject<{
|
|
3591
3613
|
id: z.ZodString;
|
|
@@ -3797,6 +3819,8 @@ export declare const formInsertSchema: z.ZodObject<{
|
|
|
3797
3819
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
3798
3820
|
max_length: z.ZodOptional<z.ZodNumber>;
|
|
3799
3821
|
default_value: z.ZodOptional<z.ZodString>;
|
|
3822
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
3823
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
3800
3824
|
}, z.core.$strip>>;
|
|
3801
3825
|
}, z.core.$strip>, z.ZodObject<{
|
|
3802
3826
|
id: z.ZodString;
|
|
@@ -4275,6 +4299,8 @@ export declare const formSchema: z.ZodObject<{
|
|
|
4275
4299
|
config: z.ZodOptional<z.ZodObject<{
|
|
4276
4300
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
4277
4301
|
default_value: z.ZodOptional<z.ZodString>;
|
|
4302
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
4303
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
4278
4304
|
}, z.core.$strip>>;
|
|
4279
4305
|
}, z.core.$strip>, z.ZodObject<{
|
|
4280
4306
|
id: z.ZodString;
|
|
@@ -4486,6 +4512,8 @@ export declare const formSchema: z.ZodObject<{
|
|
|
4486
4512
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
4487
4513
|
max_length: z.ZodOptional<z.ZodNumber>;
|
|
4488
4514
|
default_value: z.ZodOptional<z.ZodString>;
|
|
4515
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
4516
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
4489
4517
|
}, z.core.$strip>>;
|
|
4490
4518
|
}, z.core.$strip>, z.ZodObject<{
|
|
4491
4519
|
id: z.ZodString;
|
|
@@ -4955,6 +4983,8 @@ export declare const uiScreenSchema: z.ZodObject<{
|
|
|
4955
4983
|
config: z.ZodOptional<z.ZodObject<{
|
|
4956
4984
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
4957
4985
|
default_value: z.ZodOptional<z.ZodString>;
|
|
4986
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
4987
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
4958
4988
|
}, z.core.$strip>>;
|
|
4959
4989
|
}, z.core.$strip>, z.ZodObject<{
|
|
4960
4990
|
id: z.ZodString;
|
|
@@ -5166,6 +5196,8 @@ export declare const uiScreenSchema: z.ZodObject<{
|
|
|
5166
5196
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
5167
5197
|
max_length: z.ZodOptional<z.ZodNumber>;
|
|
5168
5198
|
default_value: z.ZodOptional<z.ZodString>;
|
|
5199
|
+
last_used: z.ZodOptional<z.ZodBoolean>;
|
|
5200
|
+
last_used_label: z.ZodOptional<z.ZodString>;
|
|
5169
5201
|
}, z.core.$strip>>;
|
|
5170
5202
|
}, z.core.$strip>, z.ZodObject<{
|
|
5171
5203
|
id: z.ZodString;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { z } from "@hono/zod-openapi";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in universal-login pages a page hook can interrupt the login with.
|
|
4
|
+
* The runtime redirects to `/u/{page_id}` (or `/u2/{page_id}`), so this enum
|
|
5
|
+
* is the allowlist of interstitial screens — a free-form string would let a
|
|
6
|
+
* misconfigured hook bounce logins to an arbitrary universal-login path.
|
|
7
|
+
*/
|
|
8
|
+
export declare const hookPageId: z.ZodEnum<{
|
|
9
|
+
impersonate: "impersonate";
|
|
10
|
+
}>;
|
|
11
|
+
export type HookPageId = z.infer<typeof hookPageId>;
|
|
2
12
|
export declare const hookTemplateId: z.ZodEnum<{
|
|
3
13
|
"ensure-username": "ensure-username";
|
|
4
14
|
"set-preferred-username": "set-preferred-username";
|
|
@@ -77,6 +87,19 @@ export declare const hookInsertSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
77
87
|
priority: z.ZodOptional<z.ZodNumber>;
|
|
78
88
|
hook_id: z.ZodOptional<z.ZodString>;
|
|
79
89
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
90
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
91
|
+
trigger_id: z.ZodEnum<{
|
|
92
|
+
"post-user-login": "post-user-login";
|
|
93
|
+
}>;
|
|
94
|
+
page_id: z.ZodEnum<{
|
|
95
|
+
impersonate: "impersonate";
|
|
96
|
+
}>;
|
|
97
|
+
permission_required: z.ZodOptional<z.ZodString>;
|
|
98
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
99
|
+
synchronous: z.ZodDefault<z.ZodBoolean>;
|
|
100
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
hook_id: z.ZodOptional<z.ZodString>;
|
|
102
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
80
103
|
}, z.core.$strip>]>;
|
|
81
104
|
export type HookInsert = z.infer<typeof hookInsertSchema>;
|
|
82
105
|
export declare const hookSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -148,5 +171,20 @@ export declare const hookSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
148
171
|
updated_at: z.ZodString;
|
|
149
172
|
hook_id: z.ZodString;
|
|
150
173
|
code_id: z.ZodString;
|
|
174
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
175
|
+
trigger_id: z.ZodEnum<{
|
|
176
|
+
"post-user-login": "post-user-login";
|
|
177
|
+
}>;
|
|
178
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
179
|
+
synchronous: z.ZodDefault<z.ZodBoolean>;
|
|
180
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
181
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
182
|
+
created_at: z.ZodString;
|
|
183
|
+
updated_at: z.ZodString;
|
|
184
|
+
hook_id: z.ZodString;
|
|
185
|
+
page_id: z.ZodEnum<{
|
|
186
|
+
impersonate: "impersonate";
|
|
187
|
+
}>;
|
|
188
|
+
permission_required: z.ZodOptional<z.ZodString>;
|
|
151
189
|
}, z.core.$strip>]>;
|
|
152
190
|
export type Hook = z.infer<typeof hookSchema>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SessionRetentionResponse } from "../types/Analytics";
|
|
2
|
+
export declare const WEEK_MS: number;
|
|
3
|
+
/**
|
|
4
|
+
* The Unix epoch (1970-01-01) was a Thursday; adding 3 days before dividing
|
|
5
|
+
* by a week aligns bucket boundaries to Monday 00:00 UTC.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MONDAY_EPOCH_SHIFT_MS: number;
|
|
8
|
+
/** Monday-aligned week index for an epoch-ms timestamp. */
|
|
9
|
+
export declare function weekIndex(epochMs: number): number;
|
|
10
|
+
/** Epoch ms of the UTC Monday a week index starts on. */
|
|
11
|
+
export declare function weekStartMs(week: number): number;
|
|
12
|
+
export interface SessionRetentionWindow {
|
|
13
|
+
currentWeek: number;
|
|
14
|
+
firstWeek: number;
|
|
15
|
+
/** Epoch ms lower bound for created_at_ts — the start of the first cohort week */
|
|
16
|
+
sinceMs: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function sessionRetentionWindow(weeks: number, now?: number): SessionRetentionWindow;
|
|
19
|
+
export interface SessionRetentionRawRow {
|
|
20
|
+
/** Monday-aligned week index the session was created in */
|
|
21
|
+
created_week: number;
|
|
22
|
+
/** Monday-aligned week index the session was last used in */
|
|
23
|
+
used_week: number;
|
|
24
|
+
count: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Fold raw (created-week × last-used-week) counts into per-cohort retention.
|
|
28
|
+
* A session counts as active k weeks after its cohort week when it was last
|
|
29
|
+
* used during that week or any later one, so a single last-used timestamp is
|
|
30
|
+
* enough to reconstruct the whole retention triangle.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildSessionRetention(rows: SessionRetentionRawRow[], weeks: number, now?: number): SessionRetentionResponse;
|