Skip to content

Commit 870bf5f

Browse files
authored
Merge pull request #121 from polarsquad/allow-filtering-when-retrieving-projects
Allow filtering of projects in getAllProjects
2 parents d013e7b + 25c0375 commit 870bf5f

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@polarsquad/cinode-api",
3-
"version": "0.12.5",
3+
"version": "0.12.6",
44
"description": "Cinode API for the Cinode platform",
55
"homepage": "https://github.com/polarsquad/cinode-api#readme",
66
"bugs": {

src/api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
ProjectBase,
2626
ProjectPipeline,
2727
ProjectState,
28+
SearchProjectQuery,
2829
SearchResult,
2930
SearchSkillResult,
3031
TeamBase,
@@ -66,7 +67,7 @@ export class Api {
6667
.json<CompanyCustomer>();
6768
}
6869

69-
async listAllProjects(query = {}) {
70+
async listAllProjects(query: SearchProjectQuery = {}) {
7071
const {
7172
pagedAndSortedBy: { itemsPerPage },
7273
totalItems,

src/service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type {
1919
ProjectBase,
2020
ProjectState,
2121
ProjectTeam,
22+
SearchProjectQuery,
2223
UserFilter,
2324
WithProfile,
2425
} from './types.js';
@@ -69,8 +70,8 @@ export class CinodeService {
6970
this.backofficeTeams = backofficeTeams;
7071
}
7172

72-
async getAllProjects() {
73-
const projects = await this.api.listAllProjects();
73+
async getAllProjects(query: SearchProjectQuery = {}) {
74+
const projects = await this.api.listAllProjects(query);
7475
return Promise.all(
7576
projects.flatMap((p) => (p?.id ? [this.getProject(p.id)] : []))
7677
);

src/types.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,21 @@ export enum ProjectState {
180180
Suspended = 60,
181181
}
182182

183+
export enum SortByProject {
184+
CreatedDateTime = 0,
185+
Title = 1,
186+
Identifier = 2,
187+
CustomerIdentifier = 3,
188+
SeoId = 4,
189+
UpdatedDateTime = 5,
190+
LastTouchDateTime = 6,
191+
}
192+
193+
export enum SortOrder {
194+
Ascending = 0,
195+
Descending = 1,
196+
}
197+
183198
export enum Status {
184199
Inactive = 0,
185200
Active = 1,
@@ -1267,6 +1282,27 @@ export interface Role {
12671282
level?: AccessLevel | null;
12681283
}
12691284

1285+
interface PageAndSortByProject {
1286+
sortBy?: SortByProject;
1287+
sortOrder?: SortOrder;
1288+
page?: number;
1289+
itemsPerPage?: number;
1290+
}
1291+
1292+
export interface SearchProjectQuery {
1293+
title?: string;
1294+
identification?: string;
1295+
customerIdentifier?: string;
1296+
corporateIdentityNumber?: string;
1297+
customerId?: number;
1298+
pageAndSortBy?: PageAndSortByProject;
1299+
pipelines?: number[];
1300+
salesManagers?: number[];
1301+
customers?: number[];
1302+
intermediators?: number[];
1303+
projectStates?: ProjectState[];
1304+
}
1305+
12701306
export interface SearchSkill {
12711307
keywordId?: number | null;
12721308
min?: number | null;

0 commit comments

Comments
 (0)