@xano/cli 1.1.0 → 1.3.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 (128) hide show
  1. package/README.md +155 -4
  2. package/dist/base-command.d.ts +43 -36
  3. package/dist/base-command.js +223 -160
  4. package/dist/commands/auth/index.d.ts +1 -1
  5. package/dist/commands/auth/index.js +7 -7
  6. package/dist/commands/branch/create/index.d.ts +1 -1
  7. package/dist/commands/branch/create/index.js +1 -1
  8. package/dist/commands/ephemeral/create/index.d.ts +18 -0
  9. package/dist/commands/ephemeral/create/index.js +103 -0
  10. package/dist/commands/ephemeral/delete/index.d.ts +18 -0
  11. package/dist/commands/ephemeral/delete/index.js +99 -0
  12. package/dist/commands/ephemeral/edit/index.d.ts +18 -0
  13. package/dist/commands/ephemeral/edit/index.js +109 -0
  14. package/dist/commands/ephemeral/get/index.d.ts +21 -0
  15. package/dist/commands/ephemeral/get/index.js +125 -0
  16. package/dist/commands/ephemeral/impersonate/index.d.ts +20 -0
  17. package/dist/commands/ephemeral/impersonate/index.js +120 -0
  18. package/dist/commands/ephemeral/list/index.d.ts +19 -0
  19. package/dist/commands/ephemeral/list/index.js +123 -0
  20. package/dist/commands/ephemeral/pull/index.d.ts +19 -0
  21. package/dist/commands/ephemeral/pull/index.js +163 -0
  22. package/dist/commands/ephemeral/push/index.d.ts +35 -0
  23. package/dist/commands/ephemeral/push/index.js +223 -0
  24. package/dist/commands/ephemeral/static_host/build/delete/index.d.ts +20 -0
  25. package/dist/commands/ephemeral/static_host/build/delete/index.js +121 -0
  26. package/dist/commands/ephemeral/static_host/build/get/index.d.ts +18 -0
  27. package/dist/commands/ephemeral/static_host/build/get/index.js +137 -0
  28. package/dist/commands/ephemeral/static_host/build/list/index.d.ts +18 -0
  29. package/dist/commands/ephemeral/static_host/build/list/index.js +137 -0
  30. package/dist/commands/ephemeral/static_host/build/pull/index.d.ts +53 -0
  31. package/dist/commands/ephemeral/static_host/build/pull/index.js +308 -0
  32. package/dist/commands/ephemeral/static_host/build/push/index.d.ts +24 -0
  33. package/dist/commands/ephemeral/static_host/build/push/index.js +250 -0
  34. package/dist/commands/ephemeral/static_host/create/index.d.ts +18 -0
  35. package/dist/commands/ephemeral/static_host/create/index.js +92 -0
  36. package/dist/commands/ephemeral/static_host/deploy/index.d.ts +19 -0
  37. package/dist/commands/ephemeral/static_host/deploy/index.js +112 -0
  38. package/dist/commands/ephemeral/static_host/edit/index.d.ts +24 -0
  39. package/dist/commands/ephemeral/static_host/edit/index.js +158 -0
  40. package/dist/commands/ephemeral/static_host/get/index.d.ts +19 -0
  41. package/dist/commands/ephemeral/static_host/get/index.js +101 -0
  42. package/dist/commands/ephemeral/static_host/list/index.d.ts +17 -0
  43. package/dist/commands/ephemeral/static_host/list/index.js +132 -0
  44. package/dist/commands/flatten/index.d.ts +34 -0
  45. package/dist/commands/flatten/index.js +140 -0
  46. package/dist/commands/function/create/index.js +1 -1
  47. package/dist/commands/function/edit/index.js +26 -32
  48. package/dist/commands/function/get/index.js +2 -3
  49. package/dist/commands/function/run/index.d.ts +1 -0
  50. package/dist/commands/function/run/index.js +19 -6
  51. package/dist/commands/profile/create/index.d.ts +1 -1
  52. package/dist/commands/profile/create/index.js +7 -7
  53. package/dist/commands/profile/me/index.js +1 -1
  54. package/dist/commands/profile/use/index.js +0 -4
  55. package/dist/commands/profile/wizard/index.d.ts +1 -1
  56. package/dist/commands/profile/wizard/index.js +12 -10
  57. package/dist/commands/profile/workspace/set/index.js +1 -1
  58. package/dist/commands/release/edit/index.js +2 -2
  59. package/dist/commands/release/export/index.js +1 -2
  60. package/dist/commands/release/import/index.js +1 -1
  61. package/dist/commands/release/pull/index.d.ts +0 -6
  62. package/dist/commands/release/pull/index.js +13 -99
  63. package/dist/commands/release/push/index.js +2 -2
  64. package/dist/commands/sandbox/env/get_all/index.js +1 -1
  65. package/dist/commands/sandbox/env/set_all/index.js +1 -1
  66. package/dist/commands/sandbox/get/index.js +1 -1
  67. package/dist/commands/sandbox/license/get/index.js +1 -1
  68. package/dist/commands/sandbox/license/set/index.js +1 -1
  69. package/dist/commands/sandbox/pull/index.d.ts +0 -1
  70. package/dist/commands/sandbox/pull/index.js +13 -81
  71. package/dist/commands/sandbox/push/index.d.ts +1 -1
  72. package/dist/commands/sandbox/push/index.js +5 -5
  73. package/dist/commands/sandbox/unit_test/run/index.js +17 -11
  74. package/dist/commands/sandbox/unit_test/run_all/index.js +9 -1
  75. package/dist/commands/sandbox/workflow_test/run/index.js +12 -9
  76. package/dist/commands/sandbox/workflow_test/run_all/index.js +9 -1
  77. package/dist/commands/static_host/build/create/index.d.ts +1 -1
  78. package/dist/commands/static_host/build/create/index.js +2 -2
  79. package/dist/commands/static_host/build/pull/index.js +1 -1
  80. package/dist/commands/static_host/build/push/index.js +1 -1
  81. package/dist/commands/static_host/edit/index.js +1 -1
  82. package/dist/commands/tenant/backup/export/index.js +1 -2
  83. package/dist/commands/tenant/backup/import/index.js +1 -1
  84. package/dist/commands/tenant/cluster/create/index.js +1 -1
  85. package/dist/commands/tenant/cluster/license/get/index.js +1 -1
  86. package/dist/commands/tenant/cluster/license/set/index.js +1 -1
  87. package/dist/commands/tenant/create/index.d.ts +1 -1
  88. package/dist/commands/tenant/create/index.js +6 -6
  89. package/dist/commands/tenant/deploy_platform/index.js +1 -1
  90. package/dist/commands/tenant/edit/index.js +7 -7
  91. package/dist/commands/tenant/env/get_all/index.js +1 -1
  92. package/dist/commands/tenant/env/set_all/index.js +1 -1
  93. package/dist/commands/tenant/impersonate/index.d.ts +1 -1
  94. package/dist/commands/tenant/impersonate/index.js +14 -14
  95. package/dist/commands/tenant/license/get/index.js +1 -1
  96. package/dist/commands/tenant/license/set/index.js +1 -1
  97. package/dist/commands/tenant/pull/index.d.ts +0 -6
  98. package/dist/commands/tenant/pull/index.js +14 -100
  99. package/dist/commands/tenant/unit_test/run/index.js +19 -11
  100. package/dist/commands/tenant/unit_test/run_all/index.js +13 -1
  101. package/dist/commands/tenant/workflow_test/run/index.js +14 -9
  102. package/dist/commands/tenant/workflow_test/run_all/index.js +13 -1
  103. package/dist/commands/unit_test/run/index.js +19 -11
  104. package/dist/commands/unit_test/run_all/index.js +13 -1
  105. package/dist/commands/workflow_test/run/index.js +15 -10
  106. package/dist/commands/workflow_test/run_all/index.js +15 -3
  107. package/dist/commands/workspace/git/pull/index.d.ts +4 -4
  108. package/dist/commands/workspace/git/pull/index.js +158 -97
  109. package/dist/commands/workspace/pull/index.d.ts +1 -7
  110. package/dist/commands/workspace/pull/index.js +17 -103
  111. package/dist/help.js +4 -2
  112. package/dist/update-check.d.ts +1 -1
  113. package/dist/update-check.js +1 -1
  114. package/dist/utils/document-parser.d.ts +116 -0
  115. package/dist/utils/document-parser.js +311 -4
  116. package/dist/utils/flatten.d.ts +36 -0
  117. package/dist/utils/flatten.js +68 -0
  118. package/dist/utils/knowledge-sync.d.ts +1 -0
  119. package/dist/utils/knowledge-sync.js +11 -6
  120. package/dist/utils/microservice-wait.d.ts +53 -0
  121. package/dist/utils/microservice-wait.js +84 -0
  122. package/dist/utils/multidoc-push.d.ts +88 -0
  123. package/dist/utils/multidoc-push.js +378 -15
  124. package/dist/utils/paging.d.ts +2 -1
  125. package/dist/utils/paging.js +0 -1
  126. package/dist/utils/reference-checker.js +14 -3
  127. package/oclif.manifest.json +5898 -3804
  128. package/package.json +10 -1
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Poll a tenant's microservice deployment status until every auto-deployed
3
+ * microservice settles (ok/error) or a timeout elapses. Backs `ephemeral push
4
+ * --wait`: after a multidoc push auto-deploys microservices (tenant_deploy=
5
+ * "auto"), the CLI waits here for them to become Ready and reports the outcome.
6
+ *
7
+ * The backend route (GET .../tenant/{name}/microservice, statement
8
+ * mvp:microservice_status_all) returns one entry per microservice with a live
9
+ * k8s readiness read. `manual`/`disabled` microservices are reported but not
10
+ * waited on (they were never deployed by the push).
11
+ */
12
+ /** One microservice's status as returned by the tenant status route. */
13
+ export interface MicroserviceStatusEntry {
14
+ desired?: number;
15
+ detail?: string;
16
+ microservice_id: number;
17
+ name: string;
18
+ ready?: number;
19
+ status: string;
20
+ tenant_deploy?: string;
21
+ }
22
+ export interface WaitOptions {
23
+ /** Bearer token for the authed status GET. */
24
+ accessToken: string;
25
+ /** Called once per poll with the latest entries, for progress rendering. */
26
+ onPoll?: (entries: MicroserviceStatusEntry[], elapsedMs: number) => void;
27
+ /** Poll cadence in ms (default 2000). */
28
+ pollIntervalMs?: number;
29
+ /** Absolute URL of the tenant microservice status route. */
30
+ statusUrl: string;
31
+ /** Overall wait budget in ms (default 300000 = 300s). */
32
+ timeoutMs?: number;
33
+ /** Verbose request logging passthrough. */
34
+ verbose?: boolean;
35
+ /** Authed fetch (command.verboseFetch bound), so TLS/dispatcher settings apply. */
36
+ verboseFetch: (url: string, options: RequestInit, verbose: boolean, authToken?: string) => Promise<Response>;
37
+ }
38
+ export interface WaitResult {
39
+ /** The final status entries observed. */
40
+ entries: MicroserviceStatusEntry[];
41
+ /** True if any awaited (auto) microservice ended in "error". */
42
+ hadError: boolean;
43
+ /** True if the wait budget elapsed before all awaited microservices settled. */
44
+ timedOut: boolean;
45
+ }
46
+ /** An awaited microservice is one that was auto-deployed and is not skipped/disabled. */
47
+ export declare function isAwaited(entry: MicroserviceStatusEntry): boolean;
48
+ /**
49
+ * Poll until all awaited microservices settle or the timeout elapses. Transient
50
+ * poll failures (network blips, a brief 5xx while a pod restarts) are tolerated —
51
+ * they don't abort the wait; only the overall timeout does.
52
+ */
53
+ export declare function waitForMicroservices(opts: WaitOptions): Promise<WaitResult>;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Poll a tenant's microservice deployment status until every auto-deployed
3
+ * microservice settles (ok/error) or a timeout elapses. Backs `ephemeral push
4
+ * --wait`: after a multidoc push auto-deploys microservices (tenant_deploy=
5
+ * "auto"), the CLI waits here for them to become Ready and reports the outcome.
6
+ *
7
+ * The backend route (GET .../tenant/{name}/microservice, statement
8
+ * mvp:microservice_status_all) returns one entry per microservice with a live
9
+ * k8s readiness read. `manual`/`disabled` microservices are reported but not
10
+ * waited on (they were never deployed by the push).
11
+ */
12
+ /** Statuses that mean an awaited microservice has settled (no longer in flight). */
13
+ const SETTLED = new Set(['error', 'ok']);
14
+ /** Statuses that mean we don't wait on this microservice at all. */
15
+ const NOT_AWAITED = new Set(['disabled', 'skipped']);
16
+ const sleep = (ms) => new Promise((r) => {
17
+ setTimeout(r, ms);
18
+ });
19
+ /** An awaited microservice is one that was auto-deployed and is not skipped/disabled. */
20
+ export function isAwaited(entry) {
21
+ return !NOT_AWAITED.has(entry.status) && (entry.tenant_deploy ?? 'auto') !== 'manual';
22
+ }
23
+ /** True once every awaited microservice has settled (ok/error). */
24
+ function allSettled(entries) {
25
+ const awaited = entries.filter((e) => isAwaited(e));
26
+ // No auto microservices at all → nothing to wait for.
27
+ if (awaited.length === 0)
28
+ return true;
29
+ return awaited.every((e) => SETTLED.has(e.status));
30
+ }
31
+ /**
32
+ * Fetch the status route once. Throws on a non-2xx so the caller can decide
33
+ * whether a transient failure is fatal (it isn't — we keep polling).
34
+ */
35
+ async function fetchStatus(opts) {
36
+ const res = await opts.verboseFetch(opts.statusUrl, { headers: { Authorization: `Bearer ${opts.accessToken}` }, method: 'GET' }, opts.verbose ?? false, opts.accessToken);
37
+ if (!res.ok) {
38
+ throw new Error(`status ${res.status} ${res.statusText}`);
39
+ }
40
+ const body = (await res.json());
41
+ if (!Array.isArray(body)) {
42
+ throw new TypeError('unexpected status response shape');
43
+ }
44
+ return body;
45
+ }
46
+ /**
47
+ * Poll until all awaited microservices settle or the timeout elapses. Transient
48
+ * poll failures (network blips, a brief 5xx while a pod restarts) are tolerated —
49
+ * they don't abort the wait; only the overall timeout does.
50
+ */
51
+ export async function waitForMicroservices(opts) {
52
+ const pollIntervalMs = opts.pollIntervalMs ?? 2000;
53
+ const timeoutMs = opts.timeoutMs ?? 300_000;
54
+ const start = Date.now();
55
+ let entries = [];
56
+ // Poll loop. We always do at least one fetch so `--wait` reports even when the
57
+ // deployment already settled between the push returning and the first poll.
58
+ for (;;) {
59
+ const elapsed = Date.now() - start;
60
+ try {
61
+ // eslint-disable-next-line no-await-in-loop -- polling is sequential by design
62
+ entries = await fetchStatus(opts);
63
+ opts.onPoll?.(entries, elapsed);
64
+ if (allSettled(entries)) {
65
+ return { entries, hadError: entries.some((e) => isAwaited(e) && e.status === 'error'), timedOut: false };
66
+ }
67
+ }
68
+ catch {
69
+ // A transient status read failure is non-fatal — keep polling until the
70
+ // overall timeout. There is deliberately no consecutive-failure cap: we
71
+ // don't surface each blip, and the timeout is the only failure signal.
72
+ }
73
+ if (Date.now() - start + pollIntervalMs > timeoutMs) {
74
+ // Out of budget. Report whatever we last saw as timed out.
75
+ return {
76
+ entries,
77
+ hadError: entries.some((e) => isAwaited(e) && e.status === 'error'),
78
+ timedOut: true,
79
+ };
80
+ }
81
+ // eslint-disable-next-line no-await-in-loop -- pacing the poll loop is the point
82
+ await sleep(pollIntervalMs);
83
+ }
84
+ }
@@ -89,7 +89,61 @@ export declare function collectFiles(dir: string): string[];
89
89
  * Apply include/exclude glob filters to a file list. Logs filter results.
90
90
  * Returns the filtered file list.
91
91
  */
92
+ /**
93
+ * Normalize a filter pattern into one minimatch can actually match against a
94
+ * repo-relative FILE path.
95
+ *
96
+ * minimatch has no notion of "this pattern names a directory", and the two
97
+ * spellings a person reaches for first both silently match NOTHING:
98
+ *
99
+ * "table/" a trailing slash is not directory syntax; it matches nothing
100
+ * "table" no slash, so `matchBase` compares it to the file's BASENAME,
101
+ * i.e. it asks "is this file called `table`", not "is it under
102
+ * `table/`"
103
+ *
104
+ * Silently matching nothing is the dangerous half of this: combined with
105
+ * `--delete`, a filter that fails open pushes more than intended, and a filter
106
+ * that succeeds deletes what it was meant to protect. So a pattern that names a
107
+ * real directory is expanded to `<dir>/**` rather than left to match nothing.
108
+ */
109
+ export declare function normalizeFilterPattern(pattern: string, inputDir: string): string;
92
110
  export declare function applyFilters(files: string[], inputDir: string, include: string[] | undefined, exclude: string[] | undefined, log: (msg: string) => void): string[];
111
+ /** A document the filter removed from the push, and therefore must protect. */
112
+ export interface FilteredOutDocument {
113
+ guid?: string;
114
+ key: string;
115
+ name: string;
116
+ relPath: string;
117
+ type: string;
118
+ }
119
+ /**
120
+ * Describe the documents a --include/--exclude filter removed.
121
+ *
122
+ * These are the objects the user asked NOT to touch, and they are exactly the
123
+ * ones a `--delete` sweep would remove: a filtered-out document never reaches
124
+ * the payload, so the server reads it as deleted from the tree. Their GUIDs are
125
+ * sent as `protect_guids` so the server spares them, and their keys are used to
126
+ * VERIFY the server actually did.
127
+ */
128
+ export declare function describeFilteredOut(allFiles: string[], keptFiles: string[], inputDir: string): FilteredOutDocument[];
129
+ /**
130
+ * Delete operations that would remove something the filter excluded.
131
+ *
132
+ * This is the guard's actual test, and it is deliberately performed against the
133
+ * dry-run the SERVER returned rather than trusting that `protect_guids` was
134
+ * honoured: an older instance ignores the parameter entirely, and a document
135
+ * with no GUID cannot be protected at all. Either way the answer here is the
136
+ * truth about what the push is about to do.
137
+ */
138
+ export declare function deletesHittingFilteredOut(operations: Array<{
139
+ action: string;
140
+ name: string;
141
+ type: string;
142
+ }>, filteredOut: FilteredOutDocument[]): Array<{
143
+ name: string;
144
+ relPath: string;
145
+ type: string;
146
+ }>;
93
147
  /**
94
148
  * Read .xs files into document entries, skipping empty files.
95
149
  */
@@ -97,6 +151,40 @@ export declare function readDocuments(files: string[]): Array<{
97
151
  content: string;
98
152
  filePath: string;
99
153
  }>;
154
+ /**
155
+ * Return the entries whose file holds more than one document (a `---`
156
+ * separator). Used to refuse multi-doc files before the push pipeline's
157
+ * single-doc-per-file assumptions can drop or corrupt them.
158
+ */
159
+ export declare function findMultiDocEntries(entries: Array<{
160
+ content: string;
161
+ filePath: string;
162
+ }>): Array<{
163
+ count: number;
164
+ filePath: string;
165
+ }>;
166
+ /**
167
+ * Return every `workspace` document in the push set, with the name it declares.
168
+ *
169
+ * A tree must carry at most ONE. The server applies the first workspace
170
+ * document it encounters to the workspace being pushed into and silently
171
+ * discards the rest, with no check that the document actually describes that
172
+ * workspace — so a second one renames the destination to a foreign name while
173
+ * leaving its content untouched, and which name wins flips with the contents of
174
+ * the pushed set.
175
+ *
176
+ * Trees accumulate a second one easily, because `pull` names the file after the
177
+ * workspace's own name (`workspace/{name}.xs`): pulling a different workspace
178
+ * into the same directory ADDS a file rather than overwriting, and renaming a
179
+ * workspace leaves the old-name file behind.
180
+ */
181
+ export declare function findWorkspaceEntries(entries: Array<{
182
+ content: string;
183
+ filePath: string;
184
+ }>): Array<{
185
+ filePath: string;
186
+ name: string;
187
+ }>;
100
188
  export declare function renderBadReferences(badRefs: BadReference[], log: (msg: string) => void): void;
101
189
  export declare function renderBadIndexes(badIndexes: BadIndex[], log: (msg: string) => void): void;
102
190
  export declare function confirm(message: string): Promise<boolean>;