Skip to content

Commit c623d8b

Browse files
committed
Revert "add customer list function"
This reverts commit 4bf236a.
1 parent 4bf236a commit c623d8b

File tree

3 files changed

+1
-99
lines changed

3 files changed

+1
-99
lines changed

README.md

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,3 @@
33
This is a library for interacting with the Replicated Vendor Portal API using TypeScript.
44

55
Source code: [Github](https://github.com/replicatedhq/replicated-lib)
6-
7-
## Testing Locally
8-
9-
### Prerequisites
10-
11-
- Node.js >= 20.0.0
12-
- npm
13-
14-
### Running Tests
15-
16-
1. **Install dependencies:**
17-
```bash
18-
npm install
19-
```
20-
Or using Make:
21-
```bash
22-
make deps
23-
```
24-
25-
2. **Run all tests:**
26-
```bash
27-
npm test
28-
```
29-
Or using Make:
30-
```bash
31-
make test
32-
```
33-
34-
This will:
35-
- Build the TypeScript source code
36-
- Run all test suites with coverage reporting
37-
- Display verbose output for each test
38-
39-
3. **Run tests without building first:**
40-
```bash
41-
npx jest --coverage --verbose --setupFiles ./pacts/configuration.ts
42-
```
43-
44-
### Test Structure
45-
46-
- Test files are located alongside source files with `.spec.ts` extension (e.g., `src/customers.spec.ts`)
47-
- Tests use `mockttp` for HTTP request mocking
48-
- Some tests use Pact for contract testing (configured in `pacts/configuration.ts`)
49-
50-
### Running Specific Tests
51-
52-
To run a specific test file:
53-
```bash
54-
npx jest src/customers.spec.ts
55-
```
56-
57-
To run tests matching a pattern:
58-
```bash
59-
npx jest --testNamePattern="List Customers"
60-
```

src/customers.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ export class Customer {
1212
license: string;
1313
}
1414

15-
export class CustomerSummary {
16-
name: string;
17-
customerId: string;
18-
}
19-
2015
interface entitlementValue {
2116
name: string;
2217
value: string;
@@ -118,44 +113,6 @@ export async function archiveCustomer(vendorPortalApi: VendorPortalApi, customer
118113
}
119114
}
120115

121-
export async function listCustomersByName(vendorPortalApi: VendorPortalApi, appSlug: string, customerName: string): Promise<CustomerSummary[]> {
122-
const http = await vendorPortalApi.client();
123-
124-
// 1. get the app
125-
const app = await getApplicationDetails(vendorPortalApi, appSlug);
126-
127-
// 2. list customers filtered by name
128-
const listCustomersUri = `${vendorPortalApi.endpoint}/app/${app.id}/customers?name=${encodeURIComponent(customerName)}`;
129-
const listCustomersRes = await http.get(listCustomersUri);
130-
if (listCustomersRes.message.statusCode != 200) {
131-
let body = "";
132-
try {
133-
body = await listCustomersRes.readBody();
134-
} catch (err) {
135-
// ignore
136-
}
137-
throw new Error(`Failed to list customers: Server responded with ${listCustomersRes.message.statusCode}: ${body}`);
138-
}
139-
const listCustomersBody: any = JSON.parse(await listCustomersRes.readBody());
140-
141-
// 3. Convert response body into CustomerSummary array
142-
let customers: CustomerSummary[] = [];
143-
144-
// check if listCustomersBody.customers is undefined
145-
if (!listCustomersBody.customers) {
146-
return customers;
147-
}
148-
149-
for (const customer of listCustomersBody.customers) {
150-
customers.push({
151-
name: customer.name,
152-
customerId: customer.id
153-
});
154-
}
155-
156-
return customers;
157-
}
158-
159116
export async function getUsedKubernetesDistributions(vendorPortalApi: VendorPortalApi, appSlug: string): Promise<KubernetesDistribution[]> {
160117
const http = await vendorPortalApi.client();
161118

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ export { VendorPortalApi } from "./configuration";
22
export { getApplicationDetails } from "./applications";
33
export { Channel, createChannel, getChannelDetails, archiveChannel, pollForAirgapReleaseStatus, getDownloadUrlAirgapBuildRelease } from "./channels";
44
export { ClusterVersion, createCluster, createClusterWithLicense, pollForStatus, getKubeconfig, removeCluster, upgradeCluster, getClusterVersions, createAddonObjectStore, pollForAddonStatus, exposeClusterPort } from "./clusters";
5-
export { KubernetesDistribution, CustomerSummary, archiveCustomer, createCustomer, getUsedKubernetesDistributions, listCustomersByName } from "./customers";
5+
export { KubernetesDistribution, archiveCustomer, createCustomer, getUsedKubernetesDistributions } from "./customers";
66
export { Release, CompatibilityResult, createRelease, createReleaseFromChart, promoteRelease, reportCompatibilityResult } from "./releases";

0 commit comments

Comments
 (0)