@xylex-group/athena 2.1.2 → 2.3.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/README.md +287 -116
- package/dist/browser.cjs +1628 -156
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +14 -14
- package/dist/browser.d.ts +14 -14
- package/dist/browser.js +1625 -156
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +1532 -145
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +3 -3
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +1533 -146
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +1658 -167
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1656 -168
- package/dist/index.js.map +1 -1
- package/dist/{model-form-2hqmoOUX.d.ts → model-form-BpDXlbxb.d.ts} +97 -2
- package/dist/{model-form-Cy-zaO0u.d.cts → model-form-hoE2jHIi.d.cts} +97 -2
- package/dist/{pipeline-BOPszLsL.d.ts → pipeline-BNIw8pDQ.d.ts} +1 -1
- package/dist/{pipeline-E3FDbs4W.d.cts → pipeline-DNIpEsN8.d.cts} +1 -1
- package/dist/{client-dpAp-NZK.d.cts → react-email-BvyCZnfW.d.cts} +349 -174
- package/dist/{client-BX0NQqOn.d.ts → react-email-qPA1wjFV.d.ts} +349 -174
- package/dist/react.cjs +30 -9
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +30 -9
- package/dist/react.js.map +1 -1
- package/dist/{types-BaBzjwXr.d.cts → types-A5e97acl.d.cts} +2 -1
- package/dist/{types-BaBzjwXr.d.ts → types-A5e97acl.d.ts} +2 -1
- package/dist/{types-CeBPrnGj.d.ts → types-BnD22-vb.d.ts} +1 -1
- package/dist/{types-CpqL-pZx.d.cts → types-bDlr4u7p.d.cts} +1 -1
- package/dist/utils.cjs +153 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +23 -0
- package/dist/utils.d.ts +23 -0
- package/dist/utils.js +146 -0
- package/dist/utils.js.map +1 -0
- package/package.json +75 -17
|
@@ -1,175 +1,6 @@
|
|
|
1
|
-
import { g as AthenaJsonValue, a as AthenaGatewayCallOptions, e as AthenaJsonObject, h as AthenaRpcCallOptions,
|
|
2
|
-
import { a as AthenaAuthBindings,
|
|
3
|
-
import { j as GeneratorSchemaSelection, b as GeneratorProviderConfig } from './types-
|
|
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;
|
|
1
|
+
import { g as AthenaJsonValue, a as AthenaGatewayCallOptions, e as AthenaJsonObject, h as AthenaRpcCallOptions, G as AthenaConditionValue, H as AthenaConditionArrayValue, R as RegistryDef, D as DatabaseDef, C as SchemaDef, J as AnyModelDef, v as ModelDef, y as ModelRelationMetadata, z as RowOf, m as BackendConfig, n as BackendType, c as AthenaGatewayErrorDetails, A as AthenaConditionCastType, K as AthenaConditionOperator, w as ModelMetadata, F as TenantKeyMap, T as TenantContext, M as ModelAt, o as InsertOf, U as UpdateOf, S as SchemaIntrospectionProvider, p as IntrospectionColumn } from './types-A5e97acl.js';
|
|
2
|
+
import { c as AthenaAuthClientConfig, a as AthenaAuthBindings, J as AthenaAuthSdkClient, B as AthenaAuthReactEmailProps, x as AthenaAuthReactEmailComponent, D as AthenaAuthReactEmailRenderInput, h as AthenaAuthEmailTemplateDefinition, f as AthenaAuthEmailTemplateBuilder, E as AthenaAuthReactEmailRenderOptions, C as AthenaAuthReactEmailRenderEvent, y as AthenaAuthReactEmailConfig } from './model-form-BpDXlbxb.js';
|
|
3
|
+
import { j as GeneratorSchemaSelection, b as GeneratorProviderConfig } from './types-BnD22-vb.js';
|
|
173
4
|
|
|
174
5
|
type AthenaErrorKind = 'unique_violation' | 'not_found' | 'validation' | 'auth' | 'rate_limit' | 'transient' | 'unknown';
|
|
175
6
|
declare const AthenaErrorKind: {
|
|
@@ -346,6 +177,332 @@ declare function assertInt(value: unknown, label?: string, options?: IntCoercion
|
|
|
346
177
|
*/
|
|
347
178
|
declare function withRetry<T>(config: RetryConfig, fn: () => Promise<T>): Promise<T>;
|
|
348
179
|
|
|
180
|
+
type AthenaRowShape$2 = Record<string, AthenaJsonValue | undefined>;
|
|
181
|
+
type AthenaUpsertOptions<Update> = AthenaGatewayCallOptions & {
|
|
182
|
+
updateBody?: Update;
|
|
183
|
+
onConflict?: string | string[];
|
|
184
|
+
};
|
|
185
|
+
interface AthenaDbModule {
|
|
186
|
+
from<Row = AthenaRowShape$2, Insert = Partial<Row>, Update = Partial<Insert>>(table: string): TableQueryBuilder<Row, Insert, Update>;
|
|
187
|
+
select<Row = AthenaRowShape$2, SelectedRow = Row>(table: string, columns?: string | string[], options?: AthenaGatewayCallOptions): SelectChain<Row, SelectedRow>;
|
|
188
|
+
insert<Row = AthenaRowShape$2, Insert = Partial<Row>>(table: string, values: Insert, options?: AthenaGatewayCallOptions): MutationQuery<Row>;
|
|
189
|
+
insert<Row = AthenaRowShape$2, Insert = Partial<Row>>(table: string, values: Insert[], options?: AthenaGatewayCallOptions): MutationQuery<Row[]>;
|
|
190
|
+
upsert<Row = AthenaRowShape$2, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, values: Insert, options?: AthenaUpsertOptions<Update>): MutationQuery<Row>;
|
|
191
|
+
upsert<Row = AthenaRowShape$2, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, values: Insert[], options?: AthenaUpsertOptions<Update>): MutationQuery<Row[]>;
|
|
192
|
+
update<Row = AthenaRowShape$2, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, values: Update, options?: AthenaGatewayCallOptions): UpdateChain<Row>;
|
|
193
|
+
delete<Row = AthenaRowShape$2>(table: string, options?: AthenaGatewayCallOptions & {
|
|
194
|
+
resourceId?: string;
|
|
195
|
+
}): MutationQuery<Row | null>;
|
|
196
|
+
rpc<Row = unknown, Args extends AthenaJsonObject = AthenaJsonObject>(fn: string, args?: Args, options?: AthenaRpcCallOptions): RpcQueryBuilder<Row>;
|
|
197
|
+
query<Row = unknown>(query: string, options?: AthenaGatewayCallOptions): Promise<AthenaResult<Row[]>>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
type AthenaRowShape$1 = Record<string, AthenaJsonValue | undefined>;
|
|
201
|
+
type FilterColumnKey$1<Row> = Extract<keyof NonNullable<Row>, string>;
|
|
202
|
+
type ResolvedFilterColumnKey$1<Row> = [FilterColumnKey$1<Row>] extends [never] ? string : FilterColumnKey$1<Row>;
|
|
203
|
+
type AthenaWherePrimitive = AthenaConditionValue;
|
|
204
|
+
type AthenaWhereOperatorInput = {
|
|
205
|
+
eq?: AthenaConditionValue;
|
|
206
|
+
neq?: AthenaConditionValue;
|
|
207
|
+
gt?: AthenaConditionValue;
|
|
208
|
+
gte?: AthenaConditionValue;
|
|
209
|
+
lt?: AthenaConditionValue;
|
|
210
|
+
lte?: AthenaConditionValue;
|
|
211
|
+
like?: AthenaConditionValue;
|
|
212
|
+
ilike?: AthenaConditionValue;
|
|
213
|
+
is?: AthenaConditionValue;
|
|
214
|
+
in?: AthenaConditionArrayValue;
|
|
215
|
+
contains?: AthenaConditionArrayValue;
|
|
216
|
+
containedBy?: AthenaConditionArrayValue;
|
|
217
|
+
};
|
|
218
|
+
type AthenaWhereBooleanOperand<Row = AthenaRowShape$1> = Partial<Record<ResolvedFilterColumnKey$1<Row>, AthenaWherePrimitive | AthenaWhereOperatorInput>>;
|
|
219
|
+
type AthenaWhere<Row = AthenaRowShape$1> = AthenaWhereBooleanOperand<Row> & {
|
|
220
|
+
or?: Array<AthenaWhereBooleanOperand<Row>>;
|
|
221
|
+
not?: AthenaWhereBooleanOperand<Row>;
|
|
222
|
+
};
|
|
223
|
+
interface AthenaRelationSelectNode<TSelect extends AthenaSelectShape = AthenaSelectShape> {
|
|
224
|
+
select: TSelect;
|
|
225
|
+
as?: string;
|
|
226
|
+
via?: string;
|
|
227
|
+
}
|
|
228
|
+
type AthenaSelectShape = Record<string, true | AthenaRelationSelectNode<AthenaSelectShape>>;
|
|
229
|
+
type GenericRegistryDef = RegistryDef<Record<string, DatabaseDef<Record<string, SchemaDef<Record<string, AnyModelDef>>>>>>;
|
|
230
|
+
type AthenaOrderByDirectionInput = 'asc' | 'desc' | 'ascending' | 'descending' | boolean | {
|
|
231
|
+
ascending?: boolean;
|
|
232
|
+
};
|
|
233
|
+
type AthenaOrderBy<Row = AthenaRowShape$1> = {
|
|
234
|
+
column: ResolvedFilterColumnKey$1<Row>;
|
|
235
|
+
ascending?: boolean;
|
|
236
|
+
} | Partial<Record<ResolvedFilterColumnKey$1<Row>, AthenaOrderByDirectionInput>>;
|
|
237
|
+
interface AthenaFindManyOptions<Row = AthenaRowShape$1, TSelect extends AthenaSelectShape = AthenaSelectShape> {
|
|
238
|
+
select: TSelect;
|
|
239
|
+
where?: AthenaWhere<Row>;
|
|
240
|
+
orderBy?: AthenaOrderBy<Row>;
|
|
241
|
+
limit?: number;
|
|
242
|
+
}
|
|
243
|
+
type AthenaModelContext<TRegistry extends GenericRegistryDef = GenericRegistryDef, TDatabase extends string = string, TSchema extends string = string, TModel extends AnyModelDef = AnyModelDef> = {
|
|
244
|
+
registry: TRegistry;
|
|
245
|
+
database: TDatabase;
|
|
246
|
+
schema: TSchema;
|
|
247
|
+
model: TModel;
|
|
248
|
+
};
|
|
249
|
+
type Simplify<T> = {
|
|
250
|
+
[K in keyof T]: T[K];
|
|
251
|
+
} & {};
|
|
252
|
+
type ContextRegistry<TContext> = TContext extends AthenaModelContext<infer TRegistry, string, string, AnyModelDef> ? TRegistry : never;
|
|
253
|
+
type ContextDatabase<TContext> = TContext extends AthenaModelContext<GenericRegistryDef, infer TDatabase, string, AnyModelDef> ? TDatabase : never;
|
|
254
|
+
type ContextModel<TContext> = TContext extends AthenaModelContext<GenericRegistryDef, string, string, infer TModel> ? TModel : never;
|
|
255
|
+
type ModelMetaOf<TContext> = ContextModel<TContext> extends ModelDef<unknown, unknown, unknown, infer TMeta> ? TMeta : never;
|
|
256
|
+
type ModelRelationsOf<TContext> = NonNullable<ModelMetaOf<TContext>['relations']>;
|
|
257
|
+
type SelectedResultKey<TKey extends string, TValue> = TValue extends {
|
|
258
|
+
as: infer TAlias extends string;
|
|
259
|
+
} ? TAlias : TKey;
|
|
260
|
+
type ScalarSelectionResult<Row, TSelect extends AthenaSelectShape> = {
|
|
261
|
+
[TKey in Extract<keyof TSelect, string> as TSelect[TKey] extends true ? TKey : never]-?: TKey extends keyof NonNullable<Row> ? NonNullable<Row>[TKey] : unknown;
|
|
262
|
+
};
|
|
263
|
+
type RelationByKey<TContext, TKey extends string> = TKey extends keyof ModelRelationsOf<TContext> ? ModelRelationsOf<TContext>[TKey] : never;
|
|
264
|
+
type RelationByVia<TContext, TVia extends string> = {
|
|
265
|
+
[TKey in keyof ModelRelationsOf<TContext>]: ModelRelationsOf<TContext>[TKey] extends infer TRelation ? TRelation extends ModelRelationMetadata ? TVia extends TRelation['sourceColumns'][number] ? TRelation : never : never : never;
|
|
266
|
+
}[keyof ModelRelationsOf<TContext>];
|
|
267
|
+
type ResolvedRelation<TContext, TKey extends string, TValue> = RelationByKey<TContext, TKey> extends never ? TValue extends {
|
|
268
|
+
via: infer TVia extends string;
|
|
269
|
+
} ? RelationByVia<TContext, TVia> : never : RelationByKey<TContext, TKey>;
|
|
270
|
+
type TargetDatabaseName<TContext, TRelation extends ModelRelationMetadata> = TRelation['targetDatabase'] extends string ? TRelation['targetDatabase'] : ContextDatabase<TContext>;
|
|
271
|
+
type ResolveTargetModel<TContext, TRelation extends ModelRelationMetadata> = ContextRegistry<TContext> extends infer TRegistry ? TRegistry extends GenericRegistryDef ? TargetDatabaseName<TContext, TRelation> extends keyof TRegistry & string ? TRelation['targetSchema'] extends keyof TRegistry[TargetDatabaseName<TContext, TRelation>]['schemas'] & string ? TRelation['targetModel'] extends keyof TRegistry[TargetDatabaseName<TContext, TRelation>]['schemas'][TRelation['targetSchema']]['models'] & string ? TRegistry[TargetDatabaseName<TContext, TRelation>]['schemas'][TRelation['targetSchema']]['models'][TRelation['targetModel']] : never : never : never : never : never;
|
|
272
|
+
type RelationResultValue<TRelation extends ModelRelationMetadata, TValue, TContext> = TValue extends AthenaRelationSelectNode<infer TChildSelect> ? ResolveTargetModel<TContext, TRelation> extends infer TTargetModel ? TTargetModel extends AnyModelDef ? TRelation['kind'] extends 'one-to-many' | 'many-to-many' ? Array<AthenaFindManyResult<RowOf<TTargetModel>, TChildSelect, AthenaModelContext<ContextRegistry<TContext>, TargetDatabaseName<TContext, TRelation>, TRelation['targetSchema'], TTargetModel>>> : AthenaFindManyResult<RowOf<TTargetModel>, TChildSelect, AthenaModelContext<ContextRegistry<TContext>, TargetDatabaseName<TContext, TRelation>, TRelation['targetSchema'], TTargetModel>> | null : unknown : unknown : never;
|
|
273
|
+
type RelationSelectionResult<TContext, TSelect extends AthenaSelectShape> = {
|
|
274
|
+
[TKey in Extract<keyof TSelect, string> as TSelect[TKey] extends AthenaRelationSelectNode<AthenaSelectShape> ? SelectedResultKey<TKey, TSelect[TKey]> : never]-?: ResolvedRelation<TContext, TKey, TSelect[TKey]> extends infer TRelation ? TRelation extends ModelRelationMetadata ? RelationResultValue<TRelation, TSelect[TKey], TContext> : unknown : unknown;
|
|
275
|
+
};
|
|
276
|
+
type AthenaFindManyResult<Row, TSelect extends AthenaSelectShape, TContext = unknown> = Simplify<ScalarSelectionResult<Row, TSelect> & RelationSelectionResult<TContext, TSelect>>;
|
|
277
|
+
|
|
278
|
+
interface AthenaResult<T> {
|
|
279
|
+
data: T | null;
|
|
280
|
+
error: AthenaResultError | null;
|
|
281
|
+
statusText?: string | null;
|
|
282
|
+
/**
|
|
283
|
+
* @deprecated Prefer `error?.gatewayCode`, `error?.hint`, and related fields on `error`.
|
|
284
|
+
*/
|
|
285
|
+
errorDetails?: AthenaGatewayErrorDetails | null;
|
|
286
|
+
status: number;
|
|
287
|
+
count?: number | null;
|
|
288
|
+
raw: unknown;
|
|
289
|
+
}
|
|
290
|
+
interface AthenaResultError {
|
|
291
|
+
message: string;
|
|
292
|
+
code: string | null;
|
|
293
|
+
athenaCode: NormalizedAthenaError['code'];
|
|
294
|
+
gatewayCode?: AthenaGatewayErrorDetails['code'] | null;
|
|
295
|
+
kind: NormalizedAthenaError['kind'];
|
|
296
|
+
category: NormalizedAthenaError['category'];
|
|
297
|
+
retryable: boolean;
|
|
298
|
+
details: unknown | null;
|
|
299
|
+
hint: string | null;
|
|
300
|
+
status: number;
|
|
301
|
+
statusText: string | null;
|
|
302
|
+
constraint?: string;
|
|
303
|
+
table?: string;
|
|
304
|
+
operation?: string;
|
|
305
|
+
endpoint?: AthenaGatewayErrorDetails['endpoint'];
|
|
306
|
+
method?: AthenaGatewayErrorDetails['method'];
|
|
307
|
+
requestId?: string;
|
|
308
|
+
cause?: string;
|
|
309
|
+
raw: unknown;
|
|
310
|
+
}
|
|
311
|
+
interface AthenaClientExperimentalOptions {
|
|
312
|
+
/**
|
|
313
|
+
* @deprecated Failed `AthenaResult` values now include normalized structured `error`
|
|
314
|
+
* envelopes by default. This flag is retained as a no-op compatibility switch.
|
|
315
|
+
*/
|
|
316
|
+
enableErrorNormalization?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Emit execution diagnostics for every query/mutation/RPC invocation.
|
|
319
|
+
* Includes payload, synthesized SQL, full outcome, and best-effort callsite metadata.
|
|
320
|
+
*/
|
|
321
|
+
traceQueries?: boolean | AthenaQueryTraceOptions;
|
|
322
|
+
/**
|
|
323
|
+
* Send the original `findMany(...)` AST body for clean object-select reads.
|
|
324
|
+
* This requires gateway support and falls back to legacy compiled transport
|
|
325
|
+
* when a chain carries filter/pagination state that the AST payload cannot
|
|
326
|
+
* represent losslessly yet.
|
|
327
|
+
*/
|
|
328
|
+
findManyAst?: boolean;
|
|
329
|
+
}
|
|
330
|
+
interface AthenaQueryTraceOptions {
|
|
331
|
+
/**
|
|
332
|
+
* Custom sink for trace events. Defaults to console.info.
|
|
333
|
+
*/
|
|
334
|
+
logger?: (event: AthenaQueryTraceEvent) => void;
|
|
335
|
+
}
|
|
336
|
+
interface AthenaQueryTraceCallsite {
|
|
337
|
+
filePath: string;
|
|
338
|
+
fileName: string;
|
|
339
|
+
line: number;
|
|
340
|
+
column: number;
|
|
341
|
+
frame?: string;
|
|
342
|
+
functionName?: string;
|
|
343
|
+
}
|
|
344
|
+
interface AthenaQueryTraceEvent {
|
|
345
|
+
timestamp: string;
|
|
346
|
+
durationMs: number;
|
|
347
|
+
operation: 'select' | 'insert' | 'upsert' | 'update' | 'delete' | 'rpc' | 'query';
|
|
348
|
+
endpoint: '/gateway/fetch' | '/gateway/insert' | '/gateway/update' | '/gateway/delete' | '/gateway/rpc' | '/gateway/query' | `/rpc/${string}`;
|
|
349
|
+
table?: string;
|
|
350
|
+
functionName?: string;
|
|
351
|
+
sql: string;
|
|
352
|
+
payload: unknown;
|
|
353
|
+
options?: AthenaGatewayCallOptions | AthenaRpcCallOptions;
|
|
354
|
+
callsite: AthenaQueryTraceCallsite | null;
|
|
355
|
+
outcome?: {
|
|
356
|
+
status: number;
|
|
357
|
+
error: AthenaResultError | null;
|
|
358
|
+
errorDetails?: AthenaGatewayErrorDetails | null;
|
|
359
|
+
count?: number | null;
|
|
360
|
+
data: unknown;
|
|
361
|
+
raw: unknown;
|
|
362
|
+
};
|
|
363
|
+
thrownError?: unknown;
|
|
364
|
+
}
|
|
365
|
+
type MutationSingleResult<Result> = Result extends Array<infer Item> ? Item | null : Result | null;
|
|
366
|
+
type AthenaRowShape = Record<string, AthenaJsonValue | undefined>;
|
|
367
|
+
type FilterColumnKey<Row> = Extract<keyof NonNullable<Row>, string>;
|
|
368
|
+
type ResolvedFilterColumnKey<Row> = [FilterColumnKey<Row>] extends [never] ? string : FilterColumnKey<Row>;
|
|
369
|
+
interface MutationQuery<Result> extends PromiseLike<AthenaResult<Result>> {
|
|
370
|
+
select(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<Result>>;
|
|
371
|
+
returning(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<Result>>;
|
|
372
|
+
single(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<MutationSingleResult<Result>>>;
|
|
373
|
+
maybeSingle(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<MutationSingleResult<Result>>>;
|
|
374
|
+
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>;
|
|
375
|
+
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<AthenaResult<Result> | TResult>;
|
|
376
|
+
finally(onfinally?: (() => void) | undefined | null): Promise<AthenaResult<Result>>;
|
|
377
|
+
}
|
|
378
|
+
interface OrderOptions {
|
|
379
|
+
ascending?: boolean;
|
|
380
|
+
}
|
|
381
|
+
/** Shared filter chain - supports eq, limit, etc. in any order relative to select/update */
|
|
382
|
+
interface FilterChain<Self, Row> {
|
|
383
|
+
eq(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
384
|
+
eqCast(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue, cast: AthenaConditionCastType): Self;
|
|
385
|
+
eqUuid(column: ResolvedFilterColumnKey<Row>, value: string): Self;
|
|
386
|
+
match(filters: Partial<Record<ResolvedFilterColumnKey<Row>, AthenaConditionValue>>): Self;
|
|
387
|
+
range(from: number, to: number): Self;
|
|
388
|
+
limit(count: number): Self;
|
|
389
|
+
offset(count: number): Self;
|
|
390
|
+
currentPage(value: number): Self;
|
|
391
|
+
pageSize(value: number): Self;
|
|
392
|
+
totalPages(value: number): Self;
|
|
393
|
+
order(column: ResolvedFilterColumnKey<Row>, options?: OrderOptions): Self;
|
|
394
|
+
gt(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
395
|
+
gte(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
396
|
+
lt(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
397
|
+
lte(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
398
|
+
neq(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
399
|
+
like(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
400
|
+
ilike(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
401
|
+
is(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
|
|
402
|
+
in(column: ResolvedFilterColumnKey<Row>, values: AthenaConditionArrayValue): Self;
|
|
403
|
+
contains(column: ResolvedFilterColumnKey<Row>, values: AthenaConditionArrayValue): Self;
|
|
404
|
+
containedBy(column: ResolvedFilterColumnKey<Row>, values: AthenaConditionArrayValue): Self;
|
|
405
|
+
not(columnOrExpression: ResolvedFilterColumnKey<Row> | string, operator?: AthenaConditionOperator, value?: AthenaConditionValue): Self;
|
|
406
|
+
or(expression: string): Self;
|
|
407
|
+
}
|
|
408
|
+
/** Chain returned by select() - supports filters and single/maybeSingle before execution */
|
|
409
|
+
interface SelectChain<Row, SelectedRow = Row> extends FilterChain<SelectChain<Row, SelectedRow>, Row>, PromiseLike<AthenaResult<SelectedRow[]>> {
|
|
410
|
+
single<T = SelectedRow>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
|
|
411
|
+
maybeSingle<T = SelectedRow>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
|
|
412
|
+
}
|
|
413
|
+
/** Chain returned by update() - supports filters before execution, plus select/returning */
|
|
414
|
+
interface UpdateChain<Row> extends FilterChain<UpdateChain<Row>, Row>, MutationQuery<Row[]> {
|
|
415
|
+
}
|
|
416
|
+
interface RpcFilterChain<Self> {
|
|
417
|
+
eq(column: string, value: AthenaConditionValue): Self;
|
|
418
|
+
neq(column: string, value: AthenaConditionValue): Self;
|
|
419
|
+
gt(column: string, value: AthenaConditionValue): Self;
|
|
420
|
+
gte(column: string, value: AthenaConditionValue): Self;
|
|
421
|
+
lt(column: string, value: AthenaConditionValue): Self;
|
|
422
|
+
lte(column: string, value: AthenaConditionValue): Self;
|
|
423
|
+
like(column: string, value: AthenaConditionValue): Self;
|
|
424
|
+
ilike(column: string, value: AthenaConditionValue): Self;
|
|
425
|
+
is(column: string, value: AthenaConditionValue): Self;
|
|
426
|
+
in(column: string, values: AthenaConditionArrayValue): Self;
|
|
427
|
+
}
|
|
428
|
+
interface RpcOrderOptions {
|
|
429
|
+
ascending?: boolean;
|
|
430
|
+
}
|
|
431
|
+
interface RpcQueryBuilder<Row> extends RpcFilterChain<RpcQueryBuilder<Row>>, PromiseLike<AthenaResult<Row[]>> {
|
|
432
|
+
select(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<Row[]>>;
|
|
433
|
+
single<T = Row>(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<T | null>>;
|
|
434
|
+
maybeSingle<T = Row>(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<T | null>>;
|
|
435
|
+
order(column: string, options?: RpcOrderOptions): RpcQueryBuilder<Row>;
|
|
436
|
+
limit(count: number): RpcQueryBuilder<Row>;
|
|
437
|
+
offset(count: number): RpcQueryBuilder<Row>;
|
|
438
|
+
range(from: number, to: number): RpcQueryBuilder<Row>;
|
|
439
|
+
}
|
|
440
|
+
interface TableQueryBuilder<Row, Insert = Partial<Row>, Update = Partial<Insert>, TContext = unknown> extends FilterChain<TableQueryBuilder<Row, Insert, Update, TContext>, Row> {
|
|
441
|
+
select<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): SelectChain<Row, T>;
|
|
442
|
+
findMany<const TSelect extends AthenaSelectShape>(options: AthenaFindManyOptions<Row, TSelect>): Promise<AthenaResult<Array<AthenaFindManyResult<Row, TSelect, TContext>>>>;
|
|
443
|
+
insert(values: Insert, options?: AthenaGatewayCallOptions): MutationQuery<Row>;
|
|
444
|
+
insert(values: Insert[], options?: AthenaGatewayCallOptions): MutationQuery<Row[]>;
|
|
445
|
+
upsert(values: Insert, options?: AthenaGatewayCallOptions & {
|
|
446
|
+
updateBody?: Update;
|
|
447
|
+
onConflict?: string | string[];
|
|
448
|
+
}): MutationQuery<Row>;
|
|
449
|
+
upsert(values: Insert[], options?: AthenaGatewayCallOptions & {
|
|
450
|
+
updateBody?: Update;
|
|
451
|
+
onConflict?: string | string[];
|
|
452
|
+
}): MutationQuery<Row[]>;
|
|
453
|
+
update(values: Update, options?: AthenaGatewayCallOptions): UpdateChain<Row>;
|
|
454
|
+
delete(options?: AthenaGatewayCallOptions & {
|
|
455
|
+
resourceId?: string;
|
|
456
|
+
}): MutationQuery<Row | null>;
|
|
457
|
+
single<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
|
|
458
|
+
maybeSingle<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
|
|
459
|
+
reset(): TableQueryBuilder<Row, Insert, Update, TContext>;
|
|
460
|
+
}
|
|
461
|
+
interface AthenaSdkClient {
|
|
462
|
+
from<Row = AthenaRowShape, Insert = Partial<Row>, Update = Partial<Insert>>(table: string): TableQueryBuilder<Row, Insert, Update>;
|
|
463
|
+
db: AthenaDbModule;
|
|
464
|
+
rpc<Row = unknown, Args extends AthenaJsonObject = AthenaJsonObject>(fn: string, args?: Args, options?: AthenaRpcCallOptions): RpcQueryBuilder<Row>;
|
|
465
|
+
query<Row = unknown>(query: string, options?: AthenaGatewayCallOptions): Promise<AthenaResult<Row[]>>;
|
|
466
|
+
}
|
|
467
|
+
interface AthenaSdkClientWithAuth extends AthenaSdkClient {
|
|
468
|
+
auth: AthenaAuthBindings;
|
|
469
|
+
}
|
|
470
|
+
interface AthenaClientBuilder {
|
|
471
|
+
/** Set the gateway base URL. */
|
|
472
|
+
url(url: string): AthenaClientBuilder;
|
|
473
|
+
/** Set the API key used for all requests. */
|
|
474
|
+
key(apiKey: string): AthenaClientBuilder;
|
|
475
|
+
/** Set the default backend routing strategy. */
|
|
476
|
+
backend(backend: BackendConfig | BackendType): AthenaClientBuilder;
|
|
477
|
+
/** Set the default Athena client routing key. */
|
|
478
|
+
client(clientName: string): AthenaClientBuilder;
|
|
479
|
+
/** Attach static headers to every request. */
|
|
480
|
+
headers(headers: Record<string, string>): AthenaClientBuilder;
|
|
481
|
+
/** Configure Athena Auth client behavior for `client.auth.*` methods. */
|
|
482
|
+
auth(config: AthenaAuthClientConfig): AthenaClientBuilder;
|
|
483
|
+
/** Configure experimental client options (for example query tracing or findMany AST transport). */
|
|
484
|
+
experimental(options: AthenaClientExperimentalOptions): AthenaClientBuilder;
|
|
485
|
+
/** Apply the same options object accepted by `createClient(url, key, options)`. */
|
|
486
|
+
options(options: AthenaCreateClientOptions): AthenaClientBuilder;
|
|
487
|
+
/** Enable or disable health tracking metadata. */
|
|
488
|
+
healthTracking(enabled: boolean): AthenaClientBuilder;
|
|
489
|
+
/** Build the immutable Athena SDK client. */
|
|
490
|
+
build(): AthenaSdkClientWithAuth;
|
|
491
|
+
}
|
|
492
|
+
/** Canonical Athena client factory with builder-based configuration. */
|
|
493
|
+
declare class AthenaClient {
|
|
494
|
+
/** Create a fluent builder for a strongly-typed Athena SDK client. */
|
|
495
|
+
static builder(): AthenaClientBuilder;
|
|
496
|
+
/** Build a client from process environment variables. */
|
|
497
|
+
static fromEnvironment(): AthenaSdkClientWithAuth;
|
|
498
|
+
}
|
|
499
|
+
interface AthenaCreateClientOptions extends Pick<AthenaGatewayCallOptions, 'client' | 'headers' | 'backend'> {
|
|
500
|
+
auth?: AthenaAuthClientConfig;
|
|
501
|
+
experimental?: AthenaClientExperimentalOptions;
|
|
502
|
+
}
|
|
503
|
+
/** Create client (convenience wrapper; use AthenaClient.builder() for full control) */
|
|
504
|
+
declare function createClient(url: string, apiKey: string, options?: AthenaCreateClientOptions): AthenaSdkClientWithAuth;
|
|
505
|
+
|
|
349
506
|
/**
|
|
350
507
|
* Immutable identifier object with consistent SQL rendering.
|
|
351
508
|
*/
|
|
@@ -394,7 +551,12 @@ interface TypedAthenaClient<TRegistry extends RegistryConstraint, TTenantMap ext
|
|
|
394
551
|
readonly tenantKeyMap: Readonly<TTenantMap>;
|
|
395
552
|
readonly tenantContext: TenantContext<TTenantMap>;
|
|
396
553
|
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
|
|
554
|
+
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>>, {
|
|
555
|
+
registry: TRegistry;
|
|
556
|
+
database: TDatabase;
|
|
557
|
+
schema: TSchema;
|
|
558
|
+
model: ModelAt<TRegistry, TDatabase, TSchema, TModel>;
|
|
559
|
+
}>;
|
|
398
560
|
}
|
|
399
561
|
/**
|
|
400
562
|
* Creates a typed client bound to a registry contract and optional tenant header mapping.
|
|
@@ -432,4 +594,17 @@ declare function resolveProviderSchemas(providerConfig: GeneratorProviderConfig)
|
|
|
432
594
|
*/
|
|
433
595
|
declare function createAuthClient(config?: AthenaAuthClientConfig): AthenaAuthSdkClient;
|
|
434
596
|
|
|
435
|
-
|
|
597
|
+
interface AthenaAuthRenderedReactEmail {
|
|
598
|
+
html: string;
|
|
599
|
+
text?: string;
|
|
600
|
+
}
|
|
601
|
+
interface AthenaAuthReactEmailRuntimeOptions {
|
|
602
|
+
route?: string;
|
|
603
|
+
defaults?: AthenaAuthReactEmailRenderOptions;
|
|
604
|
+
observe?: (event: AthenaAuthReactEmailRenderEvent) => void;
|
|
605
|
+
}
|
|
606
|
+
declare function createAuthReactEmailInput<TProps extends AthenaAuthReactEmailProps = AthenaAuthReactEmailProps>(component: AthenaAuthReactEmailComponent<TProps>, props: TProps, overrides?: Omit<AthenaAuthReactEmailRenderInput, 'component' | 'props' | 'element'>): AthenaAuthReactEmailRenderInput;
|
|
607
|
+
declare function defineAuthEmailTemplate<TProps extends AthenaAuthReactEmailProps = AthenaAuthReactEmailProps>(definition: AthenaAuthEmailTemplateDefinition<TProps>): AthenaAuthEmailTemplateBuilder<TProps>;
|
|
608
|
+
declare function renderAthenaReactEmail(input: AthenaAuthReactEmailRenderInput, options?: AthenaAuthReactEmailRuntimeOptions | AthenaAuthReactEmailConfig): Promise<AthenaAuthRenderedReactEmail>;
|
|
609
|
+
|
|
610
|
+
export { normalizeAthenaError as $, AthenaClient as A, type RpcOrderOptions as B, type RpcQueryBuilder as C, DEFAULT_POSTGRES_SCHEMAS as D, type TypedAthenaClient as E, type TypedClientOptions as F, type UnwrapOptions as G, assertInt as H, type IntCoercionOptions as I, coerceInt as J, createAuthClient as K, createAuthReactEmailInput as L, createClient as M, type NormalizedAthenaError as N, createPostgresIntrospectionProvider as O, type PostgresIntrospectionProviderOptions as P, createTypedClient as Q, type RequireAffectedOptions as R, defineAuthEmailTemplate as S, type TableQueryBuilder as T, type UnwrapOneOptions as U, defineDatabase as V, defineModel as W, defineRegistry as X, defineSchema as Y, identifier as Z, isOk as _, type AthenaClientExperimentalOptions as a, normalizeSchemaSelection as a0, parseBooleanFlag as a1, renderAthenaReactEmail as a2, requireAffected as a3, requireSuccess as a4, resolvePostgresColumnType as a5, resolveProviderSchemas as a6, unwrap as a7, unwrapOne as a8, unwrapRows as a9, withRetry as aa, 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 AthenaFindManyOptions as i, type AthenaFindManyResult as j, type AthenaOperationContext as k, type AthenaOrderBy as l, type AthenaQueryTraceCallsite as m, type AthenaQueryTraceEvent as n, type AthenaQueryTraceOptions as o, type AthenaRelationSelectNode as p, type AthenaResult as q, type AthenaResultError as r, type AthenaSdkClient as s, type AthenaSdkClientWithAuth as t, type AthenaSelectShape as u, type AthenaWhere as v, type AthenaWhereBooleanOperand as w, type AthenaWhereOperatorInput as x, type RetryBackoffStrategy as y, type RetryConfig as z };
|
package/dist/react.cjs
CHANGED
|
@@ -93,23 +93,39 @@ function normalizeHeaderValue(value) {
|
|
|
93
93
|
function isRecord(value) {
|
|
94
94
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
95
95
|
}
|
|
96
|
+
function nonEmptyString(value) {
|
|
97
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
98
|
+
}
|
|
99
|
+
function resolveStructuredErrorPayload(payload) {
|
|
100
|
+
if (!isRecord(payload)) return null;
|
|
101
|
+
return isRecord(payload.error) ? payload.error : payload;
|
|
102
|
+
}
|
|
96
103
|
function resolveRequestId(headers) {
|
|
97
104
|
return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
|
|
98
105
|
}
|
|
99
106
|
function resolveErrorMessage(payload, fallback) {
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
const structuredPayload = resolveStructuredErrorPayload(payload);
|
|
108
|
+
if (structuredPayload) {
|
|
109
|
+
const messageCandidates = [structuredPayload.message, structuredPayload.error, structuredPayload.details];
|
|
102
110
|
for (const candidate of messageCandidates) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
111
|
+
const resolved = nonEmptyString(candidate);
|
|
112
|
+
if (resolved) return resolved;
|
|
106
113
|
}
|
|
107
114
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
115
|
+
const rawMessage = nonEmptyString(payload);
|
|
116
|
+
if (rawMessage) return rawMessage;
|
|
111
117
|
return fallback;
|
|
112
118
|
}
|
|
119
|
+
function resolveErrorHint(payload) {
|
|
120
|
+
const structuredPayload = resolveStructuredErrorPayload(payload);
|
|
121
|
+
return structuredPayload ? nonEmptyString(structuredPayload.hint) : void 0;
|
|
122
|
+
}
|
|
123
|
+
function resolveStatusText(response, payload) {
|
|
124
|
+
const rawStatusText = nonEmptyString(response.statusText);
|
|
125
|
+
if (rawStatusText) return rawStatusText;
|
|
126
|
+
const payloadRecord = isRecord(payload) ? payload : null;
|
|
127
|
+
return payloadRecord ? nonEmptyString(payloadRecord.statusText) ?? null : null;
|
|
128
|
+
}
|
|
113
129
|
function detailsFromError(error) {
|
|
114
130
|
return error.toDetails();
|
|
115
131
|
}
|
|
@@ -280,6 +296,7 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
280
296
|
return {
|
|
281
297
|
ok: false,
|
|
282
298
|
status: response.status,
|
|
299
|
+
statusText: resolveStatusText(response, parsedBody.parsed),
|
|
283
300
|
data: null,
|
|
284
301
|
error: invalidJsonError.message,
|
|
285
302
|
errorDetails: detailsFromError(invalidJsonError),
|
|
@@ -298,11 +315,13 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
298
315
|
status: response.status,
|
|
299
316
|
endpoint,
|
|
300
317
|
method,
|
|
301
|
-
requestId
|
|
318
|
+
requestId,
|
|
319
|
+
hint: resolveErrorHint(parsed)
|
|
302
320
|
});
|
|
303
321
|
return {
|
|
304
322
|
ok: false,
|
|
305
323
|
status: response.status,
|
|
324
|
+
statusText: resolveStatusText(response, parsed),
|
|
306
325
|
data: null,
|
|
307
326
|
error: httpError.message,
|
|
308
327
|
errorDetails: detailsFromError(httpError),
|
|
@@ -314,6 +333,7 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
314
333
|
return {
|
|
315
334
|
ok: true,
|
|
316
335
|
status: response.status,
|
|
336
|
+
statusText: resolveStatusText(response, parsed),
|
|
317
337
|
data: payloadData ?? null,
|
|
318
338
|
count: payloadCount,
|
|
319
339
|
error: void 0,
|
|
@@ -333,6 +353,7 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
333
353
|
return {
|
|
334
354
|
ok: false,
|
|
335
355
|
status: 0,
|
|
356
|
+
statusText: null,
|
|
336
357
|
data: null,
|
|
337
358
|
error: networkError.message,
|
|
338
359
|
errorDetails: detailsFromError(networkError),
|