@sankhyalabs/core-docs 5.10.1 → 5.11.0-dev.1

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.
@@ -52,7 +52,7 @@ Realiza correção do horário de verão.
52
52
 
53
53
  #### Defined in
54
54
 
55
- src/utils/DateUtils.ts:138
55
+ src/utils/DateUtils.ts:136
56
56
 
57
57
  ___
58
58
 
@@ -83,7 +83,7 @@ Informo: 2023-03-09 12:42:40 | Obtenho: 2023-03-09 00:00:00
83
83
 
84
84
  #### Defined in
85
85
 
86
- src/utils/DateUtils.ts:17
86
+ src/utils/DateUtils.ts:15
87
87
 
88
88
  ___
89
89
 
@@ -108,7 +108,7 @@ Converte data para uma string no formato pt-BR.
108
108
 
109
109
  #### Defined in
110
110
 
111
- src/utils/DateUtils.ts:29
111
+ src/utils/DateUtils.ts:27
112
112
 
113
113
  ___
114
114
 
@@ -133,7 +133,7 @@ Converte a data e hora para uma string no formato pt-BR.
133
133
 
134
134
  #### Defined in
135
135
 
136
- src/utils/DateUtils.ts:55
136
+ src/utils/DateUtils.ts:53
137
137
 
138
138
  ___
139
139
 
@@ -164,7 +164,7 @@ Informo: 2023-03-09 12:42:40 | Obtenho: 2023-03-09T12:42:47-03:00
164
164
 
165
165
  #### Defined in
166
166
 
167
- src/utils/DateUtils.ts:188
167
+ src/utils/DateUtils.ts:186
168
168
 
169
169
  ___
170
170
 
@@ -189,7 +189,7 @@ Converte as horas de uma data para uma string pt-BR.
189
189
 
190
190
  #### Defined in
191
191
 
192
- src/utils/DateUtils.ts:43
192
+ src/utils/DateUtils.ts:41
193
193
 
194
194
  ___
195
195
 
@@ -213,7 +213,7 @@ Obtém a data atual.
213
213
 
214
214
  #### Defined in
215
215
 
216
- src/utils/DateUtils.ts:109
216
+ src/utils/DateUtils.ts:107
217
217
 
218
218
  ___
219
219
 
@@ -249,7 +249,7 @@ Informo: 2 | Obtenho: "02"
249
249
 
250
250
  #### Defined in
251
251
 
252
- src/utils/DateUtils.ts:157
252
+ src/utils/DateUtils.ts:155
253
253
 
254
254
  ___
255
255
 
@@ -275,7 +275,7 @@ Converte String para Date.
275
275
 
276
276
  #### Defined in
277
277
 
278
- src/utils/DateUtils.ts:67
278
+ src/utils/DateUtils.ts:65
279
279
 
280
280
  ___
281
281
 
@@ -299,7 +299,7 @@ Timezone da data.
299
299
 
300
300
  #### Defined in
301
301
 
302
- src/utils/DateUtils.ts:167
302
+ src/utils/DateUtils.ts:165
303
303
 
304
304
  ___
305
305
 
@@ -324,4 +324,4 @@ Retorna se a data é válida.
324
324
 
325
325
  #### Defined in
326
326
 
327
- src/utils/DateUtils.ts:126
327
+ src/utils/DateUtils.ts:124
@@ -0,0 +1,87 @@
1
+ [@sankhyalabs/core](../README.md) / [Exports](../modules.md) / FieldComparator
2
+
3
+ # Class: FieldComparator
4
+
5
+ ## Table of contents
6
+
7
+ ### Constructors
8
+
9
+ - [constructor](FieldComparator.md#constructor)
10
+
11
+ ### Methods
12
+
13
+ - [compare](FieldComparator.md#compare)
14
+ - [compareUndefined](FieldComparator.md#compareundefined)
15
+ - [compareValues](FieldComparator.md#comparevalues)
16
+
17
+ ## Constructors
18
+
19
+ ### constructor
20
+
21
+ • **new FieldComparator**()
22
+
23
+ ## Methods
24
+
25
+ ### compare
26
+
27
+ ▸ `Static` **compare**(`field`, `recordA`, `recordB`, `asc?`): `number`
28
+
29
+ #### Parameters
30
+
31
+ | Name | Type | Default value |
32
+ | :------ | :------ | :------ |
33
+ | `field` | [`FieldDescriptor`](../interfaces/FieldDescriptor.md) | `undefined` |
34
+ | `recordA` | [`Record`](../interfaces/Record.md) | `undefined` |
35
+ | `recordB` | [`Record`](../interfaces/Record.md) | `undefined` |
36
+ | `asc` | `boolean` | `true` |
37
+
38
+ #### Returns
39
+
40
+ `number`
41
+
42
+ #### Defined in
43
+
44
+ src/dataunit/sorting/FieldComparator.ts:7
45
+
46
+ ___
47
+
48
+ ### compareUndefined
49
+
50
+ ▸ `Static` `Private` **compareUndefined**(`isUndefinedA`, `isUndefinedB`): `undefined` \| `number`
51
+
52
+ #### Parameters
53
+
54
+ | Name | Type |
55
+ | :------ | :------ |
56
+ | `isUndefinedA` | `boolean` |
57
+ | `isUndefinedB` | `boolean` |
58
+
59
+ #### Returns
60
+
61
+ `undefined` \| `number`
62
+
63
+ #### Defined in
64
+
65
+ src/dataunit/sorting/FieldComparator.ts:25
66
+
67
+ ___
68
+
69
+ ### compareValues
70
+
71
+ ▸ `Static` **compareValues**(`descriptor`, `valueA`, `valueB`): `number`
72
+
73
+ #### Parameters
74
+
75
+ | Name | Type |
76
+ | :------ | :------ |
77
+ | `descriptor` | [`FieldDescriptor`](../interfaces/FieldDescriptor.md) |
78
+ | `valueA` | `any` |
79
+ | `valueB` | `any` |
80
+
81
+ #### Returns
82
+
83
+ `number`
84
+
85
+ #### Defined in
86
+
87
+ src/dataunit/sorting/FieldComparator.ts:21
@@ -0,0 +1,518 @@
1
+ [@sankhyalabs/core](../README.md) / [Exports](../modules.md) / IDBRepository
2
+
3
+ # Class: IDBRepository<T\>
4
+
5
+ Abstração para simplificar o uso do indexed DB
6
+
7
+ Além de facilitar os comandos de incluir, remover alterar e obter
8
+ objetos, esse repositório preserva a ordem de inserção na lista,
9
+ além de permitir filtros e ordenações compostas
10
+ (impossíveis com uso de índices).
11
+
12
+ ## Type parameters
13
+
14
+ | Name |
15
+ | :------ |
16
+ | `T` |
17
+
18
+ ## Implements
19
+
20
+ - [`IRepository`](../interfaces/IRepository.md)<`T`\>
21
+
22
+ ## Table of contents
23
+
24
+ ### Constructors
25
+
26
+ - [constructor](IDBRepository.md#constructor)
27
+
28
+ ### Properties
29
+
30
+ - [\_addedStoreName](IDBRepository.md#_addedstorename)
31
+ - [\_db](IDBRepository.md#_db)
32
+ - [\_dbName](IDBRepository.md#_dbname)
33
+ - [\_dbVersion](IDBRepository.md#_dbversion)
34
+ - [\_indexKeyPath](IDBRepository.md#_indexkeypath)
35
+ - [\_indexes](IDBRepository.md#_indexes)
36
+ - [\_operating](IDBRepository.md#_operating)
37
+ - [\_storeName](IDBRepository.md#_storename)
38
+
39
+ ### Methods
40
+
41
+ - [clear](IDBRepository.md#clear)
42
+ - [count](IDBRepository.md#count)
43
+ - [createStore](IDBRepository.md#createstore)
44
+ - [delete](IDBRepository.md#delete)
45
+ - [distict](IDBRepository.md#distict)
46
+ - [getAddedItems](IDBRepository.md#getaddeditems)
47
+ - [getItemPosition](IDBRepository.md#getitemposition)
48
+ - [getItemPositionByAdded](IDBRepository.md#getitempositionbyadded)
49
+ - [insert](IDBRepository.md#insert)
50
+ - [isEmpty](IDBRepository.md#isempty)
51
+ - [isOperating](IDBRepository.md#isoperating)
52
+ - [load](IDBRepository.md#load)
53
+ - [openDB](IDBRepository.md#opendb)
54
+ - [push](IDBRepository.md#push)
55
+ - [update](IDBRepository.md#update)
56
+
57
+ ## Constructors
58
+
59
+ ### constructor
60
+
61
+ • **new IDBRepository**<`T`\>(`dbName`, `dbVersion`, `storeName`, `indexKeyPath`, `indexes?`)
62
+
63
+ Construtor padrão
64
+
65
+ #### Type parameters
66
+
67
+ | Name |
68
+ | :------ |
69
+ | `T` |
70
+
71
+ #### Parameters
72
+
73
+ | Name | Type | Description |
74
+ | :------ | :------ | :------ |
75
+ | `dbName` | `string` | Nome do DB |
76
+ | `dbVersion` | `number` | Versão do DB |
77
+ | `storeName` | `string` | Nome da store |
78
+ | `indexKeyPath` | `string` | Um atributo que identifique os objetos guardados |
79
+ | `indexes?` | [`IRepositoryIndex`](../interfaces/IRepositoryIndex.md)[] | - |
80
+
81
+ #### Defined in
82
+
83
+ src/repository/indexeddb/IDBRepository.ts:35
84
+
85
+ ## Properties
86
+
87
+ ### \_addedStoreName
88
+
89
+ • `Private` **\_addedStoreName**: `string`
90
+
91
+ #### Defined in
92
+
93
+ src/repository/indexeddb/IDBRepository.ts:21
94
+
95
+ ___
96
+
97
+ ### \_db
98
+
99
+ • `Private` `Optional` **\_db**: `IDBPDatabase`<`unknown`\>
100
+
101
+ #### Defined in
102
+
103
+ src/repository/indexeddb/IDBRepository.ts:24
104
+
105
+ ___
106
+
107
+ ### \_dbName
108
+
109
+ • `Private` **\_dbName**: `string`
110
+
111
+ #### Defined in
112
+
113
+ src/repository/indexeddb/IDBRepository.ts:18
114
+
115
+ ___
116
+
117
+ ### \_dbVersion
118
+
119
+ • `Private` **\_dbVersion**: `number`
120
+
121
+ #### Defined in
122
+
123
+ src/repository/indexeddb/IDBRepository.ts:19
124
+
125
+ ___
126
+
127
+ ### \_indexKeyPath
128
+
129
+ • `Private` **\_indexKeyPath**: `string`
130
+
131
+ #### Defined in
132
+
133
+ src/repository/indexeddb/IDBRepository.ts:22
134
+
135
+ ___
136
+
137
+ ### \_indexes
138
+
139
+ • `Private` `Optional` **\_indexes**: [`IRepositoryIndex`](../interfaces/IRepositoryIndex.md)[]
140
+
141
+ #### Defined in
142
+
143
+ src/repository/indexeddb/IDBRepository.ts:23
144
+
145
+ ___
146
+
147
+ ### \_operating
148
+
149
+ • `Private` **\_operating**: `boolean` = `true`
150
+
151
+ #### Defined in
152
+
153
+ src/repository/indexeddb/IDBRepository.ts:25
154
+
155
+ ___
156
+
157
+ ### \_storeName
158
+
159
+ • `Private` **\_storeName**: `string`
160
+
161
+ #### Defined in
162
+
163
+ src/repository/indexeddb/IDBRepository.ts:20
164
+
165
+ ## Methods
166
+
167
+ ### clear
168
+
169
+ ▸ **clear**(): `Promise`<`void`\>
170
+
171
+ Limpa todo o repositório
172
+
173
+ #### Returns
174
+
175
+ `Promise`<`void`\>
176
+
177
+ Promessa de execução
178
+
179
+ #### Implementation of
180
+
181
+ [IRepository](../interfaces/IRepository.md).[clear](../interfaces/IRepository.md#clear)
182
+
183
+ #### Defined in
184
+
185
+ src/repository/indexeddb/IDBRepository.ts:123
186
+
187
+ ___
188
+
189
+ ### count
190
+
191
+ ▸ **count**(): `Promise`<`number`\>
192
+
193
+ Conta os itens do repositório
194
+
195
+ #### Returns
196
+
197
+ `Promise`<`number`\>
198
+
199
+ Promessa de quantidade
200
+
201
+ #### Implementation of
202
+
203
+ [IRepository](../interfaces/IRepository.md).[count](../interfaces/IRepository.md#count)
204
+
205
+ #### Defined in
206
+
207
+ src/repository/indexeddb/IDBRepository.ts:236
208
+
209
+ ___
210
+
211
+ ### createStore
212
+
213
+ ▸ `Private` **createStore**(`db`, `name`, `indexPrefix?`): `void`
214
+
215
+ #### Parameters
216
+
217
+ | Name | Type | Default value |
218
+ | :------ | :------ | :------ |
219
+ | `db` | `IDBPDatabase`<`unknown`\> | `undefined` |
220
+ | `name` | `string` | `undefined` |
221
+ | `indexPrefix` | `string` | `""` |
222
+
223
+ #### Returns
224
+
225
+ `void`
226
+
227
+ #### Defined in
228
+
229
+ src/repository/indexeddb/IDBRepository.ts:271
230
+
231
+ ___
232
+
233
+ ### delete
234
+
235
+ ▸ **delete**(`items`): `Promise`<`void`\>
236
+
237
+ Remove itens do repositório
238
+
239
+ #### Parameters
240
+
241
+ | Name | Type | Description |
242
+ | :------ | :------ | :------ |
243
+ | `items` | `T`[] | Os itens a serem removidos |
244
+
245
+ #### Returns
246
+
247
+ `Promise`<`void`\>
248
+
249
+ Promessa de execução
250
+
251
+ #### Implementation of
252
+
253
+ [IRepository](../interfaces/IRepository.md).[delete](../interfaces/IRepository.md#delete)
254
+
255
+ #### Defined in
256
+
257
+ src/repository/indexeddb/IDBRepository.ts:138
258
+
259
+ ___
260
+
261
+ ### distict
262
+
263
+ ▸ **distict**(`itemProcessor`): `Promise`<`Map`<`string`, `any`\>\>
264
+
265
+ Itera todos os items colecionando os valores distintos.
266
+
267
+ #### Parameters
268
+
269
+ | Name | Type | Description |
270
+ | :------ | :------ | :------ |
271
+ | `itemProcessor` | (`item`: `T`) => { `key`: `string` ; `value`: `any` } | Uma função que processa um item e gera a chave e valor |
272
+
273
+ #### Returns
274
+
275
+ `Promise`<`Map`<`string`, `any`\>\>
276
+
277
+ Promessa de array com os valores distintos.
278
+
279
+ #### Implementation of
280
+
281
+ [IRepository](../interfaces/IRepository.md).[distict](../interfaces/IRepository.md#distict)
282
+
283
+ #### Defined in
284
+
285
+ src/repository/indexeddb/IDBRepository.ts:78
286
+
287
+ ___
288
+
289
+ ### getAddedItems
290
+
291
+ ▸ `Private` **getAddedItems**(`db`): `Promise`<`IAddedItem`<`T`\>[]\>
292
+
293
+ #### Parameters
294
+
295
+ | Name | Type |
296
+ | :------ | :------ |
297
+ | `db` | `IDBPDatabase`<`unknown`\> |
298
+
299
+ #### Returns
300
+
301
+ `Promise`<`IAddedItem`<`T`\>[]\>
302
+
303
+ #### Defined in
304
+
305
+ src/repository/indexeddb/IDBRepository.ts:319
306
+
307
+ ___
308
+
309
+ ### getItemPosition
310
+
311
+ ▸ `Private` **getItemPosition**(`db`, `itemTest`): `Promise`<`number`\>
312
+
313
+ #### Parameters
314
+
315
+ | Name | Type |
316
+ | :------ | :------ |
317
+ | `db` | `IDBPDatabase`<`unknown`\> |
318
+ | `itemTest` | (`item`: `any`) => `boolean` |
319
+
320
+ #### Returns
321
+
322
+ `Promise`<`number`\>
323
+
324
+ #### Defined in
325
+
326
+ src/repository/indexeddb/IDBRepository.ts:284
327
+
328
+ ___
329
+
330
+ ### getItemPositionByAdded
331
+
332
+ ▸ `Private` **getItemPositionByAdded**(`db`, `itemTest`): `Promise`<`number`\>
333
+
334
+ #### Parameters
335
+
336
+ | Name | Type |
337
+ | :------ | :------ |
338
+ | `db` | `IDBPDatabase`<`unknown`\> |
339
+ | `itemTest` | (`item`: `any`) => `boolean` |
340
+
341
+ #### Returns
342
+
343
+ `Promise`<`number`\>
344
+
345
+ #### Defined in
346
+
347
+ src/repository/indexeddb/IDBRepository.ts:307
348
+
349
+ ___
350
+
351
+ ### insert
352
+
353
+ ▸ **insert**(`itemReference`, `items`): `Promise`<`void`\>
354
+
355
+ Insere itens em uma posição de referência
356
+
357
+ #### Parameters
358
+
359
+ | Name | Type | Description |
360
+ | :------ | :------ | :------ |
361
+ | `itemReference` | `T` | O item posterior aos inseridos |
362
+ | `items` | `T`[] | Os itens a serem inseridos |
363
+
364
+ #### Returns
365
+
366
+ `Promise`<`void`\>
367
+
368
+ Promessa de execução
369
+
370
+ #### Implementation of
371
+
372
+ [IRepository](../interfaces/IRepository.md).[insert](../interfaces/IRepository.md#insert)
373
+
374
+ #### Defined in
375
+
376
+ src/repository/indexeddb/IDBRepository.ts:194
377
+
378
+ ___
379
+
380
+ ### isEmpty
381
+
382
+ ▸ **isEmpty**(): `Promise`<`boolean`\>
383
+
384
+ Determina se o repositório está vazio ou ainda não foi criado.
385
+
386
+ #### Returns
387
+
388
+ `Promise`<`boolean`\>
389
+
390
+ #### Implementation of
391
+
392
+ [IRepository](../interfaces/IRepository.md).[isEmpty](../interfaces/IRepository.md#isempty)
393
+
394
+ #### Defined in
395
+
396
+ src/repository/indexeddb/IDBRepository.ts:218
397
+
398
+ ___
399
+
400
+ ### isOperating
401
+
402
+ ▸ **isOperating**(): `boolean`
403
+
404
+ Determina se o repositório está em condições normais de funcionamento.
405
+ Caso o banco tenha sido excluido, retorna false.
406
+
407
+ #### Returns
408
+
409
+ `boolean`
410
+
411
+ #### Implementation of
412
+
413
+ [IRepository](../interfaces/IRepository.md).[isOperating](../interfaces/IRepository.md#isoperating)
414
+
415
+ #### Defined in
416
+
417
+ src/repository/indexeddb/IDBRepository.ts:214
418
+
419
+ ___
420
+
421
+ ### load
422
+
423
+ ▸ **load**(`filterFunction?`, `sortingFunction?`, `offset?`, `limit?`): `Promise`<[`ILoadResult`](../interfaces/ILoadResult.md)<`T`\>\>
424
+
425
+ Recupera registros do repositório
426
+
427
+ #### Parameters
428
+
429
+ | Name | Type | Description |
430
+ | :------ | :------ | :------ |
431
+ | `filterFunction?` | (`value`: `T`) => `boolean` | Teste para determinar se um registro está no universo desejado |
432
+ | `sortingFunction?` | (`itemA`: `T`, `itemB`: `T`) => `number` | Critério comparação para ordenação |
433
+ | `offset?` | `number` | Determina que o resultado descarta os registros iniciais |
434
+ | `limit?` | `number` | Descarta o resultado a partir de uma quantidade de registros |
435
+
436
+ #### Returns
437
+
438
+ `Promise`<[`ILoadResult`](../interfaces/ILoadResult.md)<`T`\>\>
439
+
440
+ Promessa de um array que satisfaça aos critérios informados
441
+
442
+ #### Implementation of
443
+
444
+ [IRepository](../interfaces/IRepository.md).[load](../interfaces/IRepository.md#load)
445
+
446
+ #### Defined in
447
+
448
+ src/repository/indexeddb/IDBRepository.ts:44
449
+
450
+ ___
451
+
452
+ ### openDB
453
+
454
+ ▸ `Private` **openDB**(): `Promise`<`IDBPDatabase`<`unknown`\>\>
455
+
456
+ #### Returns
457
+
458
+ `Promise`<`IDBPDatabase`<`unknown`\>\>
459
+
460
+ #### Defined in
461
+
462
+ src/repository/indexeddb/IDBRepository.ts:250
463
+
464
+ ___
465
+
466
+ ### push
467
+
468
+ ▸ **push**(`items`): `Promise`<`void`\>
469
+
470
+ Adiciona registros no final do repositório
471
+
472
+ #### Parameters
473
+
474
+ | Name | Type | Description |
475
+ | :------ | :------ | :------ |
476
+ | `items` | `T`[] | Os items a serem adicionados |
477
+
478
+ #### Returns
479
+
480
+ `Promise`<`void`\>
481
+
482
+ Promessa de execução
483
+
484
+ #### Implementation of
485
+
486
+ [IRepository](../interfaces/IRepository.md).[push](../interfaces/IRepository.md#push)
487
+
488
+ #### Defined in
489
+
490
+ src/repository/indexeddb/IDBRepository.ts:103
491
+
492
+ ___
493
+
494
+ ### update
495
+
496
+ ▸ **update**(`items`): `Promise`<`void`\>
497
+
498
+ Altera itens já persistido no repositório
499
+
500
+ #### Parameters
501
+
502
+ | Name | Type | Description |
503
+ | :------ | :------ | :------ |
504
+ | `items` | `T`[] | Os itens a serem alterados |
505
+
506
+ #### Returns
507
+
508
+ `Promise`<`void`\>
509
+
510
+ Promessa de execução
511
+
512
+ #### Implementation of
513
+
514
+ [IRepository](../interfaces/IRepository.md).[update](../interfaces/IRepository.md#update)
515
+
516
+ #### Defined in
517
+
518
+ src/repository/indexeddb/IDBRepository.ts:165