@aouda/client 0.0.1 → 0.0.3

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.
@@ -1,4 +1,4 @@
1
- import { A as AoudaClient } from '../client-DXT2ZAeO.cjs';
1
+ import { A as AoudaClient } from '../client-Bvs1yerF.cjs';
2
2
 
3
3
  /**
4
4
  * CLI for @aouda/client.
@@ -1,4 +1,4 @@
1
- import { A as AoudaClient } from '../client-DXT2ZAeO.js';
1
+ import { A as AoudaClient } from '../client-Bvs1yerF.js';
2
2
 
3
3
  /**
4
4
  * CLI for @aouda/client.
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.0.3",
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 globalThis.fetch(url, {
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 globalThis.fetch(url, {
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 globalThis.fetch(url, {
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 globalThis.fetch(url, {
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 globalThis.fetch(endpoint, {
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 fetch(url, init);
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 fetch(url, init);
1687
+ const response = await localNetworkFetch(url, init);
1572
1688
  if (response.ok || config.allowStatuses?.includes(response.status)) {
1573
1689
  return response;
1574
1690
  }
@@ -4412,6 +4528,79 @@ function parseSseLogEvent(rawEvent) {
4412
4528
  return null;
4413
4529
  }
4414
4530
 
4531
+ // src/admin/notifications.ts
4532
+ var BASE_PATH7 = "/admin/notifications";
4533
+ var NotificationsAdminApi = class {
4534
+ constructor(transport) {
4535
+ this.transport = transport;
4536
+ }
4537
+ /**
4538
+ * Get current notification provider state.
4539
+ * GET /admin/notifications
4540
+ */
4541
+ async get() {
4542
+ return this.transport.get(BASE_PATH7);
4543
+ }
4544
+ /**
4545
+ * Set or update the email notification provider.
4546
+ * PUT /admin/notifications/email
4547
+ */
4548
+ async putEmail(request) {
4549
+ return this.transport.put(
4550
+ `${BASE_PATH7}/email`,
4551
+ request
4552
+ );
4553
+ }
4554
+ /**
4555
+ * Remove the email notification provider (reverts to env/appsettings).
4556
+ * DELETE /admin/notifications/email
4557
+ */
4558
+ async deleteEmail() {
4559
+ return this.transport.delete(
4560
+ `${BASE_PATH7}/email`
4561
+ );
4562
+ }
4563
+ /**
4564
+ * Set or update the SMS notification provider.
4565
+ * PUT /admin/notifications/sms
4566
+ */
4567
+ async putSms(request) {
4568
+ return this.transport.put(
4569
+ `${BASE_PATH7}/sms`,
4570
+ request
4571
+ );
4572
+ }
4573
+ /**
4574
+ * Remove the SMS notification provider (reverts to env/appsettings).
4575
+ * DELETE /admin/notifications/sms
4576
+ */
4577
+ async deleteSms() {
4578
+ return this.transport.delete(
4579
+ `${BASE_PATH7}/sms`
4580
+ );
4581
+ }
4582
+ /**
4583
+ * Send a test email via the currently configured provider.
4584
+ * POST /admin/notifications/email/test
4585
+ */
4586
+ async testEmail(request) {
4587
+ return this.transport.post(
4588
+ `${BASE_PATH7}/email/test`,
4589
+ request
4590
+ );
4591
+ }
4592
+ /**
4593
+ * Send a test SMS via the currently configured provider.
4594
+ * POST /admin/notifications/sms/test
4595
+ */
4596
+ async testSms(request) {
4597
+ return this.transport.post(
4598
+ `${BASE_PATH7}/sms/test`,
4599
+ request
4600
+ );
4601
+ }
4602
+ };
4603
+
4415
4604
  // src/admin/index.ts
4416
4605
  var AdminApi = class {
4417
4606
  constructor(transport) {
@@ -4423,6 +4612,7 @@ var AdminApi = class {
4423
4612
  this.backup = new BackupAdminApi(transport);
4424
4613
  this.config = new ConfigAdminApi(transport);
4425
4614
  this.node = new NodeAdminApi(transport);
4615
+ this.notifications = new NotificationsAdminApi(transport);
4426
4616
  }
4427
4617
  };
4428
4618
 
@@ -4883,7 +5073,7 @@ var LongPollTransport = class {
4883
5073
  this._authHandler = options.authHandler;
4884
5074
  this._onReconnected = options.onReconnected;
4885
5075
  this._waitMs = Math.max(1, options.waitMs ?? DEFAULT_WAIT_MS);
4886
- this._fetch = options.fetchImpl ?? fetch;
5076
+ this._fetch = options.fetchImpl ?? localNetworkFetch;
4887
5077
  }
4888
5078
  get lastVersion() {
4889
5079
  return this._lastVersion;
@@ -5525,6 +5715,9 @@ function createAoudaClient(options) {
5525
5715
  return new AoudaClient(options);
5526
5716
  }
5527
5717
 
5718
+ // src/index.ts
5719
+ var version = package_default.version;
5720
+
5528
5721
  // src/cli/index.ts
5529
5722
  var HELP = `Aouda TypeScript client CLI
5530
5723