@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.cjs
CHANGED
|
@@ -1113,6 +1113,31 @@ var KVService = class extends BaseService {
|
|
|
1113
1113
|
}
|
|
1114
1114
|
return void 0;
|
|
1115
1115
|
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Classify a KV 404 by reading the response body once.
|
|
1118
|
+
*
|
|
1119
|
+
* The server returns 404 both for a genuinely missing key AND for an
|
|
1120
|
+
* un-hosted space (body "Space not found"). Previously get/head/delete
|
|
1121
|
+
* collapsed every 404 to KV_NOT_FOUND before reading the body, so an
|
|
1122
|
+
* un-hosted-space read was indistinguishable from a missing key. We now
|
|
1123
|
+
* preserve status + the "Space not found" body for the un-hosted case (so the
|
|
1124
|
+
* CLI/SDK can normalize it to SPACE_NOT_HOSTED, matching put/list/sql), and
|
|
1125
|
+
* fall through to KV_NOT_FOUND for a real missing key.
|
|
1126
|
+
*/
|
|
1127
|
+
async classifyNotFound(response, key) {
|
|
1128
|
+
const errorText = await response.text();
|
|
1129
|
+
if (/space not found/i.test(errorText)) {
|
|
1130
|
+
return err(
|
|
1131
|
+
serviceError(
|
|
1132
|
+
ErrorCodes.KV_NOT_FOUND,
|
|
1133
|
+
`KV ${response.status} - ${errorText}`,
|
|
1134
|
+
"kv",
|
|
1135
|
+
{ meta: { status: response.status, statusText: response.statusText } }
|
|
1136
|
+
)
|
|
1137
|
+
);
|
|
1138
|
+
}
|
|
1139
|
+
return err(serviceError(ErrorCodes.KV_NOT_FOUND, `Key not found: ${key}`, "kv"));
|
|
1140
|
+
}
|
|
1116
1141
|
/**
|
|
1117
1142
|
* Get the full path with optional prefix.
|
|
1118
1143
|
*
|
|
@@ -1359,13 +1384,7 @@ var KVService = class extends BaseService {
|
|
|
1359
1384
|
}));
|
|
1360
1385
|
}
|
|
1361
1386
|
if (response.status === 404) {
|
|
1362
|
-
return
|
|
1363
|
-
serviceError(
|
|
1364
|
-
ErrorCodes.KV_NOT_FOUND,
|
|
1365
|
-
`Key not found: ${key}`,
|
|
1366
|
-
"kv"
|
|
1367
|
-
)
|
|
1368
|
-
);
|
|
1387
|
+
return this.classifyNotFound(response, key);
|
|
1369
1388
|
}
|
|
1370
1389
|
const errorText = await response.text();
|
|
1371
1390
|
return err(
|
|
@@ -1626,13 +1645,7 @@ var KVService = class extends BaseService {
|
|
|
1626
1645
|
}));
|
|
1627
1646
|
}
|
|
1628
1647
|
if (response.status === 404) {
|
|
1629
|
-
return
|
|
1630
|
-
serviceError(
|
|
1631
|
-
ErrorCodes.KV_NOT_FOUND,
|
|
1632
|
-
`Key not found: ${key}`,
|
|
1633
|
-
"kv"
|
|
1634
|
-
)
|
|
1635
|
-
);
|
|
1648
|
+
return this.classifyNotFound(response, key);
|
|
1636
1649
|
}
|
|
1637
1650
|
const errorText = await response.text();
|
|
1638
1651
|
return err(
|
|
@@ -1677,13 +1690,7 @@ var KVService = class extends BaseService {
|
|
|
1677
1690
|
}));
|
|
1678
1691
|
}
|
|
1679
1692
|
if (response.status === 404) {
|
|
1680
|
-
return
|
|
1681
|
-
serviceError(
|
|
1682
|
-
ErrorCodes.KV_NOT_FOUND,
|
|
1683
|
-
`Key not found: ${key}`,
|
|
1684
|
-
"kv"
|
|
1685
|
-
)
|
|
1686
|
-
);
|
|
1693
|
+
return this.classifyNotFound(response, key);
|
|
1687
1694
|
}
|
|
1688
1695
|
const errorText = await response.text();
|
|
1689
1696
|
return err(
|