@xylex-group/athena 3.3.0 → 3.5.1
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/README.md +17 -1
- package/dist/{athena-request-headers-Lr_m8xCV.d.cts → athena-request-headers-BnFN2mbd.d.cts} +1 -1
- package/dist/{athena-request-headers-DzimbvOA.d.ts → athena-request-headers-Dwdkq2WR.d.ts} +1 -1
- package/dist/billing.cjs +1 -1
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.js +1 -1
- package/dist/billing.js.map +1 -1
- package/dist/browser.cjs +3064 -163
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +10 -10
- package/dist/browser.d.ts +10 -10
- package/dist/browser.js +3064 -163
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +2990 -83
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +4 -4
- package/dist/cli/index.d.ts +4 -4
- package/dist/cli/index.js +2990 -83
- package/dist/cli/index.js.map +1 -1
- package/dist/cloudflare.cjs +12914 -0
- package/dist/cloudflare.cjs.map +1 -0
- package/dist/cloudflare.d.cts +368 -0
- package/dist/cloudflare.d.ts +368 -0
- package/dist/cloudflare.js +12885 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/cookies.cjs +4 -3
- package/dist/cookies.cjs.map +1 -1
- package/dist/cookies.js +4 -3
- package/dist/cookies.js.map +1 -1
- package/dist/env.cjs +1 -1
- package/dist/env.cjs.map +1 -1
- package/dist/env.js +1 -1
- package/dist/env.js.map +1 -1
- package/dist/index.cjs +2989 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +2989 -87
- package/dist/index.js.map +1 -1
- package/dist/{model-form-3Gr8rkdT.d.cts → model-form-D0ykVVOs.d.cts} +3 -3
- package/dist/{model-form-CotpEL7z.d.ts → model-form-U8NVtfSA.d.ts} +3 -3
- package/dist/{module-CQmOaDzP.d.cts → module-CMWlJ1z3.d.cts} +4 -4
- package/dist/{module-CWkUTcUc.d.ts → module-CZ-wPcf2.d.ts} +4 -4
- package/dist/next/client.cjs +3025 -125
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +4 -4
- package/dist/next/client.d.ts +4 -4
- package/dist/next/client.js +3025 -125
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +3108 -194
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +22 -9
- package/dist/next/server.d.ts +22 -9
- package/dist/next/server.js +3108 -194
- package/dist/next/server.js.map +1 -1
- package/dist/{pipeline-BnRKO_Pd.d.cts → pipeline-BCpb4BX1.d.cts} +1 -1
- package/dist/{pipeline-sWCmlFqu.d.ts → pipeline-CgmXwMeX.d.ts} +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +6 -6
- package/dist/react.d.ts +6 -6
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/{schema-handlers-VjFDhIMw.d.ts → schema-handlers-CvWqF-dW.d.ts} +1 -1
- package/dist/{schema-handlers-BtT_IQFi.d.cts → schema-handlers-Dr8h9Jg-.d.cts} +1 -1
- package/dist/social-providers.cjs +1 -1
- package/dist/social-providers.cjs.map +1 -1
- package/dist/social-providers.js +1 -1
- package/dist/social-providers.js.map +1 -1
- package/dist/{types-Bltx6iL6.d.cts → types-B2RZPivM.d.cts} +8 -1
- package/dist/{types-Bltx6iL6.d.ts → types-B2RZPivM.d.ts} +8 -1
- package/dist/{types-BDX8zS7w.d.ts → types-BKklrX4J.d.ts} +2 -2
- package/dist/{types-CgCv5o6R.d.cts → types-D5dj1v5Z.d.cts} +1 -1
- package/dist/{types-D-Am7YSd.d.cts → types-DqBFwfhn.d.cts} +2 -2
- package/dist/{types-B75PdABb.d.ts → types-S-bTMPiM.d.ts} +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js.map +1 -1
- package/dist/{v3-client-G1SLeHRa.d.cts → v3-client-DP-qg82X.d.cts} +300 -4
- package/dist/{v3-client-ao8BWQ8v.d.ts → v3-client-OAai_JNs.d.ts} +300 -4
- package/package.json +10 -3
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { ah as AthenaClientCapabilities, dE as D1DatabaseLike, dF as D1ResultLike, dG as AthenaGatewayClient, ag as AthenaClient, dH as R2BucketLike, aA as AthenaRequestContext, aB as AthenaRequestContextProvider, A as AthenaAuthConfig, dI as CloudflareR2StorageModule, ak as AthenaClientWithR2Storage, di as AthenaExecutionMode, al as AthenaDbConfig, g as AthenaChatConfig, aV as AthenaStorageConfig, a as AthenaBillingConfig, dJ as AthenaDiagnosticsMode, dq as AthenaQueryTraceOptions, dj as AthenaExecutionPrefer, ds as AthenaResolvedExecutionMode, ai as AthenaClientConfig } from './v3-client-OAai_JNs.js';
|
|
2
|
+
export { dK as ATHENA_EXECUTION_MODE_ENV_KEY, dL as ATHENA_EXECUTION_PREFER_ENV_KEY, dM as AthenaDbCapabilities, dN as AthenaStorageCapabilities, dO as CloudflareR2GetObjectResult, dP as CloudflareR2ListObjectsInput, dQ as CloudflareR2ListObjectsResult, dR as CloudflareR2ObjectStorage, dS as CloudflareR2PutBody, dT as CloudflareR2PutObjectInput, dU as ResolveAthenaExecutionModeInput, dV as createCloudflareR2StorageModule, dC as resolveAthenaExecutionMode } from './v3-client-OAai_JNs.js';
|
|
3
|
+
import { u as AthenaFetchPayload, v as AthenaDeletePayload, w as AthenaInsertPayload, x as AthenaUpdatePayload, o as BackendConfig, p as BackendType } from './types-B2RZPivM.js';
|
|
4
|
+
import { r as AthenaClientModelsInput } from './types-S-bTMPiM.js';
|
|
5
|
+
import './types-BVKpQmfY.js';
|
|
6
|
+
import './module-C_ab-MM1.js';
|
|
7
|
+
|
|
8
|
+
declare function createGatewayCapabilities(options?: {
|
|
9
|
+
engine?: AthenaClientCapabilities['db']['engine'];
|
|
10
|
+
authRemote?: boolean;
|
|
11
|
+
/** When false/undefined, storage flags match an unconfigured storage namespace. */
|
|
12
|
+
storageConfigured?: boolean;
|
|
13
|
+
storageCatalogs?: boolean;
|
|
14
|
+
storageBackups?: boolean;
|
|
15
|
+
}): AthenaClientCapabilities;
|
|
16
|
+
declare function createCloudflareEdgeCapabilities(options: {
|
|
17
|
+
hasR2: boolean;
|
|
18
|
+
/** Hybrid remote Athena root enables remote object storage without an R2 binding. */
|
|
19
|
+
hasRemoteStorage?: boolean;
|
|
20
|
+
authRemote: boolean;
|
|
21
|
+
findManyAst?: boolean;
|
|
22
|
+
}): AthenaClientCapabilities;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Pure D1 execution helpers shared by edge-local SDK transport and (later)
|
|
26
|
+
* apps/cloudflare-d1-proxy.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
type D1RunnerSessionInput = {
|
|
30
|
+
bookmark?: string | null;
|
|
31
|
+
sessionMode?: string | null;
|
|
32
|
+
};
|
|
33
|
+
type D1QueryInput = D1RunnerSessionInput & {
|
|
34
|
+
query: string;
|
|
35
|
+
params?: unknown[];
|
|
36
|
+
};
|
|
37
|
+
type D1BatchStatementInput = {
|
|
38
|
+
query: string;
|
|
39
|
+
params?: unknown[];
|
|
40
|
+
};
|
|
41
|
+
type D1BatchInput = D1RunnerSessionInput & {
|
|
42
|
+
statements: D1BatchStatementInput[];
|
|
43
|
+
};
|
|
44
|
+
type D1RunnerQuerySuccess = {
|
|
45
|
+
ok: true;
|
|
46
|
+
rows: unknown[];
|
|
47
|
+
columns: string[];
|
|
48
|
+
durationMs?: number;
|
|
49
|
+
count: number;
|
|
50
|
+
bookmark: string | null;
|
|
51
|
+
meta: Record<string, unknown>;
|
|
52
|
+
statementCount?: number;
|
|
53
|
+
};
|
|
54
|
+
type D1RunnerQueryFailure = {
|
|
55
|
+
ok: false;
|
|
56
|
+
error: string;
|
|
57
|
+
message: string;
|
|
58
|
+
};
|
|
59
|
+
type D1RunnerQueryResult = D1RunnerQuerySuccess | D1RunnerQueryFailure;
|
|
60
|
+
type D1RunnerBatchSuccess = {
|
|
61
|
+
ok: true;
|
|
62
|
+
results: D1ResultLike<unknown>[];
|
|
63
|
+
bookmark: string | null;
|
|
64
|
+
};
|
|
65
|
+
type D1RunnerBatchResult = D1RunnerBatchSuccess | D1RunnerQueryFailure;
|
|
66
|
+
/**
|
|
67
|
+
* True when `keyword` appears as a SQL keyword outside string/identifier literals
|
|
68
|
+
* and comments (case-insensitive). Used so `RETURNING` inside string values does
|
|
69
|
+
* not force the all() result path.
|
|
70
|
+
*/
|
|
71
|
+
declare function sqlContainsKeywordOutsideLiterals(sql: string, keyword: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* First bare SQL keyword outside leading comments / whitespace / literals.
|
|
74
|
+
* Used so `-- note\nSELECT …` still classifies as row-producing.
|
|
75
|
+
*/
|
|
76
|
+
declare function sqlFirstKeywordOutsideLiterals(sql: string): string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Whether a prepared statement is expected to return a result set via all().
|
|
79
|
+
* Leading comments, CTE terminal statements, and RETURNING (outside literals)
|
|
80
|
+
* are handled.
|
|
81
|
+
*/
|
|
82
|
+
declare function statementExpectsResultRows(sql: string): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Split SQL into statements without treating `;` inside string literals,
|
|
85
|
+
* quoted identifiers, comments, or SQLite trigger bodies as separators.
|
|
86
|
+
*
|
|
87
|
+
* Trigger DDL (`CREATE TRIGGER ... BEGIN ...; ...; END`) keeps the body as one
|
|
88
|
+
* statement. Nested `CASE ... END` inside the body does not close the trigger.
|
|
89
|
+
* Bare transaction `BEGIN` / `BEGIN TRANSACTION` is not treated as a body opener.
|
|
90
|
+
*/
|
|
91
|
+
declare function splitSqlStatements(query: string): string[];
|
|
92
|
+
/**
|
|
93
|
+
* Detect multiple SQL statements without treating `;` inside string literals,
|
|
94
|
+
* quoted identifiers, comments, or trigger bodies as separators.
|
|
95
|
+
*/
|
|
96
|
+
declare function isMultiStatement(query: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Execute a single query (or multi-statement `exec`) against a D1 binding.
|
|
99
|
+
*/
|
|
100
|
+
declare function executeD1Query(db: D1DatabaseLike, input: D1QueryInput): Promise<D1RunnerQueryResult>;
|
|
101
|
+
/**
|
|
102
|
+
* Execute a batch of prepared statements against a D1 binding.
|
|
103
|
+
*/
|
|
104
|
+
declare function executeD1Batch(db: D1DatabaseLike, input: D1BatchInput): Promise<D1RunnerBatchResult>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* L1 D1/SQLite SQL compiler for flat gateway payloads.
|
|
108
|
+
* Aligned with gateway D1 matrix: flat select/insert/update/delete + upsert.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
type D1CompiledStatement = {
|
|
112
|
+
sql: string;
|
|
113
|
+
params: unknown[];
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* One or more statements. Sparse multi-row inserts without NULL-coercion expand
|
|
117
|
+
* into a batch of single-row inserts (SQLite rejects `DEFAULT` in VALUES tuples).
|
|
118
|
+
*/
|
|
119
|
+
type D1CompiledSql = D1CompiledStatement & {
|
|
120
|
+
statements?: D1CompiledStatement[];
|
|
121
|
+
};
|
|
122
|
+
/** Optional compile-time options for D1 SQL compilation. */
|
|
123
|
+
type D1CompileOptions = {
|
|
124
|
+
/**
|
|
125
|
+
* Proven single-column unique identity for bounded UPDATE/DELETE (from
|
|
126
|
+
* PRAGMA table_info / unique indexes, or an explicit caller override).
|
|
127
|
+
* Required for limit/offset/page bounded mutations.
|
|
128
|
+
*/
|
|
129
|
+
identityColumn?: string;
|
|
130
|
+
};
|
|
131
|
+
declare class D1SqlCompileError extends Error {
|
|
132
|
+
readonly code: string;
|
|
133
|
+
constructor(code: string, message: string);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Compile flat gateway fetch to SQLite SELECT.
|
|
137
|
+
* When `head: true`, compiles a COUNT(*) query (no row body).
|
|
138
|
+
*/
|
|
139
|
+
declare function compileD1Fetch(payload: AthenaFetchPayload): D1CompiledSql;
|
|
140
|
+
/**
|
|
141
|
+
* COUNT(*) for the same filters as a fetch (used for head and exact totals).
|
|
142
|
+
*/
|
|
143
|
+
declare function compileD1Count(payload: AthenaFetchPayload): D1CompiledSql;
|
|
144
|
+
declare function extractAthenaCount(rows: unknown[]): number;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Compile insert / upsert for D1.
|
|
148
|
+
*
|
|
149
|
+
* SQLite does not allow `DEFAULT` inside multi-row VALUES tuples. Sparse multi-row
|
|
150
|
+
* inserts without `default_to_null` become a batch of single-row inserts so omitted
|
|
151
|
+
* columns keep true DB defaults.
|
|
152
|
+
*/
|
|
153
|
+
declare function compileD1Insert(payload: AthenaInsertPayload): D1CompiledSql;
|
|
154
|
+
/**
|
|
155
|
+
* Compile update with required filters.
|
|
156
|
+
* Pagination / sort bounds use a unique-identity IN (subquery) so only one page is updated.
|
|
157
|
+
*/
|
|
158
|
+
declare function compileD1Update(payload: AthenaUpdatePayload, options?: D1CompileOptions): D1CompiledSql;
|
|
159
|
+
/**
|
|
160
|
+
* Compile delete with required filters.
|
|
161
|
+
*
|
|
162
|
+
* `payload.resource_id` alone (no column filter) maps to `id = ?` for the common
|
|
163
|
+
* Athena PK path. Explicit `.eq('resource_id', …)` / other filters are preserved
|
|
164
|
+
* so tables with a real `resource_id` column are not rewritten to `id`.
|
|
165
|
+
*/
|
|
166
|
+
declare function compileD1Delete(payload: AthenaDeletePayload, options?: D1CompileOptions): D1CompiledSql;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Strip Postgres cast suffixes and normalize a few operators so UUID equality
|
|
170
|
+
* plans like `"id"::text = '…'::text` execute on D1.
|
|
171
|
+
* String/identifier literals are left unchanged.
|
|
172
|
+
*/
|
|
173
|
+
declare function rewritePostgresSqlForSqlite(sql: string): string;
|
|
174
|
+
|
|
175
|
+
type CloudflareD1TransportOptions = {
|
|
176
|
+
d1: D1DatabaseLike;
|
|
177
|
+
/** Default D1 session mode when headers omit session mode. */
|
|
178
|
+
defaultSessionMode?: string | null;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Resolve a single-column unique identity for bounded mutations from live D1
|
|
182
|
+
* schema (PRAGMA table_info + index_list). Prefer PRIMARY KEY; else a single-
|
|
183
|
+
* column UNIQUE index. Multi-column keys are rejected as unsafe for IN-subquery.
|
|
184
|
+
*/
|
|
185
|
+
declare function resolveD1BoundedIdentityColumn(d1: D1DatabaseLike, tableName: string, session?: {
|
|
186
|
+
bookmark?: string | null;
|
|
187
|
+
sessionMode?: string | null;
|
|
188
|
+
}): Promise<string>;
|
|
189
|
+
/**
|
|
190
|
+
* Gateway-shaped transport that executes against a Worker D1 binding.
|
|
191
|
+
*/
|
|
192
|
+
declare function createCloudflareD1GatewayTransport(options: CloudflareD1TransportOptions): AthenaGatewayClient;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Edge-only client façade over {@link createClient}.
|
|
196
|
+
* Prefer `createClient({ db: { d1 }, storage: { r2 } })` for new code (ADR 0001).
|
|
197
|
+
* This helper maps the historical top-level `d1` / `r2` shape onto that spine.
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
interface CloudflareAthenaClientConfig<TModels extends AthenaClientModelsInput | undefined = undefined> {
|
|
201
|
+
/** D1 database binding (e.g. env.DB). */
|
|
202
|
+
d1: D1DatabaseLike;
|
|
203
|
+
/** Optional R2 bucket binding for L3a object I/O. */
|
|
204
|
+
r2?: R2BucketLike;
|
|
205
|
+
/** Object key prefix for R2. */
|
|
206
|
+
storagePrefix?: string;
|
|
207
|
+
/** Default D1 session mode (`first-unconstrained`, `first-primary`, …). */
|
|
208
|
+
sessionMode?: string | null;
|
|
209
|
+
/**
|
|
210
|
+
* Optional unified / remote Athena URL for hybrid services (auth, billing).
|
|
211
|
+
* Not required for pure D1/R2 local mode.
|
|
212
|
+
*/
|
|
213
|
+
url?: string | null;
|
|
214
|
+
/**
|
|
215
|
+
* API key for remote hybrid services.
|
|
216
|
+
* Pure edge-local mode gets a local sentinel via {@link createClient} when omitted.
|
|
217
|
+
* Hybrid configs (`url` set) must not pre-fill that sentinel — leave unset so
|
|
218
|
+
* `createClient` / resolveCore can read `ATHENA_API_KEY` (etc.) from `env`.
|
|
219
|
+
*/
|
|
220
|
+
key?: string | null;
|
|
221
|
+
client?: string | null;
|
|
222
|
+
models?: TModels;
|
|
223
|
+
headers?: Record<string, string>;
|
|
224
|
+
context?: AthenaRequestContext | AthenaRequestContextProvider;
|
|
225
|
+
auth?: AthenaAuthConfig;
|
|
226
|
+
env?: Record<string, string | undefined>;
|
|
227
|
+
retryReads?: boolean;
|
|
228
|
+
debugAst?: boolean;
|
|
229
|
+
findManyAst?: boolean;
|
|
230
|
+
traceQueries?: boolean;
|
|
231
|
+
}
|
|
232
|
+
type CloudflareAthenaClientConfigWithR2<TModels extends AthenaClientModelsInput | undefined = undefined> = CloudflareAthenaClientConfig<TModels> & {
|
|
233
|
+
r2: R2BucketLike;
|
|
234
|
+
};
|
|
235
|
+
type CloudflareAthenaClient<TModels extends AthenaClientModelsInput | undefined = undefined> = AthenaClient<TModels> & {
|
|
236
|
+
readonly capabilities: AthenaClientCapabilities;
|
|
237
|
+
};
|
|
238
|
+
/** Edge client with L3a R2 object methods typed on `storage`. */
|
|
239
|
+
type CloudflareAthenaClientWithR2<TModels extends AthenaClientModelsInput | undefined = undefined> = Omit<CloudflareAthenaClient<TModels>, 'storage' | 'withContext'> & {
|
|
240
|
+
readonly storage: CloudflareR2StorageModule;
|
|
241
|
+
withContext(context: AthenaRequestContext): CloudflareAthenaClientWithR2<TModels>;
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Create an Athena client that executes DB operations against a D1 binding
|
|
245
|
+
* (and optional R2 for object storage) inside a Cloudflare Worker.
|
|
246
|
+
*
|
|
247
|
+
* Thin façade over {@link createClient}:
|
|
248
|
+
* ```ts
|
|
249
|
+
* createClient({
|
|
250
|
+
* db: { d1: env.DB, sessionMode },
|
|
251
|
+
* storage: { r2: env.FILES, prefix: storagePrefix },
|
|
252
|
+
* url, key, ...
|
|
253
|
+
* })
|
|
254
|
+
* ```
|
|
255
|
+
*
|
|
256
|
+
* To switch between edge and gateway at runtime, prefer {@link createAthenaRuntime}.
|
|
257
|
+
*/
|
|
258
|
+
declare function createCloudflareClient<const TModels extends AthenaClientModelsInput | undefined = undefined>(config: CloudflareAthenaClientConfigWithR2<TModels>): CloudflareAthenaClientWithR2<TModels>;
|
|
259
|
+
declare function createCloudflareClient<const TModels extends AthenaClientModelsInput | undefined = undefined>(config: CloudflareAthenaClientConfig<TModels>): CloudflareAthenaClient<TModels>;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Switchable Athena runtime façades over {@link createClient}.
|
|
263
|
+
*
|
|
264
|
+
* Prefer `createClient({ db: { d1 }, storage: { r2 }, mode, prefer, url, key })` directly.
|
|
265
|
+
* These helpers only map Worker/top-level shapes onto that single constructor.
|
|
266
|
+
*
|
|
267
|
+
* @see docs/cloudflare-edge-local.md
|
|
268
|
+
* @see ADR 0015 / 0016 / 0019
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
interface AthenaRuntimeConfig<TModels extends AthenaClientModelsInput | undefined = undefined> {
|
|
272
|
+
/**
|
|
273
|
+
* `gateway` — HTTP to athena_rs (server).
|
|
274
|
+
* `edge` — D1/R2 bindings in-process.
|
|
275
|
+
* `auto` — edge when `d1` is set, else gateway when `url` / env URL is set.
|
|
276
|
+
* Default: `auto` (overridable via `ATHENA_EXECUTION_MODE`).
|
|
277
|
+
*/
|
|
278
|
+
mode?: AthenaExecutionMode | string | null;
|
|
279
|
+
d1?: D1DatabaseLike | null;
|
|
280
|
+
r2?: R2BucketLike | null;
|
|
281
|
+
storagePrefix?: string;
|
|
282
|
+
sessionMode?: string | null;
|
|
283
|
+
url?: string | null;
|
|
284
|
+
key?: string | null;
|
|
285
|
+
client?: string | null;
|
|
286
|
+
backend?: BackendConfig | BackendType;
|
|
287
|
+
headers?: Record<string, string>;
|
|
288
|
+
models?: TModels;
|
|
289
|
+
env?: Record<string, string | undefined>;
|
|
290
|
+
context?: AthenaRequestContext | AthenaRequestContextProvider;
|
|
291
|
+
db?: AthenaDbConfig;
|
|
292
|
+
auth?: AthenaAuthConfig;
|
|
293
|
+
chat?: AthenaChatConfig;
|
|
294
|
+
storage?: AthenaStorageConfig;
|
|
295
|
+
billing?: AthenaBillingConfig;
|
|
296
|
+
retryReads?: boolean;
|
|
297
|
+
diagnostics?: AthenaDiagnosticsMode;
|
|
298
|
+
traceQueries?: boolean | AthenaQueryTraceOptions;
|
|
299
|
+
debugAst?: boolean;
|
|
300
|
+
findManyAst?: boolean;
|
|
301
|
+
gatewayTransport?: AthenaGatewayClient;
|
|
302
|
+
/**
|
|
303
|
+
* When `mode` is `auto` and both D1 and gateway URL are set, which wins.
|
|
304
|
+
* Default `edge`. Also readable from env `ATHENA_EXECUTION_PREFER`.
|
|
305
|
+
*/
|
|
306
|
+
prefer?: AthenaExecutionPrefer | string | null;
|
|
307
|
+
}
|
|
308
|
+
type AthenaRuntimeClient<TModels extends AthenaClientModelsInput | undefined = undefined> = AthenaClient<TModels> | AthenaClientWithR2Storage<TModels>;
|
|
309
|
+
interface AthenaRuntimeResult<TModels extends AthenaClientModelsInput | undefined = undefined, TClient extends AthenaRuntimeClient<TModels> = AthenaRuntimeClient<TModels>> {
|
|
310
|
+
mode: AthenaResolvedExecutionMode;
|
|
311
|
+
client: TClient;
|
|
312
|
+
capabilities: TClient["capabilities"];
|
|
313
|
+
}
|
|
314
|
+
type AthenaRuntimeConfigWithR2<TModels extends AthenaClientModelsInput | undefined = undefined> = AthenaRuntimeConfig<TModels> & {
|
|
315
|
+
r2: R2BucketLike;
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* Canonical Worker / Pages `env` bindings recognized by {@link createAthenaFromWorkerEnv}.
|
|
319
|
+
* Gateway URL keys align with {@link resolveAthenaExecutionMode} / createClient env resolution.
|
|
320
|
+
*/
|
|
321
|
+
interface AthenaWorkerEnv {
|
|
322
|
+
DB?: D1DatabaseLike | null;
|
|
323
|
+
FILES?: R2BucketLike | null;
|
|
324
|
+
ATHENA_URL?: string;
|
|
325
|
+
/** Alias for gateway/DB HTTP base (same keys as createClient env). */
|
|
326
|
+
ATHENA_DB_URL?: string;
|
|
327
|
+
ATHENA_GATEWAY_URL?: string;
|
|
328
|
+
NEXT_PUBLIC_ATHENA_URL?: string;
|
|
329
|
+
NEXT_PUBLIC_ATHENA_DB_API_URL?: string;
|
|
330
|
+
ATHENA_API_KEY?: string;
|
|
331
|
+
/** Same aliases as createClient / resolveCore `ENV_KEY_KEYS`. */
|
|
332
|
+
NEXT_PUBLIC_ATHENA_API_KEY?: string;
|
|
333
|
+
ATHENA_GATEWAY_API_KEY?: string;
|
|
334
|
+
X_API_KEY?: string;
|
|
335
|
+
ATHENA_AUTH_URL?: string;
|
|
336
|
+
ATHENA_CLIENT?: string;
|
|
337
|
+
ATHENA_EXECUTION_MODE?: string;
|
|
338
|
+
ATHENA_EXECUTION_PREFER?: string;
|
|
339
|
+
[key: string]: unknown;
|
|
340
|
+
}
|
|
341
|
+
/** Map runtime/Worker shape → {@link AthenaClientConfig} (single constructor input). */
|
|
342
|
+
declare function toCreateClientConfig<TModels extends AthenaClientModelsInput | undefined>(config: AthenaRuntimeConfig<TModels>): AthenaClientConfig<TModels>;
|
|
343
|
+
/**
|
|
344
|
+
* Create an Athena client for either gateway or edge execution.
|
|
345
|
+
* Thin façade: always materializes via {@link createClient}.
|
|
346
|
+
*/
|
|
347
|
+
declare function createAthenaRuntime<const TModels extends AthenaClientModelsInput | undefined = undefined>(config: AthenaRuntimeConfigWithR2<TModels> & {
|
|
348
|
+
mode?: "edge" | "auto" | string | null;
|
|
349
|
+
}): AthenaRuntimeResult<TModels, AthenaClientWithR2Storage<TModels>>;
|
|
350
|
+
declare function createAthenaRuntime<const TModels extends AthenaClientModelsInput | undefined = undefined>(config: AthenaRuntimeConfig<TModels>): AthenaRuntimeResult<TModels>;
|
|
351
|
+
declare function createAthenaRuntimeClient<const TModels extends AthenaClientModelsInput | undefined = undefined>(config: AthenaRuntimeConfigWithR2<TModels> & {
|
|
352
|
+
mode?: "edge" | "auto" | string | null;
|
|
353
|
+
}): AthenaClientWithR2Storage<TModels>;
|
|
354
|
+
declare function createAthenaRuntimeClient<const TModels extends AthenaClientModelsInput | undefined = undefined>(config: AthenaRuntimeConfig<TModels>): AthenaRuntimeClient<TModels>;
|
|
355
|
+
type CreateAthenaFromWorkerEnvOptions<TModels extends AthenaClientModelsInput | undefined = undefined> = Omit<AthenaRuntimeConfig<TModels>, "d1" | "r2" | "url" | "key" | "env" | "auth" | "client"> & {
|
|
356
|
+
d1Binding?: string;
|
|
357
|
+
r2Binding?: string;
|
|
358
|
+
storagePrefix?: string;
|
|
359
|
+
auth?: AthenaAuthConfig;
|
|
360
|
+
client?: string | null;
|
|
361
|
+
models?: TModels;
|
|
362
|
+
};
|
|
363
|
+
/**
|
|
364
|
+
* One-call Worker setup: map standard `env` bindings, then {@link createClient}.
|
|
365
|
+
*/
|
|
366
|
+
declare function createAthenaFromWorkerEnv<const TModels extends AthenaClientModelsInput | undefined = undefined>(workerEnv: AthenaWorkerEnv, options?: CreateAthenaFromWorkerEnvOptions<TModels>): AthenaRuntimeResult<TModels>;
|
|
367
|
+
|
|
368
|
+
export { AthenaClientCapabilities, AthenaExecutionMode, AthenaExecutionPrefer, AthenaResolvedExecutionMode, type AthenaRuntimeClient, type AthenaRuntimeConfig, type AthenaRuntimeConfigWithR2, type AthenaRuntimeResult, type AthenaWorkerEnv, type CloudflareAthenaClient, type CloudflareAthenaClientConfig, type CloudflareAthenaClientConfigWithR2, type CloudflareAthenaClientWithR2, CloudflareR2StorageModule, type CreateAthenaFromWorkerEnvOptions, D1DatabaseLike, D1SqlCompileError, R2BucketLike, compileD1Count, compileD1Delete, compileD1Fetch, compileD1Insert, compileD1Update, createAthenaFromWorkerEnv, createAthenaRuntime, createAthenaRuntimeClient, createCloudflareClient, createCloudflareD1GatewayTransport, createCloudflareEdgeCapabilities, createGatewayCapabilities, executeD1Batch, executeD1Query, extractAthenaCount, isMultiStatement, resolveD1BoundedIdentityColumn, rewritePostgresSqlForSqlite, splitSqlStatements, sqlContainsKeywordOutsideLiterals, sqlFirstKeywordOutsideLiterals, statementExpectsResultRows, toCreateClientConfig };
|