@aouda/client 0.1.11 → 0.1.12

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.
@@ -1,4 +1,4 @@
1
- import { A as AoudaClient } from '../client-CT3GdrvA.cjs';
1
+ import { A as AoudaClient } from '../client-Q83x0Mz9.cjs';
2
2
 
3
3
  /**
4
4
  * CLI for @aouda/client.
@@ -1,4 +1,4 @@
1
- import { A as AoudaClient } from '../client-CT3GdrvA.js';
1
+ import { A as AoudaClient } from '../client-Q83x0Mz9.js';
2
2
 
3
3
  /**
4
4
  * CLI for @aouda/client.
package/dist/cli/index.js CHANGED
@@ -392,7 +392,7 @@ import { fileURLToPath } from "url";
392
392
  // package.json
393
393
  var package_default = {
394
394
  name: "@aouda/client",
395
- version: "0.1.11",
395
+ version: "0.1.12",
396
396
  description: "Official TypeScript/JavaScript client library for Aouda",
397
397
  type: "module",
398
398
  main: "./dist/index.cjs",
@@ -2385,7 +2385,7 @@ var AsyncEventQueue = class {
2385
2385
  }
2386
2386
  };
2387
2387
  var TableSubscription = class {
2388
- constructor(transport, tableName, options = {}, baseFilter) {
2388
+ constructor(transport, identity, options = {}, onWarnings) {
2389
2389
  this._queue = new AsyncEventQueue();
2390
2390
  this._active = true;
2391
2391
  this._started = false;
@@ -2395,11 +2395,11 @@ var TableSubscription = class {
2395
2395
  this._forceFreshSubscribe = false;
2396
2396
  this.id = createStreamingId("sub");
2397
2397
  this._transport = transport;
2398
- this._tableName = tableName;
2399
- this._baseFilter = baseFilter;
2398
+ this._identity = identity;
2400
2399
  this._onSnapshot = options.onSnapshot;
2401
2400
  this._onChange = options.onChange;
2402
2401
  this._onError = options.onError;
2402
+ this._onWarnings = onWarnings;
2403
2403
  this._conflate = options.conflate;
2404
2404
  this._reconnectHandlerKey = `${this.id}::reconnect`;
2405
2405
  }
@@ -2462,12 +2462,18 @@ var TableSubscription = class {
2462
2462
  async _sendSubscribe(resumeFrom) {
2463
2463
  const message = {
2464
2464
  type: "subscribe",
2465
- id: this.id,
2466
- target: this._tableName
2465
+ id: this.id
2467
2466
  };
2468
- const filter = this._baseFilter;
2469
- if (filter !== void 0) {
2470
- message.filter = filter;
2467
+ if (this._identity.kind === "named") {
2468
+ message.hash = this._identity.hash;
2469
+ if (this._identity.args !== void 0) {
2470
+ message.args = this._identity.args;
2471
+ }
2472
+ } else {
2473
+ message.target = this._identity.target;
2474
+ if (this._identity.filter !== void 0) {
2475
+ message.filter = this._identity.filter;
2476
+ }
2471
2477
  }
2472
2478
  if (resumeFrom !== void 0) {
2473
2479
  message.resume_from = resumeFrom;
@@ -2506,6 +2512,9 @@ var TableSubscription = class {
2506
2512
  }
2507
2513
  _handleSnapshotComplete(message) {
2508
2514
  this._lastVersion = message.version;
2515
+ if (message.warnings != null && message.warnings.length > 0) {
2516
+ this._onWarnings?.(message.warnings);
2517
+ }
2509
2518
  const rows = this._pendingSnapshotRows;
2510
2519
  this._pendingSnapshotRows = [];
2511
2520
  this._onSnapshot?.(rows, message.version);
@@ -3255,17 +3264,16 @@ var TableQuery = class _TableQuery {
3255
3264
  const whereClause = this.buildWhereClause();
3256
3265
  const queryFilter = buildSubscriptionFilter(whereClause);
3257
3266
  const mergedFilter = mergeFilterObjects(queryFilter, options.filter);
3258
- const subscription = new TableSubscription(
3259
- wsTransport,
3260
- this.tableName,
3261
- {
3262
- onSnapshot: options.onSnapshot,
3263
- onChange: options.onChange,
3264
- onError: options.onError,
3265
- conflate: options.conflate
3266
- },
3267
- mergedFilter
3268
- );
3267
+ const subscription = new TableSubscription(wsTransport, {
3268
+ kind: "table",
3269
+ target: this.tableName,
3270
+ filter: mergedFilter
3271
+ }, {
3272
+ onSnapshot: options.onSnapshot,
3273
+ onChange: options.onChange,
3274
+ onError: options.onError,
3275
+ conflate: options.conflate
3276
+ });
3269
3277
  subscription.start();
3270
3278
  return subscription;
3271
3279
  }
@@ -3851,10 +3859,84 @@ function serializeUpdateValue(col, val) {
3851
3859
  else: toNode(cond.else)
3852
3860
  };
3853
3861
  }
3862
+ if ("$upper" in val) {
3863
+ return { type: "call", fn: "upper", args: [unaryCallArg(col, val.$upper)] };
3864
+ }
3865
+ if ("$lower" in val) {
3866
+ return { type: "call", fn: "lower", args: [unaryCallArg(col, val.$lower)] };
3867
+ }
3868
+ if ("$trim" in val) {
3869
+ return { type: "call", fn: "trim", args: [unaryCallArg(col, val.$trim)] };
3870
+ }
3871
+ if ("$concat" in val) {
3872
+ const parts = val.$concat;
3873
+ return {
3874
+ type: "call",
3875
+ fn: "concat",
3876
+ args: parts.map((p) => valueToExprNode(p))
3877
+ };
3878
+ }
3879
+ if ("$substring" in val) {
3880
+ const spec = val.$substring;
3881
+ if (Array.isArray(spec)) {
3882
+ return {
3883
+ type: "call",
3884
+ fn: "substring",
3885
+ args: [{ type: "colRef", col }, ...spec.map((p) => valueToExprNode(p))]
3886
+ };
3887
+ }
3888
+ return {
3889
+ type: "call",
3890
+ fn: "substring",
3891
+ args: [{ type: "colRef", col }, { type: "literal", value: spec }]
3892
+ };
3893
+ }
3894
+ if ("$round" in val) {
3895
+ return {
3896
+ type: "call",
3897
+ fn: "round",
3898
+ args: [
3899
+ { type: "colRef", col },
3900
+ { type: "literal", value: val.$round }
3901
+ ]
3902
+ };
3903
+ }
3904
+ if ("$roundTo" in val) {
3905
+ return {
3906
+ type: "call",
3907
+ fn: "roundTo",
3908
+ args: [
3909
+ { type: "colRef", col },
3910
+ { type: "literal", value: val.$roundTo }
3911
+ ]
3912
+ };
3913
+ }
3914
+ if ("$cast" in val) {
3915
+ return {
3916
+ type: "call",
3917
+ fn: "cast",
3918
+ args: [
3919
+ { type: "colRef", col },
3920
+ { type: "literal", value: val.$cast }
3921
+ ]
3922
+ };
3923
+ }
3854
3924
  throw new Error(
3855
3925
  `Unknown expression operator in update() for column '${col}': ${JSON.stringify(val)}`
3856
3926
  );
3857
3927
  }
3928
+ function unaryCallArg(col, operand) {
3929
+ if (operand === true || operand === 1) {
3930
+ return { type: "colRef", col };
3931
+ }
3932
+ return valueToExprNode(operand);
3933
+ }
3934
+ function valueToExprNode(v) {
3935
+ if (typeof v === "string" && v.startsWith("$")) {
3936
+ return { type: "colRef", col: v.slice(1) };
3937
+ }
3938
+ return { type: "literal", value: v };
3939
+ }
3858
3940
 
3859
3941
  // src/tables.ts
3860
3942
  function validateNonEmptyString(value, name) {
@@ -4984,10 +5066,11 @@ function emptyStats() {
4984
5066
  };
4985
5067
  }
4986
5068
  var NamedQueriesApi = class {
4987
- constructor(transport, database, onWarning) {
5069
+ constructor(transport, database, onWarning, getStreamingTransport) {
4988
5070
  this.transport = transport;
4989
5071
  this.database = database;
4990
5072
  this.onWarning = onWarning;
5073
+ this.getStreamingTransport = getStreamingTransport;
4991
5074
  }
4992
5075
  async execute(hash, args, options) {
4993
5076
  if (typeof hash !== "string" || hash.trim().length === 0) {
@@ -5055,6 +5138,26 @@ var NamedQueriesApi = class {
5055
5138
  return { isError: false, result };
5056
5139
  });
5057
5140
  }
5141
+ subscribe(hash, args, options = {}) {
5142
+ if (typeof hash !== "string" || hash.trim().length === 0) {
5143
+ throw new Error("Named query hash must be a non-empty string");
5144
+ }
5145
+ const subscription = new TableSubscription(
5146
+ this.getStreamingTransport(),
5147
+ { kind: "named", hash, args },
5148
+ {
5149
+ onSnapshot: options.onSnapshot,
5150
+ onChange: options.onChange,
5151
+ onError: options.onError,
5152
+ conflate: options.conflate
5153
+ },
5154
+ (warnings) => {
5155
+ raiseDeprecationWarnings(this.onWarning, warnings);
5156
+ }
5157
+ );
5158
+ subscription.start();
5159
+ return subscription;
5160
+ }
5058
5161
  };
5059
5162
  var NamedMutationsApi = class {
5060
5163
  constructor(transport, database, onWarning) {
@@ -5878,7 +5981,8 @@ var AoudaClient = class {
5878
5981
  this._namedQueries = new NamedQueriesApi(
5879
5982
  this.transport,
5880
5983
  this.database,
5881
- onNamedArtifactWarning
5984
+ onNamedArtifactWarning,
5985
+ () => this._getOrCreateWebSocketTransport()
5882
5986
  );
5883
5987
  this._namedMutations = new NamedMutationsApi(
5884
5988
  this.transport,