@thinger-io/cli-core 0.4.1 → 0.5.0

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +204 -0
  2. package/README.md +82 -31
  3. package/docs/thinger-concepts.md +7 -7
  4. package/docs/thinger-product-code.md +2 -2
  5. package/docs/thinger-server-admin.md +2 -2
  6. package/lib/bucket-export.js +91 -0
  7. package/lib/cli.js +106 -50
  8. package/lib/commands/_shared.js +89 -1
  9. package/lib/commands/api.js +90 -0
  10. package/lib/commands/arguments.js +62 -0
  11. package/lib/commands/bucket.js +52 -44
  12. package/lib/commands/dashboard.js +5 -2
  13. package/lib/commands/data.js +539 -0
  14. package/lib/commands/device.js +128 -241
  15. package/lib/commands/grammar.js +279 -0
  16. package/lib/commands/product.js +104 -214
  17. package/lib/commands/profile.js +1 -0
  18. package/lib/commands/resources.js +975 -0
  19. package/lib/dashboard-init.js +4 -3
  20. package/lib/dashboard.js +10 -2
  21. package/lib/mcp/catalog.js +303 -65
  22. package/lib/mcp/core-types.js +36 -0
  23. package/lib/mcp/helpers.js +23 -2
  24. package/lib/mcp/naming.js +20 -0
  25. package/lib/mcp/registry.js +18 -67
  26. package/lib/mcp/resource-hooks.js +19 -5
  27. package/lib/mcp/server.js +43 -11
  28. package/lib/mcp/tools-resource.js +1232 -330
  29. package/lib/mcp/types/bucket-data.js +151 -0
  30. package/lib/mcp/{tools-dashboards.js → types/dashboard-apps.js} +99 -37
  31. package/lib/mcp/types/device-resource.js +117 -0
  32. package/lib/mcp/types/doc.js +35 -0
  33. package/lib/mcp/types/plugin-call.js +75 -0
  34. package/lib/mcp/types/product-api.js +44 -0
  35. package/lib/mcp/types/profile.js +37 -0
  36. package/lib/mcp/types/storage-file.js +170 -0
  37. package/lib/openapi.js +18 -0
  38. package/lib/product-apply.js +121 -0
  39. package/lib/raw-api.js +111 -0
  40. package/lib/storage.js +41 -13
  41. package/lib/tokens.js +16 -2
  42. package/package.json +1 -1
  43. package/lib/mcp/tools-buckets.js +0 -130
  44. package/lib/mcp/tools-devices.js +0 -134
  45. package/lib/mcp/tools-misc.js +0 -48
  46. package/lib/mcp/tools-plugins.js +0 -63
  47. package/lib/mcp/tools-products.js +0 -52
  48. package/lib/mcp/tools-storage.js +0 -173
@@ -10,7 +10,7 @@ import { checkDestination, destinationContext, manifestName } from './dashboard.
10
10
  import { SDK_PACKAGE } from './dashboard-sdk.js';
11
11
  import { inputError } from './errors.js';
12
12
  import { identity } from './identity.js';
13
- import { toolName } from './mcp/naming.js';
13
+ import { opRef } from './mcp/naming.js';
14
14
  import { extractTgz } from './tgz.js';
15
15
 
16
16
  const run = promisify(exec);
@@ -194,8 +194,9 @@ its own as a standalone page.
194
194
  2. \`${cli} dashboard dev\` gives a link that opens the local app against the Thinger server, with
195
195
  a temporary token and the context in ${manifestName()} (\`dev\`). Open it in a browser: the
196
196
  app gets real data, reloads on every change, and its errors are in the browser console.
197
- Agents: the MCP tool \`${toolName('dashboard_dev')}\` gives the same link; open it with browser
198
- tools.
197
+ Agents: the MCP call \`${opRef('dashboard', 'dev')}\` gives the same link; open it with
198
+ browser tools.
199
+
199
200
  3. \`npm run build\`, then \`${cli} dashboard publish\`: it uploads \`${buildDir}\` and points the
200
201
  destinations in ${manifestName()} at it.
201
202
 
package/lib/dashboard.js CHANGED
@@ -166,7 +166,7 @@ export async function uploadFiles(storage, files, user) {
166
166
  }
167
167
 
168
168
  /** Paths of every file in a storage (empty when it has none yet). */
169
- async function listFiles(storage, user) {
169
+ export async function listFiles(storage, user) {
170
170
  try {
171
171
  const res = await api.get(`${v1(user)}/storages/${storage}/files`);
172
172
  return (Array.isArray(res.data) ? res.data : [])
@@ -207,9 +207,17 @@ export function checkDestination(d) {
207
207
  if (!d.dashboard === !(d.type || d.id)) {
208
208
  throw inputError('a destination is either {dashboard} or {type, id}');
209
209
  }
210
+ if (d.type === 'dashboard') {
211
+ throw inputError(
212
+ `a dashboard of the dashboards collection is {"dashboard": "${d.id ?? '<id>'}"}, not {type, id}`,
213
+ );
214
+ }
210
215
  if (d.type && !TARGETS[d.type]) {
211
- throw inputError(`type must be one of ${DASHBOARD_TARGETS.join(', ')}`);
216
+ throw inputError(
217
+ `type must be one of ${DASHBOARD_TARGETS.join(', ')} (a dashboard of the collection is {"dashboard": "<id>"})`,
218
+ );
212
219
  }
220
+
213
221
  const id = d.dashboard || d.id;
214
222
  if (!id || !ID_RE.test(id)) throw inputError(`invalid id: "${id ?? ''}"`);
215
223
  if (