@tinycloud/sdk-services 2.4.0-beta.1 → 2.4.0-beta.2
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/index.cjs +28 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -21
- package/dist/index.js.map +1 -1
- package/dist/kv/index.cjs +28 -21
- package/dist/kv/index.cjs.map +1 -1
- package/dist/kv/index.d.cts +12 -0
- package/dist/kv/index.d.ts +12 -0
- package/dist/kv/index.js +28 -21
- package/dist/kv/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -983,6 +983,31 @@ var KVService = class extends BaseService {
|
|
|
983
983
|
}
|
|
984
984
|
return void 0;
|
|
985
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* Classify a KV 404 by reading the response body once.
|
|
988
|
+
*
|
|
989
|
+
* The server returns 404 both for a genuinely missing key AND for an
|
|
990
|
+
* un-hosted space (body "Space not found"). Previously get/head/delete
|
|
991
|
+
* collapsed every 404 to KV_NOT_FOUND before reading the body, so an
|
|
992
|
+
* un-hosted-space read was indistinguishable from a missing key. We now
|
|
993
|
+
* preserve status + the "Space not found" body for the un-hosted case (so the
|
|
994
|
+
* CLI/SDK can normalize it to SPACE_NOT_HOSTED, matching put/list/sql), and
|
|
995
|
+
* fall through to KV_NOT_FOUND for a real missing key.
|
|
996
|
+
*/
|
|
997
|
+
async classifyNotFound(response, key) {
|
|
998
|
+
const errorText = await response.text();
|
|
999
|
+
if (/space not found/i.test(errorText)) {
|
|
1000
|
+
return err(
|
|
1001
|
+
serviceError(
|
|
1002
|
+
ErrorCodes.KV_NOT_FOUND,
|
|
1003
|
+
`KV ${response.status} - ${errorText}`,
|
|
1004
|
+
"kv",
|
|
1005
|
+
{ meta: { status: response.status, statusText: response.statusText } }
|
|
1006
|
+
)
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
1009
|
+
return err(serviceError(ErrorCodes.KV_NOT_FOUND, `Key not found: ${key}`, "kv"));
|
|
1010
|
+
}
|
|
986
1011
|
/**
|
|
987
1012
|
* Get the full path with optional prefix.
|
|
988
1013
|
*
|
|
@@ -1229,13 +1254,7 @@ var KVService = class extends BaseService {
|
|
|
1229
1254
|
}));
|
|
1230
1255
|
}
|
|
1231
1256
|
if (response.status === 404) {
|
|
1232
|
-
return
|
|
1233
|
-
serviceError(
|
|
1234
|
-
ErrorCodes.KV_NOT_FOUND,
|
|
1235
|
-
`Key not found: ${key}`,
|
|
1236
|
-
"kv"
|
|
1237
|
-
)
|
|
1238
|
-
);
|
|
1257
|
+
return this.classifyNotFound(response, key);
|
|
1239
1258
|
}
|
|
1240
1259
|
const errorText = await response.text();
|
|
1241
1260
|
return err(
|
|
@@ -1496,13 +1515,7 @@ var KVService = class extends BaseService {
|
|
|
1496
1515
|
}));
|
|
1497
1516
|
}
|
|
1498
1517
|
if (response.status === 404) {
|
|
1499
|
-
return
|
|
1500
|
-
serviceError(
|
|
1501
|
-
ErrorCodes.KV_NOT_FOUND,
|
|
1502
|
-
`Key not found: ${key}`,
|
|
1503
|
-
"kv"
|
|
1504
|
-
)
|
|
1505
|
-
);
|
|
1518
|
+
return this.classifyNotFound(response, key);
|
|
1506
1519
|
}
|
|
1507
1520
|
const errorText = await response.text();
|
|
1508
1521
|
return err(
|
|
@@ -1547,13 +1560,7 @@ var KVService = class extends BaseService {
|
|
|
1547
1560
|
}));
|
|
1548
1561
|
}
|
|
1549
1562
|
if (response.status === 404) {
|
|
1550
|
-
return
|
|
1551
|
-
serviceError(
|
|
1552
|
-
ErrorCodes.KV_NOT_FOUND,
|
|
1553
|
-
`Key not found: ${key}`,
|
|
1554
|
-
"kv"
|
|
1555
|
-
)
|
|
1556
|
-
);
|
|
1563
|
+
return this.classifyNotFound(response, key);
|
|
1557
1564
|
}
|
|
1558
1565
|
const errorText = await response.text();
|
|
1559
1566
|
return err(
|