@xano/cli 1.0.6-beta.6 → 1.0.6-beta.7

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 CHANGED
@@ -56,20 +56,20 @@ Notes:
56
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
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
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 `{count, items, ...}`, with `page`, `per_page`, `next_page`, `prev_page`, and `total` included only when the endpoint actually reports them. This is a **breaking change** for scripts that parsed the previous bare array — read `.items` instead.
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
60
 
61
61
  ```jsonc
62
62
  // xano function list -o json
63
63
  {
64
- "count": 50,
65
- "page": 2,
66
- "per_page": 50,
67
- "next_page": 3, // absent on the last page — never inferred
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
68
  "items": [ /* ... */ ]
69
69
  }
70
70
  ```
71
71
 
72
- The point of the envelope is that a script gets the same honest stop condition a human gets from the footer. Without it the only signal available is `items.length < per_page`, which is wrong exactly when the result count is a multiple of the page size. Absence of `next_page` means the server said there is no next page; it is never omitted as a guess.
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
73
 
74
74
  ### Authentication
75
75
 
@@ -92,25 +92,29 @@ export declare function collectAllPages<T>(fetchPage: (page: number) => Promise<
92
92
  onTruncate?: (collected: number) => void;
93
93
  }): Promise<T[]>;
94
94
  export interface PagingJson<T> {
95
- count: number;
95
+ curPage?: number;
96
96
  items: T[];
97
- next_page?: number;
98
- page?: number;
99
- per_page?: number;
100
- prev_page?: number;
101
- total?: number;
97
+ itemsTotal?: number;
98
+ nextPage?: number;
99
+ perPage?: number;
100
+ prevPage?: number;
102
101
  }
103
102
  /**
104
103
  * Build the `--output json` payload for a list command.
105
104
  *
105
+ * Field names mirror the Metadata API envelope exactly — `curPage`, `nextPage`,
106
+ * `prevPage`, `itemsTotal`, `items` — so a script can move between the CLI and
107
+ * the raw API without a translation layer. `perPage` is the one field the CLI
108
+ * injects: the API never echoes it back, and it is otherwise invisible when the
109
+ * user leaves the flag at its default.
110
+ *
106
111
  * Emits only fields the response actually proves, mirroring the footer's
107
- * honesty rule: `total` appears only when the server sent `itemsTotal`,
108
- * `next_page` only when the server computed it. `count` is always the number of
109
- * items in this payload and is the one figure that is unconditionally true.
112
+ * honesty rule: `itemsTotal` appears only when the server sent it, `nextPage`
113
+ * only when the server computed it.
110
114
  *
111
- * Without this, a script driving `--output json` sees a bare array and its only
112
- * available stop condition is `length < per_page` — precisely the page-fullness
113
- * inference this module refuses to make in the footer.
115
+ * Without this envelope, a script driving `--output json` sees a bare array and
116
+ * its only available stop condition is `length < perPage` — precisely the
117
+ * page-fullness inference this module refuses to make in the footer.
114
118
  */
115
119
  export declare function buildPagingJson<T>(list: NormalizedList<T>, options: {
116
120
  page?: number;
@@ -114,17 +114,22 @@ export async function collectAllPages(fetchPage, options = {}) {
114
114
  /**
115
115
  * Build the `--output json` payload for a list command.
116
116
  *
117
+ * Field names mirror the Metadata API envelope exactly — `curPage`, `nextPage`,
118
+ * `prevPage`, `itemsTotal`, `items` — so a script can move between the CLI and
119
+ * the raw API without a translation layer. `perPage` is the one field the CLI
120
+ * injects: the API never echoes it back, and it is otherwise invisible when the
121
+ * user leaves the flag at its default.
122
+ *
117
123
  * Emits only fields the response actually proves, mirroring the footer's
118
- * honesty rule: `total` appears only when the server sent `itemsTotal`,
119
- * `next_page` only when the server computed it. `count` is always the number of
120
- * items in this payload and is the one figure that is unconditionally true.
124
+ * honesty rule: `itemsTotal` appears only when the server sent it, `nextPage`
125
+ * only when the server computed it.
121
126
  *
122
- * Without this, a script driving `--output json` sees a bare array and its only
123
- * available stop condition is `length < per_page` — precisely the page-fullness
124
- * inference this module refuses to make in the footer.
127
+ * Without this envelope, a script driving `--output json` sees a bare array and
128
+ * its only available stop condition is `length < perPage` — precisely the
129
+ * page-fullness inference this module refuses to make in the footer.
125
130
  */
126
131
  export function buildPagingJson(list, options) {
127
- const payload = { count: list.items.length, items: list.items };
132
+ const payload = { items: list.items };
128
133
  if (options.tier === 'none') {
129
134
  return payload;
130
135
  }
@@ -136,17 +141,17 @@ export function buildPagingJson(list, options) {
136
141
  if (!hasPositionEvidence) {
137
142
  return payload;
138
143
  }
139
- const page = list.curPage ?? options.page;
140
- if (page !== undefined)
141
- payload.page = page;
144
+ const curPage = list.curPage ?? options.page;
145
+ if (curPage !== undefined)
146
+ payload.curPage = curPage;
142
147
  if (options.tier === 'envelope' && options.perPage !== undefined)
143
- payload.per_page = options.perPage;
148
+ payload.perPage = options.perPage;
144
149
  if (list.nextPage !== undefined)
145
- payload.next_page = list.nextPage;
150
+ payload.nextPage = list.nextPage;
146
151
  if (list.prevPage !== undefined)
147
- payload.prev_page = list.prevPage;
152
+ payload.prevPage = list.prevPage;
148
153
  if (list.itemsTotal !== undefined)
149
- payload.total = list.itemsTotal;
154
+ payload.itemsTotal = list.itemsTotal;
150
155
  return payload;
151
156
  }
152
157
  const SEPARATOR = ' · ';