ravcredit-lib 0.0.25 → 0.0.27

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 (68) hide show
  1. package/ng-package.json +7 -0
  2. package/package.json +14 -25
  3. package/src/index.d.ts +60 -0
  4. package/src/lib/ravcredit-lib.component.spec.ts +23 -0
  5. package/src/lib/ravcredit-lib.component.ts +16 -0
  6. package/src/lib/ravcredit-lib.service.spec.ts +16 -0
  7. package/src/lib/ravcredit-lib.service.ts +9 -0
  8. package/src/lib/v1/const/constants.ts +37 -0
  9. package/src/lib/v1/idb/idb.service.spec.ts +16 -0
  10. package/src/lib/v1/idb/indexed-db.service.ts +396 -0
  11. package/src/lib/v1/objects/oAddress.ts +9 -0
  12. package/src/lib/v1/objects/oBusiness.ts +93 -0
  13. package/src/lib/v1/objects/oClient.ts +46 -0
  14. package/src/lib/v1/objects/oConekta.ts +361 -0
  15. package/src/lib/v1/objects/oContract.ts +31 -0
  16. package/src/lib/v1/objects/oContractAll.ts +37 -0
  17. package/src/lib/v1/objects/oCustomer.ts +36 -0
  18. package/src/lib/v1/objects/oDevice.ts +5 -0
  19. package/src/lib/v1/objects/oFinancial.ts +32 -0
  20. package/src/lib/v1/objects/oLogIn.ts +26 -0
  21. package/src/lib/v1/objects/oNewPayment.ts +18 -0
  22. package/src/lib/v1/objects/oNotification.ts +33 -0
  23. package/src/lib/v1/objects/oPassport.ts +60 -0
  24. package/src/lib/v1/objects/oUser.ts +35 -0
  25. package/src/lib/v1/objects/oVerification.ts +79 -0
  26. package/src/lib/v1/util/UtilBusiness.ts +187 -0
  27. package/src/lib/v1/util/UtilClient.ts +300 -0
  28. package/src/lib/v1/util/UtilConekta.ts +97 -0
  29. package/src/lib/v1/util/UtilContract.ts +430 -0
  30. package/src/lib/v1/util/UtilDashboard.ts +19 -0
  31. package/src/lib/v1/util/UtilDynamiCore.ts +752 -0
  32. package/src/lib/v1/util/UtilNotification.ts +46 -0
  33. package/src/lib/v1/util/UtilPassport.ts +33 -0
  34. package/src/lib/v1/util/UtilPayment.ts +22 -0
  35. package/src/lib/v1/util/UtilTime.ts +179 -0
  36. package/src/lib/v1/util/UtilsHttp.ts +25 -0
  37. package/src/lib/v2/constant/constants.ts +125 -0
  38. package/src/lib/v2/constant/messages.ts +28 -0
  39. package/src/lib/v2/enum/EnumAsset.ts +4 -0
  40. package/src/lib/v2/enum/EnumAuth.ts +29 -0
  41. package/src/lib/v2/enum/EnumClient.ts +7 -0
  42. package/src/lib/v2/enum/EnumConekta.ts +14 -0
  43. package/src/lib/v2/enum/EnumDynamic.ts +8 -0
  44. package/src/lib/v2/enum/EnumNotification.ts +1 -0
  45. package/src/lib/v2/enum/EnumPassport.ts +4 -0
  46. package/src/lib/v2/enum/EnumPayment.ts +5 -0
  47. package/src/lib/v2/enum/EnumRoles.ts +7 -0
  48. package/src/lib/v2/enum/EnumToken.ts +11 -0
  49. package/src/lib/v2/enum/EnumUtil.ts +22 -0
  50. package/src/lib/v2/enum/EnumVerification.ts +22 -0
  51. package/src/lib/v2/objects/oAsset.ts +44 -0
  52. package/src/lib/v2/objects/oAws.ts +8 -0
  53. package/src/lib/v2/objects/oCatalog.ts +6 -0
  54. package/src/lib/v2/objects/oClient.ts +36 -0
  55. package/src/lib/v2/objects/oCompany.ts +10 -0
  56. package/src/lib/v2/objects/oContract.ts +10 -0
  57. package/src/lib/v2/objects/oHttp.ts +33 -0
  58. package/src/lib/v2/objects/oMediaDto.ts +10 -0
  59. package/src/lib/v2/objects/oMessaging.ts +10 -0
  60. package/src/lib/v2/objects/oScoreDto.ts +38 -0
  61. package/src/lib/v2/objects/oUtil.ts +68 -0
  62. package/src/public-api.ts +66 -0
  63. package/tsconfig.lib.json +15 -0
  64. package/tsconfig.lib.prod.json +11 -0
  65. package/tsconfig.spec.json +15 -0
  66. package/fesm2022/ravcredit-lib.mjs +0 -2181
  67. package/fesm2022/ravcredit-lib.mjs.map +0 -1
  68. package/index.d.ts +0 -1880
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/ravcredit-lib",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,25 +1,14 @@
1
- {
2
- "name": "ravcredit-lib",
3
- "version": "0.0.25",
4
- "types": "./index.d.ts",
5
- "peerDependencies": {
6
- "@angular/common": "^20.0.0",
7
- "@angular/core": "^20.0.0",
8
- "idb": "^8.0.3"
9
- },
10
- "dependencies": {
11
- "tslib": "^2.3.0"
12
- },
13
- "sideEffects": false,
14
- "module": "fesm2022/ravcredit-lib.mjs",
15
- "typings": "index.d.ts",
16
- "exports": {
17
- "./package.json": {
18
- "default": "./package.json"
19
- },
20
- ".": {
21
- "types": "./index.d.ts",
22
- "default": "./fesm2022/ravcredit-lib.mjs"
23
- }
24
- }
25
- }
1
+ {
2
+ "name": "ravcredit-lib",
3
+ "version": "0.0.27",
4
+ "types": "./index.d.ts",
5
+ "peerDependencies": {
6
+ "@angular/common": "^20.0.0",
7
+ "@angular/core": "^20.0.0",
8
+ "idb": "^8.0.3"
9
+ },
10
+ "dependencies": {
11
+ "tslib": "^2.3.0"
12
+ },
13
+ "sideEffects": false
14
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ /*
2
+ * Public API Surface of ravcredit-lib
3
+ */
4
+
5
+ export * from './lib/ravcredit-lib.service';
6
+ export * from './lib/ravcredit-lib.component';
7
+ export * from './lib/v1/objects/oAddress';
8
+ export * from './lib/v1/objects/oBusiness';
9
+ export * from './lib/v1/objects/oClient';
10
+ export * from './lib/v1/objects/oConekta';
11
+ export * from './lib/v1/objects/oContract';
12
+ export * from './lib/v1/objects/oContractAll';
13
+ export * from './lib/v1/objects/oCustomer';
14
+ export * from './lib/v1/objects/oDevice';
15
+ export * from './lib/v1/objects/oFinancial';
16
+ export * from './lib/v1/objects/oLogIn';
17
+ export * from './lib/v1/objects/oNewPayment';
18
+ export * from './lib/v1/objects/oNotification';
19
+ export * from './lib/v1/objects/oPassport';
20
+ export * from './lib/v1/objects/oUser';
21
+ export * from './lib/v1/objects/oVerification';
22
+
23
+ export * from './lib/v1/util/UtilClient';
24
+ export * from './lib/v1/util/UtilsHttp'
25
+ export * from './lib/v1/util/UtilBusiness';
26
+ export * from './lib/v1/util/UtilDynamiCore';
27
+ export * from './lib/v1/util/UtilContract';
28
+ export * from './lib/v1/util/UtilConekta';
29
+ export * from './lib/v1/util/UtilNotification';
30
+ export * from './lib/v1/util/UtilTime';
31
+ export * from './lib/v1/util/UtilDashboard';
32
+ export * from './lib/v1/util/UtilPassport';
33
+ export * from './lib/v1/util/UtilPayment';
34
+
35
+ export * from './lib/v1/idb/indexed-db.service';
36
+ export * from './lib/v1/const/constants';
37
+
38
+ export * from './lib/v2/constant/constants';
39
+ export * from './lib/v2/constant/messages';
40
+
41
+ export * from './lib/v2/objects/oAws';
42
+ export * from './lib/v2/objects/oCatalog';
43
+ export * from './lib/v2/objects/oContract';
44
+ export * from './lib/v2/objects/oAsset';
45
+ export * from './lib/v2/objects/oCompany';
46
+ export * from './lib/v2/objects/oScoreDto';
47
+ export * from './lib/v2/objects/oMediaDto';
48
+
49
+ export * from './lib/v2/objects/oUtil';
50
+ export * from './lib/v2/objects/oHttp';
51
+
52
+ export * from './lib/v2/enum/EnumAsset';
53
+ export * from './lib/v2/enum/EnumAuth';
54
+ export * from './lib/v2/enum/EnumClient';
55
+ export * from './lib/v2/enum/EnumConekta';
56
+ export * from './lib/v2/enum/EnumNotification';
57
+ export * from './lib/v2/enum/EnumPassport';
58
+ export * from './lib/v2/enum/EnumRoles';
59
+ export * from './lib/v2/enum/EnumUtil';
60
+ export * from './lib/v2/enum/EnumVerification';
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { RavcreditLibComponent } from './ravcredit-lib.component';
4
+
5
+ describe('RavcreditLibComponent', () => {
6
+ let component: RavcreditLibComponent;
7
+ let fixture: ComponentFixture<RavcreditLibComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [RavcreditLibComponent]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(RavcreditLibComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,16 @@
1
+ import { Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'lib-ravcredit-lib',
5
+ standalone: true,
6
+ imports: [],
7
+ template: `
8
+ <p>
9
+ ravcredit-lib works!
10
+ </p>
11
+ `,
12
+ styles: ``
13
+ })
14
+ export class RavcreditLibComponent {
15
+
16
+ }
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { RavcreditLibService } from './ravcredit-lib.service';
4
+
5
+ describe('RavcreditLibService', () => {
6
+ let service: RavcreditLibService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(RavcreditLibService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,9 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ @Injectable({
4
+ providedIn: 'root'
5
+ })
6
+ export class RavcreditLibService {
7
+
8
+ constructor() { }
9
+ }
@@ -0,0 +1,37 @@
1
+ export const keyUserID: string = "rc_uid"
2
+ export const dbVersion: number = 1
3
+ export const dbName: string = "RavCreditDB"
4
+ export const keyPathId: string = "id"
5
+
6
+ export const dbAuthStore: string = "authStore"
7
+ export const dbUsersStore: string = "usersStore"
8
+ export const dbContractsStore: string = "contractsStore"
9
+ export const dbClientsStore: string = "clientsStore"
10
+ export const dbBusinessInfo: string = "businessInfo"
11
+ export const dbBusinessConfig: string = "businessConfig"
12
+ export const dbConektaClientsStore: string = "conektaClientsStore"
13
+ export const dbConektaReferencesStore: string = "conektaReferencesStore"
14
+ export const dbPassportReferencesStore: string = "passportReferencesStore"
15
+ export const dbDynamicReferencesStore: string = "dynamicReferencesStore"
16
+ export const dbDynamicAccountStore: string = "dynamicAccountStore"
17
+ export const dbNotificationsStore: string = "notificationsStore"
18
+ export const dbPaymentsStore: string = "paymentsStore"
19
+
20
+ export const dbIndexAuth: string = "iAuth"
21
+ export const dbIndexUsers: string = "iUsers"
22
+ export const dbIndexContracts: string = "iContracts"
23
+ export const dbIndexClients: string = "iClients"
24
+ export const dbIndexBusiness: string = "iBusiness"
25
+ export const dbIndexConektaClients: string = "iConecktaClients"
26
+ export const dbIndexConektaClientsRef: string = "iConecktaClientsRef"
27
+ export const dbIndexPassportClientsRef: string = "iPassportClientsRef"
28
+ export const dbIndexNotification: string = "iNotification"
29
+ export const dbIndexPayments: string = "iNotification"
30
+
31
+ export const dateFormat = "EEEE, dd MMM yyyy"
32
+ export const dateCompleteFormat = "EEEE, dd MMM yyyy hh:mm aaaa"
33
+ export const timeFormat = "hh:mm aaaa"
34
+
35
+ export const expiredPayment = "expiredPayment"
36
+
37
+ export const ROLES_KEY = 'roles';
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { IndexedDbService } from './indexed-db.service';
4
+
5
+ describe('IdbService', () => {
6
+ let service: IndexedDbService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(IndexedDbService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,396 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { oUser } from '../objects/oUser';
3
+ import {IDBPDatabase, openDB} from 'idb';
4
+ import {
5
+ dbAuthStore, dbBusinessConfig, dbBusinessInfo,
6
+ dbClientsStore,
7
+ dbConektaClientsStore, dbConektaReferencesStore,
8
+ dbContractsStore, dbDynamicReferencesStore,
9
+ dbName, dbNotificationsStore, dbPassportReferencesStore,
10
+ dbVersion,
11
+ keyPathId,
12
+ keyUserID
13
+ } from '../const/constants';
14
+ import {oClient} from '../objects/oClient';
15
+ import {oContract} from '../objects/oContract';
16
+ import {eProvider} from '../util/UtilContract';
17
+ import {oBusinessConfig, oBusinessInfo} from '../objects/oBusiness';
18
+ import {oNotification} from '../objects/oNotification';
19
+ import { tyClientContract } from "../../v2/objects/oUtil";
20
+
21
+ @Injectable({
22
+ providedIn: 'root'
23
+ })
24
+ export class IndexedDbService {
25
+
26
+ indexDbStatus = false
27
+ iDb!: IDBPDatabase<unknown>
28
+
29
+ constructor() {
30
+ }
31
+
32
+ // async dbAuthorization() {
33
+ // // constant k = this.getLocalUser()
34
+ // // if (k == null) return false
35
+ // //
36
+ // // constant db = await openDB(dbName, dbVersion)
37
+ // // // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
38
+ // // constant auth = await db.get(dbAuthStore, k)
39
+ // // // utils auth = await store.get(k)
40
+ // // db.close()
41
+ //
42
+ // let auth: any = null
43
+ // return auth;
44
+ //
45
+ // }
46
+
47
+ /****************** SIMPLE Transactional - CRUD *************************************/
48
+
49
+ async dbGetObject<T>(store: string, data: any): Promise<T> {
50
+ if (!data) return data
51
+ const db = await openDB(dbName, dbVersion)
52
+ return await db.get(store, data) as T
53
+ }
54
+
55
+ async dbGetAllByStore<T>(store: string, index?: string) {
56
+ const db = await openDB(dbName, dbVersion)
57
+ return await db.getAll(store) as T
58
+ }
59
+
60
+ async dbAddObject<T>(store: string, data: any): Promise<boolean> {
61
+ try {
62
+ const db = await openDB(dbName, dbVersion)
63
+ await db.put(store, data)
64
+ return true
65
+ } catch (e) {
66
+ return false
67
+ }
68
+ }
69
+
70
+ async dbRemoveObject<T>(store: string, data: any): Promise<T> {
71
+ const db = await openDB(dbName, dbVersion)
72
+ return await db.delete(store, data) as T
73
+ }
74
+
75
+ /************************************* AUTH **************************************/
76
+
77
+ async dbSignIn(store: string, data: any) {
78
+ await this.iDb.put(store, data)
79
+ const _data = data as oUser
80
+ this.setLocalStorage(keyUserID, _data.id)
81
+ }
82
+
83
+ async dbSignOut() {
84
+
85
+ const k = this.getLocalUser()
86
+ if (!k) return
87
+
88
+ await this.iDb.delete(dbAuthStore, k)
89
+ this.removeLocalStorage(keyUserID)
90
+ }
91
+
92
+ async dbAuthorization() {
93
+ const k = this.getLocalUser()
94
+ if (k == null) return false
95
+
96
+ const db = await openDB(dbName, dbVersion)
97
+ // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
98
+ const auth = await db.get(dbAuthStore, k)
99
+ // utils auth = await store.get(k)
100
+ db.close()
101
+
102
+ if (!auth) return false
103
+ else return true
104
+ }
105
+
106
+ async dbGetToken() {
107
+ const k = this.getLocalUser()
108
+ if (k == null) return ""
109
+
110
+ const db = await openDB(dbName, dbVersion)
111
+ // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
112
+ const auth = await db.get(dbAuthStore, k) as oUser
113
+ // utils auth = await store.get(k)
114
+
115
+ db.close()
116
+ return auth.access_token != "" ? auth.access_token : ""
117
+ }
118
+
119
+ /******************************** Local Storage *************************************/
120
+
121
+ setLocalStorage(k: string, v: string) {
122
+ localStorage.setItem(k, v)
123
+ }
124
+
125
+ getLocalStorage<T>(k: string) {
126
+ return localStorage.getItem(k) as T
127
+ }
128
+
129
+ removeLocalStorage(k: string) {
130
+ return localStorage.removeItem(k)
131
+ }
132
+
133
+ getLocalUser(): string | null {
134
+ const k = localStorage.getItem(keyUserID)
135
+ return (k)
136
+ }
137
+
138
+ /********************************************************************************* **/
139
+
140
+ async getPlatformUser() {
141
+ const k = this.getLocalStorage<string>(keyUserID) as string
142
+ if (k == null) return ""
143
+
144
+ const db = await openDB(dbName, dbVersion)
145
+ // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
146
+ const auth = await db.get(dbAuthStore, k) as oUser
147
+ // utils auth = await store.get(k)
148
+
149
+ db.close()
150
+ return auth.name != "" ? auth.name : ""
151
+ }
152
+
153
+ async getToken() {
154
+ const k = this.getLocalUser()
155
+ if (k == null) return ""
156
+
157
+ const db = await openDB(dbName, dbVersion)
158
+ // utils store = db.transaction(dbUsersStore).objectStore(dbUsersStore)
159
+ const auth = await db.get(dbAuthStore, k) as oUser
160
+ // utils auth = await store.get(k)
161
+
162
+ db.close()
163
+ return auth.access_token != "" ? auth.access_token : ""
164
+ }
165
+
166
+ async addObject<T>(store: string, data: any): Promise<boolean> {
167
+ try {
168
+ const db = await openDB(dbName, dbVersion)
169
+ await db.put(store, data)
170
+ return true
171
+ } catch (e) {
172
+ return false
173
+ }
174
+ }
175
+
176
+ async patchObject<T>(store: string, data: any): Promise<T> {
177
+ try {
178
+ const db = await openDB(dbName, dbVersion)
179
+ const txn = db.transaction(store, "readwrite")
180
+ const obj = txn.objectStore(store)
181
+ // constant index = obj.index(keyPathCurp)
182
+ await obj.put(data)
183
+ return data as T
184
+ } catch (e) {
185
+ console.error(e)
186
+ return {} as T
187
+ }
188
+ }
189
+
190
+ async updateObjectByID<T>(store: string, id: string, data: T): Promise<boolean> {
191
+ try {
192
+
193
+ const db = await openDB(dbName, dbVersion)
194
+ const res = await db.get(store, id) as oClient
195
+
196
+ if (res != undefined) await this.removeObject(dbClientsStore, id)
197
+
198
+ return await this.addObject(store, data)
199
+
200
+ } catch (e) {
201
+ console.error("updateObjectByID Catch Error:", e)
202
+ return false
203
+ }
204
+ }
205
+
206
+ async upsertObjectById<T>(store: string, id: string, data: T) {
207
+
208
+ const db = await openDB(dbName, dbVersion)
209
+ const res = await db.get(store, id)
210
+
211
+ if (res) await this.removeObject<T>(store, id)
212
+
213
+ return await db.add(store, data)
214
+ }
215
+
216
+ async removeObject<T>(store: string, data: any): Promise<T> {
217
+ const db = await openDB(dbName, dbVersion)
218
+ return await db.delete(store, data) as T
219
+ }
220
+
221
+ async deleteObjectByID<T>(store: string, id: string) {
222
+ try {
223
+ const db = await openDB(dbName, dbVersion)
224
+ const txn = db.transaction(store, "readwrite")
225
+ const obj = txn.objectStore(store)
226
+ const index = obj.index(keyPathId)
227
+ const va2 = index.openCursor(id)
228
+ va2.then(async cursor => {
229
+ while (cursor) {
230
+ cursor.delete();
231
+ cursor = await cursor.continue();
232
+ }
233
+ })
234
+ return va2
235
+ } catch (e) {
236
+ console.error(e)
237
+ return {} as T
238
+ }
239
+ }
240
+
241
+ async cleanAll<T>(store: string) {
242
+ const db = await openDB(dbName, dbVersion)
243
+ return await db.clear(store)
244
+ }
245
+
246
+ async getObject<T>(store: string, data: any): Promise<T> {
247
+ if (!data) return data
248
+ const db = await openDB(dbName, dbVersion)
249
+ return await db.get(store, data) as T
250
+ }
251
+
252
+ async addBuildByStore(store: string, data: any[]) {
253
+ for (const o of data) {
254
+ const exists = await this.getObject(store, o["id"])
255
+ if (!exists) await this.addObject(store, o)
256
+ else await this.updateObject(store, o)
257
+ }
258
+ }
259
+
260
+ async updateObject<T>(store: string, data: any) {
261
+ const db = await openDB(dbName, dbVersion)
262
+ await db.put(store, data)
263
+ }
264
+
265
+ async getAllByStore<T>(store: string, index?: string) {
266
+ const db = await openDB(dbName, dbVersion)
267
+ return await db.getAll(store) as T
268
+ }
269
+
270
+ async getAuthUser() {
271
+ const data = await this.getAllByStore<oUser[]>(dbAuthStore)
272
+ return data[0]
273
+ }
274
+
275
+ async getAuthName() {
276
+ const data = await this.getAuthUser()
277
+ return data.name
278
+ }
279
+
280
+ async getAuthUsername() {
281
+ const data = await this.getAuthUser()
282
+ return data.username
283
+ }
284
+
285
+ async saveDataLocally<T>(
286
+ contract: oContract,
287
+ client: oClient,
288
+ providerData: T,
289
+ ): Promise<boolean> {
290
+ try {
291
+ await this.addObject(dbClientsStore, client)
292
+ await this.addObject(dbContractsStore, contract)
293
+
294
+ if (!providerData) return false
295
+
296
+ if (contract.financial.provider === eProvider.Conekta) {
297
+ await this.addObject(dbConektaClientsStore, providerData)
298
+ await this.addObject(dbConektaReferencesStore, providerData)
299
+ } else if (contract.financial.provider === eProvider.Passport) {
300
+ await this.addObject(dbPassportReferencesStore, providerData)
301
+ } else if (contract.financial.provider === eProvider.DynamiCore) {
302
+ await this.addObject(dbDynamicReferencesStore, providerData)
303
+ }
304
+ return true
305
+ } catch (e) {
306
+ console.error(e)
307
+ return false
308
+ }
309
+ }
310
+
311
+ /******************** MERGE **************************************/
312
+ async getAllClientContracts(): Promise<tyClientContract[]> {
313
+ const clientContract: tyClientContract[] = []
314
+ const clients = await this.getAllByStore<oClient[]>(dbClientsStore)
315
+ if (clients.length == 0) return []
316
+
317
+ for (let client of clients) {
318
+ const contract = await this.getObject<oContract>(dbContractsStore, client.contract)
319
+ const e = {...client, ...contract}
320
+ // preserve the id value over concat models
321
+ e.id = client.id
322
+ e.status = client.status
323
+ clientContract.push(e)
324
+ }
325
+ return clientContract
326
+ }
327
+
328
+ /******************** MERGE **************************************/
329
+
330
+ async dbGetAllClientContracts(): Promise<tyClientContract[]> {
331
+ const clientContract: tyClientContract[] = []
332
+ const clients = await this.dbGetAllByStore<oClient[]>(dbClientsStore)
333
+ if (clients.length == 0) return []
334
+
335
+ for (let client of clients) {
336
+ const contract = await this.dbGetObject<oContract>(dbContractsStore, client.contract)
337
+ const e = {...client, ...contract}
338
+ // preserve the id value over concat models
339
+ e.id = client.id
340
+ e.status = client.status
341
+ clientContract.push(e)
342
+ }
343
+ return clientContract
344
+ }
345
+
346
+ /****************** BUSINESS INFO *************************************/
347
+
348
+ async getBusinessInfo(): Promise<oBusinessInfo | null> {
349
+ const config: oBusinessInfo[] = await this.dbGetAllByStore<oBusinessInfo[]>(dbBusinessInfo)
350
+
351
+ if (!config) return null
352
+
353
+ return config[0]
354
+ }
355
+
356
+ /****************** BUSINESS CONFIG ************************************/
357
+
358
+ async getBusinessConfig(): Promise<oBusinessConfig | null> {
359
+ const config: oBusinessConfig[] = await this.dbGetAllByStore<oBusinessConfig[]>(dbBusinessConfig)
360
+
361
+ if (!config) return null
362
+
363
+ return config[0]
364
+ }
365
+
366
+ async updateBusinessConfig(config: oBusinessConfig) {
367
+
368
+ // config.version = "1.0"
369
+ await this.dbRemoveObject(dbBusinessConfig, "1.0")
370
+ await this.dbAddObject(dbBusinessConfig, config)
371
+ }
372
+
373
+ async updateBusinessInfo(config: oBusinessInfo) {
374
+
375
+ config.version = "v2024"
376
+ await this.dbRemoveObject(dbBusinessInfo, "v2024")
377
+ await this.dbAddObject(dbBusinessInfo, config)
378
+ }
379
+
380
+ /**************** NOTIFICATIONS *********************************/
381
+
382
+ async getLocalNotifications(): Promise<oNotification[] | null> {
383
+ const notifications: oNotification[] = await this.dbGetAllByStore<oNotification[]>(dbNotificationsStore)
384
+ if (!notifications) return null
385
+ return notifications
386
+ }
387
+
388
+ async updateNotifications(notifications: oNotification[]) {
389
+ for (const o of notifications) {
390
+ const exists = await this.dbGetObject(dbNotificationsStore, o.notification_id)
391
+ if (!exists) {
392
+ await this.dbAddObject(dbNotificationsStore, o)
393
+ }
394
+ }
395
+ }
396
+ }
@@ -0,0 +1,9 @@
1
+ export interface oAddress {
2
+ street: string,
3
+ city: string,
4
+ neighbor: string,
5
+ zip: string,
6
+ ext: string,
7
+ int: string,
8
+ state: string,
9
+ }