@silexpert/core 2.0.124 → 2.0.125

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.
@@ -1,4 +1,4 @@
1
- import"../rolldown-runtime-BhWHdk3m.mjs";import{C as e,H as t,L as n,S as r,Z as i,a,c as o,ft as s,gt as c,l,m as u,o as d,q as f,r as p,u as m,vt as h}from"../product-dgz1Fsg6.mjs";import{groupBy as g,orderBy as _,round as v,sumBy as y,uniq as b}from"lodash-es";import{isDefined as x}from"class-validator";import S from"dayjs";import C from"ejs";import"dayjs/locale/fr.js";import w from"sanitize-html";function getRoleSignature(e){if(e.positionLabel)return e.positionLabel;let t=e.roles.map(e=>e.id).includes(44)||e.roles.map(e=>e.id).includes(45),n=e.roles.map(e=>e.id).includes(19),r=e.roles.map(e=>e.id).includes(11),i=e.roles.map(e=>e.id).includes(12),a=e.roles.map(e=>e.id).includes(34),o=e.roles.map(e=>e.id).includes(20),s=e.roles.map(e=>e.id).includes(10),c=e.roles.map(e=>e.id).includes(50),l=e.roles.map(e=>e.id).includes(41),d=e.roles.map(e=>e.id).includes(51),f=e.roles.map(e=>e.id).includes(9),p=e.roles.map(e=>e.id).includes(2),m=e.roles.map(e=>e.id).includes(55),h=!!u(e.roles.map(e=>e.id),[3,15]).length;return f&&n?`Responsable commercial`:f?`Chargé${e.idCivility===2?`e`:``} de clientèle`:s&&n?`Responsable relations clients`:s?`Conseill${e.idCivility===2?`ère`:`er`} comptable`:m?`Référent${e.idCivility===2?`e`:``} technique`:c&&n?`Responsable chargé${e.idCivility===2?`e`:``} accueil clients`:c?`Chargé${e.idCivility===2?`e`:``} accueil clients`:l&&n?`Responsable chargé${e.idCivility===2?`e`:``} de la satisfaction clients`:l?`Chargé${e.idCivility===2?`e`:``} de la satisfaction clients`:d&&n?`Responsable aide comptable`:d?`Aide comptable`:a&&t?`Assistant facturation`:a&&n?`Responsable facturation`:a?`Chargé${e.idCivility===2?`e`:``} de facturation`:i&&t?`Assistant juridique`:i&&n?`Responsable juridique`:i?`Juriste`:r&&t?`Assistant paie`:r&&n?`Responsable paie`:r?`Gestionnaire de paie`:o?`Expert${e.idCivility===2?`e`:``}-comptable`:p?`Développeur web`:h&&n?`Responsable comptable`:h&&t?`Assistant comptable`:`Comptable`}function getHoraires(e){return e?.roles?.map(e=>e.id).includes(9)?`Du lundi au vendredi de 9h à 18h`:`Du lundi au jeudi de 9h à 17h<br/>Le vendredi de 9h à 12h`}function getMailSignature(e,t){let n=h({...t?{idTypeBrand:t}:{},objectWaited:`listMails.informatique`}),r=h({...t?{idTypeBrand:t}:{},objectWaited:`listMails.bonjour`});return e.roles.map(e=>e.id).includes(2)?n:e&&u(e.roles.map(e=>e.id),[3,15,51,9,55]).length?e.email:r}function getPhoneSignature(e){return e.phone&&e.phone!==`0383931414`?e.phone.replace(/\B(?=(\d{2})+(?!\d))/g,`&nbsp;`):null}function generateSignature(e){let{fromAddress:t=null,idTypeBrand:n=1,calendlyUrl:r=null,...i}=e,{user:a,forceRole:o=null}=i,s=c({idTypeBrand:n}),l=s.urlS3,d=s.name,f=s.companyInformation?.city,p=s.companyInformation?.postalAddress||``,m=s.commercialName,h=s.bank?.IBAN,g=s.bank?.BIC,_=s.listMails?.bonjour||``,v=s.listMails?.social||``,y=s.listMails?.gestion||``,b=s.listMails?.satisfaction||``,x=s.listMails?.resiliation||``,S=s.listMails?.support||``,w=s.listMails?.juridique||``,T=s.listMails?.facturation||``,E=s.colors?.primary||``,D=s.listPhones?.contact||``,O=s.listPhones?.juridique||``,k=s.listPhones?.social||``,A=[{email:b,forceRole:`satisfaction`},{email:x,forceRole:`resiliation`},{email:T,forceRole:`facturation`}].find(e=>e.email===t);A&&(o=A.forceRole);let j,M,N,P;return[j,M,N,P]=[`Expert-Comptable`,_,null,`Du lundi au vendredi de 9h à 18h`],a?.roles&&a.roles.some(e=>e.id===51)?(a={firstname:`L'équipe ${m}`,isAll:!0},M=y,j=``):u((a?.roles??[]).map(e=>e.id),[3,54]).length===2?(a={firstname:`L'équipe ${m}`,isAll:!0},M=_,j=``):o===`satisfaction`?(a={firstname:`Service satisfaction clients`,isAll:!0},M=b,j=``,N=D):o===`resiliation`?(a={firstname:`Service satisfaction clients`,isAll:!0},M=x,j=``,N=D):o===`social`?(a={firstname:`Service social`,isAll:!0},M=v,j=``,N=k):o===`support`?(a={firstname:`Service Support`,isAll:!0},M=S,j=null):o===`juridique`?(a={firstname:`Service juridique`,isAll:!0},M=w,j=null,N=O):o===`facturation`?(a={firstname:`Service facturation`,isAll:!0},M=T,j=null,N=D):!a||o===`generique`?(a={firstname:`L'équipe ${m}`,isAll:!0},j=``):a!==0&&(j=getRoleSignature(a),M=getMailSignature(a,n),P=getHoraires(a),N=getPhoneSignature(a)),r&&(a.calendlyUrl=r),C.render(`<% if (commercialName === 'Clementine' && isFacturation) { %>
1
+ import"../rolldown-runtime-BhWHdk3m.mjs";import{C as e,H as t,L as n,S as r,Z as i,a,c as o,ft as s,gt as c,l,m as u,o as d,q as f,r as p,u as m,vt as h}from"../product-q6BjuQqT.mjs";import{groupBy as g,orderBy as _,round as v,sumBy as y,uniq as b}from"lodash-es";import{isDefined as x}from"class-validator";import S from"dayjs";import C from"ejs";import"dayjs/locale/fr.js";import w from"sanitize-html";function getRoleSignature(e){if(e.positionLabel)return e.positionLabel;let t=e.roles.map(e=>e.id).includes(44)||e.roles.map(e=>e.id).includes(45),n=e.roles.map(e=>e.id).includes(19),r=e.roles.map(e=>e.id).includes(11),i=e.roles.map(e=>e.id).includes(12),a=e.roles.map(e=>e.id).includes(34),o=e.roles.map(e=>e.id).includes(20),s=e.roles.map(e=>e.id).includes(10),c=e.roles.map(e=>e.id).includes(50),l=e.roles.map(e=>e.id).includes(41),d=e.roles.map(e=>e.id).includes(51),f=e.roles.map(e=>e.id).includes(9),p=e.roles.map(e=>e.id).includes(2),m=e.roles.map(e=>e.id).includes(55),h=!!u(e.roles.map(e=>e.id),[3,15]).length;return f&&n?`Responsable commercial`:f?`Chargé${e.idCivility===2?`e`:``} de clientèle`:s&&n?`Responsable relations clients`:s?`Conseill${e.idCivility===2?`ère`:`er`} comptable`:m?`Référent${e.idCivility===2?`e`:``} technique`:c&&n?`Responsable chargé${e.idCivility===2?`e`:``} accueil clients`:c?`Chargé${e.idCivility===2?`e`:``} accueil clients`:l&&n?`Responsable chargé${e.idCivility===2?`e`:``} de la satisfaction clients`:l?`Chargé${e.idCivility===2?`e`:``} de la satisfaction clients`:d&&n?`Responsable aide comptable`:d?`Aide comptable`:a&&t?`Assistant facturation`:a&&n?`Responsable facturation`:a?`Chargé${e.idCivility===2?`e`:``} de facturation`:i&&t?`Assistant juridique`:i&&n?`Responsable juridique`:i?`Juriste`:r&&t?`Assistant paie`:r&&n?`Responsable paie`:r?`Gestionnaire de paie`:o?`Expert${e.idCivility===2?`e`:``}-comptable`:p?`Développeur web`:h&&n?`Responsable comptable`:h&&t?`Assistant comptable`:`Comptable`}function getHoraires(e){return e?.roles?.map(e=>e.id).includes(9)?`Du lundi au vendredi de 9h à 18h`:`Du lundi au jeudi de 9h à 17h<br/>Le vendredi de 9h à 12h`}function getMailSignature(e,t){let n=h({...t?{idTypeBrand:t}:{},objectWaited:`listMails.informatique`}),r=h({...t?{idTypeBrand:t}:{},objectWaited:`listMails.bonjour`});return e.roles.map(e=>e.id).includes(2)?n:e&&u(e.roles.map(e=>e.id),[3,15,51,9,55]).length?e.email:r}function getPhoneSignature(e){return e.phone&&e.phone!==`0383931414`?e.phone.replace(/\B(?=(\d{2})+(?!\d))/g,`&nbsp;`):null}function generateSignature(e){let{fromAddress:t=null,idTypeBrand:n=1,calendlyUrl:r=null,...i}=e,{user:a,forceRole:o=null}=i,s=c({idTypeBrand:n}),l=s.urlS3,d=s.name,f=s.companyInformation?.city,p=s.companyInformation?.postalAddress||``,m=s.commercialName,h=s.bank?.IBAN,g=s.bank?.BIC,_=s.listMails?.bonjour||``,v=s.listMails?.social||``,y=s.listMails?.gestion||``,b=s.listMails?.satisfaction||``,x=s.listMails?.resiliation||``,S=s.listMails?.support||``,w=s.listMails?.juridique||``,T=s.listMails?.facturation||``,E=s.colors?.primary||``,D=s.listPhones?.contact||``,O=s.listPhones?.juridique||``,k=s.listPhones?.social||``,A=[{email:b,forceRole:`satisfaction`},{email:x,forceRole:`resiliation`},{email:T,forceRole:`facturation`}].find(e=>e.email===t);A&&(o=A.forceRole);let j,M,N,P;return[j,M,N,P]=[`Expert-Comptable`,_,null,`Du lundi au vendredi de 9h à 18h`],a?.roles&&a.roles.some(e=>e.id===51)?(a={firstname:`L'équipe ${m}`,isAll:!0},M=y,j=``):u((a?.roles??[]).map(e=>e.id),[3,54]).length===2?(a={firstname:`L'équipe ${m}`,isAll:!0},M=_,j=``):o===`satisfaction`?(a={firstname:`Service satisfaction clients`,isAll:!0},M=b,j=``,N=D):o===`resiliation`?(a={firstname:`Service satisfaction clients`,isAll:!0},M=x,j=``,N=D):o===`social`?(a={firstname:`Service social`,isAll:!0},M=v,j=``,N=k):o===`support`?(a={firstname:`Service Support`,isAll:!0},M=S,j=null):o===`juridique`?(a={firstname:`Service juridique`,isAll:!0},M=w,j=null,N=O):o===`facturation`?(a={firstname:`Service facturation`,isAll:!0},M=T,j=null,N=D):!a||o===`generique`?(a={firstname:`L'équipe ${m}`,isAll:!0},j=``):a!==0&&(j=getRoleSignature(a),M=getMailSignature(a,n),P=getHoraires(a),N=getPhoneSignature(a)),r&&(a.calendlyUrl=r),C.render(`<% if (commercialName === 'Clementine' && isFacturation) { %>
2
2
  <p style="font-size: 15px; font-family: Arial; margin:0; padding:0px 0 4px; color:#6E6E71; margin-bottom: 10px; font-weight: bold;">
3
3
  <span style="color: #A0A0A0">Nos coordonnées bancaires </span>IBAN : <%= iban %> - BIC : <%= bic %>
4
4
  </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexpert/core",
3
- "version": "2.0.124",
3
+ "version": "2.0.125",
4
4
  "description": "Silex Core perform HTTP Request and object binding. Silex core helps developers to retrieve and return formatted object",
5
5
  "keywords": [
6
6
  "accounting",
@@ -197,9 +197,21 @@ type GetBrandParam = {
197
197
  nodeEnv?: string;
198
198
  };
199
199
 
200
- const getBrandNameByNodeEnv = (nodeEnv?: string): BrandList => {
200
+ const LOCAL_DEVELOPMENT_ENV = 'dev';
201
+
202
+ /**
203
+ * Environment string the brand is derived from. In local development (`NODE_ENV=dev`) the optional
204
+ * `LOCAL_BRAND` variable (e.g. `teamsystemfacture`) lets the API impersonate a brand without changing `NODE_ENV`.
205
+ */
206
+ const resolveBrandEnv = (nodeEnv?: string): string | undefined => {
201
207
  const env = nodeEnv ?? process.env.NODE_ENV ?? process.env.API_HOST;
202
- if (env && env !== 'dev') {
208
+ const localBrand = process.env.LOCAL_BRAND?.trim().toLowerCase();
209
+ return env === LOCAL_DEVELOPMENT_ENV && localBrand ? localBrand : env;
210
+ };
211
+
212
+ const getBrandNameByNodeEnv = (nodeEnv?: string): BrandList => {
213
+ const env = resolveBrandEnv(nodeEnv);
214
+ if (env && env !== LOCAL_DEVELOPMENT_ENV) {
203
215
  if (
204
216
  env.indexOf('legalstart') > -1 ||
205
217
  env.indexOf('Legalstart') > -1 ||
@@ -3,6 +3,7 @@ import { getBrand, getBrandNameByNodeEnv, isItThisEnv } from '../brands.js';
3
3
 
4
4
  afterEach(() => {
5
5
  vi.restoreAllMocks();
6
+ vi.unstubAllEnvs();
6
7
  });
7
8
 
8
9
  describe('brands utils', () => {
@@ -28,4 +29,38 @@ describe('brands utils', () => {
28
29
  expect(brand.name).toBe('LegalStart');
29
30
  expect(brand.idTypeBrand).toBe(1);
30
31
  });
32
+
33
+ describe('LOCAL_BRAND override', () => {
34
+ test('should impersonate the brand in local development', () => {
35
+ vi.stubEnv('NODE_ENV', 'dev');
36
+ vi.stubEnv('LOCAL_BRAND', 'teamsystemfacture');
37
+
38
+ expect(getBrandNameByNodeEnv()).toBe('TeamsystemFacture');
39
+ expect(getBrandNameByNodeEnv('dev')).toBe('TeamsystemFacture');
40
+ expect(getBrand().name).toBe('Teamsystem Facture');
41
+ expect(isItThisEnv('TeamsystemFacture', 'dev')).toBe(true);
42
+ });
43
+
44
+ test('should accept the brand name in any case', () => {
45
+ vi.stubEnv('NODE_ENV', 'dev');
46
+ vi.stubEnv('LOCAL_BRAND', ' Comptalib ');
47
+
48
+ expect(getBrandNameByNodeEnv()).toBe('Comptalib');
49
+ });
50
+
51
+ test('should ignore the override outside local development', () => {
52
+ vi.stubEnv('NODE_ENV', 'staging');
53
+ vi.stubEnv('LOCAL_BRAND', 'teamsystemfacture');
54
+
55
+ expect(getBrandNameByNodeEnv()).toBe('Clementine');
56
+ expect(getBrandNameByNodeEnv('production_comptalib')).toBe('Comptalib');
57
+ });
58
+
59
+ test('should keep the Clementine default in dev without override', () => {
60
+ vi.stubEnv('NODE_ENV', 'dev');
61
+ vi.stubEnv('LOCAL_BRAND', '');
62
+
63
+ expect(getBrandNameByNodeEnv()).toBe('Clementine');
64
+ });
65
+ });
31
66
  });