@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.
- package/dist/cli/index.cjs +155 -24
- 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 +155 -24
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-CT3GdrvA.d.cts → client-DFujaTFB.d.cts} +317 -8
- package/dist/{client-CT3GdrvA.d.ts → client-DFujaTFB.d.ts} +317 -8
- package/dist/index.cjs +157 -24
- 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 +156 -24
- 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.13",
|
|
425
425
|
description: "Official TypeScript/JavaScript client library for Aouda",
|
|
426
426
|
type: "module",
|
|
427
427
|
main: "./dist/index.cjs",
|
|
@@ -1434,7 +1434,9 @@ var BulkLoadCoordinator = class {
|
|
|
1434
1434
|
replicationMode: options.replicationMode,
|
|
1435
1435
|
forceSingleNodeReplicationBypass: options.forceSingleNodeReplicationBypass,
|
|
1436
1436
|
postLoadMqBehavior: options.postLoadMqBehavior,
|
|
1437
|
-
...options.identityInsert === true ? { identityInsert: true } : {}
|
|
1437
|
+
...options.identityInsert === true ? { identityInsert: true } : {},
|
|
1438
|
+
...options.applyTransforms === true ? { applyTransforms: true } : {},
|
|
1439
|
+
...options.preTransformed === true ? { preTransformed: true } : {}
|
|
1438
1440
|
}
|
|
1439
1441
|
};
|
|
1440
1442
|
const beginResp = await this.transport.post(
|
|
@@ -1527,7 +1529,11 @@ var ERROR_CODE_MAP = {
|
|
|
1527
1529
|
NAMED_QUERY_BATCH_MUTATION: AoudaValidationError,
|
|
1528
1530
|
NAMED_QUERY_BIND_FAILED: AoudaValidationError,
|
|
1529
1531
|
NAMED_QUERY_PARAM_REQUIRED: AoudaValidationError,
|
|
1530
|
-
NAMED_MUTATION_BIND_FAILED: AoudaValidationError
|
|
1532
|
+
NAMED_MUTATION_BIND_FAILED: AoudaValidationError,
|
|
1533
|
+
AUTH_IDENTITY_INVALID: AoudaValidationError,
|
|
1534
|
+
AUTH_IDENTITY_NOT_FOUND: AoudaValidationError,
|
|
1535
|
+
BULK_LOAD_TRANSFORM_INTENT_REQUIRED: AoudaValidationError,
|
|
1536
|
+
BULK_LOAD_TRANSFORM_INTENT_CONFLICT: AoudaValidationError
|
|
1531
1537
|
};
|
|
1532
1538
|
function createComposedAbortController(...signals) {
|
|
1533
1539
|
const controller = new AbortController();
|
|
@@ -2414,7 +2420,7 @@ var AsyncEventQueue = class {
|
|
|
2414
2420
|
}
|
|
2415
2421
|
};
|
|
2416
2422
|
var TableSubscription = class {
|
|
2417
|
-
constructor(transport,
|
|
2423
|
+
constructor(transport, identity, options = {}, onWarnings) {
|
|
2418
2424
|
this._queue = new AsyncEventQueue();
|
|
2419
2425
|
this._active = true;
|
|
2420
2426
|
this._started = false;
|
|
@@ -2424,11 +2430,11 @@ var TableSubscription = class {
|
|
|
2424
2430
|
this._forceFreshSubscribe = false;
|
|
2425
2431
|
this.id = createStreamingId("sub");
|
|
2426
2432
|
this._transport = transport;
|
|
2427
|
-
this.
|
|
2428
|
-
this._baseFilter = baseFilter;
|
|
2433
|
+
this._identity = identity;
|
|
2429
2434
|
this._onSnapshot = options.onSnapshot;
|
|
2430
2435
|
this._onChange = options.onChange;
|
|
2431
2436
|
this._onError = options.onError;
|
|
2437
|
+
this._onWarnings = onWarnings;
|
|
2432
2438
|
this._conflate = options.conflate;
|
|
2433
2439
|
this._reconnectHandlerKey = `${this.id}::reconnect`;
|
|
2434
2440
|
}
|
|
@@ -2491,12 +2497,18 @@ var TableSubscription = class {
|
|
|
2491
2497
|
async _sendSubscribe(resumeFrom) {
|
|
2492
2498
|
const message = {
|
|
2493
2499
|
type: "subscribe",
|
|
2494
|
-
id: this.id
|
|
2495
|
-
target: this._tableName
|
|
2500
|
+
id: this.id
|
|
2496
2501
|
};
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2502
|
+
if (this._identity.kind === "named") {
|
|
2503
|
+
message.hash = this._identity.hash;
|
|
2504
|
+
if (this._identity.args !== void 0) {
|
|
2505
|
+
message.args = this._identity.args;
|
|
2506
|
+
}
|
|
2507
|
+
} else {
|
|
2508
|
+
message.target = this._identity.target;
|
|
2509
|
+
if (this._identity.filter !== void 0) {
|
|
2510
|
+
message.filter = this._identity.filter;
|
|
2511
|
+
}
|
|
2500
2512
|
}
|
|
2501
2513
|
if (resumeFrom !== void 0) {
|
|
2502
2514
|
message.resume_from = resumeFrom;
|
|
@@ -2535,6 +2547,9 @@ var TableSubscription = class {
|
|
|
2535
2547
|
}
|
|
2536
2548
|
_handleSnapshotComplete(message) {
|
|
2537
2549
|
this._lastVersion = message.version;
|
|
2550
|
+
if (message.warnings != null && message.warnings.length > 0) {
|
|
2551
|
+
this._onWarnings?.(message.warnings);
|
|
2552
|
+
}
|
|
2538
2553
|
const rows = this._pendingSnapshotRows;
|
|
2539
2554
|
this._pendingSnapshotRows = [];
|
|
2540
2555
|
this._onSnapshot?.(rows, message.version);
|
|
@@ -3284,17 +3299,16 @@ var TableQuery = class _TableQuery {
|
|
|
3284
3299
|
const whereClause = this.buildWhereClause();
|
|
3285
3300
|
const queryFilter = buildSubscriptionFilter(whereClause);
|
|
3286
3301
|
const mergedFilter = mergeFilterObjects(queryFilter, options.filter);
|
|
3287
|
-
const subscription = new TableSubscription(
|
|
3288
|
-
|
|
3289
|
-
this.tableName,
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
);
|
|
3302
|
+
const subscription = new TableSubscription(wsTransport, {
|
|
3303
|
+
kind: "table",
|
|
3304
|
+
target: this.tableName,
|
|
3305
|
+
filter: mergedFilter
|
|
3306
|
+
}, {
|
|
3307
|
+
onSnapshot: options.onSnapshot,
|
|
3308
|
+
onChange: options.onChange,
|
|
3309
|
+
onError: options.onError,
|
|
3310
|
+
conflate: options.conflate
|
|
3311
|
+
});
|
|
3298
3312
|
subscription.start();
|
|
3299
3313
|
return subscription;
|
|
3300
3314
|
}
|
|
@@ -3880,10 +3894,84 @@ function serializeUpdateValue(col, val) {
|
|
|
3880
3894
|
else: toNode(cond.else)
|
|
3881
3895
|
};
|
|
3882
3896
|
}
|
|
3897
|
+
if ("$upper" in val) {
|
|
3898
|
+
return { type: "call", fn: "upper", args: [unaryCallArg(col, val.$upper)] };
|
|
3899
|
+
}
|
|
3900
|
+
if ("$lower" in val) {
|
|
3901
|
+
return { type: "call", fn: "lower", args: [unaryCallArg(col, val.$lower)] };
|
|
3902
|
+
}
|
|
3903
|
+
if ("$trim" in val) {
|
|
3904
|
+
return { type: "call", fn: "trim", args: [unaryCallArg(col, val.$trim)] };
|
|
3905
|
+
}
|
|
3906
|
+
if ("$concat" in val) {
|
|
3907
|
+
const parts = val.$concat;
|
|
3908
|
+
return {
|
|
3909
|
+
type: "call",
|
|
3910
|
+
fn: "concat",
|
|
3911
|
+
args: parts.map((p) => valueToExprNode(p))
|
|
3912
|
+
};
|
|
3913
|
+
}
|
|
3914
|
+
if ("$substring" in val) {
|
|
3915
|
+
const spec = val.$substring;
|
|
3916
|
+
if (Array.isArray(spec)) {
|
|
3917
|
+
return {
|
|
3918
|
+
type: "call",
|
|
3919
|
+
fn: "substring",
|
|
3920
|
+
args: [{ type: "colRef", col }, ...spec.map((p) => valueToExprNode(p))]
|
|
3921
|
+
};
|
|
3922
|
+
}
|
|
3923
|
+
return {
|
|
3924
|
+
type: "call",
|
|
3925
|
+
fn: "substring",
|
|
3926
|
+
args: [{ type: "colRef", col }, { type: "literal", value: spec }]
|
|
3927
|
+
};
|
|
3928
|
+
}
|
|
3929
|
+
if ("$round" in val) {
|
|
3930
|
+
return {
|
|
3931
|
+
type: "call",
|
|
3932
|
+
fn: "round",
|
|
3933
|
+
args: [
|
|
3934
|
+
{ type: "colRef", col },
|
|
3935
|
+
{ type: "literal", value: val.$round }
|
|
3936
|
+
]
|
|
3937
|
+
};
|
|
3938
|
+
}
|
|
3939
|
+
if ("$roundTo" in val) {
|
|
3940
|
+
return {
|
|
3941
|
+
type: "call",
|
|
3942
|
+
fn: "roundTo",
|
|
3943
|
+
args: [
|
|
3944
|
+
{ type: "colRef", col },
|
|
3945
|
+
{ type: "literal", value: val.$roundTo }
|
|
3946
|
+
]
|
|
3947
|
+
};
|
|
3948
|
+
}
|
|
3949
|
+
if ("$cast" in val) {
|
|
3950
|
+
return {
|
|
3951
|
+
type: "call",
|
|
3952
|
+
fn: "cast",
|
|
3953
|
+
args: [
|
|
3954
|
+
{ type: "colRef", col },
|
|
3955
|
+
{ type: "literal", value: val.$cast }
|
|
3956
|
+
]
|
|
3957
|
+
};
|
|
3958
|
+
}
|
|
3883
3959
|
throw new Error(
|
|
3884
3960
|
`Unknown expression operator in update() for column '${col}': ${JSON.stringify(val)}`
|
|
3885
3961
|
);
|
|
3886
3962
|
}
|
|
3963
|
+
function unaryCallArg(col, operand) {
|
|
3964
|
+
if (operand === true || operand === 1) {
|
|
3965
|
+
return { type: "colRef", col };
|
|
3966
|
+
}
|
|
3967
|
+
return valueToExprNode(operand);
|
|
3968
|
+
}
|
|
3969
|
+
function valueToExprNode(v) {
|
|
3970
|
+
if (typeof v === "string" && v.startsWith("$")) {
|
|
3971
|
+
return { type: "colRef", col: v.slice(1) };
|
|
3972
|
+
}
|
|
3973
|
+
return { type: "literal", value: v };
|
|
3974
|
+
}
|
|
3887
3975
|
|
|
3888
3976
|
// src/tables.ts
|
|
3889
3977
|
function validateNonEmptyString(value, name) {
|
|
@@ -5013,10 +5101,11 @@ function emptyStats() {
|
|
|
5013
5101
|
};
|
|
5014
5102
|
}
|
|
5015
5103
|
var NamedQueriesApi = class {
|
|
5016
|
-
constructor(transport, database, onWarning) {
|
|
5104
|
+
constructor(transport, database, onWarning, getStreamingTransport) {
|
|
5017
5105
|
this.transport = transport;
|
|
5018
5106
|
this.database = database;
|
|
5019
5107
|
this.onWarning = onWarning;
|
|
5108
|
+
this.getStreamingTransport = getStreamingTransport;
|
|
5020
5109
|
}
|
|
5021
5110
|
async execute(hash, args, options) {
|
|
5022
5111
|
if (typeof hash !== "string" || hash.trim().length === 0) {
|
|
@@ -5084,6 +5173,26 @@ var NamedQueriesApi = class {
|
|
|
5084
5173
|
return { isError: false, result };
|
|
5085
5174
|
});
|
|
5086
5175
|
}
|
|
5176
|
+
subscribe(hash, args, options = {}) {
|
|
5177
|
+
if (typeof hash !== "string" || hash.trim().length === 0) {
|
|
5178
|
+
throw new Error("Named query hash must be a non-empty string");
|
|
5179
|
+
}
|
|
5180
|
+
const subscription = new TableSubscription(
|
|
5181
|
+
this.getStreamingTransport(),
|
|
5182
|
+
{ kind: "named", hash, args },
|
|
5183
|
+
{
|
|
5184
|
+
onSnapshot: options.onSnapshot,
|
|
5185
|
+
onChange: options.onChange,
|
|
5186
|
+
onError: options.onError,
|
|
5187
|
+
conflate: options.conflate
|
|
5188
|
+
},
|
|
5189
|
+
(warnings) => {
|
|
5190
|
+
raiseDeprecationWarnings(this.onWarning, warnings);
|
|
5191
|
+
}
|
|
5192
|
+
);
|
|
5193
|
+
subscription.start();
|
|
5194
|
+
return subscription;
|
|
5195
|
+
}
|
|
5087
5196
|
};
|
|
5088
5197
|
var NamedMutationsApi = class {
|
|
5089
5198
|
constructor(transport, database, onWarning) {
|
|
@@ -5127,6 +5236,20 @@ var NamedMutationsApi = class {
|
|
|
5127
5236
|
}
|
|
5128
5237
|
};
|
|
5129
5238
|
|
|
5239
|
+
// src/policy.ts
|
|
5240
|
+
var PolicyApi = class {
|
|
5241
|
+
constructor(transport, database) {
|
|
5242
|
+
this.transport = transport;
|
|
5243
|
+
this.database = database;
|
|
5244
|
+
}
|
|
5245
|
+
inspect(body, options) {
|
|
5246
|
+
const path4 = `${databasePath2(this.database)}/policy/inspect`;
|
|
5247
|
+
return this.transport.post(path4, body, {
|
|
5248
|
+
signal: options?.signal
|
|
5249
|
+
});
|
|
5250
|
+
}
|
|
5251
|
+
};
|
|
5252
|
+
|
|
5130
5253
|
// src/streaming/websocket-transport.ts
|
|
5131
5254
|
var import_msgpack = require("@msgpack/msgpack");
|
|
5132
5255
|
var DEFAULT_PING_INTERVAL_MS = 2e4;
|
|
@@ -5907,13 +6030,15 @@ var AoudaClient = class {
|
|
|
5907
6030
|
this._namedQueries = new NamedQueriesApi(
|
|
5908
6031
|
this.transport,
|
|
5909
6032
|
this.database,
|
|
5910
|
-
onNamedArtifactWarning
|
|
6033
|
+
onNamedArtifactWarning,
|
|
6034
|
+
() => this._getOrCreateWebSocketTransport()
|
|
5911
6035
|
);
|
|
5912
6036
|
this._namedMutations = new NamedMutationsApi(
|
|
5913
6037
|
this.transport,
|
|
5914
6038
|
this.database,
|
|
5915
6039
|
onNamedArtifactWarning
|
|
5916
6040
|
);
|
|
6041
|
+
this._policy = new PolicyApi(this.transport, this.database);
|
|
5917
6042
|
}
|
|
5918
6043
|
/**
|
|
5919
6044
|
* Connects to the Aouda server.
|
|
@@ -6068,6 +6193,12 @@ var AoudaClient = class {
|
|
|
6068
6193
|
get namedMutations() {
|
|
6069
6194
|
return this._namedMutations;
|
|
6070
6195
|
}
|
|
6196
|
+
/**
|
|
6197
|
+
* Policy inspect (`POST …/policy/inspect`). Admin on the data DB.
|
|
6198
|
+
*/
|
|
6199
|
+
get policy() {
|
|
6200
|
+
return this._policy;
|
|
6201
|
+
}
|
|
6071
6202
|
/**
|
|
6072
6203
|
* Access auth operations (signUp, signIn, signOut, refresh, me, changePassword).
|
|
6073
6204
|
* @returns The auth API.
|