@xylex-group/athena 2.0.0 → 2.1.2
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 +47 -26
- package/dist/browser.cjs +3319 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +25 -0
- package/dist/browser.d.ts +25 -0
- package/dist/browser.js +3276 -0
- package/dist/browser.js.map +1 -0
- package/dist/cli/index.cjs +599 -119
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +3 -2
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.js +600 -120
- package/dist/cli/index.js.map +1 -1
- package/dist/client-BX0NQqOn.d.ts +435 -0
- package/dist/client-dpAp-NZK.d.cts +435 -0
- package/dist/cookies.cjs +890 -0
- package/dist/cookies.cjs.map +1 -0
- package/dist/cookies.d.cts +174 -0
- package/dist/cookies.d.ts +174 -0
- package/dist/cookies.js +869 -0
- package/dist/cookies.js.map +1 -0
- package/dist/index.cjs +1378 -1023
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -408
- package/dist/index.d.ts +8 -408
- package/dist/index.js +1379 -1024
- package/dist/index.js.map +1 -1
- package/dist/{model-form-CVOtC8jq.d.ts → model-form-2hqmoOUX.d.ts} +2 -2
- package/dist/{model-form-hXkvHS_3.d.cts → model-form-Cy-zaO0u.d.cts} +2 -2
- package/dist/pipeline-BOPszLsL.d.ts +8 -0
- package/dist/pipeline-E3FDbs4W.d.cts +8 -0
- package/dist/react.d.cts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/{types-BnzoaNRC.d.cts → types-BaBzjwXr.d.cts} +1 -1
- package/dist/{types-BnzoaNRC.d.ts → types-BaBzjwXr.d.ts} +1 -1
- package/dist/{pipeline-CQgV-Yfo.d.ts → types-CeBPrnGj.d.ts} +2 -7
- package/dist/{pipeline-C-cN0ACi.d.cts → types-CpqL-pZx.d.cts} +2 -7
- package/package.json +21 -1
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { g as AthenaJsonValue, a as AthenaGatewayCallOptions, e as AthenaJsonObject, h as AthenaRpcCallOptions, m as BackendConfig, n as BackendType, G as AthenaConditionValue, A as AthenaConditionCastType, H as AthenaConditionArrayValue, J as AthenaConditionOperator, c as AthenaGatewayErrorDetails, C as SchemaDef, K as AnyModelDef, D as DatabaseDef, w as ModelMetadata, v as ModelDef, R as RegistryDef, F as TenantKeyMap, T as TenantContext, z as RowOf, M as ModelAt, o as InsertOf, U as UpdateOf, S as SchemaIntrospectionProvider, p as IntrospectionColumn } from './types-BaBzjwXr.cjs';
|
|
2
|
+
import { a as AthenaAuthBindings, c as AthenaAuthClientConfig, w as AthenaAuthSdkClient } from './model-form-Cy-zaO0u.cjs';
|
|
3
|
+
import { j as GeneratorSchemaSelection, b as GeneratorProviderConfig } from './types-CpqL-pZx.cjs';
|
|
4
|
+
|
|
5
|
+
type AthenaRowShape$1 = Record<string, AthenaJsonValue | undefined>;
|
|
6
|
+
type AthenaUpsertOptions<Update> = AthenaGatewayCallOptions & {
|
|
7
|
+
updateBody?: Update;
|
|
8
|
+
onConflict?: string | string[];
|
|
9
|
+
};
|
|
10
|
+
interface AthenaDbModule {
|
|
11
|
+
from<Row = AthenaRowShape$1, Insert = Partial<Row>, Update = Partial<Insert>>(table: string): TableQueryBuilder<Row, Insert, Update>;
|
|
12
|
+
select<Row = AthenaRowShape$1, SelectedRow = Row>(table: string, columns?: string | string[], options?: AthenaGatewayCallOptions): SelectChain<Row, SelectedRow>;
|
|
13
|
+
insert<Row = AthenaRowShape$1, Insert = Partial<Row>>(table: string, values: Insert, options?: AthenaGatewayCallOptions): MutationQuery<Row>;
|
|
14
|
+
insert<Row = AthenaRowShape$1, Insert = Partial<Row>>(table: string, values: Insert[], options?: AthenaGatewayCallOptions): MutationQuery<Row[]>;
|
|
15
|
+
upsert<Row = AthenaRowShape$1, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, values: Insert, options?: AthenaUpsertOptions<Update>): MutationQuery<Row>;
|
|
16
|
+
upsert<Row = AthenaRowShape$1, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, values: Insert[], options?: AthenaUpsertOptions<Update>): MutationQuery<Row[]>;
|
|
17
|
+
update<Row = AthenaRowShape$1, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, values: Update, options?: AthenaGatewayCallOptions): UpdateChain<Row>;
|
|
18
|
+
delete<Row = AthenaRowShape$1>(table: string, options?: AthenaGatewayCallOptions & {
|
|
19
|
+
resourceId?: string;
|
|
20
|
+
}): MutationQuery<Row | null>;
|
|
21
|
+
rpc<Row = unknown, Args extends AthenaJsonObject = AthenaJsonObject>(fn: string, args?: Args, options?: AthenaRpcCallOptions): RpcQueryBuilder<Row>;
|
|
22
|
+
query<Row = unknown>(query: string, options?: AthenaGatewayCallOptions): Promise<AthenaResult<Row[]>>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface AthenaResult<T> {
|
|
26
|
+
data: T | null;
|
|
27
|
+
error: string | null;
|
|
28
|
+
errorDetails?: AthenaGatewayErrorDetails | null;
|
|
29
|
+
status: number;
|
|
30
|
+
count?: number | null;
|
|
31
|
+
raw: unknown;
|
|
32
|
+
}
|
|
33
|
+
interface AthenaClientExperimentalOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Pre-compute and attach normalized error metadata to failed AthenaResult values.
|
|
36
|
+
* Keeps AthenaResult shape intact and enables context-aware normalizeAthenaError(result) usage.
|
|
37
|
+
*/
|
|
38
|
+
enableErrorNormalization?: boolean;
|
|
39
|
+
}
|
|
40
|
+
type MutationSingleResult<Result> = Result extends Array<infer Item> ? Item | null : Result | null;
|
|
41
|
+
type AthenaRowShape = Record<string, AthenaJsonValue | undefined>;
|
|
42
|
+
type FilterColumnKey<Row> = Extract<keyof NonNullable<Row>, string>;
|
|
43
|
+
type ResolvedFilterColumnKey<Row> = [FilterColumnKey<Row>] extends [never] ? string : FilterColumnKey<Row>;
|
|
44
|
+
interface MutationQuery<Result> extends PromiseLike<AthenaResult<Result>> {
|
|
45
|
+
select(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<Result>>;
|
|
46
|
+
returning(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<Result>>;
|
|
47
|
+
single(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<MutationSingleResult<Result>>>;
|
|
48
|
+
maybeSingle(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<MutationSingleResult<Result>>>;
|
|
49
|
+
then<TResult1 = AthenaResult<Result>, TResult2 = never>(onfulfilled?: ((value: AthenaResult<Result>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
|
|
50
|
+
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<AthenaResult<Result> | TResult>;
|
|
51
|
+
finally(onfinally?: (() => void) | undefined | null): Promise<AthenaResult<Result>>;
|
|
52
|
+
}
|
|
53
|
+
interface OrderOptions {
|
|
54
|
+
ascending?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** Shared filter chain - supports eq, limit, etc. in any order relative to select/update */
|
|
57
|
+
interface FilterChain<Self, Row> {
|
|
58
|
+
eq(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
59
|
+
eqCast(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue, cast: AthenaConditionCastType): Self;
|
|
60
|
+
eqUuid(column: ResolvedFilterColumnKey<Row>, value: string): Self;
|
|
61
|
+
match(filters: Partial<Record<ResolvedFilterColumnKey<Row>, AthenaConditionValue>>): Self;
|
|
62
|
+
range(from: number, to: number): Self;
|
|
63
|
+
limit(count: number): Self;
|
|
64
|
+
offset(count: number): Self;
|
|
65
|
+
currentPage(value: number): Self;
|
|
66
|
+
pageSize(value: number): Self;
|
|
67
|
+
totalPages(value: number): Self;
|
|
68
|
+
order(column: ResolvedFilterColumnKey<Row>, options?: OrderOptions): Self;
|
|
69
|
+
gt(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
70
|
+
gte(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
71
|
+
lt(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
72
|
+
lte(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
73
|
+
neq(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
74
|
+
like(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
75
|
+
ilike(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
76
|
+
is(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
77
|
+
in(column: ResolvedFilterColumnKey<Row>, values: AthenaConditionArrayValue): Self;
|
|
78
|
+
contains(column: ResolvedFilterColumnKey<Row>, values: AthenaConditionArrayValue): Self;
|
|
79
|
+
containedBy(column: ResolvedFilterColumnKey<Row>, values: AthenaConditionArrayValue): Self;
|
|
80
|
+
not(columnOrExpression: ResolvedFilterColumnKey<Row> | string, operator?: AthenaConditionOperator, value?: AthenaConditionValue): Self;
|
|
81
|
+
or(expression: string): Self;
|
|
82
|
+
}
|
|
83
|
+
/** Chain returned by select() - supports filters and single/maybeSingle before execution */
|
|
84
|
+
interface SelectChain<Row, SelectedRow = Row> extends FilterChain<SelectChain<Row, SelectedRow>, Row>, PromiseLike<AthenaResult<SelectedRow[]>> {
|
|
85
|
+
single<T = SelectedRow>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
|
|
86
|
+
maybeSingle<T = SelectedRow>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
|
|
87
|
+
}
|
|
88
|
+
/** Chain returned by update() - supports filters before execution, plus select/returning */
|
|
89
|
+
interface UpdateChain<Row> extends FilterChain<UpdateChain<Row>, Row>, MutationQuery<Row[]> {
|
|
90
|
+
}
|
|
91
|
+
interface RpcFilterChain<Self> {
|
|
92
|
+
eq(column: string, value: AthenaConditionValue): Self;
|
|
93
|
+
neq(column: string, value: AthenaConditionValue): Self;
|
|
94
|
+
gt(column: string, value: AthenaConditionValue): Self;
|
|
95
|
+
gte(column: string, value: AthenaConditionValue): Self;
|
|
96
|
+
lt(column: string, value: AthenaConditionValue): Self;
|
|
97
|
+
lte(column: string, value: AthenaConditionValue): Self;
|
|
98
|
+
like(column: string, value: AthenaConditionValue): Self;
|
|
99
|
+
ilike(column: string, value: AthenaConditionValue): Self;
|
|
100
|
+
is(column: string, value: AthenaConditionValue): Self;
|
|
101
|
+
in(column: string, values: AthenaConditionArrayValue): Self;
|
|
102
|
+
}
|
|
103
|
+
interface RpcOrderOptions {
|
|
104
|
+
ascending?: boolean;
|
|
105
|
+
}
|
|
106
|
+
interface RpcQueryBuilder<Row> extends RpcFilterChain<RpcQueryBuilder<Row>>, PromiseLike<AthenaResult<Row[]>> {
|
|
107
|
+
select(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<Row[]>>;
|
|
108
|
+
single<T = Row>(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<T | null>>;
|
|
109
|
+
maybeSingle<T = Row>(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<T | null>>;
|
|
110
|
+
order(column: string, options?: RpcOrderOptions): RpcQueryBuilder<Row>;
|
|
111
|
+
limit(count: number): RpcQueryBuilder<Row>;
|
|
112
|
+
offset(count: number): RpcQueryBuilder<Row>;
|
|
113
|
+
range(from: number, to: number): RpcQueryBuilder<Row>;
|
|
114
|
+
}
|
|
115
|
+
interface TableQueryBuilder<Row, Insert = Partial<Row>, Update = Partial<Insert>> extends FilterChain<TableQueryBuilder<Row, Insert, Update>, Row> {
|
|
116
|
+
select<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): SelectChain<Row, T>;
|
|
117
|
+
insert(values: Insert, options?: AthenaGatewayCallOptions): MutationQuery<Row>;
|
|
118
|
+
insert(values: Insert[], options?: AthenaGatewayCallOptions): MutationQuery<Row[]>;
|
|
119
|
+
upsert(values: Insert, options?: AthenaGatewayCallOptions & {
|
|
120
|
+
updateBody?: Update;
|
|
121
|
+
onConflict?: string | string[];
|
|
122
|
+
}): MutationQuery<Row>;
|
|
123
|
+
upsert(values: Insert[], options?: AthenaGatewayCallOptions & {
|
|
124
|
+
updateBody?: Update;
|
|
125
|
+
onConflict?: string | string[];
|
|
126
|
+
}): MutationQuery<Row[]>;
|
|
127
|
+
update(values: Update, options?: AthenaGatewayCallOptions): UpdateChain<Row>;
|
|
128
|
+
delete(options?: AthenaGatewayCallOptions & {
|
|
129
|
+
resourceId?: string;
|
|
130
|
+
}): MutationQuery<Row | null>;
|
|
131
|
+
single<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
|
|
132
|
+
maybeSingle<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
|
|
133
|
+
reset(): TableQueryBuilder<Row, Insert, Update>;
|
|
134
|
+
}
|
|
135
|
+
interface AthenaSdkClient {
|
|
136
|
+
from<Row = AthenaRowShape, Insert = Partial<Row>, Update = Partial<Insert>>(table: string): TableQueryBuilder<Row, Insert, Update>;
|
|
137
|
+
db: AthenaDbModule;
|
|
138
|
+
rpc<Row = unknown, Args extends AthenaJsonObject = AthenaJsonObject>(fn: string, args?: Args, options?: AthenaRpcCallOptions): RpcQueryBuilder<Row>;
|
|
139
|
+
query<Row = unknown>(query: string, options?: AthenaGatewayCallOptions): Promise<AthenaResult<Row[]>>;
|
|
140
|
+
}
|
|
141
|
+
interface AthenaSdkClientWithAuth extends AthenaSdkClient {
|
|
142
|
+
auth: AthenaAuthBindings;
|
|
143
|
+
}
|
|
144
|
+
interface AthenaClientBuilder {
|
|
145
|
+
/** Set the gateway base URL. */
|
|
146
|
+
url(url: string): AthenaClientBuilder;
|
|
147
|
+
/** Set the API key used for all requests. */
|
|
148
|
+
key(apiKey: string): AthenaClientBuilder;
|
|
149
|
+
/** Set the default backend routing strategy. */
|
|
150
|
+
backend(backend: BackendConfig | BackendType): AthenaClientBuilder;
|
|
151
|
+
/** Set the default Athena client routing key. */
|
|
152
|
+
client(clientName: string): AthenaClientBuilder;
|
|
153
|
+
/** Attach static headers to every request. */
|
|
154
|
+
headers(headers: Record<string, string>): AthenaClientBuilder;
|
|
155
|
+
/** Enable or disable health tracking metadata. */
|
|
156
|
+
healthTracking(enabled: boolean): AthenaClientBuilder;
|
|
157
|
+
/** Build the immutable Athena SDK client. */
|
|
158
|
+
build(): AthenaSdkClientWithAuth;
|
|
159
|
+
}
|
|
160
|
+
/** Canonical Athena client factory with builder-based configuration. */
|
|
161
|
+
declare class AthenaClient {
|
|
162
|
+
/** Create a fluent builder for a strongly-typed Athena SDK client. */
|
|
163
|
+
static builder(): AthenaClientBuilder;
|
|
164
|
+
/** Build a client from process environment variables. */
|
|
165
|
+
static fromEnvironment(): AthenaSdkClientWithAuth;
|
|
166
|
+
}
|
|
167
|
+
interface AthenaCreateClientOptions extends Pick<AthenaGatewayCallOptions, 'client' | 'headers' | 'backend'> {
|
|
168
|
+
auth?: AthenaAuthClientConfig;
|
|
169
|
+
experimental?: AthenaClientExperimentalOptions;
|
|
170
|
+
}
|
|
171
|
+
/** Create client (convenience wrapper; use AthenaClient.builder() for full control) */
|
|
172
|
+
declare function createClient(url: string, apiKey: string, options?: AthenaCreateClientOptions): AthenaSdkClientWithAuth;
|
|
173
|
+
|
|
174
|
+
type AthenaErrorKind = 'unique_violation' | 'not_found' | 'validation' | 'auth' | 'rate_limit' | 'transient' | 'unknown';
|
|
175
|
+
declare const AthenaErrorKind: {
|
|
176
|
+
readonly UniqueViolation: "unique_violation";
|
|
177
|
+
readonly NotFound: "not_found";
|
|
178
|
+
readonly Validation: "validation";
|
|
179
|
+
readonly Auth: "auth";
|
|
180
|
+
readonly RateLimit: "rate_limit";
|
|
181
|
+
readonly Transient: "transient";
|
|
182
|
+
readonly Unknown: "unknown";
|
|
183
|
+
};
|
|
184
|
+
type AthenaErrorCode = 'UNIQUE_VIOLATION' | 'NOT_FOUND' | 'VALIDATION_FAILED' | 'AUTH_UNAUTHORIZED' | 'AUTH_FORBIDDEN' | 'RATE_LIMITED' | 'NETWORK_UNAVAILABLE' | 'TRANSIENT_FAILURE' | 'HTTP_FAILURE' | 'UNKNOWN';
|
|
185
|
+
declare const AthenaErrorCode: {
|
|
186
|
+
readonly UniqueViolation: "UNIQUE_VIOLATION";
|
|
187
|
+
readonly NotFound: "NOT_FOUND";
|
|
188
|
+
readonly ValidationFailed: "VALIDATION_FAILED";
|
|
189
|
+
readonly AuthUnauthorized: "AUTH_UNAUTHORIZED";
|
|
190
|
+
readonly AuthForbidden: "AUTH_FORBIDDEN";
|
|
191
|
+
readonly RateLimited: "RATE_LIMITED";
|
|
192
|
+
readonly NetworkUnavailable: "NETWORK_UNAVAILABLE";
|
|
193
|
+
readonly TransientFailure: "TRANSIENT_FAILURE";
|
|
194
|
+
readonly HttpFailure: "HTTP_FAILURE";
|
|
195
|
+
readonly Unknown: "UNKNOWN";
|
|
196
|
+
};
|
|
197
|
+
type AthenaErrorCategory = 'transport' | 'client' | 'server' | 'database' | 'unknown';
|
|
198
|
+
declare const AthenaErrorCategory: {
|
|
199
|
+
readonly Transport: "transport";
|
|
200
|
+
readonly Client: "client";
|
|
201
|
+
readonly Server: "server";
|
|
202
|
+
readonly Database: "database";
|
|
203
|
+
readonly Unknown: "unknown";
|
|
204
|
+
};
|
|
205
|
+
interface AthenaOperationContext {
|
|
206
|
+
table?: string;
|
|
207
|
+
operation?: string;
|
|
208
|
+
identity?: string | Record<string, unknown>;
|
|
209
|
+
}
|
|
210
|
+
interface NormalizedAthenaError {
|
|
211
|
+
kind: AthenaErrorKind;
|
|
212
|
+
code: AthenaErrorCode;
|
|
213
|
+
category: AthenaErrorCategory;
|
|
214
|
+
retryable: boolean;
|
|
215
|
+
status?: number;
|
|
216
|
+
constraint?: string;
|
|
217
|
+
table?: string;
|
|
218
|
+
operation?: string;
|
|
219
|
+
message: string;
|
|
220
|
+
raw: unknown;
|
|
221
|
+
}
|
|
222
|
+
interface AthenaErrorInput {
|
|
223
|
+
code: AthenaErrorCode;
|
|
224
|
+
kind: AthenaErrorKind;
|
|
225
|
+
category: AthenaErrorCategory;
|
|
226
|
+
message: string;
|
|
227
|
+
status?: number;
|
|
228
|
+
retryable?: boolean;
|
|
229
|
+
requestId?: string;
|
|
230
|
+
context?: AthenaOperationContext;
|
|
231
|
+
raw?: unknown;
|
|
232
|
+
}
|
|
233
|
+
interface UnwrapOptions {
|
|
234
|
+
allowNull?: boolean;
|
|
235
|
+
context?: AthenaOperationContext;
|
|
236
|
+
}
|
|
237
|
+
interface UnwrapOneOptions extends UnwrapOptions {
|
|
238
|
+
requireExactlyOne?: boolean;
|
|
239
|
+
}
|
|
240
|
+
interface IntCoercionOptions {
|
|
241
|
+
strictBigInt?: boolean;
|
|
242
|
+
min?: number;
|
|
243
|
+
max?: number;
|
|
244
|
+
}
|
|
245
|
+
type RetryBackoffStrategy = 'linear' | 'exponential' | ((attempt: number, error: unknown) => number);
|
|
246
|
+
interface RetryConfig {
|
|
247
|
+
retries: number;
|
|
248
|
+
baseDelayMs?: number;
|
|
249
|
+
maxDelayMs?: number;
|
|
250
|
+
backoff?: RetryBackoffStrategy;
|
|
251
|
+
jitter?: boolean | number;
|
|
252
|
+
shouldRetry?: (error: unknown, attempt: number) => boolean | Promise<boolean>;
|
|
253
|
+
}
|
|
254
|
+
interface RequireAffectedOptions {
|
|
255
|
+
min?: number;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Parses a string-based boolean flag with a deterministic fallback.
|
|
259
|
+
*
|
|
260
|
+
* Accepts common truthy/falsey token variants used by env vars and CLI flags.
|
|
261
|
+
*/
|
|
262
|
+
declare function parseBooleanFlag(rawValue: string | undefined, fallback: boolean): boolean;
|
|
263
|
+
declare class AthenaError extends Error {
|
|
264
|
+
readonly code: AthenaErrorCode;
|
|
265
|
+
readonly kind: AthenaErrorKind;
|
|
266
|
+
readonly category: AthenaErrorCategory;
|
|
267
|
+
readonly status?: number;
|
|
268
|
+
readonly retryable: boolean;
|
|
269
|
+
readonly requestId?: string;
|
|
270
|
+
readonly context?: AthenaOperationContext;
|
|
271
|
+
readonly raw?: unknown;
|
|
272
|
+
constructor(input: AthenaErrorInput);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Returns `true` when a result is successful (`2xx` status and no `error`).
|
|
276
|
+
*/
|
|
277
|
+
declare function isOk<T>(result: AthenaResult<T>): boolean;
|
|
278
|
+
/**
|
|
279
|
+
* Normalizes any Athena failure shape into a stable, typed error envelope.
|
|
280
|
+
*
|
|
281
|
+
* Accepts `AthenaResult`, `AthenaGatewayError`, native `Error`, or unknown values.
|
|
282
|
+
* Optional `context` can override inferred table/operation metadata for clearer diagnostics.
|
|
283
|
+
*/
|
|
284
|
+
declare function normalizeAthenaError(resultOrError: unknown, context?: AthenaOperationContext): NormalizedAthenaError;
|
|
285
|
+
/**
|
|
286
|
+
* Unwraps a successful result into a row array.
|
|
287
|
+
*
|
|
288
|
+
* - Throws on failed results.
|
|
289
|
+
* - Converts `null` data to an empty array.
|
|
290
|
+
* - Wraps scalar data in a single-element array.
|
|
291
|
+
*/
|
|
292
|
+
declare function unwrapRows<T>(result: AthenaResult<T[] | T | null>, options?: UnwrapOptions): T[];
|
|
293
|
+
/**
|
|
294
|
+
* Unwraps successful result data from `AthenaResult<T | null>`.
|
|
295
|
+
*
|
|
296
|
+
* By default, `null` data throws. Pass `{ allowNull: true }` to permit nullable payloads.
|
|
297
|
+
*/
|
|
298
|
+
declare function unwrap<T>(result: AthenaResult<T | null>, options: UnwrapOptions & {
|
|
299
|
+
allowNull: true;
|
|
300
|
+
}): T | null;
|
|
301
|
+
declare function unwrap<T>(result: AthenaResult<T | null>, options?: UnwrapOptions): T;
|
|
302
|
+
/**
|
|
303
|
+
* Unwraps the first row from a successful result that may contain arrays/scalars/null.
|
|
304
|
+
*
|
|
305
|
+
* - Throws on failed results.
|
|
306
|
+
* - Throws when no row exists unless `allowNull: true` is provided.
|
|
307
|
+
* - Optionally enforces exact cardinality via `requireExactlyOne`.
|
|
308
|
+
*/
|
|
309
|
+
declare function unwrapOne<T>(result: AthenaResult<T[] | T | null>, options: UnwrapOneOptions & {
|
|
310
|
+
allowNull: true;
|
|
311
|
+
}): T | null;
|
|
312
|
+
declare function unwrapOne<T>(result: AthenaResult<T[] | T | null>, options?: UnwrapOneOptions): T;
|
|
313
|
+
/**
|
|
314
|
+
* Asserts that an Athena result is successful.
|
|
315
|
+
*
|
|
316
|
+
* Returns the original result for fluent composition and throws `AthenaGatewayError` on failure.
|
|
317
|
+
*/
|
|
318
|
+
declare function requireSuccess<T>(result: AthenaResult<T>, context?: AthenaOperationContext): AthenaResult<T>;
|
|
319
|
+
/**
|
|
320
|
+
* Enforces mutation postconditions based on `result.count`.
|
|
321
|
+
*
|
|
322
|
+
* - Validates success first.
|
|
323
|
+
* - Requires a non-null count in the response.
|
|
324
|
+
* - Validates `count >= min` (default: `1`).
|
|
325
|
+
*
|
|
326
|
+
* Useful for guaranteeing that critical writes actually affected rows.
|
|
327
|
+
*/
|
|
328
|
+
declare function requireAffected<T>(result: AthenaResult<T>, options?: RequireAffectedOptions, context?: AthenaOperationContext): number;
|
|
329
|
+
/**
|
|
330
|
+
* Safely coerces `unknown` values into finite integers.
|
|
331
|
+
*
|
|
332
|
+
* Returns `null` when coercion fails or bounds/strict bigint checks are violated.
|
|
333
|
+
*/
|
|
334
|
+
declare function coerceInt(value: unknown, options?: IntCoercionOptions): number | null;
|
|
335
|
+
/**
|
|
336
|
+
* Strict integer assertion wrapper around `coerceInt`.
|
|
337
|
+
*
|
|
338
|
+
* Throws a `TypeError` with the provided label when coercion fails.
|
|
339
|
+
*/
|
|
340
|
+
declare function assertInt(value: unknown, label?: string, options?: IntCoercionOptions): number;
|
|
341
|
+
/**
|
|
342
|
+
* Retries an async operation with configurable backoff and retry policy.
|
|
343
|
+
*
|
|
344
|
+
* `retries` represents additional attempts after the first failure.
|
|
345
|
+
* By default, transient and rate-limit errors are retried.
|
|
346
|
+
*/
|
|
347
|
+
declare function withRetry<T>(config: RetryConfig, fn: () => Promise<T>): Promise<T>;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Immutable identifier object with consistent SQL rendering.
|
|
351
|
+
*/
|
|
352
|
+
interface SqlIdentifier {
|
|
353
|
+
readonly segments: string[];
|
|
354
|
+
toSql(): string;
|
|
355
|
+
toString(): string;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Creates a quoted identifier object from segment or dotted inputs.
|
|
359
|
+
*/
|
|
360
|
+
declare function identifier(...segments: string[]): SqlIdentifier;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Declares a model contract with explicit metadata and typed row/insert/update shapes.
|
|
364
|
+
*/
|
|
365
|
+
declare function defineModel<Row, Insert = Partial<Row>, Update = Partial<Insert>, Meta extends ModelMetadata<Row> = ModelMetadata<Row>>(input: {
|
|
366
|
+
meta: Meta;
|
|
367
|
+
}): ModelDef<Row, Insert, Update, Meta>;
|
|
368
|
+
/**
|
|
369
|
+
* Declares a schema-level model map.
|
|
370
|
+
*/
|
|
371
|
+
declare function defineSchema<Models extends Record<string, AnyModelDef>>(models: Models): SchemaDef<Models>;
|
|
372
|
+
/**
|
|
373
|
+
* Declares a database-level schema map.
|
|
374
|
+
*/
|
|
375
|
+
declare function defineDatabase<Schemas extends Record<string, SchemaDef<Record<string, AnyModelDef>>>>(schemas: Schemas): DatabaseDef<Schemas>;
|
|
376
|
+
/**
|
|
377
|
+
* Declares a top-level multi-database registry.
|
|
378
|
+
*/
|
|
379
|
+
declare function defineRegistry<Databases extends Record<string, DatabaseDef<Record<string, SchemaDef<Record<string, AnyModelDef>>>>>>(databases: Databases): RegistryDef<Databases>;
|
|
380
|
+
|
|
381
|
+
type RegistryConstraint = RegistryDef<Record<string, DatabaseDef<Record<string, SchemaDef<Record<string, AnyModelDef>>>>>>;
|
|
382
|
+
/**
|
|
383
|
+
* Options for creating typed Athena clients.
|
|
384
|
+
*/
|
|
385
|
+
interface TypedClientOptions<TMap extends TenantKeyMap = TenantKeyMap> extends Pick<AthenaGatewayCallOptions, 'backend' | 'client' | 'headers'> {
|
|
386
|
+
tenantKeyMap?: TMap;
|
|
387
|
+
tenantContext?: TenantContext<TMap>;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Typed Athena client with registry-driven model resolution and tenant-context propagation.
|
|
391
|
+
*/
|
|
392
|
+
interface TypedAthenaClient<TRegistry extends RegistryConstraint, TTenantMap extends TenantKeyMap = Record<never, string>> extends AthenaSdkClient {
|
|
393
|
+
readonly registry: TRegistry;
|
|
394
|
+
readonly tenantKeyMap: Readonly<TTenantMap>;
|
|
395
|
+
readonly tenantContext: TenantContext<TTenantMap>;
|
|
396
|
+
withTenantContext(context: TenantContext<TTenantMap>): TypedAthenaClient<TRegistry, TTenantMap>;
|
|
397
|
+
fromModel<TDatabase extends keyof TRegistry & string, TSchema extends keyof TRegistry[TDatabase]['schemas'] & string, TModel extends keyof TRegistry[TDatabase]['schemas'][TSchema]['models'] & string>(database: TDatabase, schema: TSchema, model: TModel): TableQueryBuilder<RowOf<ModelAt<TRegistry, TDatabase, TSchema, TModel>>, InsertOf<ModelAt<TRegistry, TDatabase, TSchema, TModel>>, UpdateOf<ModelAt<TRegistry, TDatabase, TSchema, TModel>>>;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Creates a typed client bound to a registry contract and optional tenant header mapping.
|
|
401
|
+
*/
|
|
402
|
+
declare function createTypedClient<TRegistry extends RegistryConstraint, TTenantMap extends TenantKeyMap = Record<never, string>>(registry: TRegistry, url: string, apiKey: string, options?: TypedClientOptions<TTenantMap>): TypedAthenaClient<TRegistry, TTenantMap>;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Constructor options for the PostgreSQL introspection provider.
|
|
406
|
+
*/
|
|
407
|
+
interface PostgresIntrospectionProviderOptions {
|
|
408
|
+
connectionString: string;
|
|
409
|
+
database?: string;
|
|
410
|
+
schemas?: readonly string[];
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Creates a PostgreSQL-backed schema introspection provider.
|
|
414
|
+
*/
|
|
415
|
+
declare function createPostgresIntrospectionProvider(options: PostgresIntrospectionProviderOptions): SchemaIntrospectionProvider;
|
|
416
|
+
|
|
417
|
+
declare function resolvePostgresColumnType(column: IntrospectionColumn): string;
|
|
418
|
+
|
|
419
|
+
declare const DEFAULT_POSTGRES_SCHEMAS: readonly ["public"];
|
|
420
|
+
/**
|
|
421
|
+
* Normalizes schema selection from config or env-backed strings into a stable,
|
|
422
|
+
* deduplicated list. Empty selections fall back to PostgreSQL's public schema.
|
|
423
|
+
*/
|
|
424
|
+
declare function normalizeSchemaSelection(input: GeneratorSchemaSelection | undefined): string[];
|
|
425
|
+
/**
|
|
426
|
+
* Resolves the effective schema list for provider-backed generator runs.
|
|
427
|
+
*/
|
|
428
|
+
declare function resolveProviderSchemas(providerConfig: GeneratorProviderConfig): string[];
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* @deprecated Prefer `createClient(...).auth` from `@xylex-group/athena`.
|
|
432
|
+
*/
|
|
433
|
+
declare function createAuthClient(config?: AthenaAuthClientConfig): AthenaAuthSdkClient;
|
|
434
|
+
|
|
435
|
+
export { AthenaClient as A, defineModel as B, defineRegistry as C, DEFAULT_POSTGRES_SCHEMAS as D, defineSchema as E, identifier as F, isOk as G, normalizeAthenaError as H, type IntCoercionOptions as I, normalizeSchemaSelection as J, parseBooleanFlag as K, requireAffected as L, requireSuccess as M, type NormalizedAthenaError as N, resolvePostgresColumnType as O, type PostgresIntrospectionProviderOptions as P, resolveProviderSchemas as Q, type RequireAffectedOptions as R, unwrap as S, type TableQueryBuilder as T, type UnwrapOneOptions as U, unwrapOne as V, unwrapRows as W, withRetry as X, type AthenaClientExperimentalOptions as a, type AthenaCreateClientOptions as b, type AthenaDbModule as c, AthenaError as d, AthenaErrorCategory as e, AthenaErrorCode as f, type AthenaErrorInput as g, AthenaErrorKind as h, type AthenaOperationContext as i, type AthenaResult as j, type AthenaSdkClient as k, type AthenaSdkClientWithAuth as l, type RetryBackoffStrategy as m, type RetryConfig as n, type RpcOrderOptions as o, type RpcQueryBuilder as p, type TypedAthenaClient as q, type TypedClientOptions as r, type UnwrapOptions as s, assertInt as t, coerceInt as u, createAuthClient as v, createClient as w, createPostgresIntrospectionProvider as x, createTypedClient as y, defineDatabase as z };
|