@aouda/client 0.1.6 → 0.1.8
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 +147 -16
- 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 +147 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-Bb6UxTA4.d.cts → client-TIOp5NUu.d.cts} +186 -12
- package/dist/{client-Bb6UxTA4.d.ts → client-TIOp5NUu.d.ts} +186 -12
- package/dist/index.cjs +149 -16
- 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 +148 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.d.cts
CHANGED
package/dist/cli/index.d.ts
CHANGED
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.
|
|
395
|
+
version: "0.1.8",
|
|
396
396
|
description: "Official TypeScript/JavaScript client library for Aouda",
|
|
397
397
|
type: "module",
|
|
398
398
|
main: "./dist/index.cjs",
|
|
@@ -1396,7 +1396,8 @@ var BulkLoadCoordinator = class {
|
|
|
1396
1396
|
pkUniquenessOverride: options.pkUniquenessOverride,
|
|
1397
1397
|
replicationMode: options.replicationMode,
|
|
1398
1398
|
forceSingleNodeReplicationBypass: options.forceSingleNodeReplicationBypass,
|
|
1399
|
-
postLoadMqBehavior: options.postLoadMqBehavior
|
|
1399
|
+
postLoadMqBehavior: options.postLoadMqBehavior,
|
|
1400
|
+
...options.identityInsert === true ? { identityInsert: true } : {}
|
|
1400
1401
|
}
|
|
1401
1402
|
};
|
|
1402
1403
|
const beginResp = await this.transport.post(
|
|
@@ -3406,6 +3407,8 @@ var TableQuery = class _TableQuery {
|
|
|
3406
3407
|
* a Promise. It does not use query builder state (where, orderBy, etc.).
|
|
3407
3408
|
*
|
|
3408
3409
|
* @param row - The row data to insert. Keys are column names.
|
|
3410
|
+
* @param row - The row object to insert. Keys are column names.
|
|
3411
|
+
* @param options - Optional insert options (e.g. `identityInsert`).
|
|
3409
3412
|
* @returns The insert result with row count, execution time, and optional generated values.
|
|
3410
3413
|
* @throws Error if `row` is null or undefined.
|
|
3411
3414
|
*
|
|
@@ -3416,9 +3419,12 @@ var TableQuery = class _TableQuery {
|
|
|
3416
3419
|
*
|
|
3417
3420
|
* console.log(result.rowsInserted); // 1
|
|
3418
3421
|
* console.log(result.generatedValues); // { "0": { id: 42 } }
|
|
3422
|
+
*
|
|
3423
|
+
* // Identity-insert (Bond isAutoIncrementDisabled: true): store explicit IDs including 0
|
|
3424
|
+
* await client.table('orders').insert({ id: 1000, status: 'seeded' }, { identityInsert: true });
|
|
3419
3425
|
* ```
|
|
3420
3426
|
*/
|
|
3421
|
-
async insert(row) {
|
|
3427
|
+
async insert(row, options) {
|
|
3422
3428
|
if (row == null) {
|
|
3423
3429
|
throw new Error("insert() requires a non-null row object");
|
|
3424
3430
|
}
|
|
@@ -3428,6 +3434,9 @@ var TableQuery = class _TableQuery {
|
|
|
3428
3434
|
database: this.database,
|
|
3429
3435
|
rows: [row]
|
|
3430
3436
|
};
|
|
3437
|
+
if (options?.identityInsert === true) {
|
|
3438
|
+
body.identityInsert = true;
|
|
3439
|
+
}
|
|
3431
3440
|
const response = await this.transport.post(path4, body);
|
|
3432
3441
|
const result = {
|
|
3433
3442
|
rowsInserted: response.rowsInserted,
|
|
@@ -3445,6 +3454,7 @@ var TableQuery = class _TableQuery {
|
|
|
3445
3454
|
* a Promise. It does not use query builder state (where, orderBy, etc.).
|
|
3446
3455
|
*
|
|
3447
3456
|
* @param rows - Array of row objects to insert. Must contain at least one row.
|
|
3457
|
+
* @param options - Optional insert options (e.g. `identityInsert`).
|
|
3448
3458
|
* @returns The insert result with total row count, execution time, and optional generated values.
|
|
3449
3459
|
* @throws Error if `rows` is empty.
|
|
3450
3460
|
*
|
|
@@ -3457,9 +3467,14 @@ var TableQuery = class _TableQuery {
|
|
|
3457
3467
|
* ]);
|
|
3458
3468
|
*
|
|
3459
3469
|
* console.log(result.rowsInserted); // 2
|
|
3470
|
+
*
|
|
3471
|
+
* await client.table('orders').insertMany(
|
|
3472
|
+
* [{ id: 10 }, { id: 20 }],
|
|
3473
|
+
* { identityInsert: true },
|
|
3474
|
+
* );
|
|
3460
3475
|
* ```
|
|
3461
3476
|
*/
|
|
3462
|
-
async insertMany(rows) {
|
|
3477
|
+
async insertMany(rows, options) {
|
|
3463
3478
|
if (!Array.isArray(rows) || rows.length === 0) {
|
|
3464
3479
|
throw new Error("insertMany() requires a non-empty array of rows");
|
|
3465
3480
|
}
|
|
@@ -3469,6 +3484,9 @@ var TableQuery = class _TableQuery {
|
|
|
3469
3484
|
database: this.database,
|
|
3470
3485
|
rows
|
|
3471
3486
|
};
|
|
3487
|
+
if (options?.identityInsert === true) {
|
|
3488
|
+
body.identityInsert = true;
|
|
3489
|
+
}
|
|
3472
3490
|
const response = await this.transport.post(path4, body);
|
|
3473
3491
|
const result = {
|
|
3474
3492
|
rowsInserted: response.rowsInserted,
|
|
@@ -3906,23 +3924,68 @@ var TablesApi = class {
|
|
|
3906
3924
|
);
|
|
3907
3925
|
}
|
|
3908
3926
|
/**
|
|
3909
|
-
*
|
|
3927
|
+
* Alters a column (type, nullable, encoder, autoIncrement, references, and/or rename).
|
|
3928
|
+
* PATCH /api/databases/{db}/tables/{t}/columns/{c}.
|
|
3929
|
+
* Omit a property to leave it unchanged. For `references`, omit unchanged; `""` or `null` clears.
|
|
3910
3930
|
* @param tableName - Table name.
|
|
3911
3931
|
* @param columnName - Current column name.
|
|
3912
|
-
* @param body -
|
|
3913
|
-
* @returns
|
|
3914
|
-
* @throws AoudaNotFoundError if table or column does not exist; AoudaApiError for WRITE_NOT_ALLOWED, etc.
|
|
3932
|
+
* @param body - Fields to change. `database` is injected from the client scope when omitted.
|
|
3933
|
+
* @returns Updated column detail.
|
|
3915
3934
|
*/
|
|
3916
|
-
async
|
|
3935
|
+
async alterColumn(tableName, columnName, body) {
|
|
3917
3936
|
validateNonEmptyString(tableName, "Table name");
|
|
3918
3937
|
validateNonEmptyString(columnName, "Column name");
|
|
3919
|
-
|
|
3938
|
+
const hasField = body.newName !== void 0 || body.type !== void 0 || body.nullable !== void 0 || body.encoder !== void 0 || body.autoIncrement !== void 0 || body.references !== void 0;
|
|
3939
|
+
if (!hasField) {
|
|
3940
|
+
throw new Error(
|
|
3941
|
+
"AlterColumnRequest must set at least one of: newName, type, nullable, encoder, autoIncrement, references"
|
|
3942
|
+
);
|
|
3943
|
+
}
|
|
3920
3944
|
const prefix = databasePath2(this.database);
|
|
3921
3945
|
const encodedTable = encodeURIComponent(tableName);
|
|
3922
3946
|
const encodedColumn = encodeURIComponent(columnName);
|
|
3947
|
+
const requestBody = {
|
|
3948
|
+
database: this.database,
|
|
3949
|
+
...body
|
|
3950
|
+
};
|
|
3923
3951
|
return this.transport.patch(
|
|
3924
3952
|
`${prefix}/tables/${encodedTable}/columns/${encodedColumn}`,
|
|
3925
|
-
|
|
3953
|
+
requestBody
|
|
3954
|
+
);
|
|
3955
|
+
}
|
|
3956
|
+
/**
|
|
3957
|
+
* Renames a column (convenience wrapper over {@link alterColumn}).
|
|
3958
|
+
* @param tableName - Table name.
|
|
3959
|
+
* @param columnName - Current column name.
|
|
3960
|
+
* @param body - Request body with newName (database optional; injected when omitted).
|
|
3961
|
+
* @returns 200 response body (column detail).
|
|
3962
|
+
* @throws AoudaNotFoundError if table or column does not exist; AoudaApiError for WRITE_NOT_ALLOWED, etc.
|
|
3963
|
+
*/
|
|
3964
|
+
async renameColumn(tableName, columnName, body) {
|
|
3965
|
+
validateNonEmptyString(body.newName ?? "", "New column name");
|
|
3966
|
+
return this.alterColumn(tableName, columnName, { newName: body.newName });
|
|
3967
|
+
}
|
|
3968
|
+
/**
|
|
3969
|
+
* Reorders columns in a table.
|
|
3970
|
+
* PUT /api/databases/{db}/tables/{t}/columns:order (204 No Content).
|
|
3971
|
+
* @param tableName - Table name.
|
|
3972
|
+
* @param columnsOrBody - Ordered column names, or a request body with `columns`.
|
|
3973
|
+
*/
|
|
3974
|
+
async reorderColumns(tableName, columnsOrBody) {
|
|
3975
|
+
validateNonEmptyString(tableName, "Table name");
|
|
3976
|
+
const columns = Array.isArray(columnsOrBody) ? columnsOrBody : columnsOrBody.columns;
|
|
3977
|
+
if (!columns?.length) {
|
|
3978
|
+
throw new Error("columns array is required and must be non-empty");
|
|
3979
|
+
}
|
|
3980
|
+
const prefix = databasePath2(this.database);
|
|
3981
|
+
const encodedTable = encodeURIComponent(tableName);
|
|
3982
|
+
const requestBody = {
|
|
3983
|
+
database: this.database,
|
|
3984
|
+
columns
|
|
3985
|
+
};
|
|
3986
|
+
await this.transport.put(
|
|
3987
|
+
`${prefix}/tables/${encodedTable}/columns:order`,
|
|
3988
|
+
requestBody
|
|
3926
3989
|
);
|
|
3927
3990
|
}
|
|
3928
3991
|
/**
|
|
@@ -4162,6 +4225,37 @@ var BranchesApi = class {
|
|
|
4162
4225
|
}
|
|
4163
4226
|
};
|
|
4164
4227
|
|
|
4228
|
+
// src/jobs.ts
|
|
4229
|
+
function validateNonEmptyString2(value, name) {
|
|
4230
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
4231
|
+
throw new Error(`${name} must be a non-empty string`);
|
|
4232
|
+
}
|
|
4233
|
+
}
|
|
4234
|
+
var JobsApi = class {
|
|
4235
|
+
constructor(transport, database) {
|
|
4236
|
+
this.transport = transport;
|
|
4237
|
+
this.database = database;
|
|
4238
|
+
}
|
|
4239
|
+
get prefix() {
|
|
4240
|
+
return `${databasePath2(this.database)}/jobs`;
|
|
4241
|
+
}
|
|
4242
|
+
/**
|
|
4243
|
+
* Lists jobs whose params target this database.
|
|
4244
|
+
*/
|
|
4245
|
+
async list() {
|
|
4246
|
+
return this.transport.get(this.prefix);
|
|
4247
|
+
}
|
|
4248
|
+
/**
|
|
4249
|
+
* Gets a single job by id when it belongs to this database.
|
|
4250
|
+
* @param jobId - Job GUID string.
|
|
4251
|
+
*/
|
|
4252
|
+
async get(jobId) {
|
|
4253
|
+
validateNonEmptyString2(jobId, "Job id");
|
|
4254
|
+
const encoded = encodeURIComponent(jobId);
|
|
4255
|
+
return this.transport.get(`${this.prefix}/${encoded}`);
|
|
4256
|
+
}
|
|
4257
|
+
};
|
|
4258
|
+
|
|
4165
4259
|
// src/admin/server.ts
|
|
4166
4260
|
var ServerAdminApi = class {
|
|
4167
4261
|
constructor(transport) {
|
|
@@ -4671,6 +4765,35 @@ var NotificationsAdminApi = class {
|
|
|
4671
4765
|
request
|
|
4672
4766
|
);
|
|
4673
4767
|
}
|
|
4768
|
+
/**
|
|
4769
|
+
* Get recent captured auth notifications (newest first).
|
|
4770
|
+
* GET /admin/notifications/outbox?channel=&limit=
|
|
4771
|
+
*/
|
|
4772
|
+
async getOutbox(options) {
|
|
4773
|
+
return this.transport.get(
|
|
4774
|
+
this.buildOutboxPath(options)
|
|
4775
|
+
);
|
|
4776
|
+
}
|
|
4777
|
+
/**
|
|
4778
|
+
* Clear the in-memory notification outbox.
|
|
4779
|
+
* DELETE /admin/notifications/outbox
|
|
4780
|
+
*/
|
|
4781
|
+
async clearOutbox() {
|
|
4782
|
+
return this.transport.delete(
|
|
4783
|
+
`${BASE_PATH7}/outbox`
|
|
4784
|
+
);
|
|
4785
|
+
}
|
|
4786
|
+
buildOutboxPath(options) {
|
|
4787
|
+
const params = new URLSearchParams();
|
|
4788
|
+
if (options?.channel !== void 0 && options.channel.trim().length > 0) {
|
|
4789
|
+
params.set("channel", options.channel);
|
|
4790
|
+
}
|
|
4791
|
+
if (options?.limit !== void 0) {
|
|
4792
|
+
params.set("limit", String(options.limit));
|
|
4793
|
+
}
|
|
4794
|
+
const query = params.toString();
|
|
4795
|
+
return query.length > 0 ? `${BASE_PATH7}/outbox?${query}` : `${BASE_PATH7}/outbox`;
|
|
4796
|
+
}
|
|
4674
4797
|
};
|
|
4675
4798
|
|
|
4676
4799
|
// src/admin/index.ts
|
|
@@ -5410,7 +5533,7 @@ var DEFAULT_TIMEOUT_MS = 3e4;
|
|
|
5410
5533
|
function normalizeBaseUrl(url) {
|
|
5411
5534
|
return url.replace(/\/+$/, "");
|
|
5412
5535
|
}
|
|
5413
|
-
function
|
|
5536
|
+
function validateNonEmptyString3(value, name) {
|
|
5414
5537
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
5415
5538
|
throw new Error(`${name} must be a non-empty string`);
|
|
5416
5539
|
}
|
|
@@ -5425,8 +5548,8 @@ var AoudaClient = class {
|
|
|
5425
5548
|
constructor(options) {
|
|
5426
5549
|
this.connected = false;
|
|
5427
5550
|
this._wsTransport = null;
|
|
5428
|
-
|
|
5429
|
-
|
|
5551
|
+
validateNonEmptyString3(options.serverUrl, "serverUrl");
|
|
5552
|
+
validateNonEmptyString3(options.database, "database");
|
|
5430
5553
|
this.baseUrl = normalizeBaseUrl(options.serverUrl);
|
|
5431
5554
|
this.timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
5432
5555
|
this.database = options.database.trim();
|
|
@@ -5508,6 +5631,7 @@ var AoudaClient = class {
|
|
|
5508
5631
|
this._authHandler = null;
|
|
5509
5632
|
}
|
|
5510
5633
|
this._tables = new TablesApi(this.transport, this.database);
|
|
5634
|
+
this._jobs = new JobsApi(this.transport, this.database);
|
|
5511
5635
|
this._databases = new DatabasesApi(this.transport);
|
|
5512
5636
|
this._schema = new SchemaApi(this.transport, this.database);
|
|
5513
5637
|
this._branches = new BranchesApi(this.transport, this.database);
|
|
@@ -5601,7 +5725,7 @@ var AoudaClient = class {
|
|
|
5601
5725
|
* ```
|
|
5602
5726
|
*/
|
|
5603
5727
|
table(name) {
|
|
5604
|
-
|
|
5728
|
+
validateNonEmptyString3(name, "Table name");
|
|
5605
5729
|
return new TableQuery(
|
|
5606
5730
|
this.transport,
|
|
5607
5731
|
name,
|
|
@@ -5617,6 +5741,13 @@ var AoudaClient = class {
|
|
|
5617
5741
|
get tables() {
|
|
5618
5742
|
return this._tables;
|
|
5619
5743
|
}
|
|
5744
|
+
/**
|
|
5745
|
+
* Access pending/background jobs for the current database (e.g. ColumnRewrite).
|
|
5746
|
+
* @returns The jobs API.
|
|
5747
|
+
*/
|
|
5748
|
+
get jobs() {
|
|
5749
|
+
return this._jobs;
|
|
5750
|
+
}
|
|
5620
5751
|
/**
|
|
5621
5752
|
* Access server-level database operations (list, create, get, drop).
|
|
5622
5753
|
* @returns The databases API.
|
|
@@ -5713,7 +5844,7 @@ var AoudaClient = class {
|
|
|
5713
5844
|
* ```
|
|
5714
5845
|
*/
|
|
5715
5846
|
bulkLoad(tableName, rows, options) {
|
|
5716
|
-
|
|
5847
|
+
validateNonEmptyString3(tableName, "tableName");
|
|
5717
5848
|
return new BulkLoadCoordinator(this.transport, this.database).run(
|
|
5718
5849
|
[tableName],
|
|
5719
5850
|
rows,
|