@silexpert/core 0.4.241 → 0.4.243

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 +1 @@
1
- {"version":3,"file":"date.js","mappings":";;;;;QAWsBA,kB,GAAAA,kB;;AANtB;;IAAYC,K;;AACZ;;IAAYC,S;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AANZ;;;;;;;AASAD,KAAK,CAACE,MAAN,CAAaD,SAAb;;AAEM,SAAgBF,kBAAhB,CAAmCI,aAAnC,EAAuEC,SAAvE,EAAqG;;IACzG,MAAMC,GAAG,qBAAQF,aAAR,CAAT;;IACA,IAAIC,SAAS,CAACE,KAAV,CAAgBC,MAAhB,GAAyB,CAA7B,EAAgC;MAC9B,MAAMC,kBAAkB,GAAGR,KAAK,CAACG,aAAa,CAACM,SAAf,CAAL,CAA+BC,MAA/B,EAA3B;MACA,MAAMC,gBAAgB,GAAGX,KAAK,CAACG,aAAa,CAACS,OAAf,CAAL,CAA6BF,MAA7B,EAAzB;MACA,MAAMG,eAAe,GAAGT,SAAS,CAACE,KAAlC,CAH8B,CAK9B;;MACA,MAAMQ,iBAAiB,GAAGD,eAAe,CAACE,MAAhB,CAAwBC,EAAD,IAASA,EAAE,CAACC,OAAH,IAAcjB,KAAK,CAACQ,kBAAD,CAAL,CAA0BU,IAA1B,CAA+BlB,KAAK,CAACgB,EAAE,CAACC,OAAJ,CAApC,KAAqD,CAApE,IAA2ED,EAAE,CAACG,SAAH,IAAgBnB,KAAK,CAACW,gBAAD,CAAL,CAAwBO,IAAxB,CAA6BlB,KAAK,CAACgB,EAAE,CAACG,SAAJ,CAAlC,KAAqD,CAA/K,CAA1B;;MAEA,IAAI,kBAAiB,SAAjB,qBAAiB,WAAjB,GAAiB,MAAjB,oBAAiB,CAAEZ,MAAnB,IAA4B,CAA5B,IAAiCO,iBAAiB,CAAC,CAAD,CAAjB,CAAqBK,SAAtD,IAAmEL,iBAAiB,CAAC,CAAD,CAAjB,CAAqBG,OAA5F,EAAqG;QACnG,MAAMR,SAAS,GAAGT,KAAK,CAACc,iBAAiB,CAAC,CAAD,CAAjB,CAAqBK,SAAtB,EAAiC,qBAAjC,CAAL,CAA6DT,MAA7D,EAAlB;QACA,MAAME,OAAO,GAAGZ,KAAK,CAACc,iBAAiB,CAAC,CAAD,CAAjB,CAAqBG,OAAtB,EAA+B,qBAA/B,CAAL,CAA2DP,MAA3D,EAAhB,CAFmG,CAInG;;QACAL,GAAG,CAACI,SAAJ,GAAgB,CAAET,KAAK,CAACQ,kBAAD,CAAL,CAA0BP,SAA1B,CAAoCQ,SAApC,EAA+CG,OAA/C,EAAwD,SAAxD,EAAmE,IAAnE,CAAF,GAA8EH,SAA9E,GAA0FD,kBAA1G;QACAH,GAAG,CAACO,OAAJ,GAAc,CAAEZ,KAAK,CAACW,gBAAD,CAAL,CAAwBV,SAAxB,CAAkCQ,SAAlC,EAA6CG,OAA7C,EAAsD,SAAtD,EAAiE,IAAjE,CAAF,GAA4EA,OAA5E,GAAsFD,gBAApG;MACD;IACF;;IACD,OAAON,GAAP;EACD;AAAA","names":["checkRealHoursUser","dayjs","isBetween","extend","customPayload","realHours","res","datas","length","dateToCompareStart","dateStart","toDate","dateToCompareEnd","dateEnd","realHoursObject","realHoursOfPeriod","filter","sh","endTime","diff","startTime"],"sourceRoot":"","sources":["../../ts/utils/date.ts"],"sourcesContent":["/**\n * @param dateStart (format YYYY-MM-DD)\n * @param dateEnd (format YYYY-MM-DD)\n * @returns object of date (09:00-10:00, 12:00-13:00 et 14:00-17:00)\n */\nimport * as dayjs from 'dayjs';\nimport * as isBetween from 'dayjs/plugin/isBetween';\nimport { ReadAttendanceHours, UpdateCalendarEvent } from '../types';\n\ndayjs.extend(isBetween);\n\nexport async function checkRealHoursUser(customPayload: UpdateCalendarEvent, realHours: ReadAttendanceHours):Promise<UpdateCalendarEvent> {\n const res = { ...customPayload };\n if (realHours.datas.length > 0) {\n const dateToCompareStart = dayjs(customPayload.dateStart).toDate();\n const dateToCompareEnd = dayjs(customPayload.dateEnd).toDate();\n const realHoursObject = realHours.datas;\n\n // on cherche la bonne specialhour pour comparer les horaires\n const realHoursOfPeriod = realHoursObject.filter((sh) => (sh.endTime && dayjs(dateToCompareStart).diff(dayjs(sh.endTime)) <= 0) && (sh.startTime && dayjs(dateToCompareEnd).diff(dayjs(sh.startTime)) >= 0));\n\n if (realHoursOfPeriod?.length > 0 && realHoursOfPeriod[0].startTime && realHoursOfPeriod[0].endTime) {\n const dateStart = dayjs(realHoursOfPeriod[0].startTime, 'YYYY-MM-DD HH:mm:ss').toDate();\n const dateEnd = dayjs(realHoursOfPeriod[0].endTime, 'YYYY-MM-DD HH:mm:ss').toDate();\n\n // on check si les horaires de l'event sont dans les horaires du collab sinon on les fait commencer à l'heure à laquelle il s'est connecté\n res.dateStart = !(dayjs(dateToCompareStart).isBetween(dateStart, dateEnd, 'minutes', '[]')) ? dateStart : dateToCompareStart;\n res.dateEnd = !(dayjs(dateToCompareEnd).isBetween(dateStart, dateEnd, 'minutes', '[]')) ? dateEnd : dateToCompareEnd;\n }\n }\n return res;\n}"]}
1
+ {"version":3,"file":"date.js","mappings":";;;;;QAOgBA,iC,GAAAA,iC;;AAAV,SAAUA,iCAAV,CAA4CC,aAA5C,EAAgFC,SAAhF,EAA8G;EAClH,MAAMC,GAAG,qBAAQF,aAAR,CAAT;;EACA,IAAIC,SAAS,CAACE,KAAV,CAAgBC,MAAhB,GAAyB,CAAzB,KAA8BJ,aAAa,SAAb,iBAAa,WAAb,GAAa,MAAb,gBAAa,CAAEK,SAA7C,MAA0DL,aAAa,SAAb,iBAAa,WAAb,GAAa,MAAb,gBAAa,CAAEM,OAAzE,CAAJ,EAAsF;IACpF,MAAMC,kBAAkB,GAAG,IAAIC,IAAJ,CAASR,aAAa,CAACK,SAAvB,EAAkCI,OAAlC,EAA3B;IACA,MAAMC,gBAAgB,GAAG,IAAIF,IAAJ,CAASR,aAAa,CAACM,OAA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,CAASE,gBAAT,CAAhH;IACD;EACF;;EACD,OAAOR,GAAP;AACD","names":["checkIfintervalIsBetweenRealHours","customPayload","realHours","res","datas","length","dateStart","dateEnd","dateToCompareStart","Date","getTime","dateToCompareEnd","realHoursObject","realHoursOfPeriod","filter","sh","endTime","startTime"],"sourceRoot":"","sources":["../../ts/utils/date.ts"],"sourcesContent":["/**\n * @param dateStart (format YYYY-MM-DD)\n * @param dateEnd (format YYYY-MM-DD)\n * @returns object of date (09:00-10:00, 12:00-13:00 et 14:00-17:00)\n */\nimport { ReadAttendanceHours, UpdateCalendarEvent } from '../types';\n\nexport function checkIfintervalIsBetweenRealHours(customPayload: UpdateCalendarEvent, realHours: ReadAttendanceHours):UpdateCalendarEvent {\n const res = { ...customPayload };\n if (realHours.datas.length > 0 && customPayload?.dateStart && customPayload?.dateEnd) {\n const dateToCompareStart = new Date(customPayload.dateStart).getTime();\n const dateToCompareEnd = new Date(customPayload.dateEnd).getTime();\n const realHoursObject = realHours.datas;\n\n // on cherche la bonne specialhour pour comparer les horaires\n const realHoursOfPeriod = realHoursObject.filter((sh) => (sh.endTime && (dateToCompareStart - new Date(sh.endTime).getTime() <= 0)) && (sh.startTime && (dateToCompareEnd - new Date(sh.startTime).getTime() >= 0)));\n\n if (realHoursOfPeriod?.length > 0 && realHoursOfPeriod[0].startTime && realHoursOfPeriod[0].endTime) {\n const dateStart = new Date(realHoursOfPeriod[0].startTime).getTime();\n const dateEnd = new Date(realHoursOfPeriod[0].endTime).getTime();\n\n // on check si les horaires de l'event sont dans les horaires du collab sinon on les fait commencer à l'heure à laquelle il s'est connecté\n res.dateStart = !((dateToCompareStart - dateStart) >= 0 && (dateToCompareStart - dateEnd) <= 0) ? new Date(dateStart) : new Date(dateToCompareStart);\n res.dateEnd = !((dateToCompareEnd - dateStart) >= 0 && (dateToCompareEnd - dateEnd) <= 0) ? new Date(dateEnd) : new Date(dateToCompareEnd);\n }\n }\n return res;\n}"]}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.validateSiret = validateSiret;
7
+ exports.getVatCodeBySiren = getVatCodeBySiren;
7
8
 
8
9
  function validateSiret(siret) {
9
10
  if (!/^\d{14}$/.test(siret)) throw new Error('Invalid SIRET format');
@@ -36,4 +37,10 @@ function validateSiret(siret) {
36
37
  }
37
38
  }
38
39
  }
40
+
41
+ function getVatCodeBySiren(siren, countryCode = 'FR') {
42
+ const validSiren = siren.replace(/\s/g, ''); // @ts-ignore
43
+
44
+ return `${countryCode}${[12 + 3 * (validSiren % 97)] % 97}${validSiren}`;
45
+ }
39
46
  //# sourceMappingURL=siretValidation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"siretValidation.js","mappings":";;;;;QAAgBA,a,GAAAA,a;;AAAV,SAAUA,aAAV,CAAwBC,KAAxB,EAAqC;EACzC,IAAI,CAAC,WAAWC,IAAX,CAAgBD,KAAhB,CAAL,EAA6B,MAAM,IAAIE,KAAJ,CAAU,sBAAV,CAAN;EAE7B,MAAMC,UAAU,GAAGC,KAAK,CAACC,IAAN,CAAWL,KAAX,EAAkBM,GAAlB,CAAsBC,MAAtB,EAA8BC,OAA9B,EAAnB;EACA,MAAMC,OAAO,GAAGN,UAAU,CAACO,MAAX,CAAkB,CAACC,GAAD,EAAMC,CAAN,EAASC,CAAT,KAAc;IAC9C,IAAIA,CAAC,GAAG,CAAJ,KAAU,CAAd,EAAiB;MACf,MAAMC,UAAU,GAAGF,CAAC,GAAG,CAAvB;;MACA,IAAIE,UAAU,GAAG,CAAjB,EAAoB;QAClB,MAAMC,KAAK,GAAGX,KAAK,CAACC,IAAN,CAAWS,UAAU,CAACE,QAAX,EAAX,CAAd;QACA,OAAOL,GAAG,GAAGJ,MAAM,CAACQ,KAAK,CAAC,CAAD,CAAN,CAAZ,GAAyBR,MAAM,CAACQ,KAAK,CAAC,CAAD,CAAN,CAAtC;MACD;;MACD,OAAOJ,GAAG,GAAGG,UAAb;IACD;;IACD,OAAOH,GAAG,GAAGC,CAAb;EACD,CAVe,EAUb,CAVa,CAAhB;;EAYA,IAAIH,OAAO,GAAG,EAAV,KAAiB,CAArB,EAAwB;IACtB;IACA,IAAIT,KAAK,CAACiB,UAAN,CAAiB,WAAjB,CAAJ,EAAmC;MACjC,MAAMC,GAAG,GAAGf,UAAU,CAACO,MAAX,CAAkB,CAACC,GAAD,EAAMC,CAAN,KAAYD,GAAG,GAAGC,CAApC,EAAuC,CAAvC,CAAZ;;MACA,IAAIM,GAAG,GAAG,CAAN,KAAY,CAAhB,EAAmB;QACjB,MAAM,IAAIhB,KAAJ,CAAU,eAAV,CAAN;MACD;IACF,CALD,MAKO;MACL,MAAM,IAAIA,KAAJ,CAAU,eAAV,CAAN;IACD;EACF;AACF","names":["validateSiret","siret","test","Error","siretArray","Array","from","map","Number","reverse","luhnSum","reduce","acc","v","i","currentVal","array","toString","startsWith","sum"],"sourceRoot":"","sources":["../../ts/utils/siretValidation.ts"],"sourcesContent":["export function validateSiret(siret: string) {\n if (!/^\\d{14}$/.test(siret)) throw new Error('Invalid SIRET format');\n\n const siretArray = Array.from(siret).map(Number).reverse();\n const luhnSum = siretArray.reduce((acc, v, i) => {\n if (i % 2 === 1) {\n const currentVal = v * 2;\n if (currentVal > 9) {\n const array = Array.from(currentVal.toString());\n return acc + Number(array[0]) + Number(array[1]);\n }\n return acc + currentVal;\n }\n return acc + v;\n }, 0);\n\n if (luhnSum % 10 !== 0) {\n // Specific rule for some La Poste SIRET\n if (siret.startsWith('356000000')) {\n const sum = siretArray.reduce((acc, v) => acc + v, 0);\n if (sum % 5 !== 0) {\n throw new Error('Invalid SIRET');\n }\n } else {\n throw new Error('Invalid SIRET');\n }\n }\n}"]}
1
+ {"version":3,"file":"siretValidation.js","mappings":";;;;;QAAgBA,a,GAAAA,a;QA6BAC,iB,GAAAA,iB;;AA7BV,SAAUD,aAAV,CAAwBE,KAAxB,EAAqC;EACzC,IAAI,CAAC,WAAWC,IAAX,CAAgBD,KAAhB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AK,CAACG,OAAN,CAAc,KAAd,EAAqB,EAArB,CAAnB,CADiE,CAEjE;;EACA,OAAO,GAAGF,WAAW,GAAG,CAAC,KAAK,KAAKC,UAAU,GAAG,EAAlB,CAAN,IAA+B,EAAE,GAAGA,UAAU,EAAtE;AACD","names":["validateSiret","getVatCodeBySiren","siret","test","Error","siretArray","Array","from","map","Number","reverse","luhnSum","reduce","acc","v","i","currentVal","array","toString","startsWith","sum","siren","countryCode","validSiren","replace"],"sourceRoot":"","sources":["../../ts/utils/siretValidation.ts"],"sourcesContent":["export function validateSiret(siret: string) {\n if (!/^\\d{14}$/.test(siret)) throw new Error('Invalid SIRET format');\n\n const siretArray = Array.from(siret).map(Number).reverse();\n const luhnSum = siretArray.reduce((acc, v, i) => {\n if (i % 2 === 1) {\n const currentVal = v * 2;\n if (currentVal > 9) {\n const array = Array.from(currentVal.toString());\n return acc + Number(array[0]) + Number(array[1]);\n }\n return acc + currentVal;\n }\n return acc + v;\n }, 0);\n\n if (luhnSum % 10 !== 0) {\n // Specific rule for some La Poste SIRET\n if (siret.startsWith('356000000')) {\n const sum = siretArray.reduce((acc, v) => acc + v, 0);\n if (sum % 5 !== 0) {\n throw new Error('Invalid SIRET');\n }\n } else {\n throw new Error('Invalid SIRET');\n }\n }\n}\n\nexport function getVatCodeBySiren(siren: string, countryCode = 'FR'): string {\n const validSiren = siren.replace(/\\s/g, '');\n // @ts-ignore\n return `${countryCode}${[12 + 3 * (validSiren % 97)] % 97}${validSiren}`;\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silexpert/core",
3
- "version": "0.4.241",
3
+ "version": "0.4.243",
4
4
  "description": "Silex Core perform HTTP Request and object binding. Silex core helps developers to retrieve and return formatted object",
5
5
  "homepage": "https://gitlab.compta-clementine.fr/dev/silex-api",
6
6
  "main": "js/index.js",
package/ts/types/index.ts CHANGED
@@ -479,7 +479,6 @@ export * from './Interface/api/mail/QueryAllMail';
479
479
  export * from './Interface/api/mail/QueryPaginatedMail';
480
480
  export * from './Interface/api/mail/QueryCountProcessedByUser';
481
481
  export * from './Interface/api/mail/QueryGetAnsweringTimeByUser';
482
- export * from './Interface/api/mail/QueryCountMail';
483
482
  export * from './Interface/api/mail/QueryCountUnprocessedByUserMail';
484
483
  export * from './Interface/api/mail/UpdateMail';
485
484
  export * from './Interface/api/mail/CreateMailParams';
package/ts/utils/date.ts CHANGED
@@ -3,29 +3,25 @@
3
3
  * @param dateEnd (format YYYY-MM-DD)
4
4
  * @returns object of date (09:00-10:00, 12:00-13:00 et 14:00-17:00)
5
5
  */
6
- import * as dayjs from 'dayjs';
7
- import * as isBetween from 'dayjs/plugin/isBetween';
8
6
  import { ReadAttendanceHours, UpdateCalendarEvent } from '../types';
9
7
 
10
- dayjs.extend(isBetween);
11
-
12
- export async function checkRealHoursUser(customPayload: UpdateCalendarEvent, realHours: ReadAttendanceHours):Promise<UpdateCalendarEvent> {
8
+ export function checkIfintervalIsBetweenRealHours(customPayload: UpdateCalendarEvent, realHours: ReadAttendanceHours):UpdateCalendarEvent {
13
9
  const res = { ...customPayload };
14
- if (realHours.datas.length > 0) {
15
- const dateToCompareStart = dayjs(customPayload.dateStart).toDate();
16
- const dateToCompareEnd = dayjs(customPayload.dateEnd).toDate();
10
+ if (realHours.datas.length > 0 && customPayload?.dateStart && customPayload?.dateEnd) {
11
+ const dateToCompareStart = new Date(customPayload.dateStart).getTime();
12
+ const dateToCompareEnd = new Date(customPayload.dateEnd).getTime();
17
13
  const realHoursObject = realHours.datas;
18
14
 
19
15
  // on cherche la bonne specialhour pour comparer les horaires
20
- const realHoursOfPeriod = realHoursObject.filter((sh) => (sh.endTime && dayjs(dateToCompareStart).diff(dayjs(sh.endTime)) <= 0) && (sh.startTime && dayjs(dateToCompareEnd).diff(dayjs(sh.startTime)) >= 0));
16
+ const realHoursOfPeriod = realHoursObject.filter((sh) => (sh.endTime && (dateToCompareStart - new Date(sh.endTime).getTime() <= 0)) && (sh.startTime && (dateToCompareEnd - new Date(sh.startTime).getTime() >= 0)));
21
17
 
22
18
  if (realHoursOfPeriod?.length > 0 && realHoursOfPeriod[0].startTime && realHoursOfPeriod[0].endTime) {
23
- const dateStart = dayjs(realHoursOfPeriod[0].startTime, 'YYYY-MM-DD HH:mm:ss').toDate();
24
- const dateEnd = dayjs(realHoursOfPeriod[0].endTime, 'YYYY-MM-DD HH:mm:ss').toDate();
19
+ const dateStart = new Date(realHoursOfPeriod[0].startTime).getTime();
20
+ const dateEnd = new Date(realHoursOfPeriod[0].endTime).getTime();
25
21
 
26
22
  // on check si les horaires de l'event sont dans les horaires du collab sinon on les fait commencer à l'heure à laquelle il s'est connecté
27
- res.dateStart = !(dayjs(dateToCompareStart).isBetween(dateStart, dateEnd, 'minutes', '[]')) ? dateStart : dateToCompareStart;
28
- res.dateEnd = !(dayjs(dateToCompareEnd).isBetween(dateStart, dateEnd, 'minutes', '[]')) ? dateEnd : dateToCompareEnd;
23
+ res.dateStart = !((dateToCompareStart - dateStart) >= 0 && (dateToCompareStart - dateEnd) <= 0) ? new Date(dateStart) : new Date(dateToCompareStart);
24
+ res.dateEnd = !((dateToCompareEnd - dateStart) >= 0 && (dateToCompareEnd - dateEnd) <= 0) ? new Date(dateEnd) : new Date(dateToCompareEnd);
29
25
  }
30
26
  }
31
27
  return res;
@@ -25,4 +25,10 @@ export function validateSiret(siret: string) {
25
25
  throw new Error('Invalid SIRET');
26
26
  }
27
27
  }
28
+ }
29
+
30
+ export function getVatCodeBySiren(siren: string, countryCode = 'FR'): string {
31
+ const validSiren = siren.replace(/\s/g, '');
32
+ // @ts-ignore
33
+ return `${countryCode}${[12 + 3 * (validSiren % 97)] % 97}${validSiren}`;
28
34
  }
@@ -1,9 +0,0 @@
1
- import { WhereOptions, WhereValue } from 'sequelize';
2
- import { Mail } from '../../../../api/resources/Mail';
3
- export declare class QueryCountMail {
4
- distinct?: boolean;
5
- where?: {
6
- [K in keyof Mail]?: WhereOptions | WhereValue;
7
- };
8
- }
9
- //# sourceMappingURL=QueryCountMail.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryCountMail.d.ts","sourceRoot":"","sources":["../../../../../ts/types/Interface/api/mail/QueryCountMail.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAItD,qBAAa,cAAc;IAKzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAInB,KAAK,CAAC,EAAE;SACL,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,YAAY,GAAG,UAAU;KAC9C,CAAC;CACH"}
@@ -1,27 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { IsBoolean, IsOptional, } from 'class-validator';
11
- import { ApiPropertyOptional } from '../../../../utils';
12
- import { ToBoolean } from '../../../../utils/transforms/boolean.transform';
13
- export class QueryCountMail {
14
- }
15
- __decorate([
16
- ApiPropertyOptional(),
17
- IsOptional(),
18
- IsBoolean(),
19
- ToBoolean(),
20
- __metadata("design:type", Boolean)
21
- ], QueryCountMail.prototype, "distinct", void 0);
22
- __decorate([
23
- ApiPropertyOptional(),
24
- IsOptional(),
25
- __metadata("design:type", Object)
26
- ], QueryCountMail.prototype, "where", void 0);
27
- //# sourceMappingURL=QueryCountMail.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryCountMail.js","sourceRoot":"","sources":["../../../../../ts/types/Interface/api/mail/QueryCountMail.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,SAAS,EACT,UAAU,GACX,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAC;AAE3E,MAAM,OAAO,cAAc;CAY1B;AAPC;IAJC,mBAAmB,EAAE;IACrB,UAAU,EAAE;IACZ,SAAS,EAAE;IACX,SAAS,EAAE;;gDACO;AAInB;IAFC,mBAAmB,EAAE;IACrB,UAAU,EAAE;;6CAGX","sourcesContent":["import {\n IsBoolean,\n IsOptional,\n} from 'class-validator';\nimport { WhereOptions, WhereValue } from 'sequelize';\nimport { Mail } from '../../../../api/resources/Mail';\nimport { ApiPropertyOptional } from '../../../../utils';\nimport { ToBoolean } from '../../../../utils/transforms/boolean.transform';\n\nexport class QueryCountMail {\n @ApiPropertyOptional()\n @IsOptional()\n @IsBoolean()\n @ToBoolean()\n distinct?: boolean;\n\n @ApiPropertyOptional()\n @IsOptional()\n where?: {\n [K in keyof Mail]?: WhereOptions | WhereValue\n };\n}\n"]}
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.QueryCountMail = undefined;
7
-
8
- var _classValidator = require("class-validator");
9
-
10
- var _utils = require("../../../../utils");
11
-
12
- var _boolean = require("../../../../utils/transforms/boolean.transform");
13
-
14
- var __decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
15
- var c = arguments.length,
16
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
17
- d;
18
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
19
- return c > 3 && r && Object.defineProperty(target, key, r), r;
20
- };
21
-
22
- var __metadata = undefined && undefined.__metadata || function (k, v) {
23
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
24
- };
25
-
26
- class QueryCountMail {}
27
-
28
- exports.QueryCountMail = QueryCountMail;
29
-
30
- __decorate([(0, _utils.ApiPropertyOptional)(), (0, _classValidator.IsOptional)(), (0, _classValidator.IsBoolean)(), (0, _boolean.ToBoolean)(), __metadata("design:type", Boolean)], QueryCountMail.prototype, "distinct", void 0);
31
-
32
- __decorate([(0, _utils.ApiPropertyOptional)(), (0, _classValidator.IsOptional)(), __metadata("design:type", Object)], QueryCountMail.prototype, "where", void 0);
33
- //# sourceMappingURL=QueryCountMail.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryCountMail.js","mappings":";;;;;;;AAAA;;AAMA;;AACA;;;;;;;;;;;;;;AAEM,MAAOA,cAAP,CAAqB;;QAAdA,c,GAAAA,c;;AAKXC,YAJC,iCAID,EAHC,iCAGD,EAFC,gCAED,EADC,yBACD;;AAIAA,YAFC,iCAED,EADC,iCACD","names":["QueryCountMail","__decorate"],"sourceRoot":"","sources":["../../../../../ts/types/Interface/api/mail/QueryCountMail.ts"],"sourcesContent":["import {\n IsBoolean,\n IsOptional,\n} from 'class-validator';\nimport { WhereOptions, WhereValue } from 'sequelize';\nimport { Mail } from '../../../../api/resources/Mail';\nimport { ApiPropertyOptional } from '../../../../utils';\nimport { ToBoolean } from '../../../../utils/transforms/boolean.transform';\n\nexport class QueryCountMail {\n @ApiPropertyOptional()\n @IsOptional()\n @IsBoolean()\n @ToBoolean()\n distinct?: boolean;\n\n @ApiPropertyOptional()\n @IsOptional()\n where?: {\n [K in keyof Mail]?: WhereOptions | WhereValue\n };\n}\n"]}
@@ -1,22 +0,0 @@
1
- import {
2
- IsBoolean,
3
- IsOptional,
4
- } from 'class-validator';
5
- import { WhereOptions, WhereValue } from 'sequelize';
6
- import { Mail } from '../../../../api/resources/Mail';
7
- import { ApiPropertyOptional } from '../../../../utils';
8
- import { ToBoolean } from '../../../../utils/transforms/boolean.transform';
9
-
10
- export class QueryCountMail {
11
- @ApiPropertyOptional()
12
- @IsOptional()
13
- @IsBoolean()
14
- @ToBoolean()
15
- distinct?: boolean;
16
-
17
- @ApiPropertyOptional()
18
- @IsOptional()
19
- where?: {
20
- [K in keyof Mail]?: WhereOptions | WhereValue
21
- };
22
- }