@xano/cli 1.0.6-beta.1 → 1.0.6-beta.11
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/README.md +138 -4
- package/dist/commands/branch/list/index.js +5 -1
- package/dist/commands/ephemeral/impersonate/index.d.ts +1 -0
- package/dist/commands/ephemeral/impersonate/index.js +11 -3
- package/dist/commands/ephemeral/list/index.js +2 -1
- package/dist/commands/ephemeral/pull/index.d.ts +0 -6
- package/dist/commands/ephemeral/pull/index.js +10 -95
- package/dist/commands/ephemeral/push/index.d.ts +10 -0
- package/dist/commands/ephemeral/push/index.js +77 -0
- package/dist/commands/ephemeral/static_host/build/list/index.d.ts +2 -3
- package/dist/commands/ephemeral/static_host/build/list/index.js +19 -40
- package/dist/commands/ephemeral/static_host/list/index.d.ts +2 -3
- package/dist/commands/ephemeral/static_host/list/index.js +20 -40
- package/dist/commands/flatten/index.d.ts +34 -0
- package/dist/commands/flatten/index.js +140 -0
- package/dist/commands/function/list/index.d.ts +4 -4
- package/dist/commands/function/list/index.js +30 -38
- package/dist/commands/knowledge/list/index.js +2 -1
- package/dist/commands/platform/list/index.js +13 -14
- package/dist/commands/release/list/index.js +13 -14
- package/dist/commands/release/pull/index.d.ts +0 -6
- package/dist/commands/release/pull/index.js +10 -95
- package/dist/commands/sandbox/env/list/index.js +4 -0
- package/dist/commands/sandbox/pull/index.d.ts +0 -1
- package/dist/commands/sandbox/pull/index.js +10 -77
- package/dist/commands/sandbox/unit_test/list/index.d.ts +2 -0
- package/dist/commands/sandbox/unit_test/list/index.js +9 -14
- package/dist/commands/sandbox/unit_test/run/index.js +17 -11
- package/dist/commands/sandbox/unit_test/run_all/index.d.ts +1 -0
- package/dist/commands/sandbox/unit_test/run_all/index.js +76 -38
- package/dist/commands/sandbox/workflow_test/list/index.d.ts +2 -0
- package/dist/commands/sandbox/workflow_test/list/index.js +9 -14
- package/dist/commands/sandbox/workflow_test/run/index.js +12 -9
- package/dist/commands/sandbox/workflow_test/run_all/index.d.ts +1 -0
- package/dist/commands/sandbox/workflow_test/run_all/index.js +74 -36
- package/dist/commands/static_host/build/list/index.d.ts +2 -3
- package/dist/commands/static_host/build/list/index.js +19 -40
- package/dist/commands/static_host/build/pull/index.js +12 -9
- package/dist/commands/static_host/list/index.d.ts +2 -3
- package/dist/commands/static_host/list/index.js +20 -40
- package/dist/commands/static_host/migrate/index.js +14 -10
- package/dist/commands/tenant/backup/list/index.js +13 -14
- package/dist/commands/tenant/cluster/list/index.js +9 -10
- package/dist/commands/tenant/env/list/index.js +4 -0
- package/dist/commands/tenant/list/index.js +19 -20
- package/dist/commands/tenant/pull/index.d.ts +0 -6
- package/dist/commands/tenant/pull/index.js +10 -95
- package/dist/commands/tenant/snapshot/list/index.js +5 -1
- package/dist/commands/tenant/unit_test/list/index.d.ts +4 -2
- package/dist/commands/tenant/unit_test/list/index.js +9 -14
- package/dist/commands/tenant/unit_test/run/index.js +19 -11
- package/dist/commands/tenant/unit_test/run_all/index.d.ts +1 -0
- package/dist/commands/tenant/unit_test/run_all/index.js +80 -38
- package/dist/commands/tenant/workflow_test/list/index.d.ts +4 -2
- package/dist/commands/tenant/workflow_test/list/index.js +9 -14
- package/dist/commands/tenant/workflow_test/run/index.js +14 -9
- package/dist/commands/tenant/workflow_test/run_all/index.d.ts +1 -0
- package/dist/commands/tenant/workflow_test/run_all/index.js +78 -36
- package/dist/commands/unit_test/list/index.d.ts +3 -1
- package/dist/commands/unit_test/list/index.js +9 -14
- package/dist/commands/unit_test/run/index.js +19 -11
- package/dist/commands/unit_test/run_all/index.d.ts +1 -0
- package/dist/commands/unit_test/run_all/index.js +81 -41
- package/dist/commands/workflow_test/list/index.d.ts +3 -1
- package/dist/commands/workflow_test/list/index.js +10 -13
- package/dist/commands/workflow_test/run/index.js +15 -10
- package/dist/commands/workflow_test/run_all/index.d.ts +1 -0
- package/dist/commands/workflow_test/run_all/index.js +82 -39
- package/dist/commands/workspace/git/pull/index.js +53 -3
- package/dist/commands/workspace/list/index.js +7 -13
- package/dist/commands/workspace/pull/index.d.ts +0 -6
- package/dist/commands/workspace/pull/index.js +10 -95
- package/dist/utils/concurrency.d.ts +29 -0
- package/dist/utils/concurrency.js +54 -0
- package/dist/utils/document-parser.d.ts +116 -0
- package/dist/utils/document-parser.js +274 -1
- package/dist/utils/flatten.d.ts +36 -0
- package/dist/utils/flatten.js +68 -0
- package/dist/utils/knowledge-sync.d.ts +1 -0
- package/dist/utils/knowledge-sync.js +11 -5
- package/dist/utils/microservice-wait.d.ts +53 -0
- package/dist/utils/microservice-wait.js +83 -0
- package/dist/utils/multidoc-push.d.ts +12 -0
- package/dist/utils/multidoc-push.js +84 -0
- package/dist/utils/paging.d.ts +145 -0
- package/dist/utils/paging.js +199 -0
- package/dist/utils/reference-checker.js +13 -0
- package/oclif.manifest.json +3420 -3208
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,6 +39,38 @@ Destructive commands include imperative safety prefixes in their help text and f
|
|
|
39
39
|
|
|
40
40
|
These warnings are layer 1 of broader push-safety work; ephemeral sandbox environments and push preview remain the structural safeguards.
|
|
41
41
|
|
|
42
|
+
### Paging on list commands
|
|
43
|
+
|
|
44
|
+
The Metadata API pages unevenly, so `list` commands differ in what they expose. Every command reports only what its endpoint actually returns — the CLI never guesses whether more results exist.
|
|
45
|
+
|
|
46
|
+
| Commands | Flags | Footer |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| `function list`, `unit_test list`, `workflow_test list` (plus `sandbox` / `tenant` variants) | `--page`, `--per_page` | `Page 2 · 50 shown · next: --page 3` |
|
|
49
|
+
| `static_host list`, `static_host build list` (plus `ephemeral` variants) | `--page` only | `Page 2 · 100 shown · 340 total` |
|
|
50
|
+
| `branch list`, `workspace list`, `tenant snapshot list`, `sandbox env list`, `tenant env list` | none | `12 branches` |
|
|
51
|
+
| `tenant list`, `release list`, `platform list`, `tenant cluster list`, `ephemeral list` | none | none |
|
|
52
|
+
| `tenant backup list` | `--page` only (pre-existing) | none |
|
|
53
|
+
|
|
54
|
+
Notes:
|
|
55
|
+
|
|
56
|
+
- **`--per_page` is only offered where the endpoint accepts it.** Static-host endpoints hardcode 100 items per page server-side, so those commands take `--page` alone. `xano static_host list --per_page 10` previously parsed but did nothing; it is now rejected rather than silently ignored.
|
|
57
|
+
- **All paged commands default `--per_page` to 50.** The test-list commands previously requested 10000 internally so nothing was ever cut off; now that the footer and the JSON envelope both report position, a page that stops at 50 is visible rather than silent. Raise it (up to 10000) when you want everything in one call.
|
|
58
|
+
- **The last group has no CLI paging.** Those endpoints page server-side but return a plain array with no page or total metadata, so the CLI cannot tell you where you are. Rather than show a page number with no context — or infer "more available" from a full page, which is wrong exactly when the result count is a multiple of the page size — these commands are left as-is. **They return at most 25–50 items** (50 for tenants and ephemerals, 25 for releases, platforms, and tenant backups). If you have more than that, query the Metadata API directly until those endpoints return paging metadata.
|
|
59
|
+
- **`--output json` returns an envelope, not a bare array.** Every list command emits `{items, ...}` using the Metadata API's own field names — `curPage`, `nextPage`, `prevPage`, `itemsTotal` — each included only when the endpoint actually reports it. `perPage` is the one field the CLI adds, since the API never echoes it back and it is otherwise invisible at its default. This is a **breaking change** for scripts that parsed the previous bare array — read `.items` instead.
|
|
60
|
+
|
|
61
|
+
```jsonc
|
|
62
|
+
// xano function list -o json
|
|
63
|
+
{
|
|
64
|
+
"curPage": 2,
|
|
65
|
+
"perPage": 50, // injected by the CLI; everything else mirrors the API
|
|
66
|
+
"nextPage": 3, // absent on the last page — never inferred
|
|
67
|
+
"prevPage": 1,
|
|
68
|
+
"items": [ /* ... */ ]
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The point of the envelope is that a script gets the same honest stop condition a human gets from the footer, in the same shape the raw Metadata API returns. Without it the only signal available is `items.length < perPage`, which is wrong exactly when the result count is a multiple of the page size. Absence of `nextPage` means the server said there is no next page; it is never omitted as a guess.
|
|
73
|
+
|
|
42
74
|
### Authentication
|
|
43
75
|
|
|
44
76
|
```bash
|
|
@@ -197,6 +229,35 @@ xano workspace git pull -r https://github.com/owner/private-repo -t ghp_xxx
|
|
|
197
229
|
xano workspace git pull -r https://github.com/owner/repo --path subdir
|
|
198
230
|
```
|
|
199
231
|
|
|
232
|
+
### Knowledge
|
|
233
|
+
|
|
234
|
+
Knowledge items are user-authored docs and skills (e.g. `CLAUDE.md`, `AGENTS.md`, runbooks)
|
|
235
|
+
attached to a workspace. Each knowledge item's **name is a path** (e.g. `some/thing/CLAUDE.md`):
|
|
236
|
+
`pull` writes its content to that path under the output directory, and `push` turns each local
|
|
237
|
+
file into a knowledge item named by its relative path.
|
|
238
|
+
|
|
239
|
+
Push matches local files to remote items by name. Existing items are updated (content only —
|
|
240
|
+
description, mode, tags, and other metadata are preserved); new files are created. The
|
|
241
|
+
knowledge type for new items is inferred from the filename: `AGENTS.md` → `agents.md`,
|
|
242
|
+
`SKILL.md` → `skill`, everything else → `doc`. Hidden files (dotfiles) and `node_modules`
|
|
243
|
+
are skipped.
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Pull knowledge files to local paths (defaults to current directory)
|
|
247
|
+
xano knowledge pull
|
|
248
|
+
xano knowledge pull -d ./knowledge # Specify output directory
|
|
249
|
+
xano knowledge pull -b dev # Specific branch
|
|
250
|
+
|
|
251
|
+
# Push local files as knowledge (defaults to current directory, only changed files)
|
|
252
|
+
xano knowledge push
|
|
253
|
+
xano knowledge push -d ./knowledge # Push from a specific directory
|
|
254
|
+
xano knowledge push --dry-run # Preview changes without pushing
|
|
255
|
+
xano knowledge push --sync --delete # Full push + delete remote knowledge not included
|
|
256
|
+
xano knowledge push --force # Skip preview and confirmation (for CI/CD)
|
|
257
|
+
xano knowledge push -i "guides/*" # Push only matching files
|
|
258
|
+
xano knowledge push -e "**/README.md" # Push all files except READMEs
|
|
259
|
+
```
|
|
260
|
+
|
|
200
261
|
### Branches
|
|
201
262
|
|
|
202
263
|
All branch commands use **branch labels** (e.g., `v1`, `dev`), not IDs.
|
|
@@ -372,9 +433,10 @@ xano platform get <platform_id>
|
|
|
372
433
|
#### Unit Tests
|
|
373
434
|
|
|
374
435
|
```bash
|
|
375
|
-
# List unit tests
|
|
436
|
+
# List unit tests (returns all tests by default; --per_page narrows the page)
|
|
376
437
|
xano unit_test list
|
|
377
438
|
xano unit_test list --branch dev --obj-type function
|
|
439
|
+
xano unit_test list --page 2 --per_page 25
|
|
378
440
|
|
|
379
441
|
# Run a single unit test
|
|
380
442
|
xano unit_test run <unit_test_id>
|
|
@@ -388,9 +450,10 @@ xano unit_test run_all --branch dev --obj-type function
|
|
|
388
450
|
#### Workflow Tests
|
|
389
451
|
|
|
390
452
|
```bash
|
|
391
|
-
# List workflow tests
|
|
453
|
+
# List workflow tests (returns all tests by default; --per_page narrows the page)
|
|
392
454
|
xano workflow_test list
|
|
393
455
|
xano workflow_test list --branch dev
|
|
456
|
+
xano workflow_test list --page 2 --per_page 25
|
|
394
457
|
|
|
395
458
|
# Get workflow test details
|
|
396
459
|
xano workflow_test get <workflow_test_id>
|
|
@@ -404,10 +467,77 @@ xano workflow_test run <workflow_test_id>
|
|
|
404
467
|
xano workflow_test run_all
|
|
405
468
|
xano workflow_test run_all --branch dev
|
|
406
469
|
|
|
470
|
+
# Run tests in parallel (default is 1 — sequential)
|
|
471
|
+
xano unit_test run_all --concurrency 4
|
|
472
|
+
xano workflow_test run_all --concurrency 4
|
|
473
|
+
|
|
474
|
+
# Sandbox and tenant variants take the same paging flags
|
|
475
|
+
xano sandbox unit_test list --page 2 --per_page 25
|
|
476
|
+
xano sandbox workflow_test list --page 2 --per_page 25
|
|
477
|
+
xano tenant unit_test list my-tenant --page 2 --per_page 25
|
|
478
|
+
xano tenant workflow_test list my-tenant --page 2 --per_page 25
|
|
479
|
+
|
|
407
480
|
# Delete a workflow test
|
|
408
481
|
xano workflow_test delete <workflow_test_id>
|
|
409
482
|
```
|
|
410
483
|
|
|
484
|
+
#### Running tests in parallel
|
|
485
|
+
|
|
486
|
+
Every `run_all` command takes `--concurrency` (default `1`):
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
xano unit_test run_all --concurrency 4
|
|
490
|
+
xano tenant unit_test run_all --tenant my-tenant --concurrency 8
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
Output stays in test order regardless of concurrency, so a parallel run is still diffable against a sequential one, and the JSON `results` array keeps a stable order.
|
|
494
|
+
|
|
495
|
+
`run_all` discovers the test list by paging at 100 per request rather than asking for the whole suite in one response, and stops when the API reports no next page.
|
|
496
|
+
|
|
497
|
+
**The default is 1 on purpose.** These tests execute against a shared workspace database, so tests that touch the same tables or records can interfere with each other when run at the same time — producing failures that look like flakiness rather than a real regression. Raise `--concurrency` once you know your tests are independent.
|
|
498
|
+
|
|
499
|
+
#### Exit codes
|
|
500
|
+
|
|
501
|
+
Every `run` and `run_all` command — on all four surfaces (`unit_test`, `workflow_test`, `sandbox`, `tenant`) — uses the same exit codes:
|
|
502
|
+
|
|
503
|
+
| Code | Meaning |
|
|
504
|
+
|------|---------|
|
|
505
|
+
| `0` | All tests passed, **or** there were no tests to run |
|
|
506
|
+
| `1` | At least one test failed |
|
|
507
|
+
| `2` | The command could not run the tests at all — bad workspace, auth failure, unreadable profile, or the test-list request failed |
|
|
508
|
+
|
|
509
|
+
**This is identical for `-o json` and summary output.** Adding `-o json` to get machine-readable output does not change the exit code, so a CI job can rely on it in either mode.
|
|
510
|
+
|
|
511
|
+
```bash
|
|
512
|
+
xano workflow_test run_all -o json || echo "tests failed or the command errored"
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**One asymmetry worth knowing about.** In `run`, a non-2xx response from the run endpoint is a CLI error and exits `2`. In `run_all`, a non-2xx response for an *individual* test is recorded as a failed test result with an `API error <status>` message and contributes to exit `1` — because `run_all`'s job is to finish the batch and report a roll-up rather than abort on one test's transport error. Exit `2` in `run_all` is reserved for failures that stop the batch from starting at all.
|
|
516
|
+
|
|
517
|
+
If you need to tell a backend outage apart from a genuine assertion failure, the exit code alone will not do it — inspect `results[].message` for the `API error` prefix:
|
|
518
|
+
|
|
519
|
+
```bash
|
|
520
|
+
xano workflow_test run_all -o json | jq '[.results[] | select(.message // "" | startswith("API error"))] | length'
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
#### JSON output
|
|
524
|
+
|
|
525
|
+
`run` returns the API's result object unchanged. Treat **any** `status` other than `"ok"` as a failure — several distinct non-`ok` values are returned in practice, so match on "not `ok`" rather than enumerating known failure values:
|
|
526
|
+
|
|
527
|
+
```json
|
|
528
|
+
{ "status": "exception", "timing": 0.02, "message": "Precondition failed." }
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
`run_all` returns a roll-up. A branch with no tests is a normal state — freshly created branches routinely have none — and still emits valid JSON rather than plain text, so `JSON.parse` is always safe:
|
|
532
|
+
|
|
533
|
+
```json
|
|
534
|
+
{ "passed": 0, "failed": 0, "results": [], "total_timing": 0 }
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
The `total_timing` field is currently emitted by `workflow_test run_all` only; the `unit_test`, `tenant`, and `sandbox` variants omit it. The empty-suite envelope always carries the same keys as that command's populated envelope.
|
|
538
|
+
|
|
539
|
+
> **Changed in this release:** a failing `run` in summary mode previously exited `2` and printed a spurious `EEXIT: 1` line; it now exits `1` with clean output. A failing `run` with `-o json` previously exited `0`, which silently hid failures from CI. If you match on exit code `2` specifically to detect test failures, switch to a non-zero check.
|
|
540
|
+
|
|
411
541
|
### Tenants
|
|
412
542
|
|
|
413
543
|
Manage tenants, their environment variables, backups, deployments, and clusters.
|
|
@@ -594,6 +724,7 @@ xano ephemeral push <tenant_name> -d ./my-ephemeral
|
|
|
594
724
|
# Open in the browser (or print the URL)
|
|
595
725
|
xano ephemeral impersonate <tenant_name>
|
|
596
726
|
xano ephemeral impersonate <tenant_name> --url-only
|
|
727
|
+
xano ephemeral impersonate <tenant_name> --guest # read-only session (browse only)
|
|
597
728
|
```
|
|
598
729
|
|
|
599
730
|
#### Static hosting for an ephemeral tenant
|
|
@@ -663,16 +794,19 @@ xano sandbox reset --force
|
|
|
663
794
|
### Static Hosts
|
|
664
795
|
|
|
665
796
|
```bash
|
|
666
|
-
# List static hosts
|
|
797
|
+
# List static hosts. Page size is fixed at 100 by the API, so there is no
|
|
798
|
+
# --per_page flag; the footer reports the true total.
|
|
667
799
|
xano static_host list
|
|
800
|
+
xano static_host list --page 2
|
|
668
801
|
|
|
669
802
|
# Create / get / edit a static host
|
|
670
803
|
xano static_host create marketing --description "Marketing site"
|
|
671
804
|
xano static_host get marketing
|
|
672
805
|
xano static_host edit marketing --name marketing-v2 --description "Updated"
|
|
673
806
|
|
|
674
|
-
# List builds
|
|
807
|
+
# List builds (--page only; page size is fixed at 100 by the API)
|
|
675
808
|
xano static_host build list default
|
|
809
|
+
xano static_host build list default --page 2
|
|
676
810
|
|
|
677
811
|
# Get build details
|
|
678
812
|
xano static_host build get default --build_id 52
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import BaseCommand from '../../../base-command.js';
|
|
3
|
+
import { buildPagingJson, formatPagingFooter } from '../../../utils/paging.js';
|
|
3
4
|
export function filterBackups(branches, includeBackups) {
|
|
4
5
|
return includeBackups ? branches : branches.filter((b) => !b.backup);
|
|
5
6
|
}
|
|
@@ -82,7 +83,7 @@ Available branches:
|
|
|
82
83
|
const branches = filterBackups(allBranches, flags.backups);
|
|
83
84
|
// Output results
|
|
84
85
|
if (flags.output === 'json') {
|
|
85
|
-
this.log(JSON.stringify(branches, null, 2));
|
|
86
|
+
this.log(JSON.stringify(buildPagingJson({ items: branches }, { tier: 'none' }), null, 2));
|
|
86
87
|
}
|
|
87
88
|
else {
|
|
88
89
|
// summary format
|
|
@@ -97,6 +98,9 @@ Available branches:
|
|
|
97
98
|
this.log(` - ${branch.label}${liveIndicator}${backupIndicator}`);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
101
|
+
const footer = formatPagingFooter({ items: branches }, { noun: 'branch', nounPlural: 'branches', tier: 'none' });
|
|
102
|
+
if (footer)
|
|
103
|
+
this.log(footer);
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
106
|
catch (error) {
|
|
@@ -6,6 +6,7 @@ export default class EphemeralImpersonate extends BaseCommand {
|
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
8
8
|
static flags: {
|
|
9
|
+
guest: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
10
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
'url-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -15,9 +15,16 @@ Opening browser...
|
|
|
15
15
|
Impersonation successful!
|
|
16
16
|
`,
|
|
17
17
|
`$ xano ephemeral impersonate e4f2-9ab1-xyz1 -o json`,
|
|
18
|
+
`$ xano ephemeral impersonate e4f2-9ab1-xyz1 --guest --url-only`,
|
|
18
19
|
];
|
|
19
20
|
static flags = {
|
|
20
21
|
...BaseCommand.baseFlags,
|
|
22
|
+
guest: Flags.boolean({
|
|
23
|
+
char: 'g',
|
|
24
|
+
default: false,
|
|
25
|
+
description: 'Mint a read-only guest session (browse only; no schema/data/config changes)',
|
|
26
|
+
required: false,
|
|
27
|
+
}),
|
|
21
28
|
output: Flags.string({
|
|
22
29
|
char: 'o',
|
|
23
30
|
default: 'summary',
|
|
@@ -46,7 +53,7 @@ Impersonation successful!
|
|
|
46
53
|
}
|
|
47
54
|
const tenantName = args.tenant_name;
|
|
48
55
|
try {
|
|
49
|
-
const response = await this.getImpersonateResponse(profile, workspaceId, tenantName);
|
|
56
|
+
const response = await this.getImpersonateResponse(profile, workspaceId, tenantName, flags.guest);
|
|
50
57
|
if (flags.output === 'json') {
|
|
51
58
|
this.log(JSON.stringify(response, null, 2));
|
|
52
59
|
}
|
|
@@ -76,8 +83,9 @@ Impersonation successful!
|
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
|
-
async getImpersonateResponse(profile, workspaceId, tenantName) {
|
|
80
|
-
const
|
|
86
|
+
async getImpersonateResponse(profile, workspaceId, tenantName, guest = false) {
|
|
87
|
+
const query = guest ? '?guest_read_only=true' : '';
|
|
88
|
+
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${encodeURIComponent(tenantName)}/impersonate${query}`;
|
|
81
89
|
const { verbose } = await this.parse(EphemeralImpersonate).then((r) => r.flags);
|
|
82
90
|
const response = await this.verboseFetch(apiUrl, {
|
|
83
91
|
headers: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import BaseCommand from '../../../base-command.js';
|
|
3
|
+
import { buildPagingJson } from '../../../utils/paging.js';
|
|
3
4
|
export default class EphemeralList extends BaseCommand {
|
|
4
5
|
static description = 'List ephemeral tenants in a workspace, or across the whole instance with --global';
|
|
5
6
|
static examples = [
|
|
@@ -73,7 +74,7 @@ Ephemeral tenants (all workspaces):
|
|
|
73
74
|
this.error('Unexpected API response format');
|
|
74
75
|
}
|
|
75
76
|
if (flags.output === 'json') {
|
|
76
|
-
this.log(JSON.stringify(tenants, null, 2));
|
|
77
|
+
this.log(JSON.stringify(buildPagingJson({ items: tenants }, { tier: 'none' }), null, 2));
|
|
77
78
|
}
|
|
78
79
|
else if (tenants.length === 0) {
|
|
79
80
|
this.log('No ephemeral tenants found');
|
|
@@ -16,10 +16,4 @@ export default class EphemeralPull extends BaseCommand {
|
|
|
16
16
|
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
17
|
};
|
|
18
18
|
run(): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Sanitize a document name for use as a filename.
|
|
21
|
-
* Strips quotes, replaces spaces with underscores, and removes
|
|
22
|
-
* characters that are unsafe in filenames.
|
|
23
|
-
*/
|
|
24
|
-
private sanitizeFilename;
|
|
25
19
|
}
|
|
@@ -3,7 +3,7 @@ import * as fs from 'node:fs';
|
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import snakeCase from 'lodash.snakecase';
|
|
5
5
|
import BaseCommand from '../../../base-command.js';
|
|
6
|
-
import { buildApiGroupFolderResolver, parseDocument } from '../../../utils/document-parser.js';
|
|
6
|
+
import { buildApiGroupFolderResolver, buildChannelServerResolver, parseDocument, resolveDocumentPath, } from '../../../utils/document-parser.js';
|
|
7
7
|
export default class EphemeralPull extends BaseCommand {
|
|
8
8
|
static args = {
|
|
9
9
|
tenant_name: Args.string({
|
|
@@ -130,96 +130,19 @@ Pulled 58 documents from tenant e4f2-9ab1-xyz1
|
|
|
130
130
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
131
131
|
// Resolve api_group names to unique folder names, disambiguating collisions
|
|
132
132
|
const getApiGroupFolder = buildApiGroupFolderResolver(documents, snakeCase);
|
|
133
|
+
// Resolve a realtime v2 channel path -> owning realtime_server name, so
|
|
134
|
+
// messages can nest under their channel's server (see resolver docs).
|
|
135
|
+
const getChannelServer = buildChannelServerResolver(documents);
|
|
133
136
|
// Track filenames per type to handle duplicates
|
|
134
137
|
const filenameCounters = new Map();
|
|
135
138
|
let writtenCount = 0;
|
|
136
139
|
for (const doc of documents) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
else if (doc.type === 'workspace_trigger') {
|
|
145
|
-
// workspace_trigger → workspace/trigger/{name}.xs
|
|
146
|
-
typeDir = path.join(outputDir, 'workspace', 'trigger');
|
|
147
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
148
|
-
}
|
|
149
|
-
else if (doc.type === 'error_trigger') {
|
|
150
|
-
// error_trigger → workspace/trigger/{name}.xs (singleton, colocated with workspace triggers)
|
|
151
|
-
typeDir = path.join(outputDir, 'workspace', 'trigger');
|
|
152
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
153
|
-
}
|
|
154
|
-
else if (doc.type === 'agent') {
|
|
155
|
-
// agent → ai/agent/{name}.xs
|
|
156
|
-
typeDir = path.join(outputDir, 'ai', 'agent');
|
|
157
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
158
|
-
}
|
|
159
|
-
else if (doc.type === 'mcp_server') {
|
|
160
|
-
// mcp_server → ai/mcp_server/{name}.xs
|
|
161
|
-
typeDir = path.join(outputDir, 'ai', 'mcp_server');
|
|
162
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
163
|
-
}
|
|
164
|
-
else if (doc.type === 'tool') {
|
|
165
|
-
// tool → ai/tool/{name}.xs
|
|
166
|
-
typeDir = path.join(outputDir, 'ai', 'tool');
|
|
167
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
168
|
-
}
|
|
169
|
-
else if (doc.type === 'agent_trigger') {
|
|
170
|
-
// agent_trigger → ai/agent/trigger/{name}.xs
|
|
171
|
-
typeDir = path.join(outputDir, 'ai', 'agent', 'trigger');
|
|
172
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
173
|
-
}
|
|
174
|
-
else if (doc.type === 'mcp_server_trigger') {
|
|
175
|
-
// mcp_server_trigger → ai/mcp_server/trigger/{name}.xs
|
|
176
|
-
typeDir = path.join(outputDir, 'ai', 'mcp_server', 'trigger');
|
|
177
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
178
|
-
}
|
|
179
|
-
else if (doc.type === 'table_trigger') {
|
|
180
|
-
// table_trigger → table/trigger/{name}.xs
|
|
181
|
-
typeDir = path.join(outputDir, 'table', 'trigger');
|
|
182
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
183
|
-
}
|
|
184
|
-
else if (doc.type === 'realtime_channel') {
|
|
185
|
-
// realtime_channel → realtime/channel/{name}.xs
|
|
186
|
-
typeDir = path.join(outputDir, 'realtime', 'channel');
|
|
187
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
188
|
-
}
|
|
189
|
-
else if (doc.type === 'realtime_trigger') {
|
|
190
|
-
// realtime_trigger → realtime/trigger/{name}.xs
|
|
191
|
-
typeDir = path.join(outputDir, 'realtime', 'trigger');
|
|
192
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
193
|
-
}
|
|
194
|
-
else if (doc.type === 'api_group') {
|
|
195
|
-
// api_group "test" → api/{resolved_folder}/{name}.xs
|
|
196
|
-
const groupFolder = getApiGroupFolder(doc.name);
|
|
197
|
-
typeDir = path.join(outputDir, 'api', groupFolder);
|
|
198
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
199
|
-
}
|
|
200
|
-
else if (doc.type === 'query' && doc.apiGroup) {
|
|
201
|
-
// query in group "test" → api/{resolved_folder}/{query_name}.xs
|
|
202
|
-
const groupFolder = getApiGroupFolder(doc.apiGroup);
|
|
203
|
-
const nameParts = doc.name.split('/');
|
|
204
|
-
const leafName = nameParts.pop();
|
|
205
|
-
const folderParts = nameParts.map((part) => snakeCase(part));
|
|
206
|
-
typeDir = path.join(outputDir, 'api', groupFolder, ...folderParts);
|
|
207
|
-
baseName = this.sanitizeFilename(leafName);
|
|
208
|
-
if (doc.verb) {
|
|
209
|
-
baseName = `${baseName}_${doc.verb}`;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
// Default: split folder path from name
|
|
214
|
-
const nameParts = doc.name.split('/');
|
|
215
|
-
const leafName = nameParts.pop();
|
|
216
|
-
const folderParts = nameParts.map((part) => snakeCase(part));
|
|
217
|
-
typeDir = path.join(outputDir, doc.type, ...folderParts);
|
|
218
|
-
baseName = this.sanitizeFilename(leafName);
|
|
219
|
-
if (doc.verb) {
|
|
220
|
-
baseName = `${baseName}_${doc.verb}`;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
140
|
+
const { baseName, typeDir } = resolveDocumentPath(doc, outputDir, {
|
|
141
|
+
getApiGroupFolder,
|
|
142
|
+
getChannelServer,
|
|
143
|
+
join: path.join,
|
|
144
|
+
snakeCase,
|
|
145
|
+
});
|
|
223
146
|
fs.mkdirSync(typeDir, { recursive: true });
|
|
224
147
|
// Track duplicates per directory
|
|
225
148
|
const dirKey = path.relative(outputDir, typeDir);
|
|
@@ -238,12 +161,4 @@ Pulled 58 documents from tenant e4f2-9ab1-xyz1
|
|
|
238
161
|
}
|
|
239
162
|
this.log(`Pulled ${writtenCount} documents from tenant ${tenantName} to ${flags.directory}`);
|
|
240
163
|
}
|
|
241
|
-
/**
|
|
242
|
-
* Sanitize a document name for use as a filename.
|
|
243
|
-
* Strips quotes, replaces spaces with underscores, and removes
|
|
244
|
-
* characters that are unsafe in filenames.
|
|
245
|
-
*/
|
|
246
|
-
sanitizeFilename(name) {
|
|
247
|
-
return snakeCase(name.replaceAll('"', ''));
|
|
248
|
-
}
|
|
249
164
|
}
|
|
@@ -16,10 +16,20 @@ export default class EphemeralPush extends BaseCommand {
|
|
|
16
16
|
sync: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
17
|
transaction: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
18
|
truncate: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
wait: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
'wait-timeout': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
21
|
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
22
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
23
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
24
|
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
25
|
};
|
|
24
26
|
run(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Poll GET .../tenant/{name}/microservice until auto microservices settle.
|
|
29
|
+
* Renders a one-line-per-microservice progress view that updates in place, then
|
|
30
|
+
* exits non-zero if any auto microservice failed or the wait timed out.
|
|
31
|
+
*/
|
|
32
|
+
private waitForDeploy;
|
|
33
|
+
/** Number of lines the last progress render wrote (for in-place TTY updates). */
|
|
34
|
+
private lastRenderLines;
|
|
25
35
|
}
|
|
@@ -2,6 +2,7 @@ import { Args, Flags } from '@oclif/core';
|
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import BaseCommand from '../../../base-command.js';
|
|
5
|
+
import { isAwaited, waitForMicroservices, } from '../../../utils/microservice-wait.js';
|
|
5
6
|
import { executePush } from '../../../utils/multidoc-push.js';
|
|
6
7
|
export default class EphemeralPush extends BaseCommand {
|
|
7
8
|
static args = {
|
|
@@ -88,6 +89,17 @@ Skip preview and push immediately
|
|
|
88
89
|
description: '[CRITICAL] STOP and confirm with the user; this truncates live tables before importing.',
|
|
89
90
|
required: false,
|
|
90
91
|
}),
|
|
92
|
+
wait: Flags.boolean({
|
|
93
|
+
default: false,
|
|
94
|
+
description: 'After pushing, wait for auto-deployed microservices (tenant_deploy="auto") to become ready. Exits non-zero if any fails to deploy or the wait times out. Ignored with --dry-run.',
|
|
95
|
+
required: false,
|
|
96
|
+
}),
|
|
97
|
+
'wait-timeout': Flags.integer({
|
|
98
|
+
default: 300,
|
|
99
|
+
description: 'Seconds to wait for microservices to become ready when --wait is set (default 300).',
|
|
100
|
+
min: 1,
|
|
101
|
+
required: false,
|
|
102
|
+
}),
|
|
91
103
|
workspace: Flags.string({
|
|
92
104
|
char: 'w',
|
|
93
105
|
description: 'Workspace ID (uses profile workspace if not provided)',
|
|
@@ -140,5 +152,70 @@ Skip preview and push immediately
|
|
|
140
152
|
inputDir,
|
|
141
153
|
verboseFetch: this.verboseFetch.bind(this),
|
|
142
154
|
}, target, pushFlags);
|
|
155
|
+
// --wait: after a real push, poll the tenant's live microservice status until
|
|
156
|
+
// every auto-deployed microservice (tenant_deploy="auto") is ready or the
|
|
157
|
+
// wait times out. Skipped on --dry-run (nothing was deployed).
|
|
158
|
+
if (flags.wait && !flags['dry-run']) {
|
|
159
|
+
await this.waitForDeploy(baseUrl, profile.access_token, tenantName, flags['wait-timeout'], flags.verbose);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Poll GET .../tenant/{name}/microservice until auto microservices settle.
|
|
164
|
+
* Renders a one-line-per-microservice progress view that updates in place, then
|
|
165
|
+
* exits non-zero if any auto microservice failed or the wait timed out.
|
|
166
|
+
*/
|
|
167
|
+
async waitForDeploy(baseUrl, accessToken, tenantName, timeoutSeconds, verbose) {
|
|
168
|
+
this.log('');
|
|
169
|
+
this.log(`Waiting for microservices to deploy (timeout ${timeoutSeconds}s)…`);
|
|
170
|
+
const icon = (e) => {
|
|
171
|
+
if (!isAwaited(e))
|
|
172
|
+
return '➖';
|
|
173
|
+
switch (e.status) {
|
|
174
|
+
case 'error': {
|
|
175
|
+
return '❌';
|
|
176
|
+
}
|
|
177
|
+
case 'ok': {
|
|
178
|
+
return '✅';
|
|
179
|
+
}
|
|
180
|
+
default: {
|
|
181
|
+
return '⏳';
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const line = (e) => {
|
|
186
|
+
const detail = isAwaited(e) ? e.detail || e.status : `skipped (${e.tenant_deploy ?? 'manual'})`;
|
|
187
|
+
return ` ${icon(e)} ${e.name.padEnd(24)} ${detail}`;
|
|
188
|
+
};
|
|
189
|
+
const result = await waitForMicroservices({
|
|
190
|
+
accessToken,
|
|
191
|
+
onPoll: (entries) => {
|
|
192
|
+
// Re-render the block: move the cursor up over the previous render (if any)
|
|
193
|
+
// and rewrite. Falls back to plain appends when not a TTY.
|
|
194
|
+
if (process.stdout.isTTY && this.lastRenderLines > 0) {
|
|
195
|
+
process.stdout.write(`[${this.lastRenderLines}A[0J`);
|
|
196
|
+
}
|
|
197
|
+
const lines = entries.map((e) => line(e));
|
|
198
|
+
for (const l of lines)
|
|
199
|
+
this.log(l);
|
|
200
|
+
this.lastRenderLines = process.stdout.isTTY ? lines.length : 0;
|
|
201
|
+
},
|
|
202
|
+
statusUrl: `${baseUrl}/microservice`,
|
|
203
|
+
timeoutMs: timeoutSeconds * 1000,
|
|
204
|
+
verbose,
|
|
205
|
+
verboseFetch: this.verboseFetch.bind(this),
|
|
206
|
+
});
|
|
207
|
+
const awaited = result.entries.filter((e) => isAwaited(e));
|
|
208
|
+
const ready = awaited.filter((e) => e.status === 'ok').length;
|
|
209
|
+
if (result.timedOut) {
|
|
210
|
+
this.error(`Timed out after ${timeoutSeconds}s waiting for microservices (${ready}/${awaited.length} ready). ` +
|
|
211
|
+
`Check status with the Xano dashboard or re-run with a larger --wait-timeout.`);
|
|
212
|
+
}
|
|
213
|
+
if (result.hadError) {
|
|
214
|
+
const failed = awaited.filter((e) => e.status === 'error').map((e) => `${e.name} (${e.detail || 'error'})`);
|
|
215
|
+
this.error(`Microservice deploy failed: ${failed.join(', ')}`);
|
|
216
|
+
}
|
|
217
|
+
this.log(`All microservices ready (${ready}/${awaited.length}).`);
|
|
143
218
|
}
|
|
219
|
+
/** Number of lines the last progress render wrote (for in-place TTY updates). */
|
|
220
|
+
lastRenderLines = 0;
|
|
144
221
|
}
|
|
@@ -6,11 +6,10 @@ export default class EphemeralStaticHostBuildList extends BaseCommand {
|
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
8
8
|
static flags: {
|
|
9
|
-
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
per_page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
9
|
'static-host': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
10
|
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
13
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
14
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
15
|
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|