@authhero/cloudflare-adapter 2.29.1 → 2.30.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/cloudflare-adapter.cjs +42 -36
- package/dist/cloudflare-adapter.d.ts +321 -0
- package/dist/cloudflare-adapter.mjs +1277 -1176
- package/package.json +1 -1
|
@@ -2,6 +2,262 @@
|
|
|
2
2
|
|
|
3
3
|
import { z } from '@hono/zod-openapi';
|
|
4
4
|
|
|
5
|
+
declare const actionExecutionSchema: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
tenant_id: z.ZodString;
|
|
8
|
+
trigger_id: z.ZodString;
|
|
9
|
+
status: z.ZodEnum<[
|
|
10
|
+
"unspecified",
|
|
11
|
+
"pending",
|
|
12
|
+
"final",
|
|
13
|
+
"partial",
|
|
14
|
+
"canceled",
|
|
15
|
+
"suspended"
|
|
16
|
+
]>;
|
|
17
|
+
results: z.ZodArray<z.ZodObject<{
|
|
18
|
+
action_name: z.ZodString;
|
|
19
|
+
error: z.ZodNullable<z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
msg: z.ZodString;
|
|
22
|
+
url: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
id: string;
|
|
25
|
+
msg: string;
|
|
26
|
+
url?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
id: string;
|
|
29
|
+
msg: string;
|
|
30
|
+
url?: string | undefined;
|
|
31
|
+
}>>;
|
|
32
|
+
started_at: z.ZodString;
|
|
33
|
+
ended_at: z.ZodString;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
action_name: string;
|
|
36
|
+
error: {
|
|
37
|
+
id: string;
|
|
38
|
+
msg: string;
|
|
39
|
+
url?: string | undefined;
|
|
40
|
+
} | null;
|
|
41
|
+
started_at: string;
|
|
42
|
+
ended_at: string;
|
|
43
|
+
}, {
|
|
44
|
+
action_name: string;
|
|
45
|
+
error: {
|
|
46
|
+
id: string;
|
|
47
|
+
msg: string;
|
|
48
|
+
url?: string | undefined;
|
|
49
|
+
} | null;
|
|
50
|
+
started_at: string;
|
|
51
|
+
ended_at: string;
|
|
52
|
+
}>, "many">;
|
|
53
|
+
logs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
54
|
+
action_name: z.ZodString;
|
|
55
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
56
|
+
level: z.ZodEnum<[
|
|
57
|
+
"log",
|
|
58
|
+
"info",
|
|
59
|
+
"warn",
|
|
60
|
+
"error",
|
|
61
|
+
"debug"
|
|
62
|
+
]>;
|
|
63
|
+
message: z.ZodString;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
message: string;
|
|
66
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
67
|
+
}, {
|
|
68
|
+
message: string;
|
|
69
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
70
|
+
}>, "many">;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
action_name: string;
|
|
73
|
+
lines: {
|
|
74
|
+
message: string;
|
|
75
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
76
|
+
}[];
|
|
77
|
+
}, {
|
|
78
|
+
action_name: string;
|
|
79
|
+
lines: {
|
|
80
|
+
message: string;
|
|
81
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
82
|
+
}[];
|
|
83
|
+
}>, "many">>;
|
|
84
|
+
created_at: z.ZodString;
|
|
85
|
+
updated_at: z.ZodString;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
created_at: string;
|
|
88
|
+
updated_at: string;
|
|
89
|
+
status: "unspecified" | "pending" | "final" | "partial" | "canceled" | "suspended";
|
|
90
|
+
id: string;
|
|
91
|
+
tenant_id: string;
|
|
92
|
+
trigger_id: string;
|
|
93
|
+
results: {
|
|
94
|
+
action_name: string;
|
|
95
|
+
error: {
|
|
96
|
+
id: string;
|
|
97
|
+
msg: string;
|
|
98
|
+
url?: string | undefined;
|
|
99
|
+
} | null;
|
|
100
|
+
started_at: string;
|
|
101
|
+
ended_at: string;
|
|
102
|
+
}[];
|
|
103
|
+
logs?: {
|
|
104
|
+
action_name: string;
|
|
105
|
+
lines: {
|
|
106
|
+
message: string;
|
|
107
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
108
|
+
}[];
|
|
109
|
+
}[] | undefined;
|
|
110
|
+
}, {
|
|
111
|
+
created_at: string;
|
|
112
|
+
updated_at: string;
|
|
113
|
+
status: "unspecified" | "pending" | "final" | "partial" | "canceled" | "suspended";
|
|
114
|
+
id: string;
|
|
115
|
+
tenant_id: string;
|
|
116
|
+
trigger_id: string;
|
|
117
|
+
results: {
|
|
118
|
+
action_name: string;
|
|
119
|
+
error: {
|
|
120
|
+
id: string;
|
|
121
|
+
msg: string;
|
|
122
|
+
url?: string | undefined;
|
|
123
|
+
} | null;
|
|
124
|
+
started_at: string;
|
|
125
|
+
ended_at: string;
|
|
126
|
+
}[];
|
|
127
|
+
logs?: {
|
|
128
|
+
action_name: string;
|
|
129
|
+
lines: {
|
|
130
|
+
message: string;
|
|
131
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
132
|
+
}[];
|
|
133
|
+
}[] | undefined;
|
|
134
|
+
}>;
|
|
135
|
+
export type ActionExecution = z.infer<typeof actionExecutionSchema>;
|
|
136
|
+
declare const actionExecutionInsertSchema: z.ZodObject<Omit<{
|
|
137
|
+
id: z.ZodString;
|
|
138
|
+
tenant_id: z.ZodString;
|
|
139
|
+
trigger_id: z.ZodString;
|
|
140
|
+
status: z.ZodEnum<[
|
|
141
|
+
"unspecified",
|
|
142
|
+
"pending",
|
|
143
|
+
"final",
|
|
144
|
+
"partial",
|
|
145
|
+
"canceled",
|
|
146
|
+
"suspended"
|
|
147
|
+
]>;
|
|
148
|
+
results: z.ZodArray<z.ZodObject<{
|
|
149
|
+
action_name: z.ZodString;
|
|
150
|
+
error: z.ZodNullable<z.ZodObject<{
|
|
151
|
+
id: z.ZodString;
|
|
152
|
+
msg: z.ZodString;
|
|
153
|
+
url: z.ZodOptional<z.ZodString>;
|
|
154
|
+
}, "strip", z.ZodTypeAny, {
|
|
155
|
+
id: string;
|
|
156
|
+
msg: string;
|
|
157
|
+
url?: string | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
id: string;
|
|
160
|
+
msg: string;
|
|
161
|
+
url?: string | undefined;
|
|
162
|
+
}>>;
|
|
163
|
+
started_at: z.ZodString;
|
|
164
|
+
ended_at: z.ZodString;
|
|
165
|
+
}, "strip", z.ZodTypeAny, {
|
|
166
|
+
action_name: string;
|
|
167
|
+
error: {
|
|
168
|
+
id: string;
|
|
169
|
+
msg: string;
|
|
170
|
+
url?: string | undefined;
|
|
171
|
+
} | null;
|
|
172
|
+
started_at: string;
|
|
173
|
+
ended_at: string;
|
|
174
|
+
}, {
|
|
175
|
+
action_name: string;
|
|
176
|
+
error: {
|
|
177
|
+
id: string;
|
|
178
|
+
msg: string;
|
|
179
|
+
url?: string | undefined;
|
|
180
|
+
} | null;
|
|
181
|
+
started_at: string;
|
|
182
|
+
ended_at: string;
|
|
183
|
+
}>, "many">;
|
|
184
|
+
logs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
185
|
+
action_name: z.ZodString;
|
|
186
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
187
|
+
level: z.ZodEnum<[
|
|
188
|
+
"log",
|
|
189
|
+
"info",
|
|
190
|
+
"warn",
|
|
191
|
+
"error",
|
|
192
|
+
"debug"
|
|
193
|
+
]>;
|
|
194
|
+
message: z.ZodString;
|
|
195
|
+
}, "strip", z.ZodTypeAny, {
|
|
196
|
+
message: string;
|
|
197
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
198
|
+
}, {
|
|
199
|
+
message: string;
|
|
200
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
201
|
+
}>, "many">;
|
|
202
|
+
}, "strip", z.ZodTypeAny, {
|
|
203
|
+
action_name: string;
|
|
204
|
+
lines: {
|
|
205
|
+
message: string;
|
|
206
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
207
|
+
}[];
|
|
208
|
+
}, {
|
|
209
|
+
action_name: string;
|
|
210
|
+
lines: {
|
|
211
|
+
message: string;
|
|
212
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
213
|
+
}[];
|
|
214
|
+
}>, "many">>;
|
|
215
|
+
created_at: z.ZodString;
|
|
216
|
+
updated_at: z.ZodString;
|
|
217
|
+
}, "created_at" | "updated_at" | "tenant_id">, "strip", z.ZodTypeAny, {
|
|
218
|
+
status: "unspecified" | "pending" | "final" | "partial" | "canceled" | "suspended";
|
|
219
|
+
id: string;
|
|
220
|
+
trigger_id: string;
|
|
221
|
+
results: {
|
|
222
|
+
action_name: string;
|
|
223
|
+
error: {
|
|
224
|
+
id: string;
|
|
225
|
+
msg: string;
|
|
226
|
+
url?: string | undefined;
|
|
227
|
+
} | null;
|
|
228
|
+
started_at: string;
|
|
229
|
+
ended_at: string;
|
|
230
|
+
}[];
|
|
231
|
+
logs?: {
|
|
232
|
+
action_name: string;
|
|
233
|
+
lines: {
|
|
234
|
+
message: string;
|
|
235
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
236
|
+
}[];
|
|
237
|
+
}[] | undefined;
|
|
238
|
+
}, {
|
|
239
|
+
status: "unspecified" | "pending" | "final" | "partial" | "canceled" | "suspended";
|
|
240
|
+
id: string;
|
|
241
|
+
trigger_id: string;
|
|
242
|
+
results: {
|
|
243
|
+
action_name: string;
|
|
244
|
+
error: {
|
|
245
|
+
id: string;
|
|
246
|
+
msg: string;
|
|
247
|
+
url?: string | undefined;
|
|
248
|
+
} | null;
|
|
249
|
+
started_at: string;
|
|
250
|
+
ended_at: string;
|
|
251
|
+
}[];
|
|
252
|
+
logs?: {
|
|
253
|
+
action_name: string;
|
|
254
|
+
lines: {
|
|
255
|
+
message: string;
|
|
256
|
+
level: "error" | "log" | "info" | "warn" | "debug";
|
|
257
|
+
}[];
|
|
258
|
+
}[] | undefined;
|
|
259
|
+
}>;
|
|
260
|
+
export type ActionExecutionInsert = z.infer<typeof actionExecutionInsertSchema>;
|
|
5
261
|
export interface Totals {
|
|
6
262
|
start: number;
|
|
7
263
|
limit: number;
|
|
@@ -675,6 +931,10 @@ export interface AnalyticsQueryResponse {
|
|
|
675
931
|
bytes_read?: number;
|
|
676
932
|
};
|
|
677
933
|
}
|
|
934
|
+
export interface ActionExecutionsAdapter {
|
|
935
|
+
create: (tenant_id: string, execution: ActionExecutionInsert) => Promise<ActionExecution>;
|
|
936
|
+
get: (tenant_id: string, execution_id: string) => Promise<ActionExecution | null>;
|
|
937
|
+
}
|
|
678
938
|
export interface CacheAdapter {
|
|
679
939
|
/**
|
|
680
940
|
* Get a value from the cache
|
|
@@ -1033,6 +1293,60 @@ export declare function createAnalyticsEngineAnalyticsAdapter(config: AnalyticsE
|
|
|
1033
1293
|
* ```
|
|
1034
1294
|
*/
|
|
1035
1295
|
export declare function createAnalyticsEngineLogsAdapter(config: AnalyticsEngineLogsAdapterConfig): LogsDataAdapter;
|
|
1296
|
+
export interface AnalyticsEngineActionExecutionsAdapterConfig {
|
|
1297
|
+
/**
|
|
1298
|
+
* Cloudflare Analytics Engine dataset binding (for Workers).
|
|
1299
|
+
* Pass the Analytics Engine dataset object from env (e.g.
|
|
1300
|
+
* env.AUTH_ACTION_EXECUTIONS).
|
|
1301
|
+
*/
|
|
1302
|
+
analyticsEngineBinding?: AnalyticsEngineDataset;
|
|
1303
|
+
/**
|
|
1304
|
+
* Cloudflare account ID for querying via the SQL API.
|
|
1305
|
+
* Can be passed via environment variable: CLOUDFLARE_ACCOUNT_ID.
|
|
1306
|
+
*/
|
|
1307
|
+
accountId: string;
|
|
1308
|
+
/**
|
|
1309
|
+
* Cloudflare API token for querying via the SQL API.
|
|
1310
|
+
* Must have Analytics Engine SQL API permissions.
|
|
1311
|
+
* Can be passed via environment variable: ANALYTICS_ENGINE_API_TOKEN.
|
|
1312
|
+
*/
|
|
1313
|
+
apiToken: string;
|
|
1314
|
+
/**
|
|
1315
|
+
* Analytics Engine dataset name (default: "authhero_action_executions").
|
|
1316
|
+
* Should match the dataset name configured in wrangler.toml.
|
|
1317
|
+
*/
|
|
1318
|
+
dataset?: string;
|
|
1319
|
+
/**
|
|
1320
|
+
* HTTP timeout in milliseconds for SQL API queries (default: 30000).
|
|
1321
|
+
*/
|
|
1322
|
+
timeout?: number;
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Create an Analytics Engine action_executions adapter.
|
|
1326
|
+
*
|
|
1327
|
+
* Persists Auth0-shaped action execution records (one row per execution) into
|
|
1328
|
+
* a Cloudflare Analytics Engine dataset and reads them back via the AE SQL
|
|
1329
|
+
* API. Pair with `createAnalyticsEngineLogsAdapter` so logs and the
|
|
1330
|
+
* executions they reference live in the same place.
|
|
1331
|
+
*
|
|
1332
|
+
* @example
|
|
1333
|
+
* ```typescript
|
|
1334
|
+
* // wrangler.toml:
|
|
1335
|
+
* // [[analytics_engine_datasets]]
|
|
1336
|
+
* // binding = "AUTH_ACTION_EXECUTIONS"
|
|
1337
|
+
* // dataset = "authhero_action_executions"
|
|
1338
|
+
*
|
|
1339
|
+
* import { createAnalyticsEngineActionExecutionsAdapter } from "@authhero/cloudflare-adapter";
|
|
1340
|
+
*
|
|
1341
|
+
* const adapter = createAnalyticsEngineActionExecutionsAdapter({
|
|
1342
|
+
* analyticsEngineBinding: env.AUTH_ACTION_EXECUTIONS,
|
|
1343
|
+
* accountId: env.CLOUDFLARE_ACCOUNT_ID,
|
|
1344
|
+
* apiToken: env.ANALYTICS_ENGINE_API_TOKEN,
|
|
1345
|
+
* dataset: "authhero_action_executions",
|
|
1346
|
+
* });
|
|
1347
|
+
* ```
|
|
1348
|
+
*/
|
|
1349
|
+
export declare function createAnalyticsEngineActionExecutionsAdapter(config: AnalyticsEngineActionExecutionsAdapterConfig): ActionExecutionsAdapter;
|
|
1036
1350
|
/**
|
|
1037
1351
|
* Minimal shape of the Cloudflare Workers Rate Limiter binding. We declare
|
|
1038
1352
|
* it locally rather than depending on `@cloudflare/workers-types` so the
|
|
@@ -1090,6 +1404,12 @@ export interface CloudflareConfig {
|
|
|
1090
1404
|
* Use this for low-latency log writes with Cloudflare Analytics Engine
|
|
1091
1405
|
*/
|
|
1092
1406
|
analyticsEngineLogs?: AnalyticsEngineLogsAdapterConfig;
|
|
1407
|
+
/**
|
|
1408
|
+
* Analytics Engine action_executions adapter configuration (optional).
|
|
1409
|
+
* Stores Auth0-shaped action execution records in a dedicated AE dataset
|
|
1410
|
+
* so logs and the executions they reference can both live in AE.
|
|
1411
|
+
*/
|
|
1412
|
+
analyticsEngineActionExecutions?: AnalyticsEngineActionExecutionsAdapterConfig;
|
|
1093
1413
|
/**
|
|
1094
1414
|
* Cloudflare Workers Rate Limiter bindings, keyed by logical scope.
|
|
1095
1415
|
* Each binding's `limit` and `period` are baked in at deploy time; this
|
|
@@ -1275,6 +1595,7 @@ export interface CloudflareAdapters {
|
|
|
1275
1595
|
analytics?: AnalyticsAdapter;
|
|
1276
1596
|
geo?: GeoAdapter;
|
|
1277
1597
|
rateLimit?: RateLimitAdapter;
|
|
1598
|
+
actionExecutions?: ActionExecutionsAdapter;
|
|
1278
1599
|
}
|
|
1279
1600
|
declare function createAdapters(config: CloudflareConfig): CloudflareAdapters;
|
|
1280
1601
|
|