@aouda/client 0.1.11 → 0.1.13

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-DFujaTFB.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-DFujaTFB.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.13",
396
396
  description: "Official TypeScript/JavaScript client library for Aouda",
397
397
  type: "module",
398
398
  main: "./dist/index.cjs",
@@ -1405,7 +1405,9 @@ var BulkLoadCoordinator = class {
1405
1405
  replicationMode: options.replicationMode,
1406
1406
  forceSingleNodeReplicationBypass: options.forceSingleNodeReplicationBypass,
1407
1407
  postLoadMqBehavior: options.postLoadMqBehavior,
1408
- ...options.identityInsert === true ? { identityInsert: true } : {}
1408
+ ...options.identityInsert === true ? { identityInsert: true } : {},
1409
+ ...options.applyTransforms === true ? { applyTransforms: true } : {},
1410
+ ...options.preTransformed === true ? { preTransformed: true } : {}
1409
1411
  }
1410
1412
  };
1411
1413
  const beginResp = await this.transport.post(
@@ -1498,7 +1500,11 @@ var ERROR_CODE_MAP = {
1498
1500
  NAMED_QUERY_BATCH_MUTATION: AoudaValidationError,
1499
1501
  NAMED_QUERY_BIND_FAILED: AoudaValidationError,
1500
1502
  NAMED_QUERY_PARAM_REQUIRED: AoudaValidationError,
1501
- NAMED_MUTATION_BIND_FAILED: AoudaValidationError
1503
+ NAMED_MUTATION_BIND_FAILED: AoudaValidationError,
1504
+ AUTH_IDENTITY_INVALID: AoudaValidationError,
1505
+ AUTH_IDENTITY_NOT_FOUND: AoudaValidationError,
1506
+ BULK_LOAD_TRANSFORM_INTENT_REQUIRED: AoudaValidationError,
1507
+ BULK_LOAD_TRANSFORM_INTENT_CONFLICT: AoudaValidationError
1502
1508
  };
1503
1509
  function createComposedAbortController(...signals) {
1504
1510
  const controller = new AbortController();
@@ -2385,7 +2391,7 @@ var AsyncEventQueue = class {
2385
2391
  }
2386
2392
  };
2387
2393
  var TableSubscription = class {
2388
- constructor(transport, tableName, options = {}, baseFilter) {
2394
+ constructor(transport, identity, options = {}, onWarnings) {
2389
2395
  this._queue = new AsyncEventQueue();
2390
2396
  this._active = true;
2391
2397
  this._started = false;
@@ -2395,11 +2401,11 @@ var TableSubscription = class {
2395
2401
  this._forceFreshSubscribe = false;
2396
2402
  this.id = createStreamingId("sub");
2397
2403
  this._transport = transport;
2398
- this._tableName = tableName;
2399
- this._baseFilter = baseFilter;
2404
+ this._identity = identity;
2400
2405
  this._onSnapshot = options.onSnapshot;
2401
2406
  this._onChange = options.onChange;
2402
2407
  this._onError = options.onError;
2408
+ this._onWarnings = onWarnings;
2403
2409
  this._conflate = options.conflate;
2404
2410
  this._reconnectHandlerKey = `${this.id}::reconnect`;
2405
2411
  }
@@ -2462,12 +2468,18 @@ var TableSubscription = class {
2462
2468
  async _sendSubscribe(resumeFrom) {
2463
2469
  const message = {
2464
2470
  type: "subscribe",
2465
- id: this.id,
2466
- target: this._tableName
2471
+ id: this.id
2467
2472
  };
2468
- const filter = this._baseFilter;
2469
- if (filter !== void 0) {
2470
- message.filter = filter;
2473
+ if (this._identity.kind === "named") {
2474
+ message.hash = this._identity.hash;
2475
+ if (this._identity.args !== void 0) {
2476
+ message.args = this._identity.args;
2477
+ }
2478
+ } else {
2479
+ message.target = this._identity.target;
2480
+ if (this._identity.filter !== void 0) {
2481
+ message.filter = this._identity.filter;
2482
+ }
2471
2483
  }
2472
2484
  if (resumeFrom !== void 0) {
2473
2485
  message.resume_from = resumeFrom;
@@ -2506,6 +2518,9 @@ var TableSubscription = class {
2506
2518
  }
2507
2519
  _handleSnapshotComplete(message) {
2508
2520
  this._lastVersion = message.version;
2521
+ if (message.warnings != null && message.warnings.length > 0) {
2522
+ this._onWarnings?.(message.warnings);
2523
+ }
2509
2524
  const rows = this._pendingSnapshotRows;
2510
2525
  this._pendingSnapshotRows = [];
2511
2526
  this._onSnapshot?.(rows, message.version);
@@ -3255,17 +3270,16 @@ var TableQuery = class _TableQuery {
3255
3270
  const whereClause = this.buildWhereClause();
3256
3271
  const queryFilter = buildSubscriptionFilter(whereClause);
3257
3272
  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
- );
3273
+ const subscription = new TableSubscription(wsTransport, {
3274
+ kind: "table",
3275
+ target: this.tableName,
3276
+ filter: mergedFilter
3277
+ }, {
3278
+ onSnapshot: options.onSnapshot,
3279
+ onChange: options.onChange,
3280
+ onError: options.onError,
3281
+ conflate: options.conflate
3282
+ });
3269
3283
  subscription.start();
3270
3284
  return subscription;
3271
3285
  }
@@ -3851,10 +3865,84 @@ function serializeUpdateValue(col, val) {
3851
3865
  else: toNode(cond.else)
3852
3866
  };
3853
3867
  }
3868
+ if ("$upper" in val) {
3869
+ return { type: "call", fn: "upper", args: [unaryCallArg(col, val.$upper)] };
3870
+ }
3871
+ if ("$lower" in val) {
3872
+ return { type: "call", fn: "lower", args: [unaryCallArg(col, val.$lower)] };
3873
+ }
3874
+ if ("$trim" in val) {
3875
+ return { type: "call", fn: "trim", args: [unaryCallArg(col, val.$trim)] };
3876
+ }
3877
+ if ("$concat" in val) {
3878
+ const parts = val.$concat;
3879
+ return {
3880
+ type: "call",
3881
+ fn: "concat",
3882
+ args: parts.map((p) => valueToExprNode(p))
3883
+ };
3884
+ }
3885
+ if ("$substring" in val) {
3886
+ const spec = val.$substring;
3887
+ if (Array.isArray(spec)) {
3888
+ return {
3889
+ type: "call",
3890
+ fn: "substring",
3891
+ args: [{ type: "colRef", col }, ...spec.map((p) => valueToExprNode(p))]
3892
+ };
3893
+ }
3894
+ return {
3895
+ type: "call",
3896
+ fn: "substring",
3897
+ args: [{ type: "colRef", col }, { type: "literal", value: spec }]
3898
+ };
3899
+ }
3900
+ if ("$round" in val) {
3901
+ return {
3902
+ type: "call",
3903
+ fn: "round",
3904
+ args: [
3905
+ { type: "colRef", col },
3906
+ { type: "literal", value: val.$round }
3907
+ ]
3908
+ };
3909
+ }
3910
+ if ("$roundTo" in val) {
3911
+ return {
3912
+ type: "call",
3913
+ fn: "roundTo",
3914
+ args: [
3915
+ { type: "colRef", col },
3916
+ { type: "literal", value: val.$roundTo }
3917
+ ]
3918
+ };
3919
+ }
3920
+ if ("$cast" in val) {
3921
+ return {
3922
+ type: "call",
3923
+ fn: "cast",
3924
+ args: [
3925
+ { type: "colRef", col },
3926
+ { type: "literal", value: val.$cast }
3927
+ ]
3928
+ };
3929
+ }
3854
3930
  throw new Error(
3855
3931
  `Unknown expression operator in update() for column '${col}': ${JSON.stringify(val)}`
3856
3932
  );
3857
3933
  }
3934
+ function unaryCallArg(col, operand) {
3935
+ if (operand === true || operand === 1) {
3936
+ return { type: "colRef", col };
3937
+ }
3938
+ return valueToExprNode(operand);
3939
+ }
3940
+ function valueToExprNode(v) {
3941
+ if (typeof v === "string" && v.startsWith("$")) {
3942
+ return { type: "colRef", col: v.slice(1) };
3943
+ }
3944
+ return { type: "literal", value: v };
3945
+ }
3858
3946
 
3859
3947
  // src/tables.ts
3860
3948
  function validateNonEmptyString(value, name) {
@@ -4984,10 +5072,11 @@ function emptyStats() {
4984
5072
  };
4985
5073
  }
4986
5074
  var NamedQueriesApi = class {
4987
- constructor(transport, database, onWarning) {
5075
+ constructor(transport, database, onWarning, getStreamingTransport) {
4988
5076
  this.transport = transport;
4989
5077
  this.database = database;
4990
5078
  this.onWarning = onWarning;
5079
+ this.getStreamingTransport = getStreamingTransport;
4991
5080
  }
4992
5081
  async execute(hash, args, options) {
4993
5082
  if (typeof hash !== "string" || hash.trim().length === 0) {
@@ -5055,6 +5144,26 @@ var NamedQueriesApi = class {
5055
5144
  return { isError: false, result };
5056
5145
  });
5057
5146
  }
5147
+ subscribe(hash, args, options = {}) {
5148
+ if (typeof hash !== "string" || hash.trim().length === 0) {
5149
+ throw new Error("Named query hash must be a non-empty string");
5150
+ }
5151
+ const subscription = new TableSubscription(
5152
+ this.getStreamingTransport(),
5153
+ { kind: "named", hash, args },
5154
+ {
5155
+ onSnapshot: options.onSnapshot,
5156
+ onChange: options.onChange,
5157
+ onError: options.onError,
5158
+ conflate: options.conflate
5159
+ },
5160
+ (warnings) => {
5161
+ raiseDeprecationWarnings(this.onWarning, warnings);
5162
+ }
5163
+ );
5164
+ subscription.start();
5165
+ return subscription;
5166
+ }
5058
5167
  };
5059
5168
  var NamedMutationsApi = class {
5060
5169
  constructor(transport, database, onWarning) {
@@ -5098,6 +5207,20 @@ var NamedMutationsApi = class {
5098
5207
  }
5099
5208
  };
5100
5209
 
5210
+ // src/policy.ts
5211
+ var PolicyApi = class {
5212
+ constructor(transport, database) {
5213
+ this.transport = transport;
5214
+ this.database = database;
5215
+ }
5216
+ inspect(body, options) {
5217
+ const path4 = `${databasePath2(this.database)}/policy/inspect`;
5218
+ return this.transport.post(path4, body, {
5219
+ signal: options?.signal
5220
+ });
5221
+ }
5222
+ };
5223
+
5101
5224
  // src/streaming/websocket-transport.ts
5102
5225
  import { decode as decodeMessagePack, encode as encodeMessagePack } from "@msgpack/msgpack";
5103
5226
  var DEFAULT_PING_INTERVAL_MS = 2e4;
@@ -5878,13 +6001,15 @@ var AoudaClient = class {
5878
6001
  this._namedQueries = new NamedQueriesApi(
5879
6002
  this.transport,
5880
6003
  this.database,
5881
- onNamedArtifactWarning
6004
+ onNamedArtifactWarning,
6005
+ () => this._getOrCreateWebSocketTransport()
5882
6006
  );
5883
6007
  this._namedMutations = new NamedMutationsApi(
5884
6008
  this.transport,
5885
6009
  this.database,
5886
6010
  onNamedArtifactWarning
5887
6011
  );
6012
+ this._policy = new PolicyApi(this.transport, this.database);
5888
6013
  }
5889
6014
  /**
5890
6015
  * Connects to the Aouda server.
@@ -6039,6 +6164,12 @@ var AoudaClient = class {
6039
6164
  get namedMutations() {
6040
6165
  return this._namedMutations;
6041
6166
  }
6167
+ /**
6168
+ * Policy inspect (`POST …/policy/inspect`). Admin on the data DB.
6169
+ */
6170
+ get policy() {
6171
+ return this._policy;
6172
+ }
6042
6173
  /**
6043
6174
  * Access auth operations (signUp, signIn, signOut, refresh, me, changePassword).
6044
6175
  * @returns The auth API.