@credibledata/cred-cli 0.1.3 → 0.1.5

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 (172) hide show
  1. package/.prettierignore +2 -1
  2. package/README.md +0 -2
  3. package/bun.lock +182 -283
  4. package/dist/client/api.js +804 -111
  5. package/dist/client/api.js.map +1 -1
  6. package/dist/clientconfiguration.js +55 -13
  7. package/dist/clientconfiguration.js.map +1 -1
  8. package/dist/clientconfiguration.spec.js +305 -16
  9. package/dist/clientconfiguration.spec.js.map +1 -1
  10. package/dist/commands/add.js +6 -3
  11. package/dist/commands/add.js.map +1 -1
  12. package/dist/commands/connection/createconnections.js +18 -3
  13. package/dist/commands/connection/createconnections.js.map +1 -1
  14. package/dist/commands/connection/createconnections.spec.js +219 -0
  15. package/dist/commands/connection/createconnections.spec.js.map +1 -0
  16. package/dist/commands/connection/deleteconnection.spec.js +130 -0
  17. package/dist/commands/connection/deleteconnection.spec.js.map +1 -0
  18. package/dist/commands/connection/listconnections.js +9 -3
  19. package/dist/commands/connection/listconnections.js.map +1 -1
  20. package/dist/commands/connection/listconnections.spec.js +117 -0
  21. package/dist/commands/connection/listconnections.spec.js.map +1 -0
  22. package/dist/commands/group/addmember.js +2 -0
  23. package/dist/commands/group/addmember.js.map +1 -1
  24. package/dist/commands/group/addmember.spec.js +148 -0
  25. package/dist/commands/group/addmember.spec.js.map +1 -0
  26. package/dist/commands/group/creategroup.spec.js +122 -0
  27. package/dist/commands/group/creategroup.spec.js.map +1 -0
  28. package/dist/commands/group/deletegroup.spec.js +104 -0
  29. package/dist/commands/group/deletegroup.spec.js.map +1 -0
  30. package/dist/commands/group/getgroup.spec.js +111 -0
  31. package/dist/commands/group/getgroup.spec.js.map +1 -0
  32. package/dist/commands/group/listgroups.spec.js +118 -0
  33. package/dist/commands/group/listgroups.spec.js.map +1 -0
  34. package/dist/commands/group/removemember.js +1 -0
  35. package/dist/commands/group/removemember.js.map +1 -1
  36. package/dist/commands/group/removemember.spec.js +138 -0
  37. package/dist/commands/group/removemember.spec.js.map +1 -0
  38. package/dist/commands/groupaccesstoken/createToken.js +6 -2
  39. package/dist/commands/groupaccesstoken/createToken.js.map +1 -1
  40. package/dist/commands/groupaccesstoken/createToken.spec.js +127 -0
  41. package/dist/commands/groupaccesstoken/createToken.spec.js.map +1 -0
  42. package/dist/commands/groupaccesstoken/deleteToken.js.map +1 -1
  43. package/dist/commands/groupaccesstoken/deleteToken.spec.js +103 -0
  44. package/dist/commands/groupaccesstoken/deleteToken.spec.js.map +1 -0
  45. package/dist/commands/groupaccesstoken/groupContainer.js.map +1 -1
  46. package/dist/commands/groupaccesstoken/listTokens.js.map +1 -1
  47. package/dist/commands/groupaccesstoken/listTokens.spec.js +115 -0
  48. package/dist/commands/groupaccesstoken/listTokens.spec.js.map +1 -0
  49. package/dist/commands/list.js +10 -3
  50. package/dist/commands/list.js.map +1 -1
  51. package/dist/commands/misc/login.js +146 -22
  52. package/dist/commands/misc/login.js.map +1 -1
  53. package/dist/commands/misc/login.spec.js +111 -6
  54. package/dist/commands/misc/login.spec.js.map +1 -1
  55. package/dist/commands/misc/logout.spec.js +30 -0
  56. package/dist/commands/misc/logout.spec.js.map +1 -0
  57. package/dist/commands/misc/loopbackOAuth.js +110 -0
  58. package/dist/commands/misc/loopbackOAuth.js.map +1 -0
  59. package/dist/commands/misc/set-access-token.js.map +1 -1
  60. package/dist/commands/misc/set-access-token.spec.js +65 -0
  61. package/dist/commands/misc/set-access-token.spec.js.map +1 -0
  62. package/dist/commands/package/deletepackage.spec.js +136 -0
  63. package/dist/commands/package/deletepackage.spec.js.map +1 -0
  64. package/dist/commands/package/listpackages.js +10 -5
  65. package/dist/commands/package/listpackages.js.map +1 -1
  66. package/dist/commands/package/listpackages.spec.js +129 -0
  67. package/dist/commands/package/listpackages.spec.js.map +1 -0
  68. package/dist/commands/package/publish.js +23 -0
  69. package/dist/commands/package/publish.js.map +1 -1
  70. package/dist/commands/package/publish.spec.js +511 -0
  71. package/dist/commands/package/publish.spec.js.map +1 -0
  72. package/dist/commands/package/updatepackage.spec.js +50 -0
  73. package/dist/commands/package/updatepackage.spec.js.map +1 -1
  74. package/dist/commands/project/createproject.js +11 -1
  75. package/dist/commands/project/createproject.js.map +1 -1
  76. package/dist/commands/project/createproject.spec.js +154 -0
  77. package/dist/commands/project/createproject.spec.js.map +1 -0
  78. package/dist/commands/project/deleteproject.spec.js +106 -0
  79. package/dist/commands/project/deleteproject.spec.js.map +1 -0
  80. package/dist/commands/project/getproject.spec.js +99 -0
  81. package/dist/commands/project/getproject.spec.js.map +1 -0
  82. package/dist/commands/project/listprojects.js +13 -7
  83. package/dist/commands/project/listprojects.js.map +1 -1
  84. package/dist/commands/project/listprojects.spec.js +111 -0
  85. package/dist/commands/project/listprojects.spec.js.map +1 -0
  86. package/dist/commands/project/setproject.spec.js +58 -0
  87. package/dist/commands/project/setproject.spec.js.map +1 -0
  88. package/dist/commands/project/updateproject.js +68 -0
  89. package/dist/commands/project/updateproject.js.map +1 -0
  90. package/dist/commands/project/updateproject.spec.js +129 -0
  91. package/dist/commands/project/updateproject.spec.js.map +1 -0
  92. package/dist/commands/rm.js.map +1 -1
  93. package/dist/commands/update.js +13 -0
  94. package/dist/commands/update.js.map +1 -1
  95. package/dist/commands/version/listversions.spec.js +121 -0
  96. package/dist/commands/version/listversions.spec.js.map +1 -0
  97. package/dist/common/UserGroupId.spec.js +92 -0
  98. package/dist/common/UserGroupId.spec.js.map +1 -0
  99. package/dist/constants.js +49 -13
  100. package/dist/constants.js.map +1 -1
  101. package/dist/index.js +40 -18
  102. package/dist/index.js.map +1 -1
  103. package/dist/logger.spec.js +125 -0
  104. package/dist/logger.spec.js.map +1 -0
  105. package/dist/polyfills/file.polyfill.js.map +1 -1
  106. package/dist/utils.js +59 -0
  107. package/dist/utils.js.map +1 -1
  108. package/dist/utils.spec.js +158 -0
  109. package/dist/utils.spec.js.map +1 -0
  110. package/docker/Dockerfile.ci +11 -3
  111. package/eslint.config.mjs +45 -0
  112. package/generate-client.sh +5 -0
  113. package/package.json +24 -16
  114. package/src/client/.openapi-generator/FILES +1 -0
  115. package/src/client/api.ts +1999 -696
  116. package/src/clientconfiguration.spec.ts +394 -20
  117. package/src/clientconfiguration.ts +74 -15
  118. package/src/commands/add.ts +15 -6
  119. package/src/commands/connection/createconnections.spec.ts +403 -0
  120. package/src/commands/connection/createconnections.ts +30 -5
  121. package/src/commands/connection/deleteconnection.spec.ts +189 -0
  122. package/src/commands/connection/listconnections.spec.ts +132 -0
  123. package/src/commands/connection/listconnections.ts +22 -3
  124. package/src/commands/group/addmember.spec.ts +257 -0
  125. package/src/commands/group/addmember.ts +2 -0
  126. package/src/commands/group/creategroup.spec.ts +146 -0
  127. package/src/commands/group/deletegroup.spec.ts +120 -0
  128. package/src/commands/group/getgroup.spec.ts +129 -0
  129. package/src/commands/group/listgroups.spec.ts +137 -0
  130. package/src/commands/group/removemember.spec.ts +224 -0
  131. package/src/commands/group/removemember.ts +1 -0
  132. package/src/commands/groupaccesstoken/createToken.spec.ts +211 -0
  133. package/src/commands/groupaccesstoken/createToken.ts +55 -51
  134. package/src/commands/groupaccesstoken/deleteToken.spec.ts +147 -0
  135. package/src/commands/groupaccesstoken/deleteToken.ts +16 -11
  136. package/src/commands/groupaccesstoken/groupContainer.ts +51 -51
  137. package/src/commands/groupaccesstoken/listTokens.spec.ts +147 -0
  138. package/src/commands/groupaccesstoken/listTokens.ts +16 -11
  139. package/src/commands/list.ts +50 -9
  140. package/src/commands/misc/login.spec.ts +91 -6
  141. package/src/commands/misc/login.ts +208 -25
  142. package/src/commands/misc/logout.spec.ts +32 -0
  143. package/src/commands/misc/loopbackOAuth.ts +127 -0
  144. package/src/commands/misc/set-access-token.spec.ts +95 -0
  145. package/src/commands/misc/set-access-token.ts +16 -16
  146. package/src/commands/package/deletepackage.spec.ts +164 -0
  147. package/src/commands/package/listpackages.spec.ts +147 -0
  148. package/src/commands/package/listpackages.ts +28 -5
  149. package/src/commands/package/publish.spec.ts +597 -0
  150. package/src/commands/package/publish.ts +32 -0
  151. package/src/commands/package/updatepackage.spec.ts +98 -0
  152. package/src/commands/project/createproject.spec.ts +247 -0
  153. package/src/commands/project/createproject.ts +12 -1
  154. package/src/commands/project/deleteproject.spec.ts +123 -0
  155. package/src/commands/project/getproject.spec.ts +109 -0
  156. package/src/commands/project/listprojects.spec.ts +121 -0
  157. package/src/commands/project/listprojects.ts +33 -7
  158. package/src/commands/project/setproject.spec.ts +63 -0
  159. package/src/commands/project/updateproject.spec.ts +217 -0
  160. package/src/commands/project/updateproject.ts +82 -0
  161. package/src/commands/rm.ts +1 -6
  162. package/src/commands/update.ts +24 -1
  163. package/src/commands/version/listversions.spec.ts +138 -0
  164. package/src/common/UserGroupId.spec.ts +117 -0
  165. package/src/constants.ts +59 -13
  166. package/src/index.ts +46 -20
  167. package/src/logger.spec.ts +158 -0
  168. package/src/polyfills/file.polyfill.ts +1 -0
  169. package/src/utils.spec.ts +135 -0
  170. package/src/utils.ts +81 -0
  171. package/tsconfig.json +15 -18
  172. package/.eslintrc +0 -33
@@ -0,0 +1,164 @@
1
+ import { expect } from "chai";
2
+ import sinon from "sinon";
3
+ import { PackagesApi } from "../../client/api";
4
+ import { ClientConfiguration } from "../../clientconfiguration";
5
+ import { logger } from "../../logger";
6
+ import { getConfirmation } from "../../utils";
7
+ import { deletePackage } from "./deletepackage";
8
+
9
+ describe("delete-package", () => {
10
+ let sandbox: sinon.SinonSandbox;
11
+ let deletePackageStub: sinon.SinonStub;
12
+ let loggerStub: sinon.SinonStubbedInstance<typeof logger>;
13
+ let getConfirmationStub: sinon.SinonStub;
14
+
15
+ beforeEach(() => {
16
+ sandbox = sinon.createSandbox();
17
+ deletePackageStub = sandbox.stub();
18
+ loggerStub = sandbox.stub(logger);
19
+ getConfirmationStub = sandbox.stub();
20
+
21
+ sandbox
22
+ .stub(ClientConfiguration.prototype, "getOrganization")
23
+ .returns("test-org");
24
+ sandbox
25
+ .stub(ClientConfiguration.prototype, "getProject")
26
+ .returns("test-project");
27
+ sandbox
28
+ .stub(ClientConfiguration.prototype, "doesConfigExists")
29
+ .returns(true);
30
+ sandbox
31
+ .stub(ClientConfiguration.prototype, "getHeaders")
32
+ .returns({ Authorization: "Bearer test-token" });
33
+
34
+ sandbox
35
+ .stub(PackagesApi.prototype, "deletePackage")
36
+ .callsFake(deletePackageStub);
37
+ sandbox
38
+ .stub(require("../../utils"), "getConfirmation")
39
+ .callsFake(getConfirmationStub);
40
+ });
41
+
42
+ afterEach(() => {
43
+ sandbox.restore();
44
+ });
45
+
46
+ it("should delete package successfully", async () => {
47
+ deletePackageStub.resolves({ status: 200 });
48
+ getConfirmationStub.resolves(true);
49
+
50
+ await deletePackage("http://test-server", "/test-package", false, true);
51
+
52
+ expect(deletePackageStub.calledOnce).to.be.true;
53
+ expect(deletePackageStub.firstCall.args[0]).to.equal("test-org");
54
+ expect(deletePackageStub.firstCall.args[1]).to.equal("test-project");
55
+ expect(deletePackageStub.firstCall.args[2]).to.equal("test-package");
56
+ expect(deletePackageStub.firstCall.args[3]).to.deep.include({
57
+ baseURL: "http://test-server",
58
+ headers: { Authorization: "Bearer test-token" },
59
+ });
60
+ expect(
61
+ loggerStub.info.calledWith(
62
+ sinon.match("Package deleted successfully"),
63
+ ),
64
+ ).to.be.true;
65
+ });
66
+
67
+ it("should handle package path without leading slash", async () => {
68
+ deletePackageStub.resolves({ status: 200 });
69
+ getConfirmationStub.resolves(true);
70
+
71
+ await deletePackage("http://test-server", "test-package", false, true);
72
+
73
+ expect(deletePackageStub.firstCall.args[2]).to.equal("test-package");
74
+ });
75
+
76
+ it("should handle missing config", async () => {
77
+ sandbox.restore();
78
+ sandbox = sinon.createSandbox();
79
+ deletePackageStub = sandbox.stub();
80
+ loggerStub = sandbox.stub(logger);
81
+ getConfirmationStub = sandbox.stub();
82
+
83
+ sandbox
84
+ .stub(ClientConfiguration.prototype, "doesConfigExists")
85
+ .returns(false);
86
+ sandbox
87
+ .stub(PackagesApi.prototype, "deletePackage")
88
+ .callsFake(deletePackageStub);
89
+ sandbox
90
+ .stub(require("../../utils"), "getConfirmation")
91
+ .callsFake(getConfirmationStub);
92
+
93
+ await deletePackage("http://test-server", "/test-package", false, true);
94
+
95
+ expect(deletePackageStub.called).to.be.false;
96
+ expect(
97
+ loggerStub.error.calledWith(
98
+ sinon.match("Please, make sure that you are logged in"),
99
+ ),
100
+ ).to.be.true;
101
+ });
102
+
103
+ it("should handle missing project", async () => {
104
+ sandbox.restore();
105
+ sandbox = sinon.createSandbox();
106
+ deletePackageStub = sandbox.stub();
107
+ loggerStub = sandbox.stub(logger);
108
+ getConfirmationStub = sandbox.stub();
109
+
110
+ sandbox
111
+ .stub(ClientConfiguration.prototype, "doesConfigExists")
112
+ .returns(true);
113
+ sandbox.stub(ClientConfiguration.prototype, "getProject").returns("");
114
+ sandbox
115
+ .stub(PackagesApi.prototype, "deletePackage")
116
+ .callsFake(deletePackageStub);
117
+ sandbox
118
+ .stub(require("../../utils"), "getConfirmation")
119
+ .callsFake(getConfirmationStub);
120
+
121
+ await deletePackage("http://test-server", "/test-package", false, true);
122
+
123
+ expect(deletePackageStub.called).to.be.false;
124
+ expect(
125
+ loggerStub.error.calledWith(
126
+ sinon.match("Please, make sure to set a project"),
127
+ ),
128
+ ).to.be.true;
129
+ });
130
+
131
+ it("should request confirmation when autoConfirm is false", async () => {
132
+ deletePackageStub.resolves({ status: 200 });
133
+ getConfirmationStub.resolves(true);
134
+
135
+ await deletePackage("http://test-server", "/test-package", false, false);
136
+
137
+ expect(getConfirmationStub.calledOnce).to.be.true;
138
+ expect(deletePackageStub.calledOnce).to.be.true;
139
+ });
140
+
141
+ it("should cancel when confirmation is denied", async () => {
142
+ getConfirmationStub.resolves(false);
143
+
144
+ await deletePackage("http://test-server", "/test-package", false, false);
145
+
146
+ expect(getConfirmationStub.calledOnce).to.be.true;
147
+ expect(deletePackageStub.called).to.be.false;
148
+ expect(loggerStub.info.calledWith(sinon.match("Operation cancelled."))).to
149
+ .be.true;
150
+ });
151
+
152
+ it("should handle API errors", async () => {
153
+ const mockError = new Error("API Error");
154
+ deletePackageStub.rejects(mockError);
155
+ getConfirmationStub.resolves(true);
156
+
157
+ await deletePackage("http://test-server", "/test-package", true, true);
158
+
159
+ expect(deletePackageStub.calledOnce).to.be.true;
160
+ expect(
161
+ loggerStub.error.calledWith(sinon.match("Failed to delete package")),
162
+ ).to.be.true;
163
+ });
164
+ });
@@ -0,0 +1,147 @@
1
+ import { expect } from "chai";
2
+ import sinon from "sinon";
3
+ import { PackagesApi } from "../../client/api";
4
+ import { ClientConfiguration } from "../../clientconfiguration";
5
+ import { logger } from "../../logger";
6
+ import { prettifyJson } from "../../utils";
7
+ import { listPackages, printOutPackages } from "./listpackages";
8
+
9
+ describe("list-packages", () => {
10
+ let sandbox: sinon.SinonSandbox;
11
+ let listPackagesStub: sinon.SinonStub;
12
+ let loggerStub: sinon.SinonStubbedInstance<typeof logger>;
13
+ let consoleLogStub: sinon.SinonStub;
14
+
15
+ beforeEach(() => {
16
+ sandbox = sinon.createSandbox();
17
+ listPackagesStub = sandbox.stub();
18
+ loggerStub = sandbox.stub(logger);
19
+ consoleLogStub = sandbox.stub(console, "log");
20
+
21
+ sandbox
22
+ .stub(ClientConfiguration.prototype, "getOrganization")
23
+ .returns("test-org");
24
+ sandbox
25
+ .stub(ClientConfiguration.prototype, "getProject")
26
+ .returns("test-project");
27
+ sandbox
28
+ .stub(ClientConfiguration.prototype, "doesConfigExists")
29
+ .returns(true);
30
+ sandbox
31
+ .stub(ClientConfiguration.prototype, "getHeaders")
32
+ .returns({ Authorization: "Bearer test-token" });
33
+
34
+ sandbox
35
+ .stub(PackagesApi.prototype, "listPackages")
36
+ .callsFake(listPackagesStub);
37
+ });
38
+
39
+ afterEach(() => {
40
+ sandbox.restore();
41
+ });
42
+
43
+ it("should list packages successfully", async () => {
44
+ const mockPackages = [
45
+ { name: "package1", latestVersion: "1.0.0" },
46
+ { name: "package2", latestVersion: "2.0.0" },
47
+ ];
48
+ const mockResponse = {
49
+ data: mockPackages,
50
+ headers: {},
51
+ };
52
+ listPackagesStub.resolves(mockResponse);
53
+
54
+ const result = await listPackages("http://test-server", false);
55
+
56
+ expect(listPackagesStub.calledOnce).to.be.true;
57
+ expect(listPackagesStub.firstCall.args[0]).to.equal("test-org");
58
+ expect(listPackagesStub.firstCall.args[1]).to.equal("test-project");
59
+ expect(listPackagesStub.firstCall.args[2]).to.equal(-1); // limit
60
+ expect(listPackagesStub.firstCall.args[3]).to.equal(0); // offset
61
+ expect(listPackagesStub.firstCall.args[4]).to.deep.include({
62
+ baseURL: "http://test-server",
63
+ headers: { Authorization: "Bearer test-token" },
64
+ });
65
+ expect(result).to.deep.equal({
66
+ packages: mockPackages,
67
+ totalCount: undefined,
68
+ });
69
+ });
70
+
71
+ it("should handle missing config", async () => {
72
+ sandbox.restore();
73
+ sandbox = sinon.createSandbox();
74
+ listPackagesStub = sandbox.stub();
75
+ loggerStub = sandbox.stub(logger);
76
+ consoleLogStub = sandbox.stub(console, "log");
77
+
78
+ sandbox
79
+ .stub(ClientConfiguration.prototype, "doesConfigExists")
80
+ .returns(false);
81
+ sandbox
82
+ .stub(PackagesApi.prototype, "listPackages")
83
+ .callsFake(listPackagesStub);
84
+
85
+ const result = await listPackages("http://test-server", false);
86
+
87
+ expect(listPackagesStub.called).to.be.false;
88
+ expect(result).to.be.undefined;
89
+ expect(
90
+ loggerStub.error.calledWith(
91
+ sinon.match("Please, make sure that you are logged in"),
92
+ ),
93
+ ).to.be.true;
94
+ });
95
+
96
+ it("should handle missing project", async () => {
97
+ sandbox.restore();
98
+ sandbox = sinon.createSandbox();
99
+ listPackagesStub = sandbox.stub();
100
+ loggerStub = sandbox.stub(logger);
101
+ consoleLogStub = sandbox.stub(console, "log");
102
+
103
+ sandbox
104
+ .stub(ClientConfiguration.prototype, "doesConfigExists")
105
+ .returns(true);
106
+ sandbox.stub(ClientConfiguration.prototype, "getProject").returns("");
107
+ sandbox
108
+ .stub(PackagesApi.prototype, "listPackages")
109
+ .callsFake(listPackagesStub);
110
+
111
+ const result = await listPackages("http://test-server", false);
112
+
113
+ expect(listPackagesStub.called).to.be.false;
114
+ expect(result).to.be.undefined;
115
+ expect(
116
+ loggerStub.error.calledWith(
117
+ sinon.match("Please, make sure to set a project"),
118
+ ),
119
+ ).to.be.true;
120
+ });
121
+
122
+ it("should handle API errors", async () => {
123
+ const mockError = new Error("API Error");
124
+ listPackagesStub.rejects(mockError);
125
+
126
+ const result = await listPackages("http://test-server", true);
127
+
128
+ expect(listPackagesStub.calledOnce).to.be.true;
129
+ expect(result).to.be.undefined;
130
+ expect(
131
+ loggerStub.error.calledWith(sinon.match("Failed to list packages")),
132
+ ).to.be.true;
133
+ });
134
+
135
+ it("should print packages when using printOutPackages", async () => {
136
+ const mockPackages = [{ name: "package1" }];
137
+ const mockResponse = {
138
+ data: mockPackages,
139
+ headers: {},
140
+ };
141
+ listPackagesStub.resolves(mockResponse);
142
+
143
+ await printOutPackages("http://test-server", false);
144
+
145
+ expect(consoleLogStub.called).to.be.true;
146
+ });
147
+ });
@@ -2,11 +2,21 @@ import { PackagesApi } from "../../client/api";
2
2
  import { Configuration } from "../../client/configuration";
3
3
  import { ClientConfiguration } from "../../clientconfiguration";
4
4
  import { logger } from "../../logger";
5
- import { prettifyJson, printOutError } from "../../utils";
5
+ import {
6
+ prettifyJson,
7
+ printOutError,
8
+ parsePaginationParams,
9
+ extractTotalCount,
10
+ } from "../../utils";
6
11
 
7
12
  const packagesApi = new PackagesApi(new Configuration());
8
13
 
9
- export async function listPackages(controlPlane: string, debug: boolean) {
14
+ export async function listPackages(
15
+ controlPlane: string,
16
+ debug: boolean,
17
+ page?: string | number,
18
+ pageSize?: string | number,
19
+ ) {
10
20
  const clientConfig = new ClientConfiguration();
11
21
  const organizationName = clientConfig.getOrganization();
12
22
  const projectName = clientConfig.getProject();
@@ -22,23 +32,36 @@ export async function listPackages(controlPlane: string, debug: boolean) {
22
32
  }
23
33
 
24
34
  try {
35
+ const { limit, offset } = parsePaginationParams(page, pageSize);
25
36
  const response = await packagesApi.listPackages(
26
37
  organizationName,
27
38
  projectName,
39
+ limit,
40
+ offset,
28
41
  {
29
42
  baseURL: controlPlane,
30
43
  headers: clientConfig.getHeaders(),
31
44
  },
32
45
  );
33
46
 
34
- return response.data;
47
+ const totalCount = extractTotalCount(response.headers);
48
+
49
+ return {
50
+ packages: response.data,
51
+ totalCount,
52
+ };
35
53
  } catch (e) {
36
54
  logger.error("Failed to list packages");
37
55
  printOutError(e, debug);
38
56
  }
39
57
  }
40
58
 
41
- export async function printOutPackages(controlPlane: string, debug: boolean) {
42
- const packages = await listPackages(controlPlane, debug);
59
+ export async function printOutPackages(
60
+ controlPlane: string,
61
+ debug: boolean,
62
+ page?: string | number,
63
+ pageSize?: string | number,
64
+ ) {
65
+ const packages = await listPackages(controlPlane, debug, page, pageSize);
43
66
  console.log(prettifyJson(packages));
44
67
  }