@lab-mi/ds-api-client
Advanced tools
Comparing version 1.0.2 to 1.1.1
@@ -6,1 +6,7 @@ import { GraphQLClient } from "graphql-request"; | ||
}>; | ||
export declare const getDemarcheDossiers: (client: GraphQLClient, idDemarche: number) => Promise<{ | ||
demarche: Partial<Demarche>; | ||
}>; | ||
export declare const getDemarcheDeletedDossiers: (client: GraphQLClient, idDemarche: number) => Promise<{ | ||
demarche: Partial<Demarche>; | ||
}>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDemarche = void 0; | ||
exports.getDemarcheDeletedDossiers = exports.getDemarcheDossiers = exports.getDemarche = void 0; | ||
const getDemarche_1 = require("./graphql/getDemarche"); | ||
const getDemarcheDossiers_1 = require("./graphql/getDemarcheDossiers"); | ||
const getDemarcheDeletedDossiers_1 = require("./graphql/getDemarcheDeletedDossiers"); | ||
const getDemarche = async (client, idDemarche) => { | ||
@@ -14,2 +16,20 @@ try { | ||
exports.getDemarche = getDemarche; | ||
const getDemarcheDossiers = async (client, idDemarche) => { | ||
try { | ||
return await client.request(getDemarcheDossiers_1.default, { demarcheNumber: idDemarche }, { "Content-Type": "application/json" }); | ||
} | ||
catch (error) { | ||
console.error(JSON.stringify(error, undefined, 2)); | ||
} | ||
}; | ||
exports.getDemarcheDossiers = getDemarcheDossiers; | ||
const getDemarcheDeletedDossiers = async (client, idDemarche) => { | ||
try { | ||
return await client.request(getDemarcheDeletedDossiers_1.default, { demarcheNumber: idDemarche }, { "Content-Type": "application/json" }); | ||
} | ||
catch (error) { | ||
console.error(JSON.stringify(error, undefined, 2)); | ||
} | ||
}; | ||
exports.getDemarcheDeletedDossiers = getDemarcheDeletedDossiers; | ||
//# sourceMappingURL=demarche.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const graphql_request_1 = require("graphql-request"); | ||
const DossierFragment_1 = require("./fragment/DossierFragment"); | ||
const RevisionFragment_1 = require("./fragment/RevisionFragment"); | ||
const ChampDescriptorFragment_1 = require("./fragment/ChampDescriptorFragment"); | ||
exports.default = (0, graphql_request_1.gql) ` | ||
query getDemarche( | ||
$demarcheNumber: Int! | ||
$state: DossierState | ||
$order: Order | ||
$after: String | ||
) { | ||
query getDemarche($demarcheNumber: Int!) { | ||
demarche(number: $demarcheNumber) { | ||
@@ -16,5 +12,22 @@ id | ||
title | ||
description | ||
state | ||
dateCreation | ||
dateDepublication | ||
dateDerniereModification | ||
dateFermeture | ||
datePublication | ||
declarative | ||
draftRevision { | ||
...RevisionFragment | ||
} | ||
publishedRevision { | ||
...RevisionFragment | ||
} | ||
revisions { | ||
...RevisionFragment | ||
} | ||
groupeInstructeurs { | ||
@@ -29,11 +42,15 @@ id | ||
} | ||
dossiers(state: $state, order: $order, after: $after) { | ||
nodes { | ||
...DossierFragment | ||
} | ||
service { | ||
id | ||
nom | ||
organisme | ||
siret | ||
typeOrganisme | ||
} | ||
} | ||
} | ||
${DossierFragment_1.default} | ||
${RevisionFragment_1.default} | ||
${ChampDescriptorFragment_1.default} | ||
`; | ||
//# sourceMappingURL=getDemarche.js.map |
@@ -8,2 +8,8 @@ import { GraphQLClient } from "graphql-request"; | ||
}>; | ||
demarcheDossiers(idDemarche: number): Promise<{ | ||
demarche: Partial<import("./@types/types").Demarche>; | ||
}>; | ||
demarcheDeletedDossiers(idDemarche: number): Promise<{ | ||
demarche: Partial<import("./@types/types").Demarche>; | ||
}>; | ||
dossier(idDossier: number): Promise<{ | ||
@@ -10,0 +16,0 @@ dossier: Partial<import("./@types/types").Dossier>; |
@@ -6,2 +6,4 @@ "use strict"; | ||
const demarche_1 = require("./demarche"); | ||
const demarche_2 = require("./demarche"); | ||
const demarche_3 = require("./demarche"); | ||
const dossier_1 = require("./dossier"); | ||
@@ -22,2 +24,8 @@ const groupeInstructeur_1 = require("./groupeInstructeur"); | ||
} | ||
async demarcheDossiers(idDemarche) { | ||
return await (0, demarche_2.getDemarcheDossiers)(this.client, idDemarche); | ||
} | ||
async demarcheDeletedDossiers(idDemarche) { | ||
return await (0, demarche_3.getDemarcheDeletedDossiers)(this.client, idDemarche); | ||
} | ||
async dossier(idDossier) { | ||
@@ -24,0 +32,0 @@ return await (0, dossier_1.getDossier)(this.client, idDossier); |
{ | ||
"name": "@lab-mi/ds-api-client", | ||
"version": "1.0.2", | ||
"version": "1.1.1", | ||
"description": "Un DS Client GraphQL prenant en charge Node et les navigateurs pour les scripts ou les applications simples", | ||
@@ -10,2 +10,6 @@ "author": "LAB-MI", | ||
"license": "UNLICENSED", | ||
"engines": { | ||
"node": ">=16.0.0", | ||
"npm": ">=7.10.0" | ||
}, | ||
"scripts": { | ||
@@ -12,0 +16,0 @@ "prebuild": "rimraf dist", |
@@ -41,12 +41,12 @@ # ds-api-client | ||
// ... Rechercher les dossiers d'une demarche par id de demarche | ||
const demarcheDossiers = await client.demarche(idDemarche).dossiers.then((data) => console.log(data)) | ||
const demarcheDossiers = await client.demarcheDossiers(idDemarche).then((data) => console.log(data)) | ||
// ... Rechercher les dossiers supprimés d'une demarche par id de demarche | ||
const demarcheDeletedDossiers = await client.demarcheDeletedDossiers(idDemarche).then((data) => console.log(data)) | ||
// ... Rechercher un dossier par id de dossier | ||
const dossier = await client.dossier(idDossier).then((data) => console.log(data)) | ||
// ... Rechercher les dossiers par une liste d'id de dossier | ||
const dossiers = await client.dossier(idsDossier).then((data) => console.log(data)) | ||
// ... Rechercher les groupeInstructeur par une id | ||
const groupeInstructeur = await client.groupeInstructeur(idGroupeInstructeur).then((data) => console.log(data)) | ||
``` |
@@ -8,2 +8,12 @@ import { dsApiClient } from "./__helpers"; | ||
}); | ||
it("Has to retrieve demarche number 1", async () => { | ||
const response = await dsApiClient.demarcheDossiers(1); | ||
expect(response?.demarche?.number).toBe(1); | ||
}); | ||
it("Has to retrieve demarche number 1", async () => { | ||
const response = await dsApiClient.demarcheDeletedDossiers(1); | ||
expect(response?.demarche?.number).toBe(1); | ||
}); | ||
}); |
import { GraphQLClient } from "graphql-request"; | ||
import { Demarche } from "./@types/types"; | ||
import query from "./graphql/getDemarche"; | ||
import queryDemarche from "./graphql/getDemarche"; | ||
import queryDemarcheDossiers from "./graphql/getDemarcheDossiers"; | ||
import queryDemarcheDeletedDossiers from "./graphql/getDemarcheDeletedDossiers"; | ||
@@ -12,3 +14,3 @@ export const getDemarche = async ( | ||
return await client.request<{ demarche: Partial<Demarche> }>( | ||
query, | ||
queryDemarche, | ||
{ demarcheNumber: idDemarche }, | ||
@@ -21,1 +23,31 @@ { "Content-Type": "application/json" }, | ||
}; | ||
export const getDemarcheDossiers = async ( | ||
client: GraphQLClient, | ||
idDemarche: number, | ||
) => { | ||
try { | ||
return await client.request<{ demarche: Partial<Demarche> }>( | ||
queryDemarcheDossiers, | ||
{ demarcheNumber: idDemarche }, | ||
{ "Content-Type": "application/json" }, | ||
); | ||
} catch (error) { | ||
console.error(JSON.stringify(error, undefined, 2)); | ||
} | ||
}; | ||
export const getDemarcheDeletedDossiers = async ( | ||
client: GraphQLClient, | ||
idDemarche: number, | ||
) => { | ||
try { | ||
return await client.request<{ demarche: Partial<Demarche> }>( | ||
queryDemarcheDeletedDossiers, | ||
{ demarcheNumber: idDemarche }, | ||
{ "Content-Type": "application/json" }, | ||
); | ||
} catch (error) { | ||
console.error(JSON.stringify(error, undefined, 2)); | ||
} | ||
}; |
import { gql } from "graphql-request"; | ||
import DossierFragment from "./fragment/DossierFragment"; | ||
import RevisionFragment from "./fragment/RevisionFragment"; | ||
import ChampDescriptorFragment from "./fragment/ChampDescriptorFragment"; | ||
export default gql` | ||
query getDemarche( | ||
$demarcheNumber: Int! | ||
$state: DossierState | ||
$order: Order | ||
$after: String | ||
) { | ||
query getDemarche($demarcheNumber: Int!) { | ||
demarche(number: $demarcheNumber) { | ||
@@ -16,5 +12,22 @@ id | ||
title | ||
description | ||
state | ||
dateCreation | ||
dateDepublication | ||
dateDerniereModification | ||
dateFermeture | ||
datePublication | ||
declarative | ||
draftRevision { | ||
...RevisionFragment | ||
} | ||
publishedRevision { | ||
...RevisionFragment | ||
} | ||
revisions { | ||
...RevisionFragment | ||
} | ||
groupeInstructeurs { | ||
@@ -29,10 +42,14 @@ id | ||
} | ||
dossiers(state: $state, order: $order, after: $after) { | ||
nodes { | ||
...DossierFragment | ||
} | ||
service { | ||
id | ||
nom | ||
organisme | ||
siret | ||
typeOrganisme | ||
} | ||
} | ||
} | ||
${DossierFragment} | ||
${RevisionFragment} | ||
${ChampDescriptorFragment} | ||
`; |
import { GraphQLClient } from "graphql-request"; | ||
import { getDemarche } from "./demarche"; | ||
import { getDemarcheDossiers } from "./demarche"; | ||
import { getDemarcheDeletedDossiers } from "./demarche"; | ||
import { getDossier } from "./dossier"; | ||
@@ -22,2 +24,10 @@ import { getGroupInstructeur } from "./groupeInstructeur"; | ||
async demarcheDossiers(idDemarche: number) { | ||
return await getDemarcheDossiers(this.client, idDemarche); | ||
} | ||
async demarcheDeletedDossiers(idDemarche: number) { | ||
return await getDemarcheDeletedDossiers(this.client, idDemarche); | ||
} | ||
async dossier(idDossier: number) { | ||
@@ -24,0 +34,0 @@ return await getDossier(this.client, idDossier); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
151920
114
3271
1