@aouda/client 0.0.2 → 0.1.0
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 +137 -12
- 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 +137 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-otKeBYQG.d.cts → client-Dttx8D7c.d.cts} +28 -4
- package/dist/{client-otKeBYQG.d.ts → client-Dttx8D7c.d.ts} +28 -4
- package/dist/index.cjs +159 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -4
- package/dist/index.d.ts +35 -4
- package/dist/index.js +155 -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
|
@@ -389,6 +389,74 @@ import * as fs3 from "fs";
|
|
|
389
389
|
import * as path3 from "path";
|
|
390
390
|
import { fileURLToPath } from "url";
|
|
391
391
|
|
|
392
|
+
// package.json
|
|
393
|
+
var package_default = {
|
|
394
|
+
name: "@aouda/client",
|
|
395
|
+
version: "0.1.0",
|
|
396
|
+
description: "Official TypeScript/JavaScript client library for Aouda",
|
|
397
|
+
type: "module",
|
|
398
|
+
main: "./dist/index.cjs",
|
|
399
|
+
module: "./dist/index.js",
|
|
400
|
+
types: "./dist/index.d.ts",
|
|
401
|
+
bin: "./dist/cli/index.js",
|
|
402
|
+
exports: {
|
|
403
|
+
".": {
|
|
404
|
+
types: "./dist/index.d.ts",
|
|
405
|
+
import: "./dist/index.js",
|
|
406
|
+
require: "./dist/index.cjs"
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
license: "MIT",
|
|
410
|
+
repository: {
|
|
411
|
+
type: "git",
|
|
412
|
+
url: "https://github.com/aoudadb/aouda-client-ts.git"
|
|
413
|
+
},
|
|
414
|
+
publishConfig: {
|
|
415
|
+
access: "public"
|
|
416
|
+
},
|
|
417
|
+
files: [
|
|
418
|
+
"dist",
|
|
419
|
+
"README.md",
|
|
420
|
+
"LICENSE"
|
|
421
|
+
],
|
|
422
|
+
scripts: {
|
|
423
|
+
changeset: "changeset",
|
|
424
|
+
"version-packages": "changeset version",
|
|
425
|
+
release: "changeset publish",
|
|
426
|
+
prepublishOnly: "npm run build",
|
|
427
|
+
build: "tsup",
|
|
428
|
+
dev: "tsup --watch",
|
|
429
|
+
test: "vitest run",
|
|
430
|
+
"test:watch": "vitest",
|
|
431
|
+
"test:coverage": "vitest run --coverage",
|
|
432
|
+
lint: "eslint src tests",
|
|
433
|
+
"lint:fix": "eslint src tests --fix",
|
|
434
|
+
format: 'prettier --write "src/**/*.ts" "tests/**/*.ts"',
|
|
435
|
+
typecheck: "tsc --noEmit && tsc -p tsconfig.typecheck.json --noEmit",
|
|
436
|
+
"generate-types": "node dist/cli/index.js generate --server http://localhost:5000 --output ./types/schema.ts"
|
|
437
|
+
},
|
|
438
|
+
engines: {
|
|
439
|
+
node: ">=20"
|
|
440
|
+
},
|
|
441
|
+
devDependencies: {
|
|
442
|
+
"@changesets/cli": "^2.29.8",
|
|
443
|
+
"@eslint/js": "^9.15.0",
|
|
444
|
+
"@types/node": "^25.2.1",
|
|
445
|
+
"@types/ws": "^8.18.1",
|
|
446
|
+
eslint: "^9.15.0",
|
|
447
|
+
"eslint-config-prettier": "^9.1.0",
|
|
448
|
+
prettier: "^3.3.3",
|
|
449
|
+
tsup: "^8.3.5",
|
|
450
|
+
typescript: "^5.6.3",
|
|
451
|
+
"typescript-eslint": "^8.15.0",
|
|
452
|
+
vitest: "^2.1.4"
|
|
453
|
+
},
|
|
454
|
+
dependencies: {
|
|
455
|
+
"@msgpack/msgpack": "^3.1.3",
|
|
456
|
+
ws: "^8.20.0"
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
|
|
392
460
|
// src/types.ts
|
|
393
461
|
var RetryPolicy;
|
|
394
462
|
((RetryPolicy2) => {
|
|
@@ -488,6 +556,54 @@ var AoudaCircuitBreakerOpenError = class extends AoudaError {
|
|
|
488
556
|
}
|
|
489
557
|
};
|
|
490
558
|
|
|
559
|
+
// src/local-network-fetch.ts
|
|
560
|
+
function resolveTargetAddressSpace(url) {
|
|
561
|
+
let parsed;
|
|
562
|
+
try {
|
|
563
|
+
parsed = new URL(url);
|
|
564
|
+
} catch {
|
|
565
|
+
return void 0;
|
|
566
|
+
}
|
|
567
|
+
const hostname = parsed.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
568
|
+
if (hostname === "localhost" || hostname === "::1") {
|
|
569
|
+
return "loopback";
|
|
570
|
+
}
|
|
571
|
+
const ipv4 = hostname.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
572
|
+
if (ipv4) {
|
|
573
|
+
const [first, second] = [Number(ipv4[1]), Number(ipv4[2])];
|
|
574
|
+
if (first === 127) return "loopback";
|
|
575
|
+
if (first === 10) return "local";
|
|
576
|
+
if (first === 172 && second >= 16 && second <= 31) return "local";
|
|
577
|
+
if (first === 192 && second === 168) return "local";
|
|
578
|
+
if (first === 169 && second === 254) return "local";
|
|
579
|
+
}
|
|
580
|
+
if (hostname.endsWith(".local")) {
|
|
581
|
+
return "local";
|
|
582
|
+
}
|
|
583
|
+
return void 0;
|
|
584
|
+
}
|
|
585
|
+
function applyLocalNetworkAccess(url, init) {
|
|
586
|
+
const space = resolveTargetAddressSpace(url);
|
|
587
|
+
if (!space) {
|
|
588
|
+
return init ?? {};
|
|
589
|
+
}
|
|
590
|
+
return { ...init, targetAddressSpace: space };
|
|
591
|
+
}
|
|
592
|
+
function resolveFetchUrl(input) {
|
|
593
|
+
if (typeof input === "string") {
|
|
594
|
+
return input;
|
|
595
|
+
}
|
|
596
|
+
if (input instanceof URL) {
|
|
597
|
+
return input.href;
|
|
598
|
+
}
|
|
599
|
+
return input.url;
|
|
600
|
+
}
|
|
601
|
+
function localNetworkFetch(input, init) {
|
|
602
|
+
const url = resolveFetchUrl(input);
|
|
603
|
+
const merged = applyLocalNetworkAccess(url, init);
|
|
604
|
+
return globalThis.fetch(input, merged);
|
|
605
|
+
}
|
|
606
|
+
|
|
491
607
|
// src/auth/auth-handler.ts
|
|
492
608
|
var DEFAULT_REFRESH_THRESHOLD_MS = 12e4;
|
|
493
609
|
var CONTENT_TYPE_JSON = "application/json";
|
|
@@ -678,7 +794,7 @@ var AuthHandler = class {
|
|
|
678
794
|
headers["Authorization"] = `Bearer ${this._accessToken}`;
|
|
679
795
|
}
|
|
680
796
|
try {
|
|
681
|
-
await
|
|
797
|
+
await localNetworkFetch(url, {
|
|
682
798
|
method: "POST",
|
|
683
799
|
headers,
|
|
684
800
|
signal: AbortSignal.timeout(this._timeout)
|
|
@@ -711,7 +827,7 @@ var AuthHandler = class {
|
|
|
711
827
|
if (token) {
|
|
712
828
|
headers["Authorization"] = `Bearer ${token}`;
|
|
713
829
|
}
|
|
714
|
-
const response = await
|
|
830
|
+
const response = await localNetworkFetch(url, {
|
|
715
831
|
method: "GET",
|
|
716
832
|
headers,
|
|
717
833
|
signal: AbortSignal.timeout(this._timeout)
|
|
@@ -738,7 +854,7 @@ var AuthHandler = class {
|
|
|
738
854
|
if (token) {
|
|
739
855
|
headers["Authorization"] = `Bearer ${token}`;
|
|
740
856
|
}
|
|
741
|
-
const response = await
|
|
857
|
+
const response = await localNetworkFetch(url, {
|
|
742
858
|
method: "PUT",
|
|
743
859
|
headers,
|
|
744
860
|
body: JSON.stringify({ currentPassword, newPassword }),
|
|
@@ -778,7 +894,7 @@ var AuthHandler = class {
|
|
|
778
894
|
if (this._accessToken) {
|
|
779
895
|
headers["Authorization"] = `Bearer ${this._accessToken}`;
|
|
780
896
|
}
|
|
781
|
-
return
|
|
897
|
+
return localNetworkFetch(url, {
|
|
782
898
|
method,
|
|
783
899
|
headers,
|
|
784
900
|
body: JSON.stringify(body),
|
|
@@ -1131,7 +1247,7 @@ var AuthClient = class {
|
|
|
1131
1247
|
if (token) {
|
|
1132
1248
|
headers["Authorization"] = `Bearer ${token}`;
|
|
1133
1249
|
}
|
|
1134
|
-
const response = await
|
|
1250
|
+
const response = await localNetworkFetch(endpoint, {
|
|
1135
1251
|
method,
|
|
1136
1252
|
headers,
|
|
1137
1253
|
body: body !== void 0 && method !== "GET" && method !== "DELETE" ? JSON.stringify(body) : void 0,
|
|
@@ -1454,7 +1570,7 @@ var HttpTransport = class {
|
|
|
1454
1570
|
init.body = JSON.stringify(config.body);
|
|
1455
1571
|
}
|
|
1456
1572
|
try {
|
|
1457
|
-
const response = await
|
|
1573
|
+
const response = await localNetworkFetch(url, init);
|
|
1458
1574
|
if (!response.ok) {
|
|
1459
1575
|
const text = await response.text();
|
|
1460
1576
|
if (config.allowStatuses?.includes(response.status) && text) {
|
|
@@ -1568,7 +1684,7 @@ var HttpTransport = class {
|
|
|
1568
1684
|
init.body = JSON.stringify(config.body);
|
|
1569
1685
|
}
|
|
1570
1686
|
try {
|
|
1571
|
-
const response = await
|
|
1687
|
+
const response = await localNetworkFetch(url, init);
|
|
1572
1688
|
if (response.ok || config.allowStatuses?.includes(response.status)) {
|
|
1573
1689
|
return response;
|
|
1574
1690
|
}
|
|
@@ -3805,13 +3921,19 @@ var DatabasesApi = class {
|
|
|
3805
3921
|
this.transport = transport;
|
|
3806
3922
|
}
|
|
3807
3923
|
/**
|
|
3808
|
-
* Lists
|
|
3924
|
+
* Lists databases on the server.
|
|
3809
3925
|
* GET /api/databases
|
|
3810
3926
|
*
|
|
3811
|
-
*
|
|
3927
|
+
* By default only operator-facing databases (isInternal === false) are returned.
|
|
3928
|
+
* Pass `{ includeInternal: true }` to receive the full catalog including internal
|
|
3929
|
+
* infrastructure databases such as `_serverauth` and `_settings`.
|
|
3930
|
+
*
|
|
3931
|
+
* @param options.includeInternal - When true, appends `?include=internal` to the request.
|
|
3932
|
+
* @returns Array of database info.
|
|
3812
3933
|
*/
|
|
3813
|
-
async list() {
|
|
3814
|
-
const
|
|
3934
|
+
async list(options) {
|
|
3935
|
+
const path4 = options?.includeInternal ? "/api/databases?include=internal" : "/api/databases";
|
|
3936
|
+
const response = await this.transport.get(path4);
|
|
3815
3937
|
return response.databases;
|
|
3816
3938
|
}
|
|
3817
3939
|
/**
|
|
@@ -4957,7 +5079,7 @@ var LongPollTransport = class {
|
|
|
4957
5079
|
this._authHandler = options.authHandler;
|
|
4958
5080
|
this._onReconnected = options.onReconnected;
|
|
4959
5081
|
this._waitMs = Math.max(1, options.waitMs ?? DEFAULT_WAIT_MS);
|
|
4960
|
-
this._fetch = options.fetchImpl ??
|
|
5082
|
+
this._fetch = options.fetchImpl ?? localNetworkFetch;
|
|
4961
5083
|
}
|
|
4962
5084
|
get lastVersion() {
|
|
4963
5085
|
return this._lastVersion;
|
|
@@ -5599,6 +5721,9 @@ function createAoudaClient(options) {
|
|
|
5599
5721
|
return new AoudaClient(options);
|
|
5600
5722
|
}
|
|
5601
5723
|
|
|
5724
|
+
// src/index.ts
|
|
5725
|
+
var version = package_default.version;
|
|
5726
|
+
|
|
5602
5727
|
// src/cli/index.ts
|
|
5603
5728
|
var HELP = `Aouda TypeScript client CLI
|
|
5604
5729
|
|