Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,700 changes: 839 additions & 861 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"graphql": "^16.8.1",
"graphql": "^16.11.0",
"graphql-request": "^6.1.0",
"https-proxy-agent": "7.0.1"
},
Expand All @@ -41,7 +41,7 @@
"eslint-plugin-prettier": "5.1.3",
"husky": "9.0.10",
"jest": "^29.7.0",
"npm-run-all": "4.1.5",
"npm-run-all": "^4.1.5",
"prettier": "3.2.4",
"rimraf": "3.0.2",
"source-map-support": "0.5.21",
Expand Down
10 changes: 10 additions & 0 deletions src/demarche/demarche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export const getDemarcheDossierIds = async (
client: GraphQLClient,
idDemarche: number,
updatedSince?: Date,
first?: number,
after?: string,
): Promise<getDemarcheType> => {
const variables = {
demarcheNumber: idDemarche,
Expand All @@ -86,6 +88,14 @@ export const getDemarcheDossierIds = async (
variables["updatedSince"] = updatedSince;
}

if (after) {
variables["after"] = after;
}

if (first) {
variables["first"] = first;
}

return graphQlRequest<getDemarcheType>(
client,
queryDemarcheDossierIds,
Expand Down
15 changes: 13 additions & 2 deletions src/ds-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,19 @@ export class DsApiClient {
);
}

async demarcheDossierIds(idDemarche: number, updatedSince?: Date) {
return await getDemarcheDossierIds(this.client, idDemarche, updatedSince);
async demarcheDossierIds(
idDemarche: number,
updatedSince?: Date,
first?: number,
after?: string,
) {
return await getDemarcheDossierIds(
this.client,
idDemarche,
updatedSince,
first,
after,
);
}

async demarcheDeletedDossiers(idDemarche: number) {
Expand Down
13 changes: 9 additions & 4 deletions src/ds-api-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ export class DsApiError extends Error {
].join("\n");
}

constructor(gqlResponse: any) {
constructor(e: any) {
super(DsApiError.title);
this.graphQlRequest = gqlResponse.request;
this.graphQlResponse = gqlResponse.response;
this.errors = gqlResponse?.response?.errors || [];
if ("response" in e) {
const gqlResponse = e;
this.graphQlRequest = gqlResponse.request;
this.graphQlResponse = gqlResponse.response;
this.errors = gqlResponse?.response?.errors || [];
} else {
this.errors = [e];
}
this._buildMessage();
}
}
9 changes: 9 additions & 0 deletions src/graphql/getDemarcheDossierIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default gql`
$demarcheNumber: Int!
$state: DossierState
$order: Order
$first: Int
$after: String
$updatedSince: ISO8601DateTime
) {
Expand Down Expand Up @@ -51,9 +52,17 @@ export default gql`
dossiers(
state: $state
order: $order
first: $first
after: $after
updatedSince: $updatedSince
) {
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}

nodes {
id
number
Expand Down
15 changes: 9 additions & 6 deletions test/ds-api.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ describe("ds api", () => {
it("get demarche with dossier ids number 1", async () => {
const response = await dsApiClient.demarcheDossierIds(1);
expect(response?.demarche?.number).toBe(1);
expect(response?.demarche?.dossiers.nodes).toHaveLength(1);
expect(response?.demarche?.dossiers.nodes).toMatchObject([
{
number: 220,
},
]);
expect(response?.demarche?.dossiers.nodes).toHaveLength(8);
expect(response?.demarche?.dossiers.nodes).toMatchObject(
expect.arrayContaining([
expect.objectContaining({
number: 220,
}),
]),
);
expect(response?.demarche?.dossiers.pageInfo.hasNextPage).toBeFalsy();
});

it("get one files from dossiers in annatation", async () => {
Expand Down