@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.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.8",
|
|
425
425
|
description: "Official TypeScript/JavaScript client library for Aouda",
|
|
426
426
|
type: "module",
|
|
427
427
|
main: "./dist/index.cjs",
|
|
@@ -3953,23 +3953,68 @@ var TablesApi = class {
|
|
|
3953
3953
|
);
|
|
3954
3954
|
}
|
|
3955
3955
|
/**
|
|
3956
|
-
*
|
|
3956
|
+
* Alters a column (type, nullable, encoder, autoIncrement, references, and/or rename).
|
|
3957
|
+
* PATCH /api/databases/{db}/tables/{t}/columns/{c}.
|
|
3958
|
+
* Omit a property to leave it unchanged. For `references`, omit unchanged; `""` or `null` clears.
|
|
3957
3959
|
* @param tableName - Table name.
|
|
3958
3960
|
* @param columnName - Current column name.
|
|
3959
|
-
* @param body -
|
|
3960
|
-
* @returns
|
|
3961
|
-
* @throws AoudaNotFoundError if table or column does not exist; AoudaApiError for WRITE_NOT_ALLOWED, etc.
|
|
3961
|
+
* @param body - Fields to change. `database` is injected from the client scope when omitted.
|
|
3962
|
+
* @returns Updated column detail.
|
|
3962
3963
|
*/
|
|
3963
|
-
async
|
|
3964
|
+
async alterColumn(tableName, columnName, body) {
|
|
3964
3965
|
validateNonEmptyString(tableName, "Table name");
|
|
3965
3966
|
validateNonEmptyString(columnName, "Column name");
|
|
3966
|
-
|
|
3967
|
+
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;
|
|
3968
|
+
if (!hasField) {
|
|
3969
|
+
throw new Error(
|
|
3970
|
+
"AlterColumnRequest must set at least one of: newName, type, nullable, encoder, autoIncrement, references"
|
|
3971
|
+
);
|
|
3972
|
+
}
|
|
3967
3973
|
const prefix = databasePath2(this.database);
|
|
3968
3974
|
const encodedTable = encodeURIComponent(tableName);
|
|
3969
3975
|
const encodedColumn = encodeURIComponent(columnName);
|
|
3976
|
+
const requestBody = {
|
|
3977
|
+
database: this.database,
|
|
3978
|
+
...body
|
|
3979
|
+
};
|
|
3970
3980
|
return this.transport.patch(
|
|
3971
3981
|
`${prefix}/tables/${encodedTable}/columns/${encodedColumn}`,
|
|
3972
|
-
|
|
3982
|
+
requestBody
|
|
3983
|
+
);
|
|
3984
|
+
}
|
|
3985
|
+
/**
|
|
3986
|
+
* Renames a column (convenience wrapper over {@link alterColumn}).
|
|
3987
|
+
* @param tableName - Table name.
|
|
3988
|
+
* @param columnName - Current column name.
|
|
3989
|
+
* @param body - Request body with newName (database optional; injected when omitted).
|
|
3990
|
+
* @returns 200 response body (column detail).
|
|
3991
|
+
* @throws AoudaNotFoundError if table or column does not exist; AoudaApiError for WRITE_NOT_ALLOWED, etc.
|
|
3992
|
+
*/
|
|
3993
|
+
async renameColumn(tableName, columnName, body) {
|
|
3994
|
+
validateNonEmptyString(body.newName ?? "", "New column name");
|
|
3995
|
+
return this.alterColumn(tableName, columnName, { newName: body.newName });
|
|
3996
|
+
}
|
|
3997
|
+
/**
|
|
3998
|
+
* Reorders columns in a table.
|
|
3999
|
+
* PUT /api/databases/{db}/tables/{t}/columns:order (204 No Content).
|
|
4000
|
+
* @param tableName - Table name.
|
|
4001
|
+
* @param columnsOrBody - Ordered column names, or a request body with `columns`.
|
|
4002
|
+
*/
|
|
4003
|
+
async reorderColumns(tableName, columnsOrBody) {
|
|
4004
|
+
validateNonEmptyString(tableName, "Table name");
|
|
4005
|
+
const columns = Array.isArray(columnsOrBody) ? columnsOrBody : columnsOrBody.columns;
|
|
4006
|
+
if (!columns?.length) {
|
|
4007
|
+
throw new Error("columns array is required and must be non-empty");
|
|
4008
|
+
}
|
|
4009
|
+
const prefix = databasePath2(this.database);
|
|
4010
|
+
const encodedTable = encodeURIComponent(tableName);
|
|
4011
|
+
const requestBody = {
|
|
4012
|
+
database: this.database,
|
|
4013
|
+
columns
|
|
4014
|
+
};
|
|
4015
|
+
await this.transport.put(
|
|
4016
|
+
`${prefix}/tables/${encodedTable}/columns:order`,
|
|
4017
|
+
requestBody
|
|
3973
4018
|
);
|
|
3974
4019
|
}
|
|
3975
4020
|
/**
|
|
@@ -4209,6 +4254,37 @@ var BranchesApi = class {
|
|
|
4209
4254
|
}
|
|
4210
4255
|
};
|
|
4211
4256
|
|
|
4257
|
+
// src/jobs.ts
|
|
4258
|
+
function validateNonEmptyString2(value, name) {
|
|
4259
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
4260
|
+
throw new Error(`${name} must be a non-empty string`);
|
|
4261
|
+
}
|
|
4262
|
+
}
|
|
4263
|
+
var JobsApi = class {
|
|
4264
|
+
constructor(transport, database) {
|
|
4265
|
+
this.transport = transport;
|
|
4266
|
+
this.database = database;
|
|
4267
|
+
}
|
|
4268
|
+
get prefix() {
|
|
4269
|
+
return `${databasePath2(this.database)}/jobs`;
|
|
4270
|
+
}
|
|
4271
|
+
/**
|
|
4272
|
+
* Lists jobs whose params target this database.
|
|
4273
|
+
*/
|
|
4274
|
+
async list() {
|
|
4275
|
+
return this.transport.get(this.prefix);
|
|
4276
|
+
}
|
|
4277
|
+
/**
|
|
4278
|
+
* Gets a single job by id when it belongs to this database.
|
|
4279
|
+
* @param jobId - Job GUID string.
|
|
4280
|
+
*/
|
|
4281
|
+
async get(jobId) {
|
|
4282
|
+
validateNonEmptyString2(jobId, "Job id");
|
|
4283
|
+
const encoded = encodeURIComponent(jobId);
|
|
4284
|
+
return this.transport.get(`${this.prefix}/${encoded}`);
|
|
4285
|
+
}
|
|
4286
|
+
};
|
|
4287
|
+
|
|
4212
4288
|
// src/admin/server.ts
|
|
4213
4289
|
var ServerAdminApi = class {
|
|
4214
4290
|
constructor(transport) {
|
|
@@ -5486,7 +5562,7 @@ var DEFAULT_TIMEOUT_MS = 3e4;
|
|
|
5486
5562
|
function normalizeBaseUrl(url) {
|
|
5487
5563
|
return url.replace(/\/+$/, "");
|
|
5488
5564
|
}
|
|
5489
|
-
function
|
|
5565
|
+
function validateNonEmptyString3(value, name) {
|
|
5490
5566
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
5491
5567
|
throw new Error(`${name} must be a non-empty string`);
|
|
5492
5568
|
}
|
|
@@ -5501,8 +5577,8 @@ var AoudaClient = class {
|
|
|
5501
5577
|
constructor(options) {
|
|
5502
5578
|
this.connected = false;
|
|
5503
5579
|
this._wsTransport = null;
|
|
5504
|
-
|
|
5505
|
-
|
|
5580
|
+
validateNonEmptyString3(options.serverUrl, "serverUrl");
|
|
5581
|
+
validateNonEmptyString3(options.database, "database");
|
|
5506
5582
|
this.baseUrl = normalizeBaseUrl(options.serverUrl);
|
|
5507
5583
|
this.timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
5508
5584
|
this.database = options.database.trim();
|
|
@@ -5584,6 +5660,7 @@ var AoudaClient = class {
|
|
|
5584
5660
|
this._authHandler = null;
|
|
5585
5661
|
}
|
|
5586
5662
|
this._tables = new TablesApi(this.transport, this.database);
|
|
5663
|
+
this._jobs = new JobsApi(this.transport, this.database);
|
|
5587
5664
|
this._databases = new DatabasesApi(this.transport);
|
|
5588
5665
|
this._schema = new SchemaApi(this.transport, this.database);
|
|
5589
5666
|
this._branches = new BranchesApi(this.transport, this.database);
|
|
@@ -5677,7 +5754,7 @@ var AoudaClient = class {
|
|
|
5677
5754
|
* ```
|
|
5678
5755
|
*/
|
|
5679
5756
|
table(name) {
|
|
5680
|
-
|
|
5757
|
+
validateNonEmptyString3(name, "Table name");
|
|
5681
5758
|
return new TableQuery(
|
|
5682
5759
|
this.transport,
|
|
5683
5760
|
name,
|
|
@@ -5693,6 +5770,13 @@ var AoudaClient = class {
|
|
|
5693
5770
|
get tables() {
|
|
5694
5771
|
return this._tables;
|
|
5695
5772
|
}
|
|
5773
|
+
/**
|
|
5774
|
+
* Access pending/background jobs for the current database (e.g. ColumnRewrite).
|
|
5775
|
+
* @returns The jobs API.
|
|
5776
|
+
*/
|
|
5777
|
+
get jobs() {
|
|
5778
|
+
return this._jobs;
|
|
5779
|
+
}
|
|
5696
5780
|
/**
|
|
5697
5781
|
* Access server-level database operations (list, create, get, drop).
|
|
5698
5782
|
* @returns The databases API.
|
|
@@ -5789,7 +5873,7 @@ var AoudaClient = class {
|
|
|
5789
5873
|
* ```
|
|
5790
5874
|
*/
|
|
5791
5875
|
bulkLoad(tableName, rows, options) {
|
|
5792
|
-
|
|
5876
|
+
validateNonEmptyString3(tableName, "tableName");
|
|
5793
5877
|
return new BulkLoadCoordinator(this.transport, this.database).run(
|
|
5794
5878
|
[tableName],
|
|
5795
5879
|
rows,
|