@xylex-group/athena 1.1.2 → 1.2.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/dist/index.d.ts CHANGED
@@ -1,21 +1,23 @@
1
- import { B as BackendConfig, a as BackendType, A as AthenaConditionValue, b as AthenaConditionArrayValue, c as AthenaConditionOperator, d as AthenaGatewayCallOptions } from './types-DorEXMAz.js';
2
- export { e as Backend } from './types-DorEXMAz.js';
1
+ import { B as BackendConfig, a as BackendType, A as AthenaConditionValue, b as AthenaConditionArrayValue, c as AthenaConditionOperator, d as AthenaGatewayCallOptions, e as AthenaGatewayErrorDetails, f as AthenaRpcCallOptions } from './errors-DKNcLa5O.js';
2
+ export { g as AthenaGatewayError, h as AthenaGatewayErrorCode, i as AthenaRpcFilter, j as AthenaRpcFilterOperator, k as AthenaRpcOrder, l as AthenaRpcPayload, m as Backend, n as isAthenaGatewayError } from './errors-DKNcLa5O.js';
3
3
 
4
- interface SupabaseResult<T> {
4
+ interface AthenaResult<T> {
5
5
  data: T | null;
6
6
  error: string | null;
7
+ errorDetails?: AthenaGatewayErrorDetails | null;
7
8
  status: number;
9
+ count?: number | null;
8
10
  raw: unknown;
9
11
  }
10
12
  type MutationSingleResult<Result> = Result extends Array<infer Item> ? Item | null : Result | null;
11
- interface MutationQuery<Result> extends PromiseLike<SupabaseResult<Result>> {
12
- select(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<Result>>;
13
- returning(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<Result>>;
14
- single(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<MutationSingleResult<Result>>>;
15
- maybeSingle(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<MutationSingleResult<Result>>>;
16
- then<TResult1 = SupabaseResult<Result>, TResult2 = never>(onfulfilled?: ((value: SupabaseResult<Result>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
17
- catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<SupabaseResult<Result> | TResult>;
18
- finally(onfinally?: (() => void) | undefined | null): Promise<SupabaseResult<Result>>;
13
+ interface MutationQuery<Result> extends PromiseLike<AthenaResult<Result>> {
14
+ select(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<Result>>;
15
+ returning(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<Result>>;
16
+ single(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<MutationSingleResult<Result>>>;
17
+ maybeSingle(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<MutationSingleResult<Result>>>;
18
+ 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>;
19
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<AthenaResult<Result> | TResult>;
20
+ finally(onfinally?: (() => void) | undefined | null): Promise<AthenaResult<Result>>;
19
21
  }
20
22
  /** Shared filter chain - supports eq, limit, etc. in any order relative to select/update */
21
23
  interface FilterChain<Self> {
@@ -39,13 +41,37 @@ interface FilterChain<Self> {
39
41
  or(expression: string): Self;
40
42
  }
41
43
  /** Chain returned by select() - supports filters and single/maybeSingle before execution */
42
- interface SelectChain<Row> extends FilterChain<SelectChain<Row>>, PromiseLike<SupabaseResult<Row[]>> {
43
- single<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<T | null>>;
44
- maybeSingle<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<T | null>>;
44
+ interface SelectChain<Row> extends FilterChain<SelectChain<Row>>, PromiseLike<AthenaResult<Row[]>> {
45
+ single<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
46
+ maybeSingle<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
45
47
  }
46
48
  /** Chain returned by update() - supports filters before execution, plus select/returning */
47
49
  interface UpdateChain<Row> extends FilterChain<UpdateChain<Row>>, MutationQuery<Row[]> {
48
50
  }
51
+ interface RpcFilterChain<Self> {
52
+ eq(column: string, value: AthenaConditionValue): Self;
53
+ neq(column: string, value: AthenaConditionValue): Self;
54
+ gt(column: string, value: AthenaConditionValue): Self;
55
+ gte(column: string, value: AthenaConditionValue): Self;
56
+ lt(column: string, value: AthenaConditionValue): Self;
57
+ lte(column: string, value: AthenaConditionValue): Self;
58
+ like(column: string, value: AthenaConditionValue): Self;
59
+ ilike(column: string, value: AthenaConditionValue): Self;
60
+ is(column: string, value: AthenaConditionValue): Self;
61
+ in(column: string, values: AthenaConditionArrayValue): Self;
62
+ }
63
+ interface RpcOrderOptions {
64
+ ascending?: boolean;
65
+ }
66
+ interface RpcQueryBuilder<Row> extends RpcFilterChain<RpcQueryBuilder<Row>>, PromiseLike<AthenaResult<Row[]>> {
67
+ select(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<Row[]>>;
68
+ single<T = Row>(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<T | null>>;
69
+ maybeSingle<T = Row>(columns?: string | string[], options?: AthenaRpcCallOptions): Promise<AthenaResult<T | null>>;
70
+ order(column: string, options?: RpcOrderOptions): RpcQueryBuilder<Row>;
71
+ limit(count: number): RpcQueryBuilder<Row>;
72
+ offset(count: number): RpcQueryBuilder<Row>;
73
+ range(from: number, to: number): RpcQueryBuilder<Row>;
74
+ }
49
75
  interface TableQueryBuilder<Row> extends FilterChain<TableQueryBuilder<Row>> {
50
76
  select<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): SelectChain<T>;
51
77
  insert(values: Row, options?: AthenaGatewayCallOptions): MutationQuery<Row>;
@@ -62,28 +88,39 @@ interface TableQueryBuilder<Row> extends FilterChain<TableQueryBuilder<Row>> {
62
88
  delete(options?: AthenaGatewayCallOptions & {
63
89
  resourceId?: string;
64
90
  }): MutationQuery<Row | null>;
65
- single<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<T | null>>;
66
- maybeSingle<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<T | null>>;
91
+ single<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
92
+ maybeSingle<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<AthenaResult<T | null>>;
67
93
  reset(): TableQueryBuilder<Row>;
68
94
  }
69
- interface SupabaseClient {
95
+ interface AthenaSdkClient {
70
96
  from<Row = unknown>(table: string): TableQueryBuilder<Row>;
97
+ rpc<Row = unknown, Args extends Record<string, unknown> = Record<string, unknown>>(fn: string, args?: Args, options?: AthenaRpcCallOptions): RpcQueryBuilder<Row>;
98
+ query<Row = unknown>(query: string, options?: AthenaGatewayCallOptions): Promise<AthenaResult<Row[]>>;
71
99
  }
72
100
  interface AthenaClientBuilder {
101
+ /** Set the gateway base URL. */
73
102
  url(url: string): AthenaClientBuilder;
103
+ /** Set the API key used for all requests. */
74
104
  key(apiKey: string): AthenaClientBuilder;
105
+ /** Set the default backend routing strategy. */
75
106
  backend(backend: BackendConfig | BackendType): AthenaClientBuilder;
107
+ /** Set the default Athena client routing key. */
76
108
  client(clientName: string): AthenaClientBuilder;
109
+ /** Attach static headers to every request. */
77
110
  headers(headers: Record<string, string>): AthenaClientBuilder;
111
+ /** Enable or disable health tracking metadata. */
78
112
  healthTracking(enabled: boolean): AthenaClientBuilder;
79
- build(): SupabaseClient;
113
+ /** Build the immutable Athena SDK client. */
114
+ build(): AthenaSdkClient;
115
+ }
116
+ /** Canonical Athena client factory with builder-based configuration. */
117
+ declare class AthenaClient {
118
+ /** Create a fluent builder for a strongly-typed Athena SDK client. */
119
+ static builder(): AthenaClientBuilder;
120
+ /** Build a client from process environment variables. */
121
+ static fromEnvironment(): AthenaSdkClient;
80
122
  }
81
- declare const AthenaClient: {
82
- builder(): AthenaClientBuilder;
83
- /** Build client from env: ATHENA_SUPABASE_URL, ATHENA_SUPABASE_KEY (or SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY) */
84
- fromSupabaseEnv(): SupabaseClient;
85
- };
86
123
  /** Create client (convenience wrapper; use AthenaClient.builder() for full control) */
87
- declare function createClient(url: string, apiKey: string, options?: Pick<AthenaGatewayCallOptions, 'client' | 'headers' | 'backend'>): SupabaseClient;
124
+ declare function createClient(url: string, apiKey: string, options?: Pick<AthenaGatewayCallOptions, 'client' | 'headers' | 'backend'>): AthenaSdkClient;
88
125
 
89
- export { AthenaClient, AthenaGatewayCallOptions, BackendConfig, BackendType, type SupabaseClient, type SupabaseResult, type TableQueryBuilder, createClient };
126
+ export { AthenaClient, AthenaGatewayCallOptions, AthenaGatewayErrorDetails, type AthenaResult, AthenaRpcCallOptions, type AthenaSdkClient, BackendConfig, BackendType, type RpcOrderOptions, type RpcQueryBuilder, type TableQueryBuilder, createClient };