@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.
- package/dist/cli/index.cjs +126 -22
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +126 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-CT3GdrvA.d.cts → client-Q83x0Mz9.d.cts} +34 -4
- package/dist/{client-CT3GdrvA.d.ts → client-Q83x0Mz9.d.ts} +34 -4
- package/dist/index.cjs +126 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +126 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -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.
|
|
424
|
+
version: "0.1.12",
|
|
425
425
|
description: "Official TypeScript/JavaScript client library for Aouda",
|
|
426
426
|
type: "module",
|
|
427
427
|
main: "./dist/index.cjs",
|
|
@@ -2414,7 +2414,7 @@ var AsyncEventQueue = class {
|
|
|
2414
2414
|
}
|
|
2415
2415
|
};
|
|
2416
2416
|
var TableSubscription = class {
|
|
2417
|
-
constructor(transport,
|
|
2417
|
+
constructor(transport, identity, options = {}, onWarnings) {
|
|
2418
2418
|
this._queue = new AsyncEventQueue();
|
|
2419
2419
|
this._active = true;
|
|
2420
2420
|
this._started = false;
|
|
@@ -2424,11 +2424,11 @@ var TableSubscription = class {
|
|
|
2424
2424
|
this._forceFreshSubscribe = false;
|
|
2425
2425
|
this.id = createStreamingId("sub");
|
|
2426
2426
|
this._transport = transport;
|
|
2427
|
-
this.
|
|
2428
|
-
this._baseFilter = baseFilter;
|
|
2427
|
+
this._identity = identity;
|
|
2429
2428
|
this._onSnapshot = options.onSnapshot;
|
|
2430
2429
|
this._onChange = options.onChange;
|
|
2431
2430
|
this._onError = options.onError;
|
|
2431
|
+
this._onWarnings = onWarnings;
|
|
2432
2432
|
this._conflate = options.conflate;
|
|
2433
2433
|
this._reconnectHandlerKey = `${this.id}::reconnect`;
|
|
2434
2434
|
}
|
|
@@ -2491,12 +2491,18 @@ var TableSubscription = class {
|
|
|
2491
2491
|
async _sendSubscribe(resumeFrom) {
|
|
2492
2492
|
const message = {
|
|
2493
2493
|
type: "subscribe",
|
|
2494
|
-
id: this.id
|
|
2495
|
-
target: this._tableName
|
|
2494
|
+
id: this.id
|
|
2496
2495
|
};
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2496
|
+
if (this._identity.kind === "named") {
|
|
2497
|
+
message.hash = this._identity.hash;
|
|
2498
|
+
if (this._identity.args !== void 0) {
|
|
2499
|
+
message.args = this._identity.args;
|
|
2500
|
+
}
|
|
2501
|
+
} else {
|
|
2502
|
+
message.target = this._identity.target;
|
|
2503
|
+
if (this._identity.filter !== void 0) {
|
|
2504
|
+
message.filter = this._identity.filter;
|
|
2505
|
+
}
|
|
2500
2506
|
}
|
|
2501
2507
|
if (resumeFrom !== void 0) {
|
|
2502
2508
|
message.resume_from = resumeFrom;
|
|
@@ -2535,6 +2541,9 @@ var TableSubscription = class {
|
|
|
2535
2541
|
}
|
|
2536
2542
|
_handleSnapshotComplete(message) {
|
|
2537
2543
|
this._lastVersion = message.version;
|
|
2544
|
+
if (message.warnings != null && message.warnings.length > 0) {
|
|
2545
|
+
this._onWarnings?.(message.warnings);
|
|
2546
|
+
}
|
|
2538
2547
|
const rows = this._pendingSnapshotRows;
|
|
2539
2548
|
this._pendingSnapshotRows = [];
|
|
2540
2549
|
this._onSnapshot?.(rows, message.version);
|
|
@@ -3284,17 +3293,16 @@ var TableQuery = class _TableQuery {
|
|
|
3284
3293
|
const whereClause = this.buildWhereClause();
|
|
3285
3294
|
const queryFilter = buildSubscriptionFilter(whereClause);
|
|
3286
3295
|
const mergedFilter = mergeFilterObjects(queryFilter, options.filter);
|
|
3287
|
-
const subscription = new TableSubscription(
|
|
3288
|
-
|
|
3289
|
-
this.tableName,
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
);
|
|
3296
|
+
const subscription = new TableSubscription(wsTransport, {
|
|
3297
|
+
kind: "table",
|
|
3298
|
+
target: this.tableName,
|
|
3299
|
+
filter: mergedFilter
|
|
3300
|
+
}, {
|
|
3301
|
+
onSnapshot: options.onSnapshot,
|
|
3302
|
+
onChange: options.onChange,
|
|
3303
|
+
onError: options.onError,
|
|
3304
|
+
conflate: options.conflate
|
|
3305
|
+
});
|
|
3298
3306
|
subscription.start();
|
|
3299
3307
|
return subscription;
|
|
3300
3308
|
}
|
|
@@ -3880,10 +3888,84 @@ function serializeUpdateValue(col, val) {
|
|
|
3880
3888
|
else: toNode(cond.else)
|
|
3881
3889
|
};
|
|
3882
3890
|
}
|
|
3891
|
+
if ("$upper" in val) {
|
|
3892
|
+
return { type: "call", fn: "upper", args: [unaryCallArg(col, val.$upper)] };
|
|
3893
|
+
}
|
|
3894
|
+
if ("$lower" in val) {
|
|
3895
|
+
return { type: "call", fn: "lower", args: [unaryCallArg(col, val.$lower)] };
|
|
3896
|
+
}
|
|
3897
|
+
if ("$trim" in val) {
|
|
3898
|
+
return { type: "call", fn: "trim", args: [unaryCallArg(col, val.$trim)] };
|
|
3899
|
+
}
|
|
3900
|
+
if ("$concat" in val) {
|
|
3901
|
+
const parts = val.$concat;
|
|
3902
|
+
return {
|
|
3903
|
+
type: "call",
|
|
3904
|
+
fn: "concat",
|
|
3905
|
+
args: parts.map((p) => valueToExprNode(p))
|
|
3906
|
+
};
|
|
3907
|
+
}
|
|
3908
|
+
if ("$substring" in val) {
|
|
3909
|
+
const spec = val.$substring;
|
|
3910
|
+
if (Array.isArray(spec)) {
|
|
3911
|
+
return {
|
|
3912
|
+
type: "call",
|
|
3913
|
+
fn: "substring",
|
|
3914
|
+
args: [{ type: "colRef", col }, ...spec.map((p) => valueToExprNode(p))]
|
|
3915
|
+
};
|
|
3916
|
+
}
|
|
3917
|
+
return {
|
|
3918
|
+
type: "call",
|
|
3919
|
+
fn: "substring",
|
|
3920
|
+
args: [{ type: "colRef", col }, { type: "literal", value: spec }]
|
|
3921
|
+
};
|
|
3922
|
+
}
|
|
3923
|
+
if ("$round" in val) {
|
|
3924
|
+
return {
|
|
3925
|
+
type: "call",
|
|
3926
|
+
fn: "round",
|
|
3927
|
+
args: [
|
|
3928
|
+
{ type: "colRef", col },
|
|
3929
|
+
{ type: "literal", value: val.$round }
|
|
3930
|
+
]
|
|
3931
|
+
};
|
|
3932
|
+
}
|
|
3933
|
+
if ("$roundTo" in val) {
|
|
3934
|
+
return {
|
|
3935
|
+
type: "call",
|
|
3936
|
+
fn: "roundTo",
|
|
3937
|
+
args: [
|
|
3938
|
+
{ type: "colRef", col },
|
|
3939
|
+
{ type: "literal", value: val.$roundTo }
|
|
3940
|
+
]
|
|
3941
|
+
};
|
|
3942
|
+
}
|
|
3943
|
+
if ("$cast" in val) {
|
|
3944
|
+
return {
|
|
3945
|
+
type: "call",
|
|
3946
|
+
fn: "cast",
|
|
3947
|
+
args: [
|
|
3948
|
+
{ type: "colRef", col },
|
|
3949
|
+
{ type: "literal", value: val.$cast }
|
|
3950
|
+
]
|
|
3951
|
+
};
|
|
3952
|
+
}
|
|
3883
3953
|
throw new Error(
|
|
3884
3954
|
`Unknown expression operator in update() for column '${col}': ${JSON.stringify(val)}`
|
|
3885
3955
|
);
|
|
3886
3956
|
}
|
|
3957
|
+
function unaryCallArg(col, operand) {
|
|
3958
|
+
if (operand === true || operand === 1) {
|
|
3959
|
+
return { type: "colRef", col };
|
|
3960
|
+
}
|
|
3961
|
+
return valueToExprNode(operand);
|
|
3962
|
+
}
|
|
3963
|
+
function valueToExprNode(v) {
|
|
3964
|
+
if (typeof v === "string" && v.startsWith("$")) {
|
|
3965
|
+
return { type: "colRef", col: v.slice(1) };
|
|
3966
|
+
}
|
|
3967
|
+
return { type: "literal", value: v };
|
|
3968
|
+
}
|
|
3887
3969
|
|
|
3888
3970
|
// src/tables.ts
|
|
3889
3971
|
function validateNonEmptyString(value, name) {
|
|
@@ -5013,10 +5095,11 @@ function emptyStats() {
|
|
|
5013
5095
|
};
|
|
5014
5096
|
}
|
|
5015
5097
|
var NamedQueriesApi = class {
|
|
5016
|
-
constructor(transport, database, onWarning) {
|
|
5098
|
+
constructor(transport, database, onWarning, getStreamingTransport) {
|
|
5017
5099
|
this.transport = transport;
|
|
5018
5100
|
this.database = database;
|
|
5019
5101
|
this.onWarning = onWarning;
|
|
5102
|
+
this.getStreamingTransport = getStreamingTransport;
|
|
5020
5103
|
}
|
|
5021
5104
|
async execute(hash, args, options) {
|
|
5022
5105
|
if (typeof hash !== "string" || hash.trim().length === 0) {
|
|
@@ -5084,6 +5167,26 @@ var NamedQueriesApi = class {
|
|
|
5084
5167
|
return { isError: false, result };
|
|
5085
5168
|
});
|
|
5086
5169
|
}
|
|
5170
|
+
subscribe(hash, args, options = {}) {
|
|
5171
|
+
if (typeof hash !== "string" || hash.trim().length === 0) {
|
|
5172
|
+
throw new Error("Named query hash must be a non-empty string");
|
|
5173
|
+
}
|
|
5174
|
+
const subscription = new TableSubscription(
|
|
5175
|
+
this.getStreamingTransport(),
|
|
5176
|
+
{ kind: "named", hash, args },
|
|
5177
|
+
{
|
|
5178
|
+
onSnapshot: options.onSnapshot,
|
|
5179
|
+
onChange: options.onChange,
|
|
5180
|
+
onError: options.onError,
|
|
5181
|
+
conflate: options.conflate
|
|
5182
|
+
},
|
|
5183
|
+
(warnings) => {
|
|
5184
|
+
raiseDeprecationWarnings(this.onWarning, warnings);
|
|
5185
|
+
}
|
|
5186
|
+
);
|
|
5187
|
+
subscription.start();
|
|
5188
|
+
return subscription;
|
|
5189
|
+
}
|
|
5087
5190
|
};
|
|
5088
5191
|
var NamedMutationsApi = class {
|
|
5089
5192
|
constructor(transport, database, onWarning) {
|
|
@@ -5907,7 +6010,8 @@ var AoudaClient = class {
|
|
|
5907
6010
|
this._namedQueries = new NamedQueriesApi(
|
|
5908
6011
|
this.transport,
|
|
5909
6012
|
this.database,
|
|
5910
|
-
onNamedArtifactWarning
|
|
6013
|
+
onNamedArtifactWarning,
|
|
6014
|
+
() => this._getOrCreateWebSocketTransport()
|
|
5911
6015
|
);
|
|
5912
6016
|
this._namedMutations = new NamedMutationsApi(
|
|
5913
6017
|
this.transport,
|