@jsondb-cloud/cli 1.0.19 → 1.0.21

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.
@@ -131,21 +131,18 @@ async function deleteCommand(path, client) {
131
131
  (0, output_1.success)(`Deleted ${path}`);
132
132
  }
133
133
  async function listCollectionsCommand(client) {
134
- // List documents and extract unique collection names
135
- const res = await client.get("?limit=100");
134
+ const res = await client.get("");
136
135
  if (!res.ok) {
137
136
  const data = await res.json().catch(() => ({}));
138
137
  (0, output_1.error)(data.error?.message || `Failed to list collections: ${res.status}`);
139
138
  process.exit(1);
140
139
  }
141
140
  const data = await res.json();
142
- const collections = new Set();
143
- for (const doc of data.data || []) {
144
- if (doc.$collection)
145
- collections.add(doc.$collection);
146
- }
147
- for (const coll of Array.from(collections).sort()) {
148
- console.log(coll);
141
+ const collections = data.data ?? data;
142
+ if (Array.isArray(collections)) {
143
+ for (const coll of collections.sort()) {
144
+ console.log(coll);
145
+ }
149
146
  }
150
147
  }
151
148
  async function listDocumentsCommand(collection, client, options) {
@@ -14,6 +14,8 @@ class ApiClient {
14
14
  }
15
15
  url(path) {
16
16
  const base = this.config.baseUrl.replace(/\/$/, "");
17
+ if (!path)
18
+ return `${base}/${this.config.project}`;
17
19
  return `${base}/${this.config.project}/${path}`;
18
20
  }
19
21
  headers(extra) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsondb-cloud/cli",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "CLI tool for jsondb.cloud — push, pull, manage your JSON database from the terminal",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -21,6 +21,7 @@
21
21
  "format": "prettier --write 'src/**/*.ts'",
22
22
  "format:check": "prettier --check 'src/**/*.ts'",
23
23
  "test": "vitest run",
24
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
24
25
  "prepare": "husky"
25
26
  },
26
27
  "dependencies": {
@@ -30,6 +31,7 @@
30
31
  "@eslint/js": "^10.0.1",
31
32
  "@types/node": "^20.0.0",
32
33
  "eslint": "^10.0.2",
34
+ "execa": "^9.6.1",
33
35
  "husky": "^9.1.7",
34
36
  "lint-staged": "^16.2.7",
35
37
  "prettier": "^3.8.1",