@aouda/client 0.0.2 → 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.
@@ -2008,7 +2008,7 @@ declare class AdminApi {
2008
2008
  * Two-layer auth model: clients connect via API key (Layer 1); user sign-in is performed
2009
2009
  * explicitly via AuthClient.signIn() (Layer 2). There is no auto-authentication on first request.
2010
2010
  *
2011
- * All auth endpoint calls use direct globalThis.fetch to avoid
2011
+ * All auth endpoint calls use direct fetch (with LNA hints) to avoid
2012
2012
  * circular refresh through the transport pipeline.
2013
2013
  *
2014
2014
  * @internal
@@ -2008,7 +2008,7 @@ declare class AdminApi {
2008
2008
  * Two-layer auth model: clients connect via API key (Layer 1); user sign-in is performed
2009
2009
  * explicitly via AuthClient.signIn() (Layer 2). There is no auto-authentication on first request.
2010
2010
  *
2011
- * All auth endpoint calls use direct globalThis.fetch to avoid
2011
+ * All auth endpoint calls use direct fetch (with LNA hints) to avoid
2012
2012
  * circular refresh through the transport pipeline.
2013
2013
  *
2014
2014
  * @internal
package/dist/index.cjs CHANGED
@@ -65,13 +65,85 @@ __export(index_exports, {
65
65
  TableQuery: () => TableQuery,
66
66
  TablesApi: () => TablesApi,
67
67
  WhereGroupBuilder: () => WhereGroupBuilder,
68
+ applyLocalNetworkAccess: () => applyLocalNetworkAccess,
68
69
  coerceColumnarValue: () => coerceColumnarValue,
69
70
  createAoudaClient: () => createAoudaClient,
70
71
  createAoudaClusterMcpToolSet: () => createAoudaClusterMcpToolSet,
72
+ installLocalNetworkFetch: () => installLocalNetworkFetch,
73
+ localNetworkFetch: () => localNetworkFetch,
74
+ resolveTargetAddressSpace: () => resolveTargetAddressSpace,
71
75
  version: () => version
72
76
  });
73
77
  module.exports = __toCommonJS(index_exports);
74
78
 
79
+ // package.json
80
+ var package_default = {
81
+ name: "@aouda/client",
82
+ version: "0.0.3",
83
+ description: "Official TypeScript/JavaScript client library for Aouda",
84
+ type: "module",
85
+ main: "./dist/index.cjs",
86
+ module: "./dist/index.js",
87
+ types: "./dist/index.d.ts",
88
+ bin: "./dist/cli/index.js",
89
+ exports: {
90
+ ".": {
91
+ types: "./dist/index.d.ts",
92
+ import: "./dist/index.js",
93
+ require: "./dist/index.cjs"
94
+ }
95
+ },
96
+ license: "MIT",
97
+ repository: {
98
+ type: "git",
99
+ url: "https://github.com/aoudadb/aouda-client-ts.git"
100
+ },
101
+ publishConfig: {
102
+ access: "public"
103
+ },
104
+ files: [
105
+ "dist",
106
+ "README.md",
107
+ "LICENSE"
108
+ ],
109
+ scripts: {
110
+ changeset: "changeset",
111
+ "version-packages": "changeset version",
112
+ release: "changeset publish",
113
+ prepublishOnly: "npm run build",
114
+ build: "tsup",
115
+ dev: "tsup --watch",
116
+ test: "vitest run",
117
+ "test:watch": "vitest",
118
+ "test:coverage": "vitest run --coverage",
119
+ lint: "eslint src tests",
120
+ "lint:fix": "eslint src tests --fix",
121
+ format: 'prettier --write "src/**/*.ts" "tests/**/*.ts"',
122
+ typecheck: "tsc --noEmit && tsc -p tsconfig.typecheck.json --noEmit",
123
+ "generate-types": "node dist/cli/index.js generate --server http://localhost:5000 --output ./types/schema.ts"
124
+ },
125
+ engines: {
126
+ node: ">=20"
127
+ },
128
+ devDependencies: {
129
+ "@changesets/cli": "^2.29.8",
130
+ "@eslint/js": "^9.15.0",
131
+ "@types/node": "^25.2.1",
132
+ "@types/ws": "^8.18.1",
133
+ eslint: "^9.15.0",
134
+ "eslint-config-prettier": "^9.1.0",
135
+ prettier: "^3.3.3",
136
+ tsup: "^8.3.5",
137
+ typescript: "^5.6.3",
138
+ "typescript-eslint": "^8.15.0",
139
+ vitest: "^2.1.4"
140
+ },
141
+ dependencies: {
142
+ "@msgpack/msgpack": "^3.1.3",
143
+ ws: "^8.20.0"
144
+ }
145
+ };
146
+
75
147
  // src/types.ts
76
148
  var RetryPolicy;
77
149
  ((RetryPolicy2) => {
@@ -188,6 +260,70 @@ var AoudaCircuitBreakerOpenError = class extends AoudaError {
188
260
  }
189
261
  };
190
262
 
263
+ // src/local-network-fetch.ts
264
+ function resolveTargetAddressSpace(url) {
265
+ let parsed;
266
+ try {
267
+ parsed = new URL(url);
268
+ } catch {
269
+ return void 0;
270
+ }
271
+ const hostname = parsed.hostname.replace(/^\[|\]$/g, "").toLowerCase();
272
+ if (hostname === "localhost" || hostname === "::1") {
273
+ return "loopback";
274
+ }
275
+ const ipv4 = hostname.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
276
+ if (ipv4) {
277
+ const [first, second] = [Number(ipv4[1]), Number(ipv4[2])];
278
+ if (first === 127) return "loopback";
279
+ if (first === 10) return "local";
280
+ if (first === 172 && second >= 16 && second <= 31) return "local";
281
+ if (first === 192 && second === 168) return "local";
282
+ if (first === 169 && second === 254) return "local";
283
+ }
284
+ if (hostname.endsWith(".local")) {
285
+ return "local";
286
+ }
287
+ return void 0;
288
+ }
289
+ function applyLocalNetworkAccess(url, init) {
290
+ const space = resolveTargetAddressSpace(url);
291
+ if (!space) {
292
+ return init ?? {};
293
+ }
294
+ return { ...init, targetAddressSpace: space };
295
+ }
296
+ function resolveFetchUrl(input) {
297
+ if (typeof input === "string") {
298
+ return input;
299
+ }
300
+ if (input instanceof URL) {
301
+ return input.href;
302
+ }
303
+ return input.url;
304
+ }
305
+ function localNetworkFetch(input, init) {
306
+ const url = resolveFetchUrl(input);
307
+ const merged = applyLocalNetworkAccess(url, init);
308
+ return globalThis.fetch(input, merged);
309
+ }
310
+ var installed = false;
311
+ function installLocalNetworkFetch() {
312
+ if (installed || typeof globalThis.window === "undefined") {
313
+ return;
314
+ }
315
+ installed = true;
316
+ const nativeFetch = globalThis.fetch.bind(globalThis);
317
+ globalThis.fetch = (input, init) => {
318
+ const url = resolveFetchUrl(input);
319
+ const space = resolveTargetAddressSpace(url);
320
+ if (!space) {
321
+ return nativeFetch(input, init);
322
+ }
323
+ return nativeFetch(input, applyLocalNetworkAccess(url, init));
324
+ };
325
+ }
326
+
191
327
  // src/auth/auth-handler.ts
192
328
  var DEFAULT_REFRESH_THRESHOLD_MS = 12e4;
193
329
  var CONTENT_TYPE_JSON = "application/json";
@@ -378,7 +514,7 @@ var AuthHandler = class {
378
514
  headers["Authorization"] = `Bearer ${this._accessToken}`;
379
515
  }
380
516
  try {
381
- await globalThis.fetch(url, {
517
+ await localNetworkFetch(url, {
382
518
  method: "POST",
383
519
  headers,
384
520
  signal: AbortSignal.timeout(this._timeout)
@@ -411,7 +547,7 @@ var AuthHandler = class {
411
547
  if (token) {
412
548
  headers["Authorization"] = `Bearer ${token}`;
413
549
  }
414
- const response = await globalThis.fetch(url, {
550
+ const response = await localNetworkFetch(url, {
415
551
  method: "GET",
416
552
  headers,
417
553
  signal: AbortSignal.timeout(this._timeout)
@@ -438,7 +574,7 @@ var AuthHandler = class {
438
574
  if (token) {
439
575
  headers["Authorization"] = `Bearer ${token}`;
440
576
  }
441
- const response = await globalThis.fetch(url, {
577
+ const response = await localNetworkFetch(url, {
442
578
  method: "PUT",
443
579
  headers,
444
580
  body: JSON.stringify({ currentPassword, newPassword }),
@@ -478,7 +614,7 @@ var AuthHandler = class {
478
614
  if (this._accessToken) {
479
615
  headers["Authorization"] = `Bearer ${this._accessToken}`;
480
616
  }
481
- return globalThis.fetch(url, {
617
+ return localNetworkFetch(url, {
482
618
  method,
483
619
  headers,
484
620
  body: JSON.stringify(body),
@@ -831,7 +967,7 @@ var AuthClient = class {
831
967
  if (token) {
832
968
  headers["Authorization"] = `Bearer ${token}`;
833
969
  }
834
- const response = await globalThis.fetch(endpoint, {
970
+ const response = await localNetworkFetch(endpoint, {
835
971
  method,
836
972
  headers,
837
973
  body: body !== void 0 && method !== "GET" && method !== "DELETE" ? JSON.stringify(body) : void 0,
@@ -1154,7 +1290,7 @@ var HttpTransport = class {
1154
1290
  init.body = JSON.stringify(config.body);
1155
1291
  }
1156
1292
  try {
1157
- const response = await fetch(url, init);
1293
+ const response = await localNetworkFetch(url, init);
1158
1294
  if (!response.ok) {
1159
1295
  const text = await response.text();
1160
1296
  if (config.allowStatuses?.includes(response.status) && text) {
@@ -1268,7 +1404,7 @@ var HttpTransport = class {
1268
1404
  init.body = JSON.stringify(config.body);
1269
1405
  }
1270
1406
  try {
1271
- const response = await fetch(url, init);
1407
+ const response = await localNetworkFetch(url, init);
1272
1408
  if (response.ok || config.allowStatuses?.includes(response.status)) {
1273
1409
  return response;
1274
1410
  }
@@ -4670,7 +4806,7 @@ var LongPollTransport = class {
4670
4806
  this._authHandler = options.authHandler;
4671
4807
  this._onReconnected = options.onReconnected;
4672
4808
  this._waitMs = Math.max(1, options.waitMs ?? DEFAULT_WAIT_MS);
4673
- this._fetch = options.fetchImpl ?? fetch;
4809
+ this._fetch = options.fetchImpl ?? localNetworkFetch;
4674
4810
  }
4675
4811
  get lastVersion() {
4676
4812
  return this._lastVersion;
@@ -5563,7 +5699,7 @@ function createAoudaClusterMcpToolSet(client) {
5563
5699
  }
5564
5700
 
5565
5701
  // src/index.ts
5566
- var version = "0.0.2";
5702
+ var version = package_default.version;
5567
5703
  // Annotate the CommonJS export names for ESM import in node:
5568
5704
  0 && (module.exports = {
5569
5705
  AOUDA_DATA_TYPES,
@@ -5601,9 +5737,13 @@ var version = "0.0.2";
5601
5737
  TableQuery,
5602
5738
  TablesApi,
5603
5739
  WhereGroupBuilder,
5740
+ applyLocalNetworkAccess,
5604
5741
  coerceColumnarValue,
5605
5742
  createAoudaClient,
5606
5743
  createAoudaClusterMcpToolSet,
5744
+ installLocalNetworkFetch,
5745
+ localNetworkFetch,
5746
+ resolveTargetAddressSpace,
5607
5747
  version
5608
5748
  });
5609
5749
  //# sourceMappingURL=index.cjs.map