@aouda/client 0.1.7 → 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 +97 -13
- 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 +97 -13
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-BbyXG5AL.d.cts → client-TIOp5NUu.d.cts} +107 -8
- package/dist/{client-BbyXG5AL.d.ts → client-TIOp5NUu.d.ts} +107 -8
- package/dist/index.cjs +99 -13
- 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 +98 -13
- 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",
|
|
@@ -3924,23 +3924,68 @@ var TablesApi = class {
|
|
|
3924
3924
|
);
|
|
3925
3925
|
}
|
|
3926
3926
|
/**
|
|
3927
|
-
*
|
|
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.
|
|
3928
3930
|
* @param tableName - Table name.
|
|
3929
3931
|
* @param columnName - Current column name.
|
|
3930
|
-
* @param body -
|
|
3931
|
-
* @returns
|
|
3932
|
-
* @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.
|
|
3933
3934
|
*/
|
|
3934
|
-
async
|
|
3935
|
+
async alterColumn(tableName, columnName, body) {
|
|
3935
3936
|
validateNonEmptyString(tableName, "Table name");
|
|
3936
3937
|
validateNonEmptyString(columnName, "Column name");
|
|
3937
|
-
|
|
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
|
+
}
|
|
3938
3944
|
const prefix = databasePath2(this.database);
|
|
3939
3945
|
const encodedTable = encodeURIComponent(tableName);
|
|
3940
3946
|
const encodedColumn = encodeURIComponent(columnName);
|
|
3947
|
+
const requestBody = {
|
|
3948
|
+
database: this.database,
|
|
3949
|
+
...body
|
|
3950
|
+
};
|
|
3941
3951
|
return this.transport.patch(
|
|
3942
3952
|
`${prefix}/tables/${encodedTable}/columns/${encodedColumn}`,
|
|
3943
|
-
|
|
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
|
|
3944
3989
|
);
|
|
3945
3990
|
}
|
|
3946
3991
|
/**
|
|
@@ -4180,6 +4225,37 @@ var BranchesApi = class {
|
|
|
4180
4225
|
}
|
|
4181
4226
|
};
|
|
4182
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
|
+
|
|
4183
4259
|
// src/admin/server.ts
|
|
4184
4260
|
var ServerAdminApi = class {
|
|
4185
4261
|
constructor(transport) {
|
|
@@ -5457,7 +5533,7 @@ var DEFAULT_TIMEOUT_MS = 3e4;
|
|
|
5457
5533
|
function normalizeBaseUrl(url) {
|
|
5458
5534
|
return url.replace(/\/+$/, "");
|
|
5459
5535
|
}
|
|
5460
|
-
function
|
|
5536
|
+
function validateNonEmptyString3(value, name) {
|
|
5461
5537
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
5462
5538
|
throw new Error(`${name} must be a non-empty string`);
|
|
5463
5539
|
}
|
|
@@ -5472,8 +5548,8 @@ var AoudaClient = class {
|
|
|
5472
5548
|
constructor(options) {
|
|
5473
5549
|
this.connected = false;
|
|
5474
5550
|
this._wsTransport = null;
|
|
5475
|
-
|
|
5476
|
-
|
|
5551
|
+
validateNonEmptyString3(options.serverUrl, "serverUrl");
|
|
5552
|
+
validateNonEmptyString3(options.database, "database");
|
|
5477
5553
|
this.baseUrl = normalizeBaseUrl(options.serverUrl);
|
|
5478
5554
|
this.timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
5479
5555
|
this.database = options.database.trim();
|
|
@@ -5555,6 +5631,7 @@ var AoudaClient = class {
|
|
|
5555
5631
|
this._authHandler = null;
|
|
5556
5632
|
}
|
|
5557
5633
|
this._tables = new TablesApi(this.transport, this.database);
|
|
5634
|
+
this._jobs = new JobsApi(this.transport, this.database);
|
|
5558
5635
|
this._databases = new DatabasesApi(this.transport);
|
|
5559
5636
|
this._schema = new SchemaApi(this.transport, this.database);
|
|
5560
5637
|
this._branches = new BranchesApi(this.transport, this.database);
|
|
@@ -5648,7 +5725,7 @@ var AoudaClient = class {
|
|
|
5648
5725
|
* ```
|
|
5649
5726
|
*/
|
|
5650
5727
|
table(name) {
|
|
5651
|
-
|
|
5728
|
+
validateNonEmptyString3(name, "Table name");
|
|
5652
5729
|
return new TableQuery(
|
|
5653
5730
|
this.transport,
|
|
5654
5731
|
name,
|
|
@@ -5664,6 +5741,13 @@ var AoudaClient = class {
|
|
|
5664
5741
|
get tables() {
|
|
5665
5742
|
return this._tables;
|
|
5666
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
|
+
}
|
|
5667
5751
|
/**
|
|
5668
5752
|
* Access server-level database operations (list, create, get, drop).
|
|
5669
5753
|
* @returns The databases API.
|
|
@@ -5760,7 +5844,7 @@ var AoudaClient = class {
|
|
|
5760
5844
|
* ```
|
|
5761
5845
|
*/
|
|
5762
5846
|
bulkLoad(tableName, rows, options) {
|
|
5763
|
-
|
|
5847
|
+
validateNonEmptyString3(tableName, "tableName");
|
|
5764
5848
|
return new BulkLoadCoordinator(this.transport, this.database).run(
|
|
5765
5849
|
[tableName],
|
|
5766
5850
|
rows,
|