@bussolabs/closeyourit-cli 0.7.2 → 0.7.3

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.
@@ -18,7 +18,7 @@ class SecretsAssetsList extends base_1.BaseCommand {
18
18
  const data = await (0, paginate_1.fetchAllPages)(this.api, `/cli/v1/projects/${encodeURIComponent(projectId)}/secret_assets`);
19
19
  if (!this.jsonEnabled())
20
20
  this.log((0, output_1.renderTable)(['ID', 'NAME', 'TYPE', 'ENV', 'VERSION', 'BYTES'], data.map((a) => [a.id, a.name, a.asset_type, a.environment?.code ?? 'all', a.current_version?.number ?? '', a.current_version?.byte_size ?? ''])));
21
- return { data };
21
+ return { data, meta: (0, paginate_1.aggregatedMeta)(data.length) };
22
22
  }
23
23
  }
24
24
  exports.default = SecretsAssetsList;
@@ -10,7 +10,7 @@ class SecretsAssetsSharedList extends base_1.BaseCommand {
10
10
  const data = await (0, paginate_1.fetchAllPages)(this.api, '/cli/v1/shared_secret_assets');
11
11
  if (!this.jsonEnabled())
12
12
  this.log((0, output_1.renderTable)(['ID', 'NAME', 'TYPE', 'ENV'], data.map((a) => [a.id, a.name, a.asset_type, a.environment?.code ?? 'all'])));
13
- return { data };
13
+ return { data, meta: (0, paginate_1.aggregatedMeta)(data.length) };
14
14
  }
15
15
  }
16
16
  exports.default = SecretsAssetsSharedList;
@@ -27,7 +27,7 @@ class SecretsList extends base_1.BaseCommand {
27
27
  ]);
28
28
  this.log((0, output_1.renderTable)(['NAME', 'ENVIRONMENT', 'DESCRIPTION'], rows));
29
29
  }
30
- return { data };
30
+ return { data, meta: (0, paginate_1.aggregatedMeta)(data.length) };
31
31
  }
32
32
  }
33
33
  exports.default = SecretsList;
@@ -7,3 +7,15 @@ import type { CliApi } from './api';
7
7
  * A backend that does not paginate returns everything on page 1 (`meta` absent) → single fetch.
8
8
  */
9
9
  export declare function fetchAllPages<T = Record<string, unknown>>(api: CliApi, basePath: string, params?: Record<string, string>): Promise<T[]>;
10
+ /**
11
+ * Meta for a fully-aggregated collection. `fetchAllPages` collapses every backend page into a
12
+ * single logical page, so page-1's meta (e.g. `total_pages: 2`) would misdescribe the payload —
13
+ * and dropping `meta` altogether breaks `--json` consumers of the envelope. This restates the
14
+ * backend's `{page, per, total, total_pages}` contract consistently with the aggregated `data`.
15
+ */
16
+ export declare function aggregatedMeta(count: number): {
17
+ page: number;
18
+ per: number;
19
+ total: number;
20
+ total_pages: number;
21
+ };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchAllPages = fetchAllPages;
4
+ exports.aggregatedMeta = aggregatedMeta;
4
5
  /**
5
6
  * Read every page of a paginated collection endpoint and return the aggregated rows.
6
7
  *
@@ -22,3 +23,12 @@ async function fetchAllPages(api, basePath, params = {}) {
22
23
  } while (page <= totalPages);
23
24
  return all;
24
25
  }
26
+ /**
27
+ * Meta for a fully-aggregated collection. `fetchAllPages` collapses every backend page into a
28
+ * single logical page, so page-1's meta (e.g. `total_pages: 2`) would misdescribe the payload —
29
+ * and dropping `meta` altogether breaks `--json` consumers of the envelope. This restates the
30
+ * backend's `{page, per, total, total_pages}` contract consistently with the aggregated `data`.
31
+ */
32
+ function aggregatedMeta(count) {
33
+ return { page: 1, per: count, total: count, total_pages: 1 };
34
+ }