@xylex-group/athena 2.3.0 → 2.4.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 +124 -106
- package/dist/browser.cjs +584 -99
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +7 -7
- package/dist/browser.d.ts +7 -7
- package/dist/browser.js +583 -100
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +573 -97
- 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 +573 -97
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +584 -99
- 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 +583 -100
- package/dist/index.js.map +1 -1
- package/dist/{model-form-BpDXlbxb.d.ts → model-form-C0FAbOaf.d.ts} +1 -1
- package/dist/{model-form-hoE2jHIi.d.cts → model-form-GzTqhEzM.d.cts} +1 -1
- package/dist/{pipeline-BNIw8pDQ.d.ts → pipeline-CR4V15jF.d.ts} +1 -1
- package/dist/{pipeline-DNIpEsN8.d.cts → pipeline-DZeExYMA.d.cts} +1 -1
- package/dist/{react-email-BvyCZnfW.d.cts → react-email-BuApZuyG.d.ts} +19 -6
- package/dist/{react-email-qPA1wjFV.d.ts → react-email-CQJq92zQ.d.cts} +19 -6
- package/dist/react.cjs +249 -12
- 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 +249 -12
- package/dist/react.js.map +1 -1
- package/dist/{types-A5e97acl.d.cts → types-09Q4D86N.d.cts} +23 -2
- package/dist/{types-A5e97acl.d.ts → types-09Q4D86N.d.ts} +23 -2
- package/dist/{types-bDlr4u7p.d.cts → types-D1JvL21V.d.cts} +1 -1
- package/dist/{types-BnD22-vb.d.ts → types-DU3gNdFv.d.ts} +1 -1
- package/package.json +40 -40
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as AthenaGatewayErrorCode, Z as AthenaGatewayEndpointPath, _ as AthenaGatewayMethod, e as AthenaGatewayErrorDetails, W as AthenaGatewayResponse, L as AnyModelDef, E as RowOf, q as InsertOf, U as UpdateOf } from './types-09Q4D86N.js';
|
|
2
2
|
|
|
3
3
|
type AthenaAuthMethod = 'GET' | 'POST';
|
|
4
4
|
type AthenaAuthCredentials = 'omit' | 'same-origin' | 'include';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as AthenaGatewayErrorCode, Z as AthenaGatewayEndpointPath, _ as AthenaGatewayMethod, e as AthenaGatewayErrorDetails, W as AthenaGatewayResponse, L as AnyModelDef, E as RowOf, q as InsertOf, U as UpdateOf } from './types-09Q4D86N.cjs';
|
|
2
2
|
|
|
3
3
|
type AthenaAuthMethod = 'GET' | 'POST';
|
|
4
4
|
type AthenaAuthCredentials = 'omit' | 'same-origin' | 'include';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RunGeneratorOptions, l as RunGeneratorResult } from './types-
|
|
1
|
+
import { R as RunGeneratorOptions, l as RunGeneratorResult } from './types-DU3gNdFv.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* End-to-end generator execution: load config, introspect, render, and optionally write files.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RunGeneratorOptions, l as RunGeneratorResult } from './types-
|
|
1
|
+
import { R as RunGeneratorOptions, l as RunGeneratorResult } from './types-D1JvL21V.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* End-to-end generator execution: load config, introspect, render, and optionally write files.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
3
|
-
import { j as GeneratorSchemaSelection, b as GeneratorProviderConfig } from './types-
|
|
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.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-C0FAbOaf.js';
|
|
3
|
+
import { j as GeneratorSchemaSelection, b as GeneratorProviderConfig } from './types-DU3gNdFv.js';
|
|
4
4
|
|
|
5
5
|
type AthenaErrorKind = 'unique_violation' | 'not_found' | 'validation' | 'auth' | 'rate_limit' | 'transient' | 'unknown';
|
|
6
6
|
declare const AthenaErrorKind: {
|
|
@@ -183,7 +183,7 @@ type AthenaUpsertOptions<Update> = AthenaGatewayCallOptions & {
|
|
|
183
183
|
onConflict?: string | string[];
|
|
184
184
|
};
|
|
185
185
|
interface AthenaDbModule {
|
|
186
|
-
from<Row = AthenaRowShape$2, Insert = Partial<Row>, Update = Partial<Insert>>(table: string): TableQueryBuilder<Row, Insert, Update>;
|
|
186
|
+
from<Row = AthenaRowShape$2, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, options?: AthenaFromOptions): TableQueryBuilder<Row, Insert, Update>;
|
|
187
187
|
select<Row = AthenaRowShape$2, SelectedRow = Row>(table: string, columns?: string | string[], options?: AthenaGatewayCallOptions): SelectChain<Row, SelectedRow>;
|
|
188
188
|
insert<Row = AthenaRowShape$2, Insert = Partial<Row>>(table: string, values: Insert, options?: AthenaGatewayCallOptions): MutationQuery<Row>;
|
|
189
189
|
insert<Row = AthenaRowShape$2, Insert = Partial<Row>>(table: string, values: Insert[], options?: AthenaGatewayCallOptions): MutationQuery<Row[]>;
|
|
@@ -224,6 +224,7 @@ interface AthenaRelationSelectNode<TSelect extends AthenaSelectShape = AthenaSel
|
|
|
224
224
|
select: TSelect;
|
|
225
225
|
as?: string;
|
|
226
226
|
via?: string;
|
|
227
|
+
schema?: string;
|
|
227
228
|
}
|
|
228
229
|
type AthenaSelectShape = Record<string, true | AthenaRelationSelectNode<AthenaSelectShape>>;
|
|
229
230
|
type GenericRegistryDef = RegistryDef<Record<string, DatabaseDef<Record<string, SchemaDef<Record<string, AnyModelDef>>>>>>;
|
|
@@ -437,6 +438,9 @@ interface RpcQueryBuilder<Row> extends RpcFilterChain<RpcQueryBuilder<Row>>, Pro
|
|
|
437
438
|
offset(count: number): RpcQueryBuilder<Row>;
|
|
438
439
|
range(from: number, to: number): RpcQueryBuilder<Row>;
|
|
439
440
|
}
|
|
441
|
+
interface AthenaFromOptions {
|
|
442
|
+
schema?: string;
|
|
443
|
+
}
|
|
440
444
|
interface TableQueryBuilder<Row, Insert = Partial<Row>, Update = Partial<Insert>, TContext = unknown> extends FilterChain<TableQueryBuilder<Row, Insert, Update, TContext>, Row> {
|
|
441
445
|
select<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): SelectChain<Row, T>;
|
|
442
446
|
findMany<const TSelect extends AthenaSelectShape>(options: AthenaFindManyOptions<Row, TSelect>): Promise<AthenaResult<Array<AthenaFindManyResult<Row, TSelect, TContext>>>>;
|
|
@@ -459,10 +463,11 @@ interface TableQueryBuilder<Row, Insert = Partial<Row>, Update = Partial<Insert>
|
|
|
459
463
|
reset(): TableQueryBuilder<Row, Insert, Update, TContext>;
|
|
460
464
|
}
|
|
461
465
|
interface AthenaSdkClient {
|
|
462
|
-
from<Row = AthenaRowShape, Insert = Partial<Row>, Update = Partial<Insert>>(table: string): TableQueryBuilder<Row, Insert, Update>;
|
|
466
|
+
from<Row = AthenaRowShape, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, options?: AthenaFromOptions): TableQueryBuilder<Row, Insert, Update>;
|
|
463
467
|
db: AthenaDbModule;
|
|
464
468
|
rpc<Row = unknown, Args extends AthenaJsonObject = AthenaJsonObject>(fn: string, args?: Args, options?: AthenaRpcCallOptions): RpcQueryBuilder<Row>;
|
|
465
469
|
query<Row = unknown>(query: string, options?: AthenaGatewayCallOptions): Promise<AthenaResult<Row[]>>;
|
|
470
|
+
verifyConnection(options?: AthenaGatewayConnectionOptions): Promise<AthenaGatewayConnectionResult>;
|
|
466
471
|
}
|
|
467
472
|
interface AthenaSdkClientWithAuth extends AthenaSdkClient {
|
|
468
473
|
auth: AthenaAuthBindings;
|
|
@@ -503,6 +508,14 @@ interface AthenaCreateClientOptions extends Pick<AthenaGatewayCallOptions, 'clie
|
|
|
503
508
|
/** Create client (convenience wrapper; use AthenaClient.builder() for full control) */
|
|
504
509
|
declare function createClient(url: string, apiKey: string, options?: AthenaCreateClientOptions): AthenaSdkClientWithAuth;
|
|
505
510
|
|
|
511
|
+
declare function verifyAthenaGatewayUrl(baseUrl: string, options?: AthenaGatewayConnectionOptions): Promise<AthenaGatewayConnectionResult>;
|
|
512
|
+
|
|
513
|
+
interface NormalizeAthenaGatewayBaseUrlOptions {
|
|
514
|
+
defaultBaseUrl?: string;
|
|
515
|
+
label?: string;
|
|
516
|
+
}
|
|
517
|
+
declare function normalizeAthenaGatewayBaseUrl(input: string | null | undefined, options?: NormalizeAthenaGatewayBaseUrlOptions): string;
|
|
518
|
+
|
|
506
519
|
/**
|
|
507
520
|
* Immutable identifier object with consistent SQL rendering.
|
|
508
521
|
*/
|
|
@@ -607,4 +620,4 @@ declare function createAuthReactEmailInput<TProps extends AthenaAuthReactEmailPr
|
|
|
607
620
|
declare function defineAuthEmailTemplate<TProps extends AthenaAuthReactEmailProps = AthenaAuthReactEmailProps>(definition: AthenaAuthEmailTemplateDefinition<TProps>): AthenaAuthEmailTemplateBuilder<TProps>;
|
|
608
621
|
declare function renderAthenaReactEmail(input: AthenaAuthReactEmailRenderInput, options?: AthenaAuthReactEmailRuntimeOptions | AthenaAuthReactEmailConfig): Promise<AthenaAuthRenderedReactEmail>;
|
|
609
622
|
|
|
610
|
-
export {
|
|
623
|
+
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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
3
|
-
import { j as GeneratorSchemaSelection, b as GeneratorProviderConfig } from './types-
|
|
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 { 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-GzTqhEzM.cjs';
|
|
3
|
+
import { j as GeneratorSchemaSelection, b as GeneratorProviderConfig } from './types-D1JvL21V.cjs';
|
|
4
4
|
|
|
5
5
|
type AthenaErrorKind = 'unique_violation' | 'not_found' | 'validation' | 'auth' | 'rate_limit' | 'transient' | 'unknown';
|
|
6
6
|
declare const AthenaErrorKind: {
|
|
@@ -183,7 +183,7 @@ type AthenaUpsertOptions<Update> = AthenaGatewayCallOptions & {
|
|
|
183
183
|
onConflict?: string | string[];
|
|
184
184
|
};
|
|
185
185
|
interface AthenaDbModule {
|
|
186
|
-
from<Row = AthenaRowShape$2, Insert = Partial<Row>, Update = Partial<Insert>>(table: string): TableQueryBuilder<Row, Insert, Update>;
|
|
186
|
+
from<Row = AthenaRowShape$2, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, options?: AthenaFromOptions): TableQueryBuilder<Row, Insert, Update>;
|
|
187
187
|
select<Row = AthenaRowShape$2, SelectedRow = Row>(table: string, columns?: string | string[], options?: AthenaGatewayCallOptions): SelectChain<Row, SelectedRow>;
|
|
188
188
|
insert<Row = AthenaRowShape$2, Insert = Partial<Row>>(table: string, values: Insert, options?: AthenaGatewayCallOptions): MutationQuery<Row>;
|
|
189
189
|
insert<Row = AthenaRowShape$2, Insert = Partial<Row>>(table: string, values: Insert[], options?: AthenaGatewayCallOptions): MutationQuery<Row[]>;
|
|
@@ -224,6 +224,7 @@ interface AthenaRelationSelectNode<TSelect extends AthenaSelectShape = AthenaSel
|
|
|
224
224
|
select: TSelect;
|
|
225
225
|
as?: string;
|
|
226
226
|
via?: string;
|
|
227
|
+
schema?: string;
|
|
227
228
|
}
|
|
228
229
|
type AthenaSelectShape = Record<string, true | AthenaRelationSelectNode<AthenaSelectShape>>;
|
|
229
230
|
type GenericRegistryDef = RegistryDef<Record<string, DatabaseDef<Record<string, SchemaDef<Record<string, AnyModelDef>>>>>>;
|
|
@@ -437,6 +438,9 @@ interface RpcQueryBuilder<Row> extends RpcFilterChain<RpcQueryBuilder<Row>>, Pro
|
|
|
437
438
|
offset(count: number): RpcQueryBuilder<Row>;
|
|
438
439
|
range(from: number, to: number): RpcQueryBuilder<Row>;
|
|
439
440
|
}
|
|
441
|
+
interface AthenaFromOptions {
|
|
442
|
+
schema?: string;
|
|
443
|
+
}
|
|
440
444
|
interface TableQueryBuilder<Row, Insert = Partial<Row>, Update = Partial<Insert>, TContext = unknown> extends FilterChain<TableQueryBuilder<Row, Insert, Update, TContext>, Row> {
|
|
441
445
|
select<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): SelectChain<Row, T>;
|
|
442
446
|
findMany<const TSelect extends AthenaSelectShape>(options: AthenaFindManyOptions<Row, TSelect>): Promise<AthenaResult<Array<AthenaFindManyResult<Row, TSelect, TContext>>>>;
|
|
@@ -459,10 +463,11 @@ interface TableQueryBuilder<Row, Insert = Partial<Row>, Update = Partial<Insert>
|
|
|
459
463
|
reset(): TableQueryBuilder<Row, Insert, Update, TContext>;
|
|
460
464
|
}
|
|
461
465
|
interface AthenaSdkClient {
|
|
462
|
-
from<Row = AthenaRowShape, Insert = Partial<Row>, Update = Partial<Insert>>(table: string): TableQueryBuilder<Row, Insert, Update>;
|
|
466
|
+
from<Row = AthenaRowShape, Insert = Partial<Row>, Update = Partial<Insert>>(table: string, options?: AthenaFromOptions): TableQueryBuilder<Row, Insert, Update>;
|
|
463
467
|
db: AthenaDbModule;
|
|
464
468
|
rpc<Row = unknown, Args extends AthenaJsonObject = AthenaJsonObject>(fn: string, args?: Args, options?: AthenaRpcCallOptions): RpcQueryBuilder<Row>;
|
|
465
469
|
query<Row = unknown>(query: string, options?: AthenaGatewayCallOptions): Promise<AthenaResult<Row[]>>;
|
|
470
|
+
verifyConnection(options?: AthenaGatewayConnectionOptions): Promise<AthenaGatewayConnectionResult>;
|
|
466
471
|
}
|
|
467
472
|
interface AthenaSdkClientWithAuth extends AthenaSdkClient {
|
|
468
473
|
auth: AthenaAuthBindings;
|
|
@@ -503,6 +508,14 @@ interface AthenaCreateClientOptions extends Pick<AthenaGatewayCallOptions, 'clie
|
|
|
503
508
|
/** Create client (convenience wrapper; use AthenaClient.builder() for full control) */
|
|
504
509
|
declare function createClient(url: string, apiKey: string, options?: AthenaCreateClientOptions): AthenaSdkClientWithAuth;
|
|
505
510
|
|
|
511
|
+
declare function verifyAthenaGatewayUrl(baseUrl: string, options?: AthenaGatewayConnectionOptions): Promise<AthenaGatewayConnectionResult>;
|
|
512
|
+
|
|
513
|
+
interface NormalizeAthenaGatewayBaseUrlOptions {
|
|
514
|
+
defaultBaseUrl?: string;
|
|
515
|
+
label?: string;
|
|
516
|
+
}
|
|
517
|
+
declare function normalizeAthenaGatewayBaseUrl(input: string | null | undefined, options?: NormalizeAthenaGatewayBaseUrlOptions): string;
|
|
518
|
+
|
|
506
519
|
/**
|
|
507
520
|
* Immutable identifier object with consistent SQL rendering.
|
|
508
521
|
*/
|
|
@@ -607,4 +620,4 @@ declare function createAuthReactEmailInput<TProps extends AthenaAuthReactEmailPr
|
|
|
607
620
|
declare function defineAuthEmailTemplate<TProps extends AthenaAuthReactEmailProps = AthenaAuthReactEmailProps>(definition: AthenaAuthEmailTemplateDefinition<TProps>): AthenaAuthEmailTemplateBuilder<TProps>;
|
|
608
621
|
declare function renderAthenaReactEmail(input: AthenaAuthReactEmailRenderInput, options?: AthenaAuthReactEmailRuntimeOptions | AthenaAuthReactEmailConfig): Promise<AthenaAuthRenderedReactEmail>;
|
|
609
622
|
|
|
610
|
-
export {
|
|
623
|
+
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 };
|
package/dist/react.cjs
CHANGED
|
@@ -65,8 +65,74 @@ function isAthenaGatewayError(error) {
|
|
|
65
65
|
return error instanceof AthenaGatewayError;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// src/gateway/url.ts
|
|
69
|
+
var ATHENA_DEFAULT_BASE_URL = "https://athena-db.com";
|
|
70
|
+
function describeReceivedValue(value) {
|
|
71
|
+
if (value === void 0) return "undefined";
|
|
72
|
+
if (value === null) return "null";
|
|
73
|
+
if (typeof value === "string") {
|
|
74
|
+
return value.trim().length > 0 ? JSON.stringify(value) : "an empty string";
|
|
75
|
+
}
|
|
76
|
+
return `${typeof value} ${JSON.stringify(value)}`;
|
|
77
|
+
}
|
|
78
|
+
function invalidBaseUrlError(message, hint) {
|
|
79
|
+
return new AthenaGatewayError({
|
|
80
|
+
code: "INVALID_URL",
|
|
81
|
+
message,
|
|
82
|
+
status: 0,
|
|
83
|
+
hint
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function normalizeAthenaGatewayBaseUrl(input, options = {}) {
|
|
87
|
+
const label = options.label ?? "Athena gateway base URL";
|
|
88
|
+
const candidate = input ?? options.defaultBaseUrl;
|
|
89
|
+
if (candidate === void 0 || candidate === null) {
|
|
90
|
+
throw invalidBaseUrlError(
|
|
91
|
+
`${label} must be a non-empty absolute http(s) URL. Received ${describeReceivedValue(input)}.`,
|
|
92
|
+
'Set ATHENA_URL (or pass createClient(url, ...)) to a full URL such as "https://mirror3.athena-db.com".'
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const trimmed = candidate.trim();
|
|
96
|
+
if (!trimmed) {
|
|
97
|
+
throw invalidBaseUrlError(
|
|
98
|
+
`${label} must be a non-empty absolute http(s) URL. Received ${describeReceivedValue(candidate)}.`,
|
|
99
|
+
'Set ATHENA_URL (or pass createClient(url, ...)) to a full URL such as "https://mirror3.athena-db.com".'
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
let parsed;
|
|
103
|
+
try {
|
|
104
|
+
parsed = new URL(trimmed);
|
|
105
|
+
} catch {
|
|
106
|
+
throw invalidBaseUrlError(
|
|
107
|
+
`${label} must be a valid absolute http(s) URL. Received ${describeReceivedValue(candidate)}.`,
|
|
108
|
+
'Use a full URL including the protocol, for example "https://mirror3.athena-db.com".'
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
112
|
+
throw invalidBaseUrlError(
|
|
113
|
+
`${label} must use http or https. Received ${JSON.stringify(trimmed)}.`,
|
|
114
|
+
'Use an Athena gateway URL such as "https://mirror3.athena-db.com".'
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
if (parsed.search || parsed.hash) {
|
|
118
|
+
throw invalidBaseUrlError(
|
|
119
|
+
`${label} must not include query parameters or hash fragments. Received ${JSON.stringify(trimmed)}.`,
|
|
120
|
+
'Pass only the base URL. Endpoint paths such as "/gateway/fetch" are appended by the SDK.'
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
return parsed.toString().replace(/\/+$/, "");
|
|
124
|
+
}
|
|
125
|
+
function buildAthenaGatewayUrl(baseUrl, path) {
|
|
126
|
+
if (!path.startsWith("/")) {
|
|
127
|
+
throw invalidBaseUrlError(
|
|
128
|
+
`Athena gateway path must start with "/". Received ${JSON.stringify(path)}.`,
|
|
129
|
+
'Use a leading slash such as "/gateway/fetch" or "/".'
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return `${baseUrl}${path}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
68
135
|
// src/gateway/client.ts
|
|
69
|
-
var DEFAULT_BASE_URL = "https://athena-db.com";
|
|
70
136
|
var DEFAULT_CLIENT = "railway_direct";
|
|
71
137
|
var FALLBACK_SDK_VERSION = "1.3.0";
|
|
72
138
|
var SDK_NAME = "xylex-group/athena";
|
|
@@ -263,9 +329,168 @@ function buildHeaders(config, options) {
|
|
|
263
329
|
});
|
|
264
330
|
return headers;
|
|
265
331
|
}
|
|
332
|
+
function toInvalidUrlResponse(error, endpoint, method) {
|
|
333
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
334
|
+
const gatewayError = error instanceof AthenaGatewayError ? error : new AthenaGatewayError({
|
|
335
|
+
code: "INVALID_URL",
|
|
336
|
+
message,
|
|
337
|
+
status: 0,
|
|
338
|
+
endpoint,
|
|
339
|
+
method,
|
|
340
|
+
cause: message,
|
|
341
|
+
hint: "Set ATHENA_URL to a full http(s) URL before running queries."
|
|
342
|
+
});
|
|
343
|
+
return {
|
|
344
|
+
ok: false,
|
|
345
|
+
status: 0,
|
|
346
|
+
statusText: null,
|
|
347
|
+
data: null,
|
|
348
|
+
error: gatewayError.message,
|
|
349
|
+
errorDetails: detailsFromError(
|
|
350
|
+
new AthenaGatewayError({
|
|
351
|
+
code: gatewayError.code,
|
|
352
|
+
message: gatewayError.message,
|
|
353
|
+
status: gatewayError.status,
|
|
354
|
+
endpoint,
|
|
355
|
+
method,
|
|
356
|
+
requestId: gatewayError.requestId,
|
|
357
|
+
hint: gatewayError.hint,
|
|
358
|
+
cause: gatewayError.causeDetail
|
|
359
|
+
})
|
|
360
|
+
),
|
|
361
|
+
raw: null
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function resolveGatewayBaseUrl(input) {
|
|
365
|
+
return normalizeAthenaGatewayBaseUrl(input, {
|
|
366
|
+
defaultBaseUrl: ATHENA_DEFAULT_BASE_URL
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
function resolveProbePath(path) {
|
|
370
|
+
if (!path) return "/";
|
|
371
|
+
if (!path.startsWith("/")) {
|
|
372
|
+
throw new AthenaGatewayError({
|
|
373
|
+
code: "INVALID_URL",
|
|
374
|
+
message: `Athena gateway probe path must start with "/". Received ${JSON.stringify(path)}.`,
|
|
375
|
+
status: 0,
|
|
376
|
+
hint: 'Use a leading slash such as "/" or "/health".'
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
return path;
|
|
380
|
+
}
|
|
381
|
+
function mergeConnectionHeaders(baseHeaders, headers) {
|
|
382
|
+
const merged = {
|
|
383
|
+
...baseHeaders,
|
|
384
|
+
...headers ?? {}
|
|
385
|
+
};
|
|
386
|
+
if (!merged["X-Athena-Sdk"] && !merged["x-athena-sdk"]) {
|
|
387
|
+
merged["X-Athena-Sdk"] = SDK_HEADER_VALUE;
|
|
388
|
+
}
|
|
389
|
+
return merged;
|
|
390
|
+
}
|
|
391
|
+
async function performConnectionCheck(baseUrl, requestHeaders, options) {
|
|
392
|
+
const path = resolveProbePath(options?.path);
|
|
393
|
+
const url = buildAthenaGatewayUrl(baseUrl, path);
|
|
394
|
+
try {
|
|
395
|
+
const response = await fetch(url, {
|
|
396
|
+
method: "GET",
|
|
397
|
+
headers: mergeConnectionHeaders(requestHeaders, options?.headers),
|
|
398
|
+
signal: options?.signal
|
|
399
|
+
});
|
|
400
|
+
const rawText = await response.text();
|
|
401
|
+
const requestId = resolveRequestId(response.headers);
|
|
402
|
+
const parsedBody = parseResponseBody(
|
|
403
|
+
rawText ?? "",
|
|
404
|
+
response.headers.get("content-type")
|
|
405
|
+
);
|
|
406
|
+
if (parsedBody.parseFailed) {
|
|
407
|
+
const invalidJsonError = new AthenaGatewayError({
|
|
408
|
+
code: "INVALID_JSON",
|
|
409
|
+
message: "Gateway probe returned malformed JSON",
|
|
410
|
+
status: response.status,
|
|
411
|
+
method: "GET",
|
|
412
|
+
requestId,
|
|
413
|
+
hint: "Verify the gateway response body is valid JSON.",
|
|
414
|
+
cause: rawText.slice(0, 300)
|
|
415
|
+
});
|
|
416
|
+
return {
|
|
417
|
+
ok: false,
|
|
418
|
+
reachable: true,
|
|
419
|
+
status: response.status,
|
|
420
|
+
statusText: resolveStatusText(response, parsedBody.parsed),
|
|
421
|
+
baseUrl,
|
|
422
|
+
url,
|
|
423
|
+
error: invalidJsonError.message,
|
|
424
|
+
errorDetails: detailsFromError(invalidJsonError),
|
|
425
|
+
raw: parsedBody.parsed
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
const parsed = parsedBody.parsed;
|
|
429
|
+
if (!response.ok) {
|
|
430
|
+
const httpError = new AthenaGatewayError({
|
|
431
|
+
code: "HTTP_ERROR",
|
|
432
|
+
message: resolveErrorMessage(
|
|
433
|
+
parsed,
|
|
434
|
+
`Athena gateway GET ${path} failed with status ${response.status}`
|
|
435
|
+
),
|
|
436
|
+
status: response.status,
|
|
437
|
+
method: "GET",
|
|
438
|
+
requestId,
|
|
439
|
+
hint: resolveErrorHint(parsed)
|
|
440
|
+
});
|
|
441
|
+
return {
|
|
442
|
+
ok: false,
|
|
443
|
+
reachable: true,
|
|
444
|
+
status: response.status,
|
|
445
|
+
statusText: resolveStatusText(response, parsed),
|
|
446
|
+
baseUrl,
|
|
447
|
+
url,
|
|
448
|
+
error: httpError.message,
|
|
449
|
+
errorDetails: detailsFromError(httpError),
|
|
450
|
+
raw: parsed
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
return {
|
|
454
|
+
ok: true,
|
|
455
|
+
reachable: true,
|
|
456
|
+
status: response.status,
|
|
457
|
+
statusText: resolveStatusText(response, parsed),
|
|
458
|
+
baseUrl,
|
|
459
|
+
url,
|
|
460
|
+
error: void 0,
|
|
461
|
+
errorDetails: null,
|
|
462
|
+
raw: parsed
|
|
463
|
+
};
|
|
464
|
+
} catch (callError) {
|
|
465
|
+
const message = callError instanceof Error ? callError.message : String(callError);
|
|
466
|
+
const networkError = new AthenaGatewayError({
|
|
467
|
+
code: "NETWORK_ERROR",
|
|
468
|
+
message: `Network error while probing Athena gateway ${url}: ${message}`,
|
|
469
|
+
method: "GET",
|
|
470
|
+
cause: message,
|
|
471
|
+
hint: "Check gateway URL, DNS, and network reachability."
|
|
472
|
+
});
|
|
473
|
+
return {
|
|
474
|
+
ok: false,
|
|
475
|
+
reachable: false,
|
|
476
|
+
status: 0,
|
|
477
|
+
statusText: null,
|
|
478
|
+
baseUrl,
|
|
479
|
+
url,
|
|
480
|
+
error: networkError.message,
|
|
481
|
+
errorDetails: detailsFromError(networkError),
|
|
482
|
+
raw: null
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
}
|
|
266
486
|
async function callAthena(config, endpoint, method, payload, options) {
|
|
267
|
-
|
|
268
|
-
|
|
487
|
+
let baseUrl;
|
|
488
|
+
try {
|
|
489
|
+
baseUrl = resolveGatewayBaseUrl(options?.baseUrl ?? config.baseUrl);
|
|
490
|
+
} catch (error) {
|
|
491
|
+
return toInvalidUrlResponse(error, endpoint, method);
|
|
492
|
+
}
|
|
493
|
+
const url = buildAthenaGatewayUrl(baseUrl, endpoint);
|
|
269
494
|
const headers = buildHeaders(config, options);
|
|
270
495
|
try {
|
|
271
496
|
const requestInit = {
|
|
@@ -362,32 +587,44 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
362
587
|
}
|
|
363
588
|
}
|
|
364
589
|
function createAthenaGatewayClient(config = {}) {
|
|
590
|
+
const normalizedBaseUrl = resolveGatewayBaseUrl(config.baseUrl);
|
|
591
|
+
const normalizedConfig = {
|
|
592
|
+
...config,
|
|
593
|
+
baseUrl: normalizedBaseUrl
|
|
594
|
+
};
|
|
365
595
|
return {
|
|
366
|
-
baseUrl:
|
|
596
|
+
baseUrl: normalizedBaseUrl,
|
|
367
597
|
buildHeaders(options) {
|
|
368
|
-
return buildHeaders(
|
|
598
|
+
return buildHeaders(normalizedConfig, options);
|
|
599
|
+
},
|
|
600
|
+
verifyConnection(options) {
|
|
601
|
+
return performConnectionCheck(
|
|
602
|
+
normalizedBaseUrl,
|
|
603
|
+
buildHeaders(normalizedConfig),
|
|
604
|
+
options
|
|
605
|
+
);
|
|
369
606
|
},
|
|
370
607
|
fetchGateway(payload, options) {
|
|
371
|
-
return callAthena(
|
|
608
|
+
return callAthena(normalizedConfig, "/gateway/fetch", "POST", payload, options);
|
|
372
609
|
},
|
|
373
610
|
insertGateway(payload, options) {
|
|
374
|
-
return callAthena(
|
|
611
|
+
return callAthena(normalizedConfig, "/gateway/insert", "PUT", payload, options);
|
|
375
612
|
},
|
|
376
613
|
updateGateway(payload, options) {
|
|
377
|
-
return callAthena(
|
|
614
|
+
return callAthena(normalizedConfig, "/gateway/update", "POST", payload, options);
|
|
378
615
|
},
|
|
379
616
|
deleteGateway(payload, options) {
|
|
380
|
-
return callAthena(
|
|
617
|
+
return callAthena(normalizedConfig, "/gateway/delete", "DELETE", payload, options);
|
|
381
618
|
},
|
|
382
619
|
rpcGateway(payload, options) {
|
|
383
620
|
if (options?.get) {
|
|
384
621
|
const endpoint = buildRpcGetEndpoint(payload);
|
|
385
|
-
return callAthena(
|
|
622
|
+
return callAthena(normalizedConfig, endpoint, "GET", null, options);
|
|
386
623
|
}
|
|
387
|
-
return callAthena(
|
|
624
|
+
return callAthena(normalizedConfig, "/gateway/rpc", "POST", payload, options);
|
|
388
625
|
},
|
|
389
626
|
queryGateway(payload, options) {
|
|
390
|
-
return callAthena(
|
|
627
|
+
return callAthena(normalizedConfig, "/gateway/query", "POST", payload, options);
|
|
391
628
|
}
|
|
392
629
|
};
|
|
393
630
|
}
|