layero 0.11.21 → 0.11.22

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.
@@ -35,10 +35,25 @@ async function gateway(url, key, path, init = {}) {
35
35
  }
36
36
  if (!res.ok) {
37
37
  const message = body?.message || body?.error || `${res.status}`;
38
- throw new LayeroError("storage_refused", `хранилище отказало: ${message}`, body?.hint ?? "проверьте, что файлы включены: layero data enable --storage");
38
+ throw new LayeroError("storage_refused", `хранилище отказало: ${message}`, body?.hint ?? refusalAdvice(res.status, body));
39
39
  }
40
40
  return body;
41
41
  }
42
+ /** Совет по отказу — по его причине. Раньше на любой отказ советовали
43
+ * включить файлы, и на «бакет уже есть» это был совет мимо (R2-04, 27.10). */
44
+ function refusalAdvice(status, body) {
45
+ const text = `${body?.error ?? ""} ${body?.message ?? ""} ${body?.statusCode ?? ""}`.toLowerCase();
46
+ if (status === 409 || text.includes("already exists") || text.includes("duplicate")) {
47
+ return "бакет с таким именем уже есть — посмотреть: layero data buckets list, или выберите другое имя";
48
+ }
49
+ if (status === 401 || status === 403) {
50
+ return "ключ хранилища не подошёл — повторите команду; не помогло — проверьте, что файлы включены: layero data enable --storage";
51
+ }
52
+ if (status === 400 && text.includes("name")) {
53
+ return "имя бакета — латиница, цифры, дефис и подчёркивание";
54
+ }
55
+ return "проверьте, что файлы включены: layero data enable --storage";
56
+ }
42
57
  export async function dataBucketsListCmd(opts) {
43
58
  const { api, org, db, ref } = await target(opts);
44
59
  const s = await api.openStorageSession(org, db.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "layero",
3
- "version": "0.11.21",
3
+ "version": "0.11.22",
4
4
  "description": "Layero CLI — deploy a directory or a repo to hosting with build servers in Russia. JSON events and exit codes for AI agents and CI.",
5
5
  "license": "MIT",
6
6
  "type": "module",