@aouda/client 0.1.3 → 0.1.5

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.
@@ -421,7 +421,7 @@ var import_node_url = require("url");
421
421
  // package.json
422
422
  var package_default = {
423
423
  name: "@aouda/client",
424
- version: "0.1.3",
424
+ version: "0.1.5",
425
425
  description: "Official TypeScript/JavaScript client library for Aouda",
426
426
  type: "module",
427
427
  main: "./dist/index.cjs",
@@ -2848,7 +2848,8 @@ var TableQuery = class _TableQuery {
2848
2848
  limitValue: null,
2849
2849
  offsetValue: null,
2850
2850
  crossPartitionAccess: false,
2851
- selectExprs: null
2851
+ selectExprs: null,
2852
+ isDistinct: false
2852
2853
  };
2853
2854
  }
2854
2855
  where(column, operator, value) {
@@ -3017,11 +3018,46 @@ var TableQuery = class _TableQuery {
3017
3018
  * ```
3018
3019
  */
3019
3020
  select(...columns) {
3021
+ if (this.state.isDistinct) {
3022
+ throw new Error(
3023
+ "select() cannot be combined with distinct(). Use distinct(columns) instead."
3024
+ );
3025
+ }
3020
3026
  return new _TableQuery(this.transport, this.tableName, this.database, {
3021
3027
  ...this.state,
3022
3028
  selectColumns: columns.length > 0 ? columns : null
3023
3029
  }, this.getWebSocketTransport);
3024
3030
  }
3031
+ /**
3032
+ * Return only distinct (de-duplicated) rows for the given columns — SQL `SELECT DISTINCT`.
3033
+ * Mutually exclusive with `selectExpr()` and joins.
3034
+ *
3035
+ * When T is a specific row type, only keys of T are accepted as column names.
3036
+ *
3037
+ * @param columns - The column names to de-duplicate on.
3038
+ * @returns A new TableQuery with distinct projection set.
3039
+ *
3040
+ * @example
3041
+ * ```typescript
3042
+ * query.distinct('category', 'region')
3043
+ * ```
3044
+ */
3045
+ distinct(...columns) {
3046
+ if (columns.length === 0) {
3047
+ throw new Error("At least one column is required.");
3048
+ }
3049
+ if (this.state.selectExprs !== null && this.state.selectExprs.length > 0) {
3050
+ throw new Error("distinct() cannot be combined with selectExpr().");
3051
+ }
3052
+ if (this.state.joinClauses.length > 0) {
3053
+ throw new Error("distinct() cannot be combined with joins().");
3054
+ }
3055
+ return new _TableQuery(this.transport, this.tableName, this.database, {
3056
+ ...this.state,
3057
+ selectColumns: columns,
3058
+ isDistinct: true
3059
+ }, this.getWebSocketTransport);
3060
+ }
3025
3061
  /**
3026
3062
  * Adds server-side computed columns to the query result.
3027
3063
  *
@@ -3043,6 +3079,9 @@ var TableQuery = class _TableQuery {
3043
3079
  if (projections.length === 0) {
3044
3080
  throw new Error("selectExpr() requires at least one projection.");
3045
3081
  }
3082
+ if (this.state.isDistinct) {
3083
+ throw new Error("selectExpr() cannot be combined with distinct().");
3084
+ }
3046
3085
  return new _TableQuery(this.transport, this.tableName, this.database, {
3047
3086
  ...this.state,
3048
3087
  selectExprs: projections
@@ -3087,6 +3126,9 @@ var TableQuery = class _TableQuery {
3087
3126
  if (rightTable.trim().length === 0) {
3088
3127
  throw new Error("crossJoin() requires a non-empty rightTable");
3089
3128
  }
3129
+ if (this.state.isDistinct) {
3130
+ throw new Error("joins() cannot be combined with distinct().");
3131
+ }
3090
3132
  return new _TableQuery(
3091
3133
  this.transport,
3092
3134
  this.tableName,
@@ -3226,6 +3268,9 @@ var TableQuery = class _TableQuery {
3226
3268
  if (this.state.selectExprs !== null && this.state.selectExprs.length > 0) {
3227
3269
  request.selectExpr = this.state.selectExprs;
3228
3270
  }
3271
+ if (this.state.isDistinct) {
3272
+ request.distinct = true;
3273
+ }
3229
3274
  return request;
3230
3275
  }
3231
3276
  buildWhereClause() {
@@ -3247,6 +3292,9 @@ var TableQuery = class _TableQuery {
3247
3292
  if (rightTable.trim().length === 0) {
3248
3293
  throw new Error("join() requires a non-empty rightTable");
3249
3294
  }
3295
+ if (this.state.isDistinct) {
3296
+ throw new Error("joins() cannot be combined with distinct().");
3297
+ }
3250
3298
  const joinClause = {
3251
3299
  table: rightTable,
3252
3300
  type