@xylex-group/athena 2.4.1 → 2.7.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.
Files changed (49) hide show
  1. package/README.md +52 -1
  2. package/bin/athena-js.js +0 -0
  3. package/dist/browser.cjs +2642 -56
  4. package/dist/browser.cjs.map +1 -1
  5. package/dist/browser.d.cts +8 -7
  6. package/dist/browser.d.ts +8 -7
  7. package/dist/browser.js +2635 -57
  8. package/dist/browser.js.map +1 -1
  9. package/dist/cli/index.cjs +1648 -239
  10. package/dist/cli/index.cjs.map +1 -1
  11. package/dist/cli/index.d.cts +3 -3
  12. package/dist/cli/index.d.ts +3 -3
  13. package/dist/cli/index.js +1648 -239
  14. package/dist/cli/index.js.map +1 -1
  15. package/dist/cookies.cjs +10 -3
  16. package/dist/cookies.cjs.map +1 -1
  17. package/dist/cookies.d.cts +1 -174
  18. package/dist/cookies.d.ts +1 -174
  19. package/dist/cookies.js +10 -3
  20. package/dist/cookies.js.map +1 -1
  21. package/dist/index-CVcQCGyG.d.cts +174 -0
  22. package/dist/index-CVcQCGyG.d.ts +174 -0
  23. package/dist/index.cjs +2642 -56
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +8 -7
  26. package/dist/index.d.ts +8 -7
  27. package/dist/index.js +2635 -57
  28. package/dist/index.js.map +1 -1
  29. package/dist/model-form-AKYrgede.d.ts +2772 -0
  30. package/dist/model-form-ehfqLuG7.d.cts +2772 -0
  31. package/dist/{pipeline-CR4V15jF.d.ts → pipeline-BUsR9XlO.d.ts} +1 -1
  32. package/dist/{pipeline-DZeExYMA.d.cts → pipeline-BfCWSRYl.d.cts} +1 -1
  33. package/dist/react-email-BQzmXBDE.d.cts +304 -0
  34. package/dist/react-email-BrVRp80B.d.ts +304 -0
  35. package/dist/react.cjs +178 -71
  36. package/dist/react.cjs.map +1 -1
  37. package/dist/react.d.cts +22 -5
  38. package/dist/react.d.ts +22 -5
  39. package/dist/react.js +92 -5
  40. package/dist/react.js.map +1 -1
  41. package/dist/{types-D1JvL21V.d.cts → types-BSIsyss1.d.cts} +1 -1
  42. package/dist/{types-09Q4D86N.d.cts → types-BsyRW49r.d.cts} +3 -3
  43. package/dist/{types-09Q4D86N.d.ts → types-BsyRW49r.d.ts} +3 -3
  44. package/dist/{types-DU3gNdFv.d.ts → types-t_TVqnmp.d.ts} +1 -1
  45. package/package.json +22 -21
  46. package/dist/model-form-4LPnOPAF.d.cts +0 -1383
  47. package/dist/model-form-CO4-LmNC.d.ts +0 -1383
  48. package/dist/react-email-6mOyxBo4.d.cts +0 -657
  49. package/dist/react-email-Buhcpglm.d.ts +0 -657
@@ -1,657 +0,0 @@
1
- import { i as AthenaJsonValue, a as AthenaGatewayCallOptions, g as AthenaJsonObject, j as AthenaRpcCallOptions, J as AthenaConditionValue, K as AthenaConditionArrayValue, R as RegistryDef, D as DatabaseDef, F as SchemaDef, L as AnyModelDef, x as ModelDef, C as ModelRelationMetadata, E as RowOf, o as BackendConfig, p as BackendType, e as AthenaGatewayErrorDetails, A as AthenaConditionCastType, N as AthenaConditionOperator, b as AthenaGatewayConnectionOptions, c as AthenaGatewayConnectionResult, y as ModelMetadata, H as TenantKeyMap, T as TenantContext, M as ModelAt, q as InsertOf, U as UpdateOf, S as SchemaIntrospectionProvider, r as IntrospectionColumn } from './types-09Q4D86N.cjs';
2
- import { f as AthenaAuthClientConfig, d as AthenaAuthBindings, N as AthenaAuthSdkClient, F as AthenaAuthReactEmailProps, C as AthenaAuthReactEmailComponent, H as AthenaAuthReactEmailRenderInput, k as AthenaAuthEmailTemplateDefinition, i as AthenaAuthEmailTemplateBuilder, I as AthenaAuthReactEmailRenderOptions, G as AthenaAuthReactEmailRenderEvent, D as AthenaAuthReactEmailConfig } from './model-form-4LPnOPAF.cjs';
3
- import { j as GeneratorSchemaSelection, b as GeneratorProviderConfig } from './types-D1JvL21V.cjs';
4
-
5
- type AthenaErrorKind = 'unique_violation' | 'not_found' | 'validation' | 'auth' | 'rate_limit' | 'transient' | 'unknown';
6
- declare const AthenaErrorKind: {
7
- readonly UniqueViolation: "unique_violation";
8
- readonly NotFound: "not_found";
9
- readonly Validation: "validation";
10
- readonly Auth: "auth";
11
- readonly RateLimit: "rate_limit";
12
- readonly Transient: "transient";
13
- readonly Unknown: "unknown";
14
- };
15
- type AthenaErrorCode = 'UNIQUE_VIOLATION' | 'NOT_FOUND' | 'VALIDATION_FAILED' | 'AUTH_UNAUTHORIZED' | 'AUTH_FORBIDDEN' | 'RATE_LIMITED' | 'NETWORK_UNAVAILABLE' | 'TRANSIENT_FAILURE' | 'HTTP_FAILURE' | 'UNKNOWN';
16
- declare const AthenaErrorCode: {
17
- readonly UniqueViolation: "UNIQUE_VIOLATION";
18
- readonly NotFound: "NOT_FOUND";
19
- readonly ValidationFailed: "VALIDATION_FAILED";
20
- readonly AuthUnauthorized: "AUTH_UNAUTHORIZED";
21
- readonly AuthForbidden: "AUTH_FORBIDDEN";
22
- readonly RateLimited: "RATE_LIMITED";
23
- readonly NetworkUnavailable: "NETWORK_UNAVAILABLE";
24
- readonly TransientFailure: "TRANSIENT_FAILURE";
25
- readonly HttpFailure: "HTTP_FAILURE";
26
- readonly Unknown: "UNKNOWN";
27
- };
28
- type AthenaErrorCategory = 'transport' | 'client' | 'server' | 'database' | 'unknown';
29
- declare const AthenaErrorCategory: {
30
- readonly Transport: "transport";
31
- readonly Client: "client";
32
- readonly Server: "server";
33
- readonly Database: "database";
34
- readonly Unknown: "unknown";
35
- };
36
- interface AthenaOperationContext {
37
- table?: string;
38
- operation?: string;
39
- identity?: string | Record<string, unknown>;
40
- }
41
- interface NormalizedAthenaError {
42
- kind: AthenaErrorKind;
43
- code: AthenaErrorCode;
44
- category: AthenaErrorCategory;
45
- retryable: boolean;
46
- status?: number;
47
- constraint?: string;
48
- table?: string;
49
- operation?: string;
50
- message: string;
51
- raw: unknown;
52
- }
53
- interface AthenaErrorInput {
54
- code: AthenaErrorCode;
55
- kind: AthenaErrorKind;
56
- category: AthenaErrorCategory;
57
- message: string;
58
- status?: number;
59
- retryable?: boolean;
60
- requestId?: string;
61
- context?: AthenaOperationContext;
62
- raw?: unknown;
63
- }
64
- interface UnwrapOptions {
65
- allowNull?: boolean;
66
- context?: AthenaOperationContext;
67
- }
68
- interface UnwrapOneOptions extends UnwrapOptions {
69
- requireExactlyOne?: boolean;
70
- }
71
- interface IntCoercionOptions {
72
- strictBigInt?: boolean;
73
- min?: number;
74
- max?: number;
75
- }
76
- type RetryBackoffStrategy = 'linear' | 'exponential' | ((attempt: number, error: unknown) => number);
77
- interface RetryConfig {
78
- retries: number;
79
- baseDelayMs?: number;
80
- maxDelayMs?: number;
81
- backoff?: RetryBackoffStrategy;
82
- jitter?: boolean | number;
83
- shouldRetry?: (error: unknown, attempt: number) => boolean | Promise<boolean>;
84
- }
85
- interface RequireAffectedOptions {
86
- min?: number;
87
- }
88
- /**
89
- * Parses a string-based boolean flag with a deterministic fallback.
90
- *
91
- * Accepts common truthy/falsey token variants used by env vars and CLI flags.
92
- */
93
- declare function parseBooleanFlag(rawValue: string | undefined, fallback: boolean): boolean;
94
- declare class AthenaError extends Error {
95
- readonly code: AthenaErrorCode;
96
- readonly kind: AthenaErrorKind;
97
- readonly category: AthenaErrorCategory;
98
- readonly status?: number;
99
- readonly retryable: boolean;
100
- readonly requestId?: string;
101
- readonly context?: AthenaOperationContext;
102
- readonly raw?: unknown;
103
- constructor(input: AthenaErrorInput);
104
- }
105
- /**
106
- * Returns `true` when a result is successful (`2xx` status and no `error`).
107
- */
108
- declare function isOk<T>(result: AthenaResult<T>): boolean;
109
- /**
110
- * Normalizes any Athena failure shape into a stable, typed error envelope.
111
- *
112
- * Accepts `AthenaResult`, `AthenaGatewayError`, native `Error`, or unknown values.
113
- * Optional `context` can override inferred table/operation metadata for clearer diagnostics.
114
- */
115
- declare function normalizeAthenaError(resultOrError: unknown, context?: AthenaOperationContext): NormalizedAthenaError;
116
- /**
117
- * Unwraps a successful result into a row array.
118
- *
119
- * - Throws on failed results.
120
- * - Converts `null` data to an empty array.
121
- * - Wraps scalar data in a single-element array.
122
- */
123
- declare function unwrapRows<T>(result: AthenaResult<T[] | T | null>, options?: UnwrapOptions): T[];
124
- /**
125
- * Unwraps successful result data from `AthenaResult<T | null>`.
126
- *
127
- * By default, `null` data throws. Pass `{ allowNull: true }` to permit nullable payloads.
128
- */
129
- declare function unwrap<T>(result: AthenaResult<T | null>, options: UnwrapOptions & {
130
- allowNull: true;
131
- }): T | null;
132
- declare function unwrap<T>(result: AthenaResult<T | null>, options?: UnwrapOptions): T;
133
- /**
134
- * Unwraps the first row from a successful result that may contain arrays/scalars/null.
135
- *
136
- * - Throws on failed results.
137
- * - Throws when no row exists unless `allowNull: true` is provided.
138
- * - Optionally enforces exact cardinality via `requireExactlyOne`.
139
- */
140
- declare function unwrapOne<T>(result: AthenaResult<T[] | T | null>, options: UnwrapOneOptions & {
141
- allowNull: true;
142
- }): T | null;
143
- declare function unwrapOne<T>(result: AthenaResult<T[] | T | null>, options?: UnwrapOneOptions): T;
144
- /**
145
- * Asserts that an Athena result is successful.
146
- *
147
- * Returns the original result for fluent composition and throws `AthenaGatewayError` on failure.
148
- */
149
- declare function requireSuccess<T>(result: AthenaResult<T>, context?: AthenaOperationContext): AthenaResult<T>;
150
- /**
151
- * Enforces mutation postconditions based on `result.count`.
152
- *
153
- * - Validates success first.
154
- * - Requires a non-null count in the response.
155
- * - Validates `count >= min` (default: `1`).
156
- *
157
- * Useful for guaranteeing that critical writes actually affected rows.
158
- */
159
- declare function requireAffected<T>(result: AthenaResult<T>, options?: RequireAffectedOptions, context?: AthenaOperationContext): number;
160
- /**
161
- * Safely coerces `unknown` values into finite integers.
162
- *
163
- * Returns `null` when coercion fails or bounds/strict bigint checks are violated.
164
- */
165
- declare function coerceInt(value: unknown, options?: IntCoercionOptions): number | null;
166
- /**
167
- * Strict integer assertion wrapper around `coerceInt`.
168
- *
169
- * Throws a `TypeError` with the provided label when coercion fails.
170
- */
171
- declare function assertInt(value: unknown, label?: string, options?: IntCoercionOptions): number;
172
- /**
173
- * Retries an async operation with configurable backoff and retry policy.
174
- *
175
- * `retries` represents additional attempts after the first failure.
176
- * By default, transient and rate-limit errors are retried.
177
- */
178
- declare function withRetry<T>(config: RetryConfig, fn: () => Promise<T>): Promise<T>;
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, options?: AthenaFromOptions): 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 AthenaFilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'contains' | 'containedBy';
204
- type AthenaWherePrimitive = AthenaConditionValue;
205
- type AthenaWhereOperatorInput = {
206
- eq?: AthenaConditionValue;
207
- neq?: AthenaConditionValue;
208
- gt?: AthenaConditionValue;
209
- gte?: AthenaConditionValue;
210
- lt?: AthenaConditionValue;
211
- lte?: AthenaConditionValue;
212
- like?: AthenaConditionValue;
213
- ilike?: AthenaConditionValue;
214
- is?: AthenaConditionValue;
215
- in?: AthenaConditionArrayValue;
216
- contains?: AthenaConditionArrayValue;
217
- containedBy?: AthenaConditionArrayValue;
218
- };
219
- type AthenaWhereColumnInput<Row = AthenaRowShape$1> = Partial<Record<ResolvedFilterColumnKey$1<Row>, AthenaWherePrimitive | AthenaWhereOperatorInput>>;
220
- type AthenaBooleanSafeOperator = Exclude<AthenaFilterOperator, 'in' | 'contains' | 'containedBy'>;
221
- type AthenaWhereBooleanSafeOperatorInput = Partial<Record<AthenaBooleanSafeOperator, AthenaConditionValue>>;
222
- type AthenaWhereBooleanNotOperatorInput = {
223
- [K in AthenaBooleanSafeOperator]: {
224
- [P in K]: AthenaConditionValue;
225
- } & Partial<Record<Exclude<AthenaBooleanSafeOperator, K>, never>>;
226
- }[AthenaBooleanSafeOperator];
227
- type AthenaStrictBooleanOperand<Keys extends string, Value> = {
228
- [K in Keys]: {
229
- [P in K]: Value;
230
- } & Partial<Record<Exclude<Keys, K>, never>>;
231
- }[Keys];
232
- type AthenaNonEmptyArray<T> = [T, ...T[]];
233
- type AthenaWhereBooleanOperand<Row = AthenaRowShape$1> = string extends ResolvedFilterColumnKey$1<Row> ? AthenaWhereColumnInput<Row> : AthenaStrictBooleanOperand<ResolvedFilterColumnKey$1<Row>, AthenaWherePrimitive | AthenaWhereBooleanSafeOperatorInput>;
234
- type AthenaWhereNotOperand<Row = AthenaRowShape$1> = string extends ResolvedFilterColumnKey$1<Row> ? AthenaWhereColumnInput<Row> : AthenaStrictBooleanOperand<ResolvedFilterColumnKey$1<Row>, AthenaWherePrimitive | AthenaWhereBooleanNotOperatorInput>;
235
- type AthenaWhere<Row = AthenaRowShape$1> = AthenaWhereColumnInput<Row> & {
236
- or?: string extends ResolvedFilterColumnKey$1<Row> ? Array<AthenaWhereColumnInput<Row>> : AthenaNonEmptyArray<AthenaWhereBooleanOperand<Row>>;
237
- not?: AthenaWhereNotOperand<Row>;
238
- };
239
- interface AthenaRelationSelectNode<TSelect extends AthenaSelectShape = AthenaSelectShape> {
240
- select: TSelect;
241
- as?: string;
242
- via?: string;
243
- schema?: string;
244
- }
245
- type AthenaSelectShape = Record<string, true | AthenaRelationSelectNode<AthenaSelectShape>>;
246
- type AthenaAllowedRelationSelectNodeKey = 'select' | 'as' | 'via' | 'schema';
247
- type AthenaValidatedRelationSelectNode<TNode> = TNode extends {
248
- select: infer TChild;
249
- } ? Exclude<keyof TNode, AthenaAllowedRelationSelectNodeKey> extends never ? TNode extends {
250
- schema: string;
251
- via: string;
252
- } ? never : TChild extends Record<string, unknown> ? {
253
- [K in keyof TNode]: K extends 'select' ? AthenaValidatedSelectShape<TChild> : K extends AthenaAllowedRelationSelectNodeKey ? TNode[K] : never;
254
- } : never : never : never;
255
- type AthenaValidatedSelectShape<TSelect> = {
256
- [K in keyof TSelect]: TSelect[K] extends true ? true : AthenaValidatedRelationSelectNode<TSelect[K]>;
257
- };
258
- type GenericRegistryDef = RegistryDef<Record<string, DatabaseDef<Record<string, SchemaDef<Record<string, AnyModelDef>>>>>>;
259
- type AthenaOrderByDirectionInput = 'asc' | 'desc' | 'ascending' | 'descending' | boolean | {
260
- ascending?: boolean;
261
- };
262
- type AthenaOrderBy<Row = AthenaRowShape$1> = {
263
- column: ResolvedFilterColumnKey$1<Row>;
264
- ascending?: boolean;
265
- } | Partial<Record<ResolvedFilterColumnKey$1<Row>, AthenaOrderByDirectionInput>>;
266
- interface AthenaFindManyOptions<Row = AthenaRowShape$1, TSelect extends AthenaSelectShape = AthenaSelectShape> {
267
- select: TSelect;
268
- where?: AthenaWhere<Row>;
269
- orderBy?: AthenaOrderBy<Row>;
270
- limit?: number;
271
- }
272
- type AthenaModelContext<TRegistry extends GenericRegistryDef = GenericRegistryDef, TDatabase extends string = string, TSchema extends string = string, TModel extends AnyModelDef = AnyModelDef> = {
273
- registry: TRegistry;
274
- database: TDatabase;
275
- schema: TSchema;
276
- model: TModel;
277
- };
278
- type Simplify<T> = {
279
- [K in keyof T]: T[K];
280
- } & {};
281
- type ContextRegistry<TContext> = TContext extends AthenaModelContext<infer TRegistry, string, string, AnyModelDef> ? TRegistry : never;
282
- type ContextDatabase<TContext> = TContext extends AthenaModelContext<GenericRegistryDef, infer TDatabase, string, AnyModelDef> ? TDatabase : never;
283
- type ContextModel<TContext> = TContext extends AthenaModelContext<GenericRegistryDef, string, string, infer TModel> ? TModel : never;
284
- type ModelMetaOf<TContext> = ContextModel<TContext> extends ModelDef<unknown, unknown, unknown, infer TMeta> ? TMeta : never;
285
- type ModelRelationsOf<TContext> = NonNullable<ModelMetaOf<TContext>['relations']>;
286
- type SelectedResultKey<TKey extends string, TValue> = TValue extends {
287
- as: infer TAlias extends string;
288
- } ? TAlias : TKey;
289
- type ScalarSelectionResult<Row, TSelect extends AthenaSelectShape> = {
290
- [TKey in Extract<keyof TSelect, string> as TSelect[TKey] extends true ? TKey : never]-?: TKey extends keyof NonNullable<Row> ? NonNullable<Row>[TKey] : unknown;
291
- };
292
- type RelationByKey<TContext, TKey extends string> = TKey extends keyof ModelRelationsOf<TContext> ? ModelRelationsOf<TContext>[TKey] : never;
293
- type RelationByVia<TContext, TVia extends string> = {
294
- [TKey in keyof ModelRelationsOf<TContext>]: ModelRelationsOf<TContext>[TKey] extends infer TRelation ? TRelation extends ModelRelationMetadata ? TVia extends TRelation['sourceColumns'][number] ? TRelation : never : never : never;
295
- }[keyof ModelRelationsOf<TContext>];
296
- type ResolvedRelation<TContext, TKey extends string, TValue> = RelationByKey<TContext, TKey> extends never ? TValue extends {
297
- via: infer TVia extends string;
298
- } ? RelationByVia<TContext, TVia> : never : RelationByKey<TContext, TKey>;
299
- type TargetDatabaseName<TContext, TRelation extends ModelRelationMetadata> = TRelation['targetDatabase'] extends string ? TRelation['targetDatabase'] : ContextDatabase<TContext>;
300
- 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;
301
- 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;
302
- type RelationSelectionResult<TContext, TSelect extends AthenaSelectShape> = {
303
- [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;
304
- };
305
- type AthenaFindManyResult<Row, TSelect extends AthenaSelectShape, TContext = unknown> = Simplify<ScalarSelectionResult<Row, TSelect> & RelationSelectionResult<TContext, TSelect>>;
306
-
307
- interface AthenaResult<T> {
308
- data: T | null;
309
- error: AthenaResultError | null;
310
- statusText?: string | null;
311
- /**
312
- * @deprecated Prefer `error?.gatewayCode`, `error?.hint`, and related fields on `error`.
313
- */
314
- errorDetails?: AthenaGatewayErrorDetails | null;
315
- status: number;
316
- count?: number | null;
317
- raw: unknown;
318
- }
319
- interface AthenaResultError {
320
- message: string;
321
- code: string | null;
322
- athenaCode: NormalizedAthenaError['code'];
323
- gatewayCode?: AthenaGatewayErrorDetails['code'] | null;
324
- kind: NormalizedAthenaError['kind'];
325
- category: NormalizedAthenaError['category'];
326
- retryable: boolean;
327
- details: unknown | null;
328
- hint: string | null;
329
- status: number;
330
- statusText: string | null;
331
- constraint?: string;
332
- table?: string;
333
- operation?: string;
334
- endpoint?: AthenaGatewayErrorDetails['endpoint'];
335
- method?: AthenaGatewayErrorDetails['method'];
336
- requestId?: string;
337
- cause?: string;
338
- raw: unknown;
339
- }
340
- interface AthenaClientExperimentalOptions {
341
- /**
342
- * @deprecated Failed `AthenaResult` values now include normalized structured `error`
343
- * envelopes by default. This flag is retained as a no-op compatibility switch.
344
- */
345
- enableErrorNormalization?: boolean;
346
- /**
347
- * Retry retryable read failures (`select`, `findMany`, `query`) with a fixed internal policy.
348
- *
349
- * Applies two additional attempts with exponential backoff and jitter.
350
- */
351
- retryReads?: boolean;
352
- /**
353
- * Emit execution diagnostics for every query/mutation/RPC invocation.
354
- * Includes payload, synthesized SQL, full outcome, and best-effort callsite metadata.
355
- */
356
- traceQueries?: boolean | AthenaQueryTraceOptions;
357
- /**
358
- * Send the original `findMany(...)` AST body for clean object-select reads.
359
- * This requires gateway support and falls back to legacy compiled transport
360
- * when a chain carries filter/pagination state that the AST payload cannot
361
- * represent losslessly yet.
362
- */
363
- findManyAst?: boolean;
364
- }
365
- interface AthenaQueryTraceOptions {
366
- /**
367
- * Custom sink for trace events. Defaults to console.info.
368
- */
369
- logger?: (event: AthenaQueryTraceEvent) => void;
370
- }
371
- interface AthenaQueryTraceCallsite {
372
- filePath: string;
373
- fileName: string;
374
- line: number;
375
- column: number;
376
- frame?: string;
377
- functionName?: string;
378
- }
379
- interface AthenaQueryTraceEvent {
380
- timestamp: string;
381
- durationMs: number;
382
- operation: 'select' | 'insert' | 'upsert' | 'update' | 'delete' | 'rpc' | 'query';
383
- endpoint: '/gateway/fetch' | '/gateway/insert' | '/gateway/update' | '/gateway/delete' | '/gateway/rpc' | '/gateway/query' | `/rpc/${string}`;
384
- table?: string;
385
- functionName?: string;
386
- sql: string;
387
- payload: unknown;
388
- options?: AthenaGatewayCallOptions | AthenaRpcCallOptions;
389
- callsite: AthenaQueryTraceCallsite | null;
390
- outcome?: {
391
- status: number;
392
- error: AthenaResultError | null;
393
- errorDetails?: AthenaGatewayErrorDetails | null;
394
- count?: number | null;
395
- data: unknown;
396
- raw: unknown;
397
- };
398
- thrownError?: unknown;
399
- }
400
- type MutationSingleResult<Result> = Result extends Array<infer Item> ? Item | null : Result | null;
401
- type AthenaRowShape = Record<string, AthenaJsonValue | undefined>;
402
- type FilterColumnKey<Row> = Extract<keyof NonNullable<Row>, string>;
403
- type ResolvedFilterColumnKey<Row> = [FilterColumnKey<Row>] extends [never] ? string : FilterColumnKey<Row>;
404
- interface MutationQuery<Result> extends PromiseLike<AthenaResult<Result>> {
405
- select(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<Result>>;
406
- returning(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<Result>>;
407
- single(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<MutationSingleResult<Result>>>;
408
- maybeSingle(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<MutationSingleResult<Result>>>;
409
- 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>;
410
- catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<AthenaResult<Result> | TResult>;
411
- finally(onfinally?: (() => void) | undefined | null): Promise<AthenaResult<Result>>;
412
- }
413
- interface OrderOptions {
414
- ascending?: boolean;
415
- }
416
- /** Shared filter chain - supports eq, limit, etc. in any order relative to select/update */
417
- interface FilterChain<Self, Row> {
418
- eq(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
419
- eqCast(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue, cast: AthenaConditionCastType): Self;
420
- eqUuid(column: ResolvedFilterColumnKey<Row>, value: string): Self;
421
- match(filters: Partial<Record<ResolvedFilterColumnKey<Row>, AthenaConditionValue>>): Self;
422
- range(from: number, to: number): Self;
423
- limit(count: number): Self;
424
- offset(count: number): Self;
425
- currentPage(value: number): Self;
426
- pageSize(value: number): Self;
427
- totalPages(value: number): Self;
428
- order(column: ResolvedFilterColumnKey<Row>, options?: OrderOptions): Self;
429
- gt(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
430
- gte(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
431
- lt(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
432
- lte(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
433
- neq(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
434
- like(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
435
- ilike(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
436
- is(column: ResolvedFilterColumnKey<Row>, value: AthenaConditionValue): Self;
437
- in(column: ResolvedFilterColumnKey<Row>, values: AthenaConditionArrayValue): Self;
438
- contains(column: ResolvedFilterColumnKey<Row>, values: AthenaConditionArrayValue): Self;
439
- containedBy(column: ResolvedFilterColumnKey<Row>, values: AthenaConditionArrayValue): Self;
440
- not(columnOrExpression: ResolvedFilterColumnKey<Row> | string, operator?: AthenaConditionOperator, value?: AthenaConditionValue): Self;
441
- or(expression: string): Self;
442
- }
443
- /** Chain returned by select() - supports filters and single/maybeSingle before execution */
444
- interface SelectChain<Row, SelectedRow = Row> extends FilterChain<SelectChain<Row, SelectedRow>, Row>, PromiseLike<AthenaResult<SelectedRow[]>> {
445
- single<T = SelectedRow>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
446
- maybeSingle<T = SelectedRow>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
447
- }
448
- /** Chain returned by update() - supports filters before execution, plus select/returning */
449
- interface UpdateChain<Row> extends FilterChain<UpdateChain<Row>, Row>, MutationQuery<Row[]> {
450
- }
451
- interface RpcFilterChain<Self> {
452
- eq(column: string, value: AthenaConditionValue): Self;
453
- neq(column: string, value: AthenaConditionValue): Self;
454
- gt(column: string, value: AthenaConditionValue): Self;
455
- gte(column: string, value: AthenaConditionValue): Self;
456
- lt(column: string, value: AthenaConditionValue): Self;
457
- lte(column: string, value: AthenaConditionValue): Self;
458
- like(column: string, value: AthenaConditionValue): Self;
459
- ilike(column: string, value: AthenaConditionValue): Self;
460
- is(column: string, value: AthenaConditionValue): Self;
461
- in(column: string, values: AthenaConditionArrayValue): Self;
462
- }
463
- interface RpcOrderOptions {
464
- ascending?: boolean;
465
- }
466
- interface RpcQueryBuilder<Row> extends RpcFilterChain<RpcQueryBuilder<Row>>, PromiseLike<AthenaResult<Row[]>> {
467
- select(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<Row[]>>;
468
- single<T = Row>(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<T | null>>;
469
- maybeSingle<T = Row>(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<T | null>>;
470
- order(column: string, options?: RpcOrderOptions): RpcQueryBuilder<Row>;
471
- limit(count: number): RpcQueryBuilder<Row>;
472
- offset(count: number): RpcQueryBuilder<Row>;
473
- range(from: number, to: number): RpcQueryBuilder<Row>;
474
- }
475
- interface AthenaFromOptions {
476
- schema?: string;
477
- }
478
- interface TableQueryBuilder<Row, Insert = Partial<Row>, Update = Partial<Insert>, TContext = unknown> extends FilterChain<TableQueryBuilder<Row, Insert, Update, TContext>, Row> {
479
- select<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): SelectChain<Row, T>;
480
- findMany<const TSelect extends AthenaSelectShape>(options: AthenaFindManyOptions<Row, TSelect> & {
481
- select: AthenaValidatedSelectShape<TSelect>;
482
- }): Promise<AthenaResult<Array<AthenaFindManyResult<Row, TSelect, TContext>>>>;
483
- insert(values: Insert, options?: AthenaGatewayCallOptions): MutationQuery<Row>;
484
- insert(values: Insert[], options?: AthenaGatewayCallOptions): MutationQuery<Row[]>;
485
- upsert(values: Insert, options?: AthenaGatewayCallOptions & {
486
- updateBody?: Update;
487
- onConflict?: string | string[];
488
- }): MutationQuery<Row>;
489
- upsert(values: Insert[], options?: AthenaGatewayCallOptions & {
490
- updateBody?: Update;
491
- onConflict?: string | string[];
492
- }): MutationQuery<Row[]>;
493
- update(values: Update, options?: AthenaGatewayCallOptions): UpdateChain<Row>;
494
- delete(options?: AthenaGatewayCallOptions & {
495
- resourceId?: string;
496
- }): MutationQuery<Row | null>;
497
- single<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
498
- maybeSingle<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
499
- reset(): TableQueryBuilder<Row, Insert, Update, TContext>;
500
- }
501
- interface AthenaSdkClient {
502
- from<Row = AthenaRowShape, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, options?: AthenaFromOptions): TableQueryBuilder<Row, Insert, Update>;
503
- db: AthenaDbModule;
504
- rpc<Row = unknown, Args extends AthenaJsonObject = AthenaJsonObject>(fn: string, args?: Args, options?: AthenaRpcCallOptions): RpcQueryBuilder<Row>;
505
- query<Row = unknown>(query: string, options?: AthenaGatewayCallOptions): Promise<AthenaResult<Row[]>>;
506
- verifyConnection(options?: AthenaGatewayConnectionOptions): Promise<AthenaGatewayConnectionResult>;
507
- }
508
- interface AthenaSdkClientWithAuth extends AthenaSdkClient {
509
- auth: AthenaAuthBindings;
510
- }
511
- interface AthenaClientBuilder {
512
- /** Set the gateway base URL. */
513
- url(url: string): AthenaClientBuilder;
514
- /** Set the API key used for all requests. */
515
- key(apiKey: string): AthenaClientBuilder;
516
- /** Set the default backend routing strategy. */
517
- backend(backend: BackendConfig | BackendType): AthenaClientBuilder;
518
- /** Set the default Athena client routing key. */
519
- client(clientName: string): AthenaClientBuilder;
520
- /** Attach static headers to every request. */
521
- headers(headers: Record<string, string>): AthenaClientBuilder;
522
- /** Configure Athena Auth client behavior for `client.auth.*` methods. */
523
- auth(config: AthenaAuthClientConfig): AthenaClientBuilder;
524
- /** Configure experimental client options (for example query tracing or findMany AST transport). */
525
- experimental(options: AthenaClientExperimentalOptions): AthenaClientBuilder;
526
- /** Apply the same options object accepted by `createClient(url, key, options)`. */
527
- options(options: AthenaCreateClientOptions): AthenaClientBuilder;
528
- /** Build the immutable Athena SDK client. */
529
- build(): AthenaSdkClientWithAuth;
530
- }
531
- /** Canonical Athena client factory with builder-based configuration. */
532
- declare class AthenaClient {
533
- /** Create a fluent builder for a strongly-typed Athena SDK client. */
534
- static builder(): AthenaClientBuilder;
535
- /** Build a client from process environment variables. */
536
- static fromEnvironment(): AthenaSdkClientWithAuth;
537
- }
538
- interface AthenaCreateClientOptions extends Pick<AthenaGatewayCallOptions, 'client' | 'headers' | 'backend'> {
539
- auth?: AthenaAuthClientConfig;
540
- experimental?: AthenaClientExperimentalOptions;
541
- }
542
- /** Create client (convenience wrapper; use AthenaClient.builder() for full control) */
543
- declare function createClient(url: string, apiKey: string, options?: AthenaCreateClientOptions): AthenaSdkClientWithAuth;
544
-
545
- declare function verifyAthenaGatewayUrl(baseUrl: string, options?: AthenaGatewayConnectionOptions): Promise<AthenaGatewayConnectionResult>;
546
-
547
- interface NormalizeAthenaGatewayBaseUrlOptions {
548
- defaultBaseUrl?: string;
549
- label?: string;
550
- }
551
- declare function normalizeAthenaGatewayBaseUrl(input: string | null | undefined, options?: NormalizeAthenaGatewayBaseUrlOptions): string;
552
-
553
- /**
554
- * Immutable identifier object with consistent SQL rendering.
555
- */
556
- interface SqlIdentifier {
557
- readonly segments: string[];
558
- toSql(): string;
559
- toString(): string;
560
- }
561
- /**
562
- * Creates a quoted identifier object from segment or dotted inputs.
563
- */
564
- declare function identifier(...segments: string[]): SqlIdentifier;
565
-
566
- /**
567
- * Declares a model contract with explicit metadata and typed row/insert/update shapes.
568
- */
569
- declare function defineModel<Row, Insert = Partial<Row>, Update = Partial<Insert>, Meta extends ModelMetadata<Row> = ModelMetadata<Row>>(input: {
570
- meta: Meta;
571
- }): ModelDef<Row, Insert, Update, Meta>;
572
- /**
573
- * Declares a schema-level model map.
574
- */
575
- declare function defineSchema<Models extends Record<string, AnyModelDef>>(models: Models): SchemaDef<Models>;
576
- /**
577
- * Declares a database-level schema map.
578
- */
579
- declare function defineDatabase<Schemas extends Record<string, SchemaDef<Record<string, AnyModelDef>>>>(schemas: Schemas): DatabaseDef<Schemas>;
580
- /**
581
- * Declares a top-level multi-database registry.
582
- */
583
- declare function defineRegistry<Databases extends Record<string, DatabaseDef<Record<string, SchemaDef<Record<string, AnyModelDef>>>>>>(databases: Databases): RegistryDef<Databases>;
584
-
585
- type RegistryConstraint = RegistryDef<Record<string, DatabaseDef<Record<string, SchemaDef<Record<string, AnyModelDef>>>>>>;
586
- /**
587
- * Options for creating typed Athena clients.
588
- */
589
- interface TypedClientOptions<TMap extends TenantKeyMap = TenantKeyMap> extends Pick<AthenaGatewayCallOptions, 'backend' | 'client' | 'headers'> {
590
- tenantKeyMap?: TMap;
591
- tenantContext?: TenantContext<TMap>;
592
- }
593
- /**
594
- * Typed Athena client with registry-driven model resolution and tenant-context propagation.
595
- */
596
- interface TypedAthenaClient<TRegistry extends RegistryConstraint, TTenantMap extends TenantKeyMap = Record<never, string>> extends AthenaSdkClient {
597
- readonly registry: TRegistry;
598
- readonly tenantKeyMap: Readonly<TTenantMap>;
599
- readonly tenantContext: TenantContext<TTenantMap>;
600
- withTenantContext(context: TenantContext<TTenantMap>): TypedAthenaClient<TRegistry, TTenantMap>;
601
- 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>>, {
602
- registry: TRegistry;
603
- database: TDatabase;
604
- schema: TSchema;
605
- model: ModelAt<TRegistry, TDatabase, TSchema, TModel>;
606
- }>;
607
- }
608
- /**
609
- * Creates a typed client bound to a registry contract and optional tenant header mapping.
610
- */
611
- declare function createTypedClient<TRegistry extends RegistryConstraint, TTenantMap extends TenantKeyMap = Record<never, string>>(registry: TRegistry, url: string, apiKey: string, options?: TypedClientOptions<TTenantMap>): TypedAthenaClient<TRegistry, TTenantMap>;
612
-
613
- /**
614
- * Constructor options for the PostgreSQL introspection provider.
615
- */
616
- interface PostgresIntrospectionProviderOptions {
617
- connectionString: string;
618
- database?: string;
619
- schemas?: readonly string[];
620
- }
621
- /**
622
- * Creates a PostgreSQL-backed schema introspection provider.
623
- */
624
- declare function createPostgresIntrospectionProvider(options: PostgresIntrospectionProviderOptions): SchemaIntrospectionProvider;
625
-
626
- declare function resolvePostgresColumnType(column: IntrospectionColumn): string;
627
-
628
- declare const DEFAULT_POSTGRES_SCHEMAS: readonly ["public"];
629
- /**
630
- * Normalizes schema selection from config or env-backed strings into a stable,
631
- * deduplicated list. Empty selections fall back to PostgreSQL's public schema.
632
- */
633
- declare function normalizeSchemaSelection(input: GeneratorSchemaSelection | undefined): string[];
634
- /**
635
- * Resolves the effective schema list for provider-backed generator runs.
636
- */
637
- declare function resolveProviderSchemas(providerConfig: GeneratorProviderConfig): string[];
638
-
639
- /**
640
- * @deprecated Prefer `createClient(...).auth` from `@xylex-group/athena`.
641
- */
642
- declare function createAuthClient(config?: AthenaAuthClientConfig): AthenaAuthSdkClient;
643
-
644
- interface AthenaAuthRenderedReactEmail {
645
- html: string;
646
- text?: string;
647
- }
648
- interface AthenaAuthReactEmailRuntimeOptions {
649
- route?: string;
650
- defaults?: AthenaAuthReactEmailRenderOptions;
651
- observe?: (event: AthenaAuthReactEmailRenderEvent) => void;
652
- }
653
- declare function createAuthReactEmailInput<TProps extends AthenaAuthReactEmailProps = AthenaAuthReactEmailProps>(component: AthenaAuthReactEmailComponent<TProps>, props: TProps, overrides?: Omit<AthenaAuthReactEmailRenderInput, 'component' | 'props' | 'element'>): AthenaAuthReactEmailRenderInput;
654
- declare function defineAuthEmailTemplate<TProps extends AthenaAuthReactEmailProps = AthenaAuthReactEmailProps>(definition: AthenaAuthEmailTemplateDefinition<TProps>): AthenaAuthEmailTemplateBuilder<TProps>;
655
- declare function renderAthenaReactEmail(input: AthenaAuthReactEmailRenderInput, options?: AthenaAuthReactEmailRuntimeOptions | AthenaAuthReactEmailConfig): Promise<AthenaAuthRenderedReactEmail>;
656
-
657
- export { isOk as $, AthenaClient as A, type RetryConfig as B, type RpcOrderOptions as C, DEFAULT_POSTGRES_SCHEMAS as D, type RpcQueryBuilder as E, type TypedAthenaClient as F, type TypedClientOptions as G, type UnwrapOptions as H, type IntCoercionOptions as I, assertInt as J, coerceInt as K, createAuthClient as L, createAuthReactEmailInput as M, type NormalizedAthenaError as N, createClient as O, type PostgresIntrospectionProviderOptions as P, createPostgresIntrospectionProvider as Q, type RequireAffectedOptions as R, createTypedClient as S, type TableQueryBuilder as T, type UnwrapOneOptions as U, defineAuthEmailTemplate as V, defineDatabase as W, defineModel as X, defineRegistry as Y, defineSchema as Z, identifier as _, type AthenaClientExperimentalOptions as a, normalizeAthenaError as a0, normalizeAthenaGatewayBaseUrl as a1, normalizeSchemaSelection as a2, parseBooleanFlag as a3, renderAthenaReactEmail as a4, requireAffected as a5, requireSuccess as a6, resolvePostgresColumnType as a7, resolveProviderSchemas as a8, unwrap as a9, unwrapOne as aa, unwrapRows as ab, verifyAthenaGatewayUrl as ac, withRetry as ad, 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 AthenaFromOptions as k, type AthenaOperationContext as l, type AthenaOrderBy as m, type AthenaQueryTraceCallsite as n, type AthenaQueryTraceEvent as o, type AthenaQueryTraceOptions as p, type AthenaRelationSelectNode as q, type AthenaResult as r, type AthenaResultError as s, type AthenaSdkClient as t, type AthenaSdkClientWithAuth as u, type AthenaSelectShape as v, type AthenaWhere as w, type AthenaWhereBooleanOperand as x, type AthenaWhereOperatorInput as y, type RetryBackoffStrategy as z };