@xylex-group/athena 1.3.0 → 1.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
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-DHmpYG46.cjs';
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-DHmpYG46.cjs';
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-CB-eJQ7x.cjs';
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-CB-eJQ7x.cjs';
3
3
 
4
4
  interface AthenaResult<T> {
5
5
  data: T | null;
@@ -19,6 +19,9 @@ interface MutationQuery<Result> extends PromiseLike<AthenaResult<Result>> {
19
19
  catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<AthenaResult<Result> | TResult>;
20
20
  finally(onfinally?: (() => void) | undefined | null): Promise<AthenaResult<Result>>;
21
21
  }
22
+ interface OrderOptions {
23
+ ascending?: boolean;
24
+ }
22
25
  /** Shared filter chain - supports eq, limit, etc. in any order relative to select/update */
23
26
  interface FilterChain<Self> {
24
27
  eq(column: string, value: AthenaConditionValue): Self;
@@ -26,6 +29,10 @@ interface FilterChain<Self> {
26
29
  range(from: number, to: number): Self;
27
30
  limit(count: number): Self;
28
31
  offset(count: number): Self;
32
+ currentPage(value: number): Self;
33
+ pageSize(value: number): Self;
34
+ totalPages(value: number): Self;
35
+ order(column: string, options?: OrderOptions): Self;
29
36
  gt(column: string, value: AthenaConditionValue): Self;
30
37
  gte(column: string, value: AthenaConditionValue): Self;
31
38
  lt(column: string, value: AthenaConditionValue): Self;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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-DHmpYG46.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-DHmpYG46.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-CB-eJQ7x.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-CB-eJQ7x.js';
3
3
 
4
4
  interface AthenaResult<T> {
5
5
  data: T | null;
@@ -19,6 +19,9 @@ interface MutationQuery<Result> extends PromiseLike<AthenaResult<Result>> {
19
19
  catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<AthenaResult<Result> | TResult>;
20
20
  finally(onfinally?: (() => void) | undefined | null): Promise<AthenaResult<Result>>;
21
21
  }
22
+ interface OrderOptions {
23
+ ascending?: boolean;
24
+ }
22
25
  /** Shared filter chain - supports eq, limit, etc. in any order relative to select/update */
23
26
  interface FilterChain<Self> {
24
27
  eq(column: string, value: AthenaConditionValue): Self;
@@ -26,6 +29,10 @@ interface FilterChain<Self> {
26
29
  range(from: number, to: number): Self;
27
30
  limit(count: number): Self;
28
31
  offset(count: number): Self;
32
+ currentPage(value: number): Self;
33
+ pageSize(value: number): Self;
34
+ totalPages(value: number): Self;
35
+ order(column: string, options?: OrderOptions): Self;
29
36
  gt(column: string, value: AthenaConditionValue): Self;
30
37
  gte(column: string, value: AthenaConditionValue): Self;
31
38
  lt(column: string, value: AthenaConditionValue): Self;
package/dist/index.js CHANGED
@@ -61,6 +61,10 @@ function isAthenaGatewayError(error) {
61
61
  // src/gateway/client.ts
62
62
  var DEFAULT_BASE_URL = "https://athena-db.com";
63
63
  var DEFAULT_CLIENT = "railway_direct";
64
+ var FALLBACK_SDK_VERSION = "1.3.0";
65
+ var SDK_NAME = "xylex-group/athena";
66
+ var SDK_VERSION = typeof process !== "undefined" && process?.env?.npm_package_version ? process.env.npm_package_version : FALLBACK_SDK_VERSION;
67
+ var SDK_HEADER_VALUE = `${SDK_NAME} ${SDK_VERSION}`;
64
68
  function parseResponseBody(rawText, contentType) {
65
69
  if (!rawText) {
66
70
  return { parsed: null, parseFailed: false };
@@ -199,7 +203,8 @@ function buildHeaders(config, options) {
199
203
  const finalApiKey = options?.apiKey ?? config.apiKey;
200
204
  const finalPublishEvent = options?.publishEvent ?? config.publishEvent;
201
205
  const headers = {
202
- "Content-Type": "application/json"
206
+ "Content-Type": "application/json",
207
+ "X-Athena-Sdk": SDK_HEADER_VALUE
203
208
  };
204
209
  if (options?.userId ?? config.userId) {
205
210
  headers["X-User-Id"] = options?.userId ?? config.userId ?? "";
@@ -464,6 +469,25 @@ function createFilterMethods(state, addCondition, self) {
464
469
  state.offset = count;
465
470
  return self;
466
471
  },
472
+ currentPage(value) {
473
+ state.currentPage = value;
474
+ return self;
475
+ },
476
+ pageSize(value) {
477
+ state.pageSize = value;
478
+ return self;
479
+ },
480
+ totalPages(value) {
481
+ state.totalPages = value;
482
+ return self;
483
+ },
484
+ order(column, options) {
485
+ state.order = {
486
+ field: column,
487
+ direction: options?.ascending === false ? "descending" : "ascending"
488
+ };
489
+ return self;
490
+ },
467
491
  gt(column, value) {
468
492
  addCondition("gt", column, value);
469
493
  return self;
@@ -678,6 +702,10 @@ function createTableBuilder(tableName, client) {
678
702
  conditions: state.conditions.length ? [...state.conditions] : void 0,
679
703
  limit: state.limit,
680
704
  offset: state.offset,
705
+ current_page: state.currentPage,
706
+ page_size: state.pageSize,
707
+ total_pages: state.totalPages,
708
+ sort_by: state.order,
681
709
  strip_nulls: options?.stripNulls ?? true,
682
710
  count: options?.count,
683
711
  head: options?.head
@@ -713,6 +741,10 @@ function createTableBuilder(tableName, client) {
713
741
  state.conditions = [];
714
742
  state.limit = void 0;
715
743
  state.offset = void 0;
744
+ state.order = void 0;
745
+ state.currentPage = void 0;
746
+ state.pageSize = void 0;
747
+ state.totalPages = void 0;
716
748
  return builder;
717
749
  },
718
750
  select(columns = DEFAULT_COLUMNS, options) {
@@ -804,6 +836,10 @@ function createTableBuilder(tableName, client) {
804
836
  conditions: filters,
805
837
  strip_nulls: mergedOptions?.stripNulls ?? true
806
838
  };
839
+ if (state.order) payload.sort_by = state.order;
840
+ if (state.currentPage !== void 0) payload.current_page = state.currentPage;
841
+ if (state.pageSize !== void 0) payload.page_size = state.pageSize;
842
+ if (state.totalPages !== void 0) payload.total_pages = state.totalPages;
807
843
  if (columns) payload.columns = columns;
808
844
  const response = await client.updateGateway(payload, mergedOptions);
809
845
  return formatResult(response);
@@ -827,6 +863,10 @@ function createTableBuilder(tableName, client) {
827
863
  resource_id: resourceId,
828
864
  conditions: filters
829
865
  };
866
+ if (state.order) payload.sort_by = state.order;
867
+ if (state.currentPage !== void 0) payload.current_page = state.currentPage;
868
+ if (state.pageSize !== void 0) payload.page_size = state.pageSize;
869
+ if (state.totalPages !== void 0) payload.total_pages = state.totalPages;
830
870
  if (columns) payload.columns = columns;
831
871
  const response = await client.deleteGateway(payload, mergedOptions);
832
872
  return formatResult(response);