monkey-front-core 0.0.610 → 0.0.612

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.
@@ -88,6 +88,109 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
88
88
  }]
89
89
  }] });
90
90
 
91
+ /* eslint-disable no-plusplus */
92
+ class CNPJValidator {
93
+ static removeMask(document) {
94
+ return document.replace(this.maskCharactersRegex, '');
95
+ }
96
+ static calculateCheckDigits(document) {
97
+ if (!this.invalidCharactersRegex.test(document)) {
98
+ const unmaskedCnpj = this.removeMask(document);
99
+ if (this.baseRegex.test(unmaskedCnpj) &&
100
+ unmaskedCnpj !== this.zeroCnpj.substring(0, this.baseLength)) {
101
+ let sumDV1 = 0;
102
+ let sumDV2 = 0;
103
+ for (let i = 0; i < this.baseLength; i++) {
104
+ const digitAscii = unmaskedCnpj.charCodeAt(i) - this.zeroCharCode;
105
+ sumDV1 += digitAscii * this.checkDigitWeights[i + 1];
106
+ sumDV2 += digitAscii * this.checkDigitWeights[i];
107
+ }
108
+ const dv1 = sumDV1 % 11 < 2 ? 0 : 11 - (sumDV1 % 11);
109
+ sumDV2 += dv1 * this.checkDigitWeights[this.baseLength];
110
+ const dv2 = sumDV2 % 11 < 2 ? 0 : 11 - (sumDV2 % 11);
111
+ return `${dv1}${dv2}`;
112
+ }
113
+ }
114
+ throw new Error('');
115
+ }
116
+ static isValid(document) {
117
+ try {
118
+ if (!this.invalidCharactersRegex.test(document)) {
119
+ const unmasked = this.removeMask(document);
120
+ if (this.fullRegex.test(unmasked) && unmasked !== this.zeroCnpj) {
121
+ const providedCheckDigits = unmasked.substring(this.baseLength);
122
+ const calculatedCheckDigits = this.calculateCheckDigits(unmasked.substring(0, this.baseLength));
123
+ return providedCheckDigits === calculatedCheckDigits;
124
+ }
125
+ }
126
+ }
127
+ catch (e) {
128
+ // not to do
129
+ }
130
+ return false;
131
+ }
132
+ }
133
+ CNPJValidator.baseLength = 12;
134
+ CNPJValidator.baseRegex = /^([A-Z\d]){12}$/;
135
+ CNPJValidator.fullRegex = /^([A-Z\d]){12}(\d){2}$/;
136
+ CNPJValidator.maskCharactersRegex = /[./-]/g;
137
+ CNPJValidator.invalidCharactersRegex = /[^A-Z\d./-]/i;
138
+ CNPJValidator.zeroCharCode = '0'.charCodeAt(0);
139
+ CNPJValidator.checkDigitWeights = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
140
+ CNPJValidator.zeroCnpj = '00000000000000';
141
+
142
+ /* eslint-disable no-plusplus */
143
+ class CPFValidator {
144
+ static removeMask(document) {
145
+ return document.replace(this.maskCharactersRegex, '');
146
+ }
147
+ static calculateCheckDigits(document) {
148
+ if (!this.invalidCharactersRegex.test(document)) {
149
+ const unmasked = this.removeMask(document);
150
+ if (this.baseRegex.test(unmasked) &&
151
+ unmasked !== this.zeroCpf.substring(0, this.baseLength)) {
152
+ const weightsDV1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
153
+ const weightsDV2 = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
154
+ let sumDV1 = 0;
155
+ let sumDV2 = 0;
156
+ for (let i = 0; i < document.length; i++) {
157
+ sumDV1 += Number(document[i]) * weightsDV1[i];
158
+ }
159
+ const dv1 = sumDV1 % 11 <= 1 ? 0 : 11 - (sumDV1 % 11);
160
+ document = `${document}${dv1}`;
161
+ for (let i = 0; i < document.length; i++) {
162
+ sumDV2 += Number(document[i]) * weightsDV2[i];
163
+ }
164
+ const dv2 = sumDV2 % 11 <= 1 ? 0 : 11 - (sumDV2 % 11);
165
+ return `${dv1}${dv2}`;
166
+ }
167
+ }
168
+ throw new Error('');
169
+ }
170
+ static isValid(document) {
171
+ try {
172
+ if (!this.invalidCharactersRegex.test(document)) {
173
+ const unmasked = this.removeMask(document);
174
+ if (this.fullRegex.test(unmasked) && unmasked !== this.zeroCpf) {
175
+ const providedCheckDigits = unmasked.substring(this.baseLength);
176
+ const calculatedCheckDigits = this.calculateCheckDigits(unmasked.substring(0, this.baseLength));
177
+ return providedCheckDigits === calculatedCheckDigits;
178
+ }
179
+ }
180
+ }
181
+ catch (e) {
182
+ // not to do
183
+ }
184
+ return false;
185
+ }
186
+ }
187
+ CPFValidator.baseLength = 9;
188
+ CPFValidator.baseRegex = /^([A-Z\d]){9}$/;
189
+ CPFValidator.maskCharactersRegex = /[./-]/g;
190
+ CPFValidator.invalidCharactersRegex = /[^A-Z\d./-]/i;
191
+ CPFValidator.fullRegex = /^([\d]){9}(\d){2}$/;
192
+ CPFValidator.zeroCpf = '00000000000';
193
+
91
194
  /* eslint-disable no-unused-vars */
92
195
  /* eslint-disable no-shadow */
93
196
  var MonkeyEcxQueueEvents;
@@ -268,6 +371,19 @@ class MonkeyEcxUtils {
268
371
  }
269
372
  return false;
270
373
  }
374
+ static isCPFAlphanumericCNPJValid(document) {
375
+ document = document.replace(/[./-]/g, '');
376
+ const handled = document.replace(new RegExp(document.charAt(0), 'g'), '');
377
+ if (!handled)
378
+ return false;
379
+ if (document.length === 11) {
380
+ return CPFValidator.isValid(document);
381
+ }
382
+ if (document.length === 14 || /0{14}/.test(document)) {
383
+ return CNPJValidator.isValid(document);
384
+ }
385
+ return false;
386
+ }
271
387
  static isValidRUT(document) {
272
388
  if (!document || document.trim().length < 3)
273
389
  return false;
@@ -1135,6 +1251,20 @@ class DocumentValidator {
1135
1251
  return null;
1136
1252
  }
1137
1253
  }
1254
+ class AlphanumericDocumentValidator {
1255
+ static do(control) {
1256
+ if (!control.parent || !control)
1257
+ return null;
1258
+ if (control && control.value) {
1259
+ if (!MonkeyEcxUtils.isCPFAlphanumericCNPJValid(control.value)) {
1260
+ return {
1261
+ invalidCpfCnpj: true
1262
+ };
1263
+ }
1264
+ }
1265
+ return null;
1266
+ }
1267
+ }
1138
1268
  class DocumentRutValidator {
1139
1269
  static do(control) {
1140
1270
  if (!control.parent || !control)
@@ -1328,6 +1458,7 @@ var validateUtils = /*#__PURE__*/Object.freeze({
1328
1458
  __proto__: null,
1329
1459
  DateValidator: DateValidator,
1330
1460
  DocumentValidator: DocumentValidator,
1461
+ AlphanumericDocumentValidator: AlphanumericDocumentValidator,
1331
1462
  DocumentRutValidator: DocumentRutValidator,
1332
1463
  DocumentRFCValidator: DocumentRFCValidator,
1333
1464
  ZipCodeValidator: ZipCodeValidator,
@@ -6635,6 +6766,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
6635
6766
  }] }];
6636
6767
  } });
6637
6768
 
6769
+ class GTMService {
6770
+ constructor(tokenStorage) {
6771
+ this.tokenStorage = tokenStorage;
6772
+ // not to do
6773
+ }
6774
+ get dataLayer() {
6775
+ return window.dataLayer || [];
6776
+ }
6777
+ dispatch(event, data = {}) {
6778
+ return __awaiter(this, void 0, void 0, function* () {
6779
+ const { tokenStorage, dataLayer } = this;
6780
+ try {
6781
+ const { username, name } = yield tokenStorage.getMe();
6782
+ const { governmentId, companyType } = yield tokenStorage.getToken();
6783
+ const getValue = (value, property) => {
6784
+ return Object.assign({}, (value && { [property || value]: value }));
6785
+ };
6786
+ dataLayer.push({
6787
+ event,
6788
+ payload: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, getValue(username, 'userEmail')), getValue(name, 'userName')), getValue(governmentId, 'companyCnpj')), getValue(companyType)), data)
6789
+ });
6790
+ }
6791
+ catch (error) {
6792
+ MonkeyEcxLogs.log({
6793
+ message: `[GTMService -> dispatch ] try dispatch event: ${event}`,
6794
+ error
6795
+ });
6796
+ }
6797
+ });
6798
+ }
6799
+ }
6800
+ GTMService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: GTMService, deps: [{ token: MonkeyEcxTokenStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
6801
+ GTMService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: GTMService, providedIn: 'root' });
6802
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: GTMService, decorators: [{
6803
+ type: Injectable,
6804
+ args: [{ providedIn: 'root' }]
6805
+ }], ctorParameters: function () { return [{ type: MonkeyEcxTokenStorageService }]; } });
6806
+
6638
6807
  class MonkeyEcxFeatureByProgramDirective {
6639
6808
  constructor(cdr, elementRef, monkeyConfigService) {
6640
6809
  this.cdr = cdr;
@@ -7234,5 +7403,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
7234
7403
  * Generated bundle index. Do not edit.
7235
7404
  */
7236
7405
 
7237
- export { AlertsComponent, AlertsModule, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, LService, Link, MECX_ALPHA, MECX_BETA, MECX_DATE_FORMAT, MECX_ENV, MECX_LANG, MECX_TIMEZONEOFFSET, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, MonkeyEcxAuthGuardByRole, MonkeyEcxAuthGuardCompany, MonkeyEcxAuthGuardLogin, MonkeyEcxAuthenticationService, MonkeyEcxBlobSecurePipe, MonkeyEcxCommonsActions, MonkeyEcxCommonsResolveBaseService, MonkeyEcxCommonsResolveService, MonkeyEcxCommonsSelectors, MonkeyEcxCommonsService, MonkeyEcxCommonsStoreBaseService, MonkeyEcxCommonsStoreService, MonkeyEcxConfigModule, MonkeyEcxConfigService, MonkeyEcxCookieStorageService, MonkeyEcxCoreCharts, MonkeyEcxCoreClearDecorators, MonkeyEcxCoreLog, MonkeyEcxCoreService, MonkeyEcxCoreServiceConstructor, MonkeyEcxCoreServicePaged, MonkeyEcxCoreServiceQueue, MonkeyEcxCurrencyCodePipe, MonkeyEcxCurrencyConfigService, MonkeyEcxDirectivesModule, MonkeyEcxDiscoveryParamsService, MonkeyEcxDisplayFirstNamePipe, MonkeyEcxDisplayInitialsPipe, MonkeyEcxDisplaySupportPhone, MonkeyEcxDragDropDirective, MonkeyEcxErrorConfigService, MonkeyEcxErrorHandlingModule, MonkeyEcxErrorHandlingService, MonkeyEcxFeatureByProgramDirective, MonkeyEcxFeatureDirective, MonkeyEcxFeatureToggleService, MonkeyEcxFormatAddressPipe, MonkeyEcxFormatBeaufityJSONPipe, MonkeyEcxFormatCurrency, MonkeyEcxFormatCurrencyPipe, MonkeyEcxFormatDateGroupPipe, MonkeyEcxFormatDatePipe, MonkeyEcxFormatDateTimelapsePipe, MonkeyEcxFormatDateUnixTimelapsePipe, MonkeyEcxFormatDocumentPipe, MonkeyEcxFormatDocumentTypePipe, MonkeyEcxFormatNumberPipe, MonkeyEcxFormatPhonePipe, MonkeyEcxFormatSizePipe, MonkeyEcxFormatTaxPipe, MonkeyEcxFormatUpper, MonkeyEcxFormatValue, MonkeyEcxFormatZipCodePipe, MonkeyEcxHandlingService, MonkeyEcxHttpConfigErrorInterceptor, MonkeyEcxHttpConfigHeaderInterceptor, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxHttpConfigLoadingInProgressInterceptor, MonkeyEcxHttpConfigQueueInterceptor, MonkeyEcxHttpErrorHandlingService, MonkeyEcxLinksModel, MonkeyEcxLoadingDirective, MonkeyEcxLoggedHandlingService, MonkeyEcxLogs, MonkeyEcxLogsConfigService, MonkeyEcxMaintenanceConfigService, MonkeyEcxModel, MonkeyEcxOnlyAlphaNumericDirective, MonkeyEcxOnlyNumbersDirective, MonkeyEcxOthersErrorsHandlingService, MonkeyEcxPaginationService, MonkeyEcxPipesModule, MonkeyEcxPopoverDirective, MonkeyEcxPopoverOptionsDirective, MonkeyEcxProgressBarComponent, MonkeyEcxProgressBarModule, MonkeyEcxProgressBarService, MonkeyEcxRequestDownloadHandlingService, MonkeyEcxRequestDownloadedHandlingService, MonkeyEcxRequestPagedHandling, MonkeyEcxRequestQueueHandlingService, MonkeyEcxRequestQueueModalHandlingService, MonkeyEcxRequestScheduleService, MonkeyEcxSecurityConsoleConfigService, MonkeyEcxSecurityDirective, MonkeyEcxService, MonkeyEcxServiceDownload, MonkeyEcxServiceUpload, MonkeyEcxServiceWorkerConfigService, MonkeyEcxSpecificationSearch, MonkeyEcxTextTruncatePipe, MonkeyEcxTokenStorageService, MonkeyEcxTooltipDirective, MonkeyEcxTruncateQtdPipe, MonkeyEcxUtils, MonkeyEcxi18nConfigService, MonkeyFrontCoreModule, OpSearch, POPOVER_OPTIONS, statics as Statics, validateUtils as ValidateUtils, Validators, VersionChangedComponent, VersionChangedModule, comboValidator, containsNumber, dateRangeValidator, dateStartEndValidator, dateValidator, differentFromZero, documentValidator, documentValidatorByType, emailValidator, minYearsValidator, passwordConfirmValidator, registerValidator, requiredWithTrimValidator, index as store, trueValidator, urlValidator, validateFullName, valueGreaterThanZero, zipCodeValidator };
7406
+ export { AlertsComponent, AlertsModule, CNPJValidator, CPFValidator, ClosedToMaintenanceComponent, ClosedToMaintenanceModule, CurrencyConfigComponent, CurrencyConfigModule, decoratorsUtils as DecoratorsUtils, GTMService, LService, Link, MECX_ALPHA, MECX_BETA, MECX_DATE_FORMAT, MECX_ENV, MECX_LANG, MECX_TIMEZONEOFFSET, MonkeyEcxAlertsService, MonkeyEcxAuthGuard, MonkeyEcxAuthGuardByRole, MonkeyEcxAuthGuardCompany, MonkeyEcxAuthGuardLogin, MonkeyEcxAuthenticationService, MonkeyEcxBlobSecurePipe, MonkeyEcxCommonsActions, MonkeyEcxCommonsResolveBaseService, MonkeyEcxCommonsResolveService, MonkeyEcxCommonsSelectors, MonkeyEcxCommonsService, MonkeyEcxCommonsStoreBaseService, MonkeyEcxCommonsStoreService, MonkeyEcxConfigModule, MonkeyEcxConfigService, MonkeyEcxCookieStorageService, MonkeyEcxCoreCharts, MonkeyEcxCoreClearDecorators, MonkeyEcxCoreLog, MonkeyEcxCoreService, MonkeyEcxCoreServiceConstructor, MonkeyEcxCoreServicePaged, MonkeyEcxCoreServiceQueue, MonkeyEcxCurrencyCodePipe, MonkeyEcxCurrencyConfigService, MonkeyEcxDirectivesModule, MonkeyEcxDiscoveryParamsService, MonkeyEcxDisplayFirstNamePipe, MonkeyEcxDisplayInitialsPipe, MonkeyEcxDisplaySupportPhone, MonkeyEcxDragDropDirective, MonkeyEcxErrorConfigService, MonkeyEcxErrorHandlingModule, MonkeyEcxErrorHandlingService, MonkeyEcxFeatureByProgramDirective, MonkeyEcxFeatureDirective, MonkeyEcxFeatureToggleService, MonkeyEcxFormatAddressPipe, MonkeyEcxFormatBeaufityJSONPipe, MonkeyEcxFormatCurrency, MonkeyEcxFormatCurrencyPipe, MonkeyEcxFormatDateGroupPipe, MonkeyEcxFormatDatePipe, MonkeyEcxFormatDateTimelapsePipe, MonkeyEcxFormatDateUnixTimelapsePipe, MonkeyEcxFormatDocumentPipe, MonkeyEcxFormatDocumentTypePipe, MonkeyEcxFormatNumberPipe, MonkeyEcxFormatPhonePipe, MonkeyEcxFormatSizePipe, MonkeyEcxFormatTaxPipe, MonkeyEcxFormatUpper, MonkeyEcxFormatValue, MonkeyEcxFormatZipCodePipe, MonkeyEcxHandlingService, MonkeyEcxHttpConfigErrorInterceptor, MonkeyEcxHttpConfigHeaderInterceptor, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxHttpConfigLoadingInProgressInterceptor, MonkeyEcxHttpConfigQueueInterceptor, MonkeyEcxHttpErrorHandlingService, MonkeyEcxLinksModel, MonkeyEcxLoadingDirective, MonkeyEcxLoggedHandlingService, MonkeyEcxLogs, MonkeyEcxLogsConfigService, MonkeyEcxMaintenanceConfigService, MonkeyEcxModel, MonkeyEcxOnlyAlphaNumericDirective, MonkeyEcxOnlyNumbersDirective, MonkeyEcxOthersErrorsHandlingService, MonkeyEcxPaginationService, MonkeyEcxPipesModule, MonkeyEcxPopoverDirective, MonkeyEcxPopoverOptionsDirective, MonkeyEcxProgressBarComponent, MonkeyEcxProgressBarModule, MonkeyEcxProgressBarService, MonkeyEcxRequestDownloadHandlingService, MonkeyEcxRequestDownloadedHandlingService, MonkeyEcxRequestPagedHandling, MonkeyEcxRequestQueueHandlingService, MonkeyEcxRequestQueueModalHandlingService, MonkeyEcxRequestScheduleService, MonkeyEcxSecurityConsoleConfigService, MonkeyEcxSecurityDirective, MonkeyEcxService, MonkeyEcxServiceDownload, MonkeyEcxServiceUpload, MonkeyEcxServiceWorkerConfigService, MonkeyEcxSpecificationSearch, MonkeyEcxTextTruncatePipe, MonkeyEcxTokenStorageService, MonkeyEcxTooltipDirective, MonkeyEcxTruncateQtdPipe, MonkeyEcxUtils, MonkeyEcxi18nConfigService, MonkeyFrontCoreModule, OpSearch, POPOVER_OPTIONS, statics as Statics, validateUtils as ValidateUtils, Validators, VersionChangedComponent, VersionChangedModule, comboValidator, containsNumber, dateRangeValidator, dateStartEndValidator, dateValidator, differentFromZero, documentValidator, documentValidatorByType, emailValidator, minYearsValidator, passwordConfirmValidator, registerValidator, requiredWithTrimValidator, index as store, trueValidator, urlValidator, validateFullName, valueGreaterThanZero, zipCodeValidator };
7238
7407
  //# sourceMappingURL=monkey-front-core.mjs.map