@silexpert/core 0.4.83 → 0.4.85

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 (57) hide show
  1. package/es/api/resources/Society.d.ts +2 -1
  2. package/es/api/resources/Society.d.ts.map +1 -1
  3. package/es/api/resources/Society.js +3 -0
  4. package/es/api/resources/Society.js.map +1 -1
  5. package/es/types/Enum/BrandClementine.d.ts +48 -0
  6. package/es/types/Enum/BrandClementine.d.ts.map +1 -0
  7. package/es/types/Enum/BrandClementine.js +62 -0
  8. package/es/types/Enum/BrandClementine.js.map +1 -0
  9. package/es/types/Enum/BrandComptalib.d.ts +23 -0
  10. package/es/types/Enum/BrandComptalib.d.ts.map +1 -0
  11. package/es/types/Enum/BrandComptalib.js +47 -0
  12. package/es/types/Enum/BrandComptalib.js.map +1 -0
  13. package/es/types/Enum/BrandLegalstart.d.ts +23 -0
  14. package/es/types/Enum/BrandLegalstart.d.ts.map +1 -0
  15. package/es/types/Enum/BrandLegalstart.js +25 -0
  16. package/es/types/Enum/BrandLegalstart.js.map +1 -0
  17. package/es/types/Interface/api/society/QuerySociety.d.ts +5 -0
  18. package/es/types/Interface/api/society/QuerySociety.d.ts.map +1 -0
  19. package/es/types/Interface/api/society/QuerySociety.js +21 -0
  20. package/es/types/Interface/api/society/QuerySociety.js.map +1 -0
  21. package/es/types/index.d.ts +4 -0
  22. package/es/types/index.d.ts.map +1 -1
  23. package/es/types/index.js +4 -0
  24. package/es/types/index.js.map +1 -1
  25. package/es/utils/brands.d.ts +12 -0
  26. package/es/utils/brands.d.ts.map +1 -0
  27. package/es/utils/brands.js +54 -0
  28. package/es/utils/brands.js.map +1 -0
  29. package/es/utils/index.d.ts +1 -0
  30. package/es/utils/index.d.ts.map +1 -1
  31. package/es/utils/index.js +1 -0
  32. package/es/utils/index.js.map +1 -1
  33. package/js/api/resources/Society.js +6 -0
  34. package/js/api/resources/Society.js.map +1 -1
  35. package/js/types/Enum/BrandClementine.js +61 -0
  36. package/js/types/Enum/BrandClementine.js.map +1 -0
  37. package/js/types/Enum/BrandComptalib.js +49 -0
  38. package/js/types/Enum/BrandComptalib.js.map +1 -0
  39. package/js/types/Enum/BrandLegalstart.js +28 -0
  40. package/js/types/Enum/BrandLegalstart.js.map +1 -0
  41. package/js/types/Interface/api/society/QuerySociety.js +29 -0
  42. package/js/types/Interface/api/society/QuerySociety.js.map +1 -0
  43. package/js/types/index.js +48 -0
  44. package/js/types/index.js.map +1 -1
  45. package/js/utils/brands.js +82 -0
  46. package/js/utils/brands.js.map +1 -0
  47. package/js/utils/index.js +12 -0
  48. package/js/utils/index.js.map +1 -1
  49. package/package.json +1 -1
  50. package/ts/api/resources/Society.ts +5 -0
  51. package/ts/types/Enum/BrandClementine.ts +61 -0
  52. package/ts/types/Enum/BrandComptalib.ts +46 -0
  53. package/ts/types/Enum/BrandLegalstart.ts +24 -0
  54. package/ts/types/Interface/api/society/QuerySociety.ts +9 -0
  55. package/ts/types/index.ts +4 -0
  56. package/ts/utils/brands.ts +71 -0
  57. package/ts/utils/index.ts +1 -0
package/ts/types/index.ts CHANGED
@@ -350,6 +350,9 @@ export * from './Enum/Notification';
350
350
  export * from './Enum/Comment';
351
351
  export * from './Enum/Channel';
352
352
  export * from './Enum/ExerciceNoteType';
353
+ export * from './Enum/BrandClementine';
354
+ export * from './Enum/BrandLegalstart';
355
+ export * from './Enum/BrandComptalib';
353
356
 
354
357
  // Interfaces API
355
358
  export * from './Interface/api/businessPartner/ReadBusinessPartner';
@@ -382,6 +385,7 @@ export * from './Interface/api/file/TFile';
382
385
  export * from './Interface/api/cerfa/CreateCerfa';
383
386
  export * from './Interface/api/customerProviderOperation/CreateCustomerProviderOperation';
384
387
  export * from './Interface/api/society/LegalFormSiren';
388
+ export * from './Interface/api/society/QuerySociety';
385
389
  export * from './Interface/api/society/GetDataSociety';
386
390
  export * from './Interface/api/society/CreateSociety';
387
391
  export * from './Interface/api/society/UpdateSociety';
@@ -0,0 +1,71 @@
1
+ import { get as getLodash } from 'lodash';
2
+ import { BrandClementine } from '../types/Enum/BrandClementine';
3
+ import { BrandLegalstart } from '../types/Enum/BrandLegalstart';
4
+ import { BrandComptalib } from '../types/Enum/BrandComptalib';
5
+
6
+ type brand = {
7
+ idTypeBrand: number,
8
+ name: string
9
+ };
10
+
11
+ type getBrandConfigParams = {
12
+ idTypeBrand?: number,
13
+ objectWaited?: string,
14
+ };
15
+
16
+ const getBrandNameByNodeEnv = (): 'Legalstart'| 'Comptalib' | 'Clementine' => {
17
+ if (process.env.NODE_ENV) {
18
+ if (['staging_legalstart', 'production_legalstart'].includes(process.env.NODE_ENV)) {
19
+ return 'Legalstart';
20
+ }
21
+ if (['staging_comptalib', 'production_comptalib'].includes(process.env.NODE_ENV)) {
22
+ return 'Comptalib';
23
+ }
24
+ } else if (process.env.API_HOST) {
25
+ if (process.env.API_HOST.indexOf('legalstart') > -1) {
26
+ return 'Legalstart';
27
+ }
28
+ if (process.env.API_HOST.indexOf('comptalib') > -1) {
29
+ return 'Comptalib';
30
+ }
31
+ }
32
+ return 'Clementine';
33
+ };
34
+
35
+ const getBrandConfig = (params: getBrandConfigParams): brand => {
36
+ const {
37
+ idTypeBrand = null, objectWaited = null,
38
+ } = params;
39
+ let brand;
40
+ const currentEnvName = getBrandNameByNodeEnv();
41
+ const listEnvEnum = { BrandClementine, BrandLegalstart, BrandComptalib };
42
+ // @ts-ignore
43
+ const currentConfigFile:brand[] = listEnvEnum[`Brand${currentEnvName}`];
44
+
45
+ if (idTypeBrand) {
46
+ // Récupération de la brand via idTypeBrand
47
+ brand = currentConfigFile.find((b: brand) => b.idTypeBrand === idTypeBrand);
48
+ }
49
+ // else if (idSociety) {
50
+ // Récupération de la brand via l'idSociety -> impossible directement depuis le core (pas d'accès au resources, ni au token pour l'appel via fetch)
51
+
52
+ if (!brand) {
53
+ // Si aucune brand trouvée, on passe par défaut la première brand de la liste
54
+ [brand] = currentConfigFile.sort((a: brand, b: brand) => a.idTypeBrand - b.idTypeBrand);
55
+ }
56
+
57
+ if (objectWaited) {
58
+ // Si on attend un attribut particulier de la brand, on le parcourt
59
+ let objectToReturn = getLodash(brand, objectWaited);
60
+ // Si aucun attribut trouvé, on renvoit celui de Clementine par défaut
61
+ if (!objectToReturn) {
62
+ const brandDefault = currentConfigFile.find((b: brand) => b.name === currentEnvName);
63
+ objectToReturn = getLodash(brandDefault, objectWaited);
64
+ }
65
+ return objectToReturn;
66
+ }
67
+
68
+ return brand;
69
+ };
70
+
71
+ export { getBrandConfig, getBrandNameByNodeEnv };
package/ts/utils/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './objectUtils';
2
2
  export * from './stringUtils';
3
+ export * from './brands';
3
4
  export * from './decorators';