ravcredit-lib 0.0.4 → 0.0.5
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.
- package/fesm2022/ravcredit-lib.mjs +247 -1
- package/fesm2022/ravcredit-lib.mjs.map +1 -1
- package/index.d.ts +1516 -4
- package/package.json +3 -4
- package/esm2022/lib/ravcredit-lib.component.mjs +0 -19
- package/esm2022/lib/ravcredit-lib.service.mjs +0 -14
- package/esm2022/lib/v1/objects/oAddress.mjs +0 -10
- package/esm2022/lib/v1/objects/oBusiness.mjs +0 -2
- package/esm2022/lib/v1/objects/oClient.mjs +0 -2
- package/esm2022/lib/v1/objects/oConekta.mjs +0 -85
- package/esm2022/lib/v1/objects/oContract.mjs +0 -2
- package/esm2022/lib/v1/objects/oContractAll.mjs +0 -2
- package/esm2022/lib/v1/objects/oCustomer.mjs +0 -18
- package/esm2022/lib/v1/objects/oDevice.mjs +0 -2
- package/esm2022/lib/v1/objects/oFinancial.mjs +0 -2
- package/esm2022/lib/v1/objects/oGlobal.mjs +0 -86
- package/esm2022/lib/v1/objects/oLogIn.mjs +0 -17
- package/esm2022/lib/v1/objects/oNewPayment.mjs +0 -2
- package/esm2022/lib/v1/objects/oNotification.mjs +0 -17
- package/esm2022/lib/v1/objects/oPassport.mjs +0 -7
- package/esm2022/lib/v1/objects/oUser.mjs +0 -2
- package/esm2022/lib/v1/util/UtilBusiness.mjs +0 -171
- package/esm2022/lib/v1/util/UtilClient.mjs +0 -221
- package/esm2022/lib/v1/util/UtilContract.mjs +0 -331
- package/esm2022/lib/v1/util/UtilDynamiCore.mjs +0 -292
- package/esm2022/public-api.mjs +0 -25
- package/esm2022/ravcredit-lib.mjs +0 -5
- package/lib/ravcredit-lib.component.d.ts +0 -5
- package/lib/ravcredit-lib.service.d.ts +0 -6
- package/lib/v1/objects/oAddress.d.ts +0 -10
- package/lib/v1/objects/oBusiness.d.ts +0 -101
- package/lib/v1/objects/oClient.d.ts +0 -43
- package/lib/v1/objects/oConekta.d.ts +0 -305
- package/lib/v1/objects/oContract.d.ts +0 -23
- package/lib/v1/objects/oContractAll.d.ts +0 -21
- package/lib/v1/objects/oCustomer.d.ts +0 -17
- package/lib/v1/objects/oDevice.d.ts +0 -5
- package/lib/v1/objects/oFinancial.d.ts +0 -30
- package/lib/v1/objects/oGlobal.d.ts +0 -149
- package/lib/v1/objects/oLogIn.d.ts +0 -30
- package/lib/v1/objects/oNewPayment.d.ts +0 -11
- package/lib/v1/objects/oNotification.d.ts +0 -25
- package/lib/v1/objects/oPassport.d.ts +0 -55
- package/lib/v1/objects/oUser.d.ts +0 -25
- package/lib/v1/util/UtilBusiness.d.ts +0 -52
- package/lib/v1/util/UtilClient.d.ts +0 -34
- package/lib/v1/util/UtilContract.d.ts +0 -70
- package/lib/v1/util/UtilDynamiCore.d.ts +0 -453
- package/public-api.d.ts +0 -21
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, Component } from '@angular/core';
|
|
3
3
|
import { UntypedFormControl, Validators, UntypedFormArray } from '@angular/forms';
|
|
4
|
+
import { openDB } from 'idb';
|
|
4
5
|
|
|
5
6
|
class RavcreditLibService {
|
|
6
7
|
constructor() { }
|
|
@@ -1272,6 +1273,251 @@ class FactoryDynamiCore {
|
|
|
1272
1273
|
}
|
|
1273
1274
|
}
|
|
1274
1275
|
|
|
1276
|
+
const keyUserID = "rc_uid";
|
|
1277
|
+
const dbVersion = 1;
|
|
1278
|
+
const dbName = "RavCreditDB";
|
|
1279
|
+
const keyPathId = "id";
|
|
1280
|
+
const dbAuthStore = "authStore";
|
|
1281
|
+
const dbUsersStore = "usersStore";
|
|
1282
|
+
const dbContractsStore = "contractsStore";
|
|
1283
|
+
const dbClientsStore = "clientsStore";
|
|
1284
|
+
const dbBusinessInfo = "businessInfo";
|
|
1285
|
+
const dbBusinessConfig = "businessConfig";
|
|
1286
|
+
const dbConektaClientsStore = "conektaClientsStore";
|
|
1287
|
+
const dbConektaReferencesStore = "conektaReferencesStore";
|
|
1288
|
+
const dbPassportReferencesStore = "passportReferencesStore";
|
|
1289
|
+
const dbDynamicReferencesStore = "dynamicReferencesStore";
|
|
1290
|
+
const dbDynamicAccountStore = "dynamicAccountStore";
|
|
1291
|
+
const dbNotificationsStore = "notificationsStore";
|
|
1292
|
+
const dbPaymentsStore = "paymentsStore";
|
|
1293
|
+
const dbIndexAuth = "iAuth";
|
|
1294
|
+
const dbIndexUsers = "iUsers";
|
|
1295
|
+
const dbIndexContracts = "iContracts";
|
|
1296
|
+
const dbIndexClients = "iClients";
|
|
1297
|
+
const dbIndexBusiness = "iBusiness";
|
|
1298
|
+
const dbIndexConektaClients = "iConecktaClients";
|
|
1299
|
+
const dbIndexConektaClientsRef = "iConecktaClientsRef";
|
|
1300
|
+
const dbIndexPassportClientsRef = "iPassportClientsRef";
|
|
1301
|
+
const dbIndexNotification = "iNotification";
|
|
1302
|
+
const dbIndexPayments = "iNotification";
|
|
1303
|
+
const dateFormat = "EEEE, dd MMM yyyy";
|
|
1304
|
+
const dateCompleteFormat = "EEEE, dd MMM yyyy hh:mm aaaa";
|
|
1305
|
+
const timeFormat = "hh:mm aaaa";
|
|
1306
|
+
const expiredPayment = "expiredPayment";
|
|
1307
|
+
|
|
1308
|
+
class IndexedDbService {
|
|
1309
|
+
indexDbStatus = false;
|
|
1310
|
+
iDb;
|
|
1311
|
+
constructor() {
|
|
1312
|
+
}
|
|
1313
|
+
async dbAuthorization() {
|
|
1314
|
+
// const k = this.getLocalUser()
|
|
1315
|
+
// if (k == null) return false
|
|
1316
|
+
//
|
|
1317
|
+
// const db = await openDB(dbName, dbVersion)
|
|
1318
|
+
// // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
|
|
1319
|
+
// const auth = await db.get(dbAuthStore, k)
|
|
1320
|
+
// // utils auth = await store.get(k)
|
|
1321
|
+
// db.close()
|
|
1322
|
+
let auth = null;
|
|
1323
|
+
return auth;
|
|
1324
|
+
}
|
|
1325
|
+
async dbSignIn(store, data) {
|
|
1326
|
+
await this.iDb.put(store, data);
|
|
1327
|
+
const _data = data;
|
|
1328
|
+
this.setLocalStorage(keyUserID, _data.id);
|
|
1329
|
+
}
|
|
1330
|
+
setLocalStorage(k, v) {
|
|
1331
|
+
localStorage.setItem(k, v);
|
|
1332
|
+
}
|
|
1333
|
+
getLocalStorage(k) {
|
|
1334
|
+
return localStorage.getItem(k);
|
|
1335
|
+
}
|
|
1336
|
+
deleteLocalStorage(k) {
|
|
1337
|
+
return localStorage.removeItem(k);
|
|
1338
|
+
}
|
|
1339
|
+
getLocalUser() {
|
|
1340
|
+
const k = localStorage.getItem(keyUserID);
|
|
1341
|
+
return (k);
|
|
1342
|
+
}
|
|
1343
|
+
async getPlatformUser() {
|
|
1344
|
+
const k = this.getLocalStorage(keyUserID);
|
|
1345
|
+
if (k == null)
|
|
1346
|
+
return "";
|
|
1347
|
+
const db = await openDB(dbName, dbVersion);
|
|
1348
|
+
// utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
|
|
1349
|
+
const auth = await db.get(dbAuthStore, k);
|
|
1350
|
+
// utils auth = await store.get(k)
|
|
1351
|
+
db.close();
|
|
1352
|
+
return auth.name != "" ? auth.name : "";
|
|
1353
|
+
}
|
|
1354
|
+
async getToken() {
|
|
1355
|
+
const k = this.getLocalUser();
|
|
1356
|
+
if (k == null)
|
|
1357
|
+
return "";
|
|
1358
|
+
const db = await openDB(dbName, dbVersion);
|
|
1359
|
+
// utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
|
|
1360
|
+
const auth = await db.get(dbAuthStore, k);
|
|
1361
|
+
// utils auth = await store.get(k)
|
|
1362
|
+
db.close();
|
|
1363
|
+
return auth.access_token != "" ? auth.access_token : "";
|
|
1364
|
+
}
|
|
1365
|
+
async addObject(store, data) {
|
|
1366
|
+
try {
|
|
1367
|
+
const db = await openDB(dbName, dbVersion);
|
|
1368
|
+
await db.put(store, data);
|
|
1369
|
+
return true;
|
|
1370
|
+
}
|
|
1371
|
+
catch (e) {
|
|
1372
|
+
return false;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
async patchObject(store, data) {
|
|
1376
|
+
try {
|
|
1377
|
+
const db = await openDB(dbName, dbVersion);
|
|
1378
|
+
const txn = db.transaction(store, "readwrite");
|
|
1379
|
+
const obj = txn.objectStore(store);
|
|
1380
|
+
// const index = obj.index(keyPathCurp)
|
|
1381
|
+
await obj.put(data);
|
|
1382
|
+
return data;
|
|
1383
|
+
}
|
|
1384
|
+
catch (e) {
|
|
1385
|
+
console.error(e);
|
|
1386
|
+
return {};
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
async updateObjectByID(store, id, data) {
|
|
1390
|
+
try {
|
|
1391
|
+
const db = await openDB(dbName, dbVersion);
|
|
1392
|
+
const res = await db.get(store, id);
|
|
1393
|
+
if (res != undefined)
|
|
1394
|
+
await this.removeObject(dbClientsStore, id);
|
|
1395
|
+
return await this.addObject(store, data);
|
|
1396
|
+
}
|
|
1397
|
+
catch (e) {
|
|
1398
|
+
console.error("updateObjectByID Catch Error:", e);
|
|
1399
|
+
return false;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
async upsertObjectById(store, id, data) {
|
|
1403
|
+
const db = await openDB(dbName, dbVersion);
|
|
1404
|
+
const res = await db.get(store, id);
|
|
1405
|
+
if (res)
|
|
1406
|
+
await this.removeObject(store, id);
|
|
1407
|
+
return await db.add(store, data);
|
|
1408
|
+
}
|
|
1409
|
+
async removeObject(store, data) {
|
|
1410
|
+
const db = await openDB(dbName, dbVersion);
|
|
1411
|
+
return await db.delete(store, data);
|
|
1412
|
+
}
|
|
1413
|
+
async deleteObjectByID(store, id) {
|
|
1414
|
+
try {
|
|
1415
|
+
const db = await openDB(dbName, dbVersion);
|
|
1416
|
+
const txn = db.transaction(store, "readwrite");
|
|
1417
|
+
const obj = txn.objectStore(store);
|
|
1418
|
+
const index = obj.index(keyPathId);
|
|
1419
|
+
const va2 = index.openCursor(id);
|
|
1420
|
+
va2.then(async (cursor) => {
|
|
1421
|
+
while (cursor) {
|
|
1422
|
+
cursor.delete();
|
|
1423
|
+
cursor = await cursor.continue();
|
|
1424
|
+
}
|
|
1425
|
+
});
|
|
1426
|
+
return va2;
|
|
1427
|
+
}
|
|
1428
|
+
catch (e) {
|
|
1429
|
+
console.error(e);
|
|
1430
|
+
return {};
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
async cleanAll(store) {
|
|
1434
|
+
const db = await openDB(dbName, dbVersion);
|
|
1435
|
+
return await db.clear(store);
|
|
1436
|
+
}
|
|
1437
|
+
async getObject(store, data) {
|
|
1438
|
+
if (!data)
|
|
1439
|
+
return data;
|
|
1440
|
+
const db = await openDB(dbName, dbVersion);
|
|
1441
|
+
return await db.get(store, data);
|
|
1442
|
+
}
|
|
1443
|
+
async addBuildByStore(store, data) {
|
|
1444
|
+
for (const o of data) {
|
|
1445
|
+
const exists = await this.getObject(store, o["id"]);
|
|
1446
|
+
if (!exists)
|
|
1447
|
+
await this.addObject(store, o);
|
|
1448
|
+
else
|
|
1449
|
+
await this.updateObject(store, o);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
async updateObject(store, data) {
|
|
1453
|
+
const db = await openDB(dbName, dbVersion);
|
|
1454
|
+
await db.put(store, data);
|
|
1455
|
+
}
|
|
1456
|
+
async getAllByStore(store, index) {
|
|
1457
|
+
const db = await openDB(dbName, dbVersion);
|
|
1458
|
+
return await db.getAll(store);
|
|
1459
|
+
}
|
|
1460
|
+
async getAuthUser() {
|
|
1461
|
+
const data = await this.getAllByStore(dbAuthStore);
|
|
1462
|
+
return data[0];
|
|
1463
|
+
}
|
|
1464
|
+
async getAuthName() {
|
|
1465
|
+
const data = await this.getAuthUser();
|
|
1466
|
+
return data.name;
|
|
1467
|
+
}
|
|
1468
|
+
async getAuthUsername() {
|
|
1469
|
+
const data = await this.getAuthUser();
|
|
1470
|
+
return data.username;
|
|
1471
|
+
}
|
|
1472
|
+
async saveDataLocally(contract, client, providerData) {
|
|
1473
|
+
try {
|
|
1474
|
+
await this.addObject(dbClientsStore, client);
|
|
1475
|
+
await this.addObject(dbContractsStore, contract);
|
|
1476
|
+
if (!providerData)
|
|
1477
|
+
return false;
|
|
1478
|
+
if (contract.financial.provider === eProvider.Conekta) {
|
|
1479
|
+
await this.addObject(dbConektaClientsStore, providerData);
|
|
1480
|
+
await this.addObject(dbConektaReferencesStore, providerData);
|
|
1481
|
+
}
|
|
1482
|
+
else if (contract.financial.provider === eProvider.Passport) {
|
|
1483
|
+
await this.addObject(dbPassportReferencesStore, providerData);
|
|
1484
|
+
}
|
|
1485
|
+
else if (contract.financial.provider === eProvider.DynamiCore) {
|
|
1486
|
+
await this.addObject(dbDynamicReferencesStore, providerData);
|
|
1487
|
+
}
|
|
1488
|
+
return true;
|
|
1489
|
+
}
|
|
1490
|
+
catch (e) {
|
|
1491
|
+
console.error(e);
|
|
1492
|
+
return false;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
/******************** MERGE **************************************/
|
|
1496
|
+
async getAllClientContracts() {
|
|
1497
|
+
const clientContract = [];
|
|
1498
|
+
const clients = await this.getAllByStore(dbClientsStore);
|
|
1499
|
+
if (clients.length == 0)
|
|
1500
|
+
return [];
|
|
1501
|
+
for (let client of clients) {
|
|
1502
|
+
const contract = await this.getObject(dbContractsStore, client.contract);
|
|
1503
|
+
const e = { ...client, ...contract };
|
|
1504
|
+
// preserve the id value over concat models
|
|
1505
|
+
e.id = client.id;
|
|
1506
|
+
e.status = client.status;
|
|
1507
|
+
clientContract.push(e);
|
|
1508
|
+
}
|
|
1509
|
+
return clientContract;
|
|
1510
|
+
}
|
|
1511
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1512
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, providedIn: 'root' });
|
|
1513
|
+
}
|
|
1514
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IndexedDbService, decorators: [{
|
|
1515
|
+
type: Injectable,
|
|
1516
|
+
args: [{
|
|
1517
|
+
providedIn: 'root'
|
|
1518
|
+
}]
|
|
1519
|
+
}], ctorParameters: () => [] });
|
|
1520
|
+
|
|
1275
1521
|
/*
|
|
1276
1522
|
* Public API Surface of ravcredit-lib
|
|
1277
1523
|
*/
|
|
@@ -1280,5 +1526,5 @@ class FactoryDynamiCore {
|
|
|
1280
1526
|
* Generated bundle index. Do not edit.
|
|
1281
1527
|
*/
|
|
1282
1528
|
|
|
1283
|
-
export { FactoryBusiness, FactoryClient, FactoryContract, FactoryDynamiCore, RavcreditLibComponent, RavcreditLibService, cAddress, cAuthConfig, cBusinessConfig, cBusinessDeadlines, cBusinessInfo, cClient, cClientConekta, cClientContract, cClientDynamicStatus, cConektaRecurrent, cContract, cDefinedSchedule, cDevice, cEmptyDay, cFinancial, cIDCCharge, cIDCCustomer, cIDCDataPii, cIDCGeneratedReference, cIDCPayment, cNotification, cOptionsClientStatus, cOxxoRecurrentSources, cOxxorecurrentSourcesData, cPaymentDalay, cSchedule, cSingleOptionClientStatus, cTopic, cTyClientContract, cUserReference, eAccountDynamicStatus, eAuthActions, eAuthType, eClientDynamicStatus, eClientStatus, eConektaOrderStatus, eConektaRes, eContractSteps, eLoginStatus, eNotificationType, ePassportTypes, eProcessStatus, eProvider, eReferenceStatusRav, eRoles, eRolesSelect, snackBarConfigAction, snackBarConfigNoAction, week };
|
|
1529
|
+
export { FactoryBusiness, FactoryClient, FactoryContract, FactoryDynamiCore, IndexedDbService, RavcreditLibComponent, RavcreditLibService, cAddress, cAuthConfig, cBusinessConfig, cBusinessDeadlines, cBusinessInfo, cClient, cClientConekta, cClientContract, cClientDynamicStatus, cConektaRecurrent, cContract, cDefinedSchedule, cDevice, cEmptyDay, cFinancial, cIDCCharge, cIDCCustomer, cIDCDataPii, cIDCGeneratedReference, cIDCPayment, cNotification, cOptionsClientStatus, cOxxoRecurrentSources, cOxxorecurrentSourcesData, cPaymentDalay, cSchedule, cSingleOptionClientStatus, cTopic, cTyClientContract, cUserReference, dateCompleteFormat, dateFormat, dbAuthStore, dbBusinessConfig, dbBusinessInfo, dbClientsStore, dbConektaClientsStore, dbConektaReferencesStore, dbContractsStore, dbDynamicAccountStore, dbDynamicReferencesStore, dbIndexAuth, dbIndexBusiness, dbIndexClients, dbIndexConektaClients, dbIndexConektaClientsRef, dbIndexContracts, dbIndexNotification, dbIndexPassportClientsRef, dbIndexPayments, dbIndexUsers, dbName, dbNotificationsStore, dbPassportReferencesStore, dbPaymentsStore, dbUsersStore, dbVersion, eAccountDynamicStatus, eAuthActions, eAuthType, eClientDynamicStatus, eClientStatus, eConektaOrderStatus, eConektaRes, eContractSteps, eLoginStatus, eNotificationType, ePassportTypes, eProcessStatus, eProvider, eReferenceStatusRav, eRoles, eRolesSelect, expiredPayment, keyPathId, keyUserID, snackBarConfigAction, snackBarConfigNoAction, timeFormat, week };
|
|
1284
1530
|
//# sourceMappingURL=ravcredit-lib.mjs.map
|