@sankhyalabs/core 6.1.0-dev.4 → 6.1.0-rc.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.
Files changed (99) hide show
  1. package/.docs/classes/Change.md +11 -11
  2. package/.docs/classes/ColumnFilterManager.md +6 -6
  3. package/.docs/classes/DataUnit.md +157 -157
  4. package/.docs/classes/DataUnitLoaderUtils.md +6 -6
  5. package/.docs/classes/SelectionInfo.md +16 -16
  6. package/.docs/enumerations/ChangeOperation.md +4 -4
  7. package/.docs/enumerations/SelectionMode.md +2 -2
  8. package/.docs/functions/defaultDataLoader.md +1 -1
  9. package/.docs/interfaces/DUActionInterceptor.md +1 -1
  10. package/.docs/interfaces/PageRequest.md +3 -3
  11. package/.docs/interfaces/PaginationInfoBuilderParams.md +3 -3
  12. package/.docs/interfaces/QuickFilter.md +3 -3
  13. package/.docs/interfaces/Record.md +4 -4
  14. package/.docs/interfaces/SavedRecord.md +5 -5
  15. package/.docs/interfaces/WaitingChange.md +3 -3
  16. package/.docs/type-aliases/DataUnitEventOptions.md +1 -1
  17. package/dist/dataunit/DataUnit.d.ts +129 -9
  18. package/dist/dataunit/DataUnit.js +177 -87
  19. package/dist/dataunit/DataUnit.js.map +1 -1
  20. package/dist/dataunit/DataUnitHelper.d.ts +1 -2
  21. package/dist/dataunit/DataUnitHelper.js.map +1 -1
  22. package/dist/dataunit/formatting/PrettyFormatter.js +3 -5
  23. package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -1
  24. package/dist/dataunit/loader/utils/dataUnitLoaderUtils.d.ts +1 -2
  25. package/dist/dataunit/loader/utils/dataUnitLoaderUtils.js.map +1 -1
  26. package/dist/dataunit/loading/LoadDataRequest.d.ts +1 -1
  27. package/dist/dataunit/loading/LoadDataResponse.d.ts +1 -1
  28. package/dist/dataunit/sorting/FieldComparator.d.ts +1 -1
  29. package/dist/dataunit/state/slice/AddedRecordsSlice.d.ts +1 -1
  30. package/dist/dataunit/state/slice/ChangesSlice.d.ts +1 -2
  31. package/dist/dataunit/state/slice/ChangesSlice.js +1 -2
  32. package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -1
  33. package/dist/dataunit/state/slice/LoadingControlSlice.js.map +1 -1
  34. package/dist/dataunit/state/slice/RecordsSlice.d.ts +1 -1
  35. package/dist/dataunit/state/slice/RecordsSlice.js +1 -1
  36. package/dist/dataunit/state/slice/RecordsSlice.js.map +1 -1
  37. package/dist/dataunit/state/slice/SelectionSlice.d.ts +1 -2
  38. package/dist/dataunit/state/slice/SelectionSlice.js +1 -2
  39. package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -1
  40. package/dist/dataunit/state/slice/SnapshotSlice.d.ts +1 -1
  41. package/dist/dataunit/state/slice/WaitingChangesSlice.d.ts +1 -1
  42. package/dist/index.d.ts +1 -4
  43. package/dist/index.js +1 -4
  44. package/dist/index.js.map +1 -1
  45. package/dist/utils/ColumnFilterManager.d.ts +1 -2
  46. package/dist/utils/ColumnFilterManager.js.map +1 -1
  47. package/dist/utils/SortingUtils.d.ts +1 -1
  48. package/package.json +1 -2
  49. package/reports/test-report.xml +557 -758
  50. package/src/dataunit/DataUnit.ts +397 -242
  51. package/src/dataunit/DataUnitHelper.ts +1 -2
  52. package/src/dataunit/formatting/PrettyFormatter.ts +5 -4
  53. package/src/dataunit/loader/utils/dataUnitLoaderUtils.ts +1 -2
  54. package/src/dataunit/loading/LoadDataRequest.ts +1 -1
  55. package/src/dataunit/loading/LoadDataResponse.ts +1 -1
  56. package/src/dataunit/sorting/FieldComparator.ts +1 -1
  57. package/src/dataunit/state/slice/AddedRecordsSlice.ts +1 -1
  58. package/src/dataunit/state/slice/ChangesSlice.ts +1 -2
  59. package/src/dataunit/state/slice/LoadingControlSlice.ts +2 -1
  60. package/src/dataunit/state/slice/RecordsSlice.ts +2 -3
  61. package/src/dataunit/state/slice/SelectionSlice.ts +1 -2
  62. package/src/dataunit/state/slice/SnapshotSlice.ts +1 -1
  63. package/src/dataunit/state/slice/WaitingChangesSlice.ts +1 -1
  64. package/src/dataunit/state/slice/test/RecordsSlice.spec.ts +1 -1
  65. package/src/dataunit/test/DataUnit.spec.ts +44 -0
  66. package/src/index.ts +1 -4
  67. package/src/utils/ColumnFilterManager.ts +1 -2
  68. package/src/utils/SortingUtils.ts +1 -1
  69. package/test/dataunit/formatting/PrettyFormatter.spec.ts +1 -1
  70. package/test/dataunit/loader/dataUnitInMemoryLoader.spec.ts +1 -2
  71. package/test/dataunit/loader/utils/dataUnitLoaderUtils.spec.ts +1 -1
  72. package/test/util/ColumnFilterManager.spec.ts +1 -2
  73. package/tsconfig.json +0 -1
  74. package/dist/dataunit/Changes.d.ts +0 -52
  75. package/dist/dataunit/Changes.js +0 -64
  76. package/dist/dataunit/Changes.js.map +0 -1
  77. package/dist/dataunit/SelectionInfo.d.ts +0 -16
  78. package/dist/dataunit/SelectionInfo.js +0 -39
  79. package/dist/dataunit/SelectionInfo.js.map +0 -1
  80. package/dist/dataunit/interfaces/dataUnit.d.ts +0 -61
  81. package/dist/dataunit/interfaces/dataUnit.js +0 -13
  82. package/dist/dataunit/interfaces/dataUnit.js.map +0 -1
  83. package/src/dataunit/Changes.ts +0 -77
  84. package/src/dataunit/SelectionInfo.ts +0 -55
  85. package/src/dataunit/interfaces/dataUnit.ts +0 -71
  86. package/test/dataunit/AccessParentsDataUnit.spec.ts +0 -69
  87. package/test/dataunit/Actions.spec.ts +0 -74
  88. package/test/dataunit/Change.spec.ts +0 -66
  89. package/test/dataunit/FieldManager.spec.ts +0 -286
  90. package/test/dataunit/FilterSortsLockersAndObservers.spec.ts +0 -339
  91. package/test/dataunit/InfoManager.spec.ts +0 -254
  92. package/test/dataunit/LoadDataAndMetadata.spec.ts +0 -269
  93. package/test/dataunit/RecodsSelection.spec.ts +0 -229
  94. package/test/dataunit/RecordsManager.spec.ts +0 -323
  95. package/test/dataunit/SavingData.spec.ts +0 -206
  96. package/test/dataunit/SelectionInfo.spec.ts +0 -143
  97. package/test/dataunit/loader/utils/createDataUnitMock.ts +0 -34
  98. package/test/dataunit/resources/metadata.ts +0 -39
  99. package/test/dataunit/resources/records.ts +0 -29
@@ -1,5 +1,4 @@
1
- import DataUnit from './DataUnit.js';
2
- import { Record } from './interfaces/dataUnit.js';
1
+ import DataUnit, { Record } from './DataUnit.js';
3
2
  import { DataType } from './metadata/DataType.js';
4
3
  import { LoadDataRequest, LoadDataResponse, PaginationInfo, Sort, SortMode, StringUtils } from '../index.js';
5
4
 
@@ -7,7 +7,7 @@ import { FieldDescriptor, UserInterface } from '../metadata/UnitMetadata.js';
7
7
 
8
8
  export const getFormattedValue = (value: any, descriptor?: FieldDescriptor) => {
9
9
  if(descriptor?.userInterface === UserInterface.FILE){
10
- return getFileFormat(value);
10
+ return getFileFotmat(value);
11
11
  }
12
12
 
13
13
  if(descriptor?.dataType === DataType.OBJECT){
@@ -131,9 +131,10 @@ const getMask = (value: string, descriptor: FieldDescriptor | undefined): string
131
131
  return mask;
132
132
  }
133
133
 
134
- const getFileFormat = (value: any) => {
135
- if (value == undefined) return '';
136
- if (!value || !Array.isArray(value)) return value;
134
+ const getFileFotmat = (value: any) =>{
135
+ if (!value || !Array.isArray(value)) return '';
136
+
137
137
  if (value.length === 1) return value[0].name;
138
+
138
139
  return `${value.length} arquivos`;
139
140
  }
@@ -1,5 +1,4 @@
1
- import DataUnit from '../../DataUnit.js';
2
- import { Record } from '../../interfaces/dataUnit.js';
1
+ import DataUnit, { Record } from '../../DataUnit.js';
3
2
  import { Filter, Sort } from '../../metadata/UnitMetadata.js';
4
3
  import { LoadDataRequest } from '../../loading/LoadDataRequest.js';
5
4
  import { PaginationInfo } from '../../loading/PaginationInfo.js';
@@ -1,4 +1,4 @@
1
- import { QuickFilter } from '../interfaces/dataUnit.js';
1
+ import { QuickFilter } from "../DataUnit.js";
2
2
  import { Filter, Sort } from "../metadata/UnitMetadata.js";
3
3
 
4
4
  /** Atributos enviados na requisição de carregamento dos registros */
@@ -1,4 +1,4 @@
1
- import { Record } from "../interfaces/dataUnit.js";
1
+ import { Record } from "../DataUnit.js";
2
2
  import { PaginationInfo } from "./PaginationInfo.js";
3
3
 
4
4
  /** Retorno dos registros da requisição de carregamento de dados */
@@ -1,4 +1,4 @@
1
- import { Record } from "../interfaces/dataUnit.js";
1
+ import { Record } from '../DataUnit.js';
2
2
  import { compareValues } from '../metadata/DataType.js';
3
3
  import { FieldDescriptor } from '../metadata/UnitMetadata.js';
4
4
 
@@ -2,7 +2,7 @@
2
2
  import { ActionReducer, StateAction } from "../StateManager.js";
3
3
  import { Action } from "../action/DataUnitAction.js";
4
4
  import StateManager from "../StateManager.js";
5
- import { Record } from "../../interfaces/dataUnit.js";
5
+ import { Record } from "../../DataUnit.js";
6
6
 
7
7
  class AddedRecordsReducerImpl implements ActionReducer{
8
8
 
@@ -6,8 +6,7 @@ import { getSelection } from "./SelectionSlice.js";
6
6
  import { getRecords } from "./RecordsSlice.js";
7
7
  import { getRemovedRecords } from "./RemovedRecordsSlice.js";
8
8
  import { getAddedRecords, isAddedRecord } from "./AddedRecordsSlice.js";
9
- import { ChangeOperation, Record } from "../../interfaces/dataUnit.js";
10
- import { Change } from "../../Changes.js";
9
+ import { Change, ChangeOperation, Record } from "../../DataUnit.js";
11
10
  import { getWaitingChanges } from "./WaitingChangesSlice.js";
12
11
  import { getSelectionRecords } from "./SnapshotSlice.js";
13
12
 
@@ -1,4 +1,5 @@
1
- import { ChangeOperation } from "../../interfaces/dataUnit.js";
1
+
2
+ import { ChangeOperation } from "../../DataUnit.js";
2
3
  import { LoadDataRequest } from "../../loading/LoadDataRequest.js";
3
4
  import { PaginationInfo } from "../../loading/PaginationInfo.js";
4
5
  import { Action } from "../action/DataUnitAction.js";
@@ -2,8 +2,7 @@ import { ActionReducer, StateAction } from "../StateManager.js";
2
2
  import StateManager from "../StateManager.js";
3
3
  import { getRemovedRecords } from "./RemovedRecordsSlice.js";
4
4
  import { Action } from "../action/DataUnitAction.js";
5
- import { Record, SavedRecord } from "../../interfaces/dataUnit.js";
6
-
5
+ import { Record, SavedRecord } from "../../DataUnit.js";
7
6
 
8
7
  class RecordsReducerImpl implements ActionReducer {
9
8
 
@@ -13,7 +12,7 @@ class RecordsReducerImpl implements ActionReducer {
13
12
  switch (action.type) {
14
13
 
15
14
  case Action.DATA_LOADED:
16
- return action.payload ? action.payload.records : [];
15
+ return action.payload ? action.payload.records : undefined;
17
16
  case Action.RECORDS_REMOVED:
18
17
 
19
18
  const {records, buffered} = action.payload;
@@ -2,8 +2,7 @@ import { ActionReducer, StateAction } from "../StateManager.js";
2
2
  import { Action } from "../action/DataUnitAction.js";
3
3
  import StateManager from "../StateManager.js";
4
4
  import { getCurrentRecords, getSelectionRecords } from "./SnapshotSlice.js";
5
- import { Record, SavedRecord, SelectionMode } from "../../interfaces/dataUnit.js";
6
- import { SelectionInfo } from "../../SelectionInfo.js";
5
+ import { Record, SavedRecord, SelectionInfo, SelectionMode } from "../../DataUnit.js";
7
6
  import { getCurrentRequest, getPaginationInfo } from "./LoadingControlSlice.js";
8
7
  import { PaginationInfo } from "../../loading/PaginationInfo.js";
9
8
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { ActionReducer } from "../StateManager.js";
3
3
  import StateManager from "../StateManager.js";
4
- import { Record } from "../../interfaces/dataUnit.js";
4
+ import { Record } from "../../DataUnit.js";
5
5
  import { getRecords } from "./RecordsSlice.js";
6
6
  import { getSelection } from "./SelectionSlice.js";
7
7
  import { getChangedFieldValue, getChanges } from "./ChangesSlice.js";
@@ -1,5 +1,5 @@
1
1
 
2
- import { WaitingChange } from "../../interfaces/dataUnit.js";
2
+ import { WaitingChange } from "../../DataUnit.js";
3
3
  import { Action } from "../action/DataUnitAction.js";
4
4
  import StateManager, { ActionReducer, StateAction } from "../StateManager.js";
5
5
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  import * as RecordsReducerModule from '../RecordsSlice';
3
3
  import StateManager from '../../StateManager';
4
- import { Record } from '../../../interfaces/dataUnit';
4
+ import { Record } from '../../../DataUnit';
5
5
  import { Action } from '../../action/DataUnitAction';
6
6
 
7
7
  jest.spyOn(RecordsReducerModule, "getRecords").mockImplementation(() => [
@@ -0,0 +1,44 @@
1
+ import DataUnit from '../DataUnit';
2
+ import { Action } from '../state/action/DataUnitAction';
3
+
4
+ describe('DataUnit', () => {
5
+
6
+ let dataUnit: DataUnit;
7
+
8
+ beforeEach(() => {
9
+ dataUnit = new DataUnit();
10
+
11
+ dataUnit['dispatchAction'] = jest.fn();
12
+ });
13
+
14
+ it('should return false when not waiting to reload', () => {
15
+ expect(dataUnit.isWaitingToReload()).toBe(false);
16
+ });
17
+
18
+ it('should set waitingToReload to true', () => {
19
+ dataUnit.setWaitingToReload(true);
20
+ expect(dataUnit.isWaitingToReload()).toBe(true);
21
+ });
22
+
23
+ it('should set waitingToReload to false', () => {
24
+ dataUnit.setWaitingToReload(true);
25
+ dataUnit.setWaitingToReload(false);
26
+ expect(dataUnit.isWaitingToReload()).toBe(false);
27
+ });
28
+
29
+ it('should dispatch SAVING_CANCELED action with correct fields and recordId', () => {
30
+ const fields = [
31
+ { name: 'field1', message: 'error1' },
32
+ { name: 'field2', message: 'error2' }
33
+ ];
34
+ const recordId = '12345';
35
+
36
+ dataUnit.savingCanceled(fields, recordId);
37
+
38
+ expect(dataUnit['dispatchAction']).toHaveBeenCalledWith(
39
+ Action.SAVING_CANCELED,
40
+ { fields, recordId },
41
+ undefined
42
+ );
43
+ });
44
+ });
package/src/index.ts CHANGED
@@ -9,10 +9,7 @@ import { HttpProvider } from "./http/HttpProvider.js";
9
9
  import { SkwHttpProvider } from "./http/SkwHttpProvider.js";
10
10
  import { RequestMetadata } from "./http/RequestMetadata.js";
11
11
  import { AuthorizedServiceCaller } from "./http/AuthorizedServiceCaller.js";
12
- import DataUnit from "./dataunit/DataUnit.js";
13
- import {SavedRecord, Record, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter, SelectionMode, DataUnitEventOptions} from "./dataunit/interfaces/dataUnit.js";
14
- import { Change } from "./dataunit/Changes.js";
15
- import { SelectionInfo } from "./dataunit/SelectionInfo.js";
12
+ import DataUnit, {SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter, SelectionMode, SelectionInfo, DataUnitEventOptions} from "./dataunit/DataUnit.js";
16
13
  import { DataType } from "./dataunit/metadata/DataType.js";
17
14
  import { UnitMetadata, FieldDescriptor, UserInterface, Sort, SortMode, SortingProvider, Filter, DependencyType, ChildDescriptor, ChildLink } from "./dataunit/metadata/UnitMetadata.js";
18
15
  import { DataUnitAction, Action, ExecutionContext } from "./dataunit/state/action/DataUnitAction.js";
@@ -1,6 +1,5 @@
1
1
  import { Filter } from '../dataunit/metadata/UnitMetadata.js';
2
- import DataUnit from '../dataunit/DataUnit.js';
3
- import { Record } from '../dataunit/interfaces/dataUnit.js';
2
+ import DataUnit, { Record } from '../dataunit/DataUnit.js';
4
3
  import { FieldComparator } from '../dataunit/sorting/FieldComparator.js';
5
4
  import { LoadDataRequest } from '../dataunit/loading/LoadDataRequest.js';
6
5
 
@@ -1,7 +1,7 @@
1
1
  import DataUnit from "../dataunit/DataUnit.js";
2
2
  import { FieldDescriptor, Sort, SortMode } from "../dataunit/metadata/UnitMetadata.js";
3
3
  import { FieldComparator } from "../dataunit/sorting/FieldComparator.js";
4
- import { Record } from '../dataunit/interfaces/dataUnit.js';
4
+ import { Record } from '../dataunit/DataUnit.js';
5
5
 
6
6
  /**
7
7
  * `SortingUtils`: Utilizado para auxiliar na ordenacao de registros.
@@ -18,7 +18,7 @@ describe('getFormattedValue', () => {
18
18
  it('should return empty string when value is not an array', () => {
19
19
  const value = 'not an array';
20
20
  const descriptor = getFileFieldDescriptor();
21
- expect(getFormattedValue(value, descriptor)).toBe(value);
21
+ expect(getFormattedValue(value, descriptor)).toBe('');
22
22
  });
23
23
 
24
24
  it('should return empty string when value is an empty array', () => {
@@ -6,8 +6,7 @@ import {
6
6
  import { FieldDescriptor, UnitMetadata } from '../../../src/dataunit/metadata/UnitMetadata.js';
7
7
  import { DataType } from '../../../src/dataunit/metadata/DataType.js';
8
8
  import DateUtils from '../../../src/utils/DateUtils.js';
9
- import DataUnit from '../../../src/dataunit/DataUnit.js';
10
- import { Record } from '../../../src/dataunit/interfaces/dataUnit.js';
9
+ import DataUnit, { Record } from '../../../src/dataunit/DataUnit.js';
11
10
 
12
11
  describe('DataUnitInMemoryLoader - loadData', () => {
13
12
  const dataUnitMetetadata: UnitMetadata = {
@@ -17,7 +17,7 @@ jest.mock('../../../../src/utils/SortingUtils', () => {
17
17
 
18
18
  import { DataUnitLoaderUtils } from '../../../../src/dataunit/loader/utils/dataUnitLoaderUtils';
19
19
  import { IColumnFilter } from '../../../../src/utils/ColumnFilterManager';
20
- import { Record } from '../../../../src/dataunit/interfaces/dataUnit';
20
+ import { Record } from '../../../../src/dataunit/DataUnit';
21
21
  import { Filter, Sort, SortMode } from '../../../../src/dataunit/metadata/UnitMetadata';
22
22
  import { DataType } from '../../../../src/dataunit/metadata/DataType';
23
23
  import { ColumnFilterManager } from '../../../../src/utils/ColumnFilterManager';
@@ -1,7 +1,6 @@
1
1
  import { ColumnFilterManager, IColumnFilter } from '../../src/utils/ColumnFilterManager.js';
2
2
  import { FieldDescriptor, Filter, FilterParam } from '../../src/dataunit/metadata/UnitMetadata.js';
3
- import DataUnit from '../../src/dataunit/DataUnit';
4
- import { Record } from '../../src/dataunit/interfaces/dataUnit';
3
+ import DataUnit, { Record } from '../../src/dataunit/DataUnit';
5
4
 
6
5
 
7
6
  describe('ColumnFilterManager', () => {
package/tsconfig.json CHANGED
@@ -8,7 +8,6 @@
8
8
  "strict": true,
9
9
  "moduleResolution": "node",
10
10
  "declaration": true,
11
- "esModuleInterop": true
12
11
  },
13
12
  "removeComments": true,
14
13
  "preserveConstEnums": true,
@@ -1,52 +0,0 @@
1
- import { ChangeOperation, Record } from "./interfaces/dataUnit.js";
2
- /***
3
- * `Change`: Dados que representam uma alteração.
4
- */
5
- export declare class Change {
6
- dataUnit: string;
7
- record: Record;
8
- sourceId: string | undefined;
9
- updatingFields: any;
10
- private _operation;
11
- constructor(dataUnit: string, record: Record, updates: any, operation: ChangeOperation, sourceId?: string);
12
- /**
13
- *
14
- * Obtém o tipo de operação que está sendo realizada.
15
- *
16
- * @returns - Ação que está sendo executada.
17
- *
18
- */
19
- get operation(): string;
20
- /**
21
- *
22
- * Retorna se o DataUnit está em uma operação de inserção.
23
- *
24
- * @returns - Verdadeiro se a operação for de inserção.
25
- *
26
- */
27
- isInsert(): boolean;
28
- /**
29
- *
30
- * Retorna se o DataUnit está em uma operação de cópia.
31
- *
32
- * @returns - Verdadeiro se a operação for de cópia.
33
- *
34
- */
35
- isCopy(): boolean;
36
- /**
37
- *
38
- * Retorna se o DataUnit está em uma operação de deleção.
39
- *
40
- * @returns - Verdadeiro se a operação for de deleção.
41
- *
42
- */
43
- isDelete(): boolean;
44
- /**
45
- *
46
- * Retorna se o DataUnit está em uma operação de atualização.
47
- *
48
- * @returns - Verdadeiro se a operação for de atualização.
49
- *
50
- */
51
- isUpdate(): boolean;
52
- }
@@ -1,64 +0,0 @@
1
- import { ChangeOperation } from "./interfaces/dataUnit.js";
2
- /***
3
- * `Change`: Dados que representam uma alteração.
4
- */
5
- export class Change {
6
- constructor(dataUnit, record, updates, operation, sourceId) {
7
- this.dataUnit = dataUnit;
8
- this.record = record;
9
- this.sourceId = sourceId;
10
- this.updatingFields = updates;
11
- this._operation = operation;
12
- }
13
- /**
14
- *
15
- * Obtém o tipo de operação que está sendo realizada.
16
- *
17
- * @returns - Ação que está sendo executada.
18
- *
19
- */
20
- get operation() {
21
- return this._operation.toString();
22
- }
23
- /**
24
- *
25
- * Retorna se o DataUnit está em uma operação de inserção.
26
- *
27
- * @returns - Verdadeiro se a operação for de inserção.
28
- *
29
- */
30
- isInsert() {
31
- return this._operation === ChangeOperation.INSERT;
32
- }
33
- /**
34
- *
35
- * Retorna se o DataUnit está em uma operação de cópia.
36
- *
37
- * @returns - Verdadeiro se a operação for de cópia.
38
- *
39
- */
40
- isCopy() {
41
- return this._operation === ChangeOperation.COPY;
42
- }
43
- /**
44
- *
45
- * Retorna se o DataUnit está em uma operação de deleção.
46
- *
47
- * @returns - Verdadeiro se a operação for de deleção.
48
- *
49
- */
50
- isDelete() {
51
- return this._operation === ChangeOperation.DELETE;
52
- }
53
- /**
54
- *
55
- * Retorna se o DataUnit está em uma operação de atualização.
56
- *
57
- * @returns - Verdadeiro se a operação for de atualização.
58
- *
59
- */
60
- isUpdate() {
61
- return this._operation === ChangeOperation.UPDATE;
62
- }
63
- }
64
- //# sourceMappingURL=Changes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Changes.js","sourceRoot":"","sources":["../../src/dataunit/Changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,0BAA0B,CAAC;AAEnE;;GAEG;AACH,MAAM,OAAO,MAAM;IASf,YAAY,QAAgB,EAAE,MAAc,EAAE,OAAY,EAAE,SAA0B,EAAE,QAAiB;QACrG,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,UAAU,KAAK,eAAe,CAAC,MAAM,CAAC;IACtD,CAAC;IAED;;;;;;OAMG;IACI,MAAM;QACT,OAAO,IAAI,CAAC,UAAU,KAAK,eAAe,CAAC,IAAI,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,UAAU,KAAK,eAAe,CAAC,MAAM,CAAC;IACtD,CAAC;IAED;;;;;;OAMG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,UAAU,KAAK,eAAe,CAAC,MAAM,CAAC;IACtD,CAAC;CACJ"}
@@ -1,16 +0,0 @@
1
- import { Record, SelectionMode } from "./interfaces/dataUnit.js";
2
- import { Filter, Sort } from "./metadata/UnitMetadata.js";
3
- export declare class SelectionInfo {
4
- mode: SelectionMode;
5
- filters?: Array<Filter>;
6
- sort?: Array<Sort>;
7
- getAllRecords?: () => Array<Record>;
8
- private _records;
9
- private _total?;
10
- constructor(records: Array<Record>, mode?: SelectionMode, total?: number, filters?: Array<Filter>, sort?: Array<Sort>);
11
- get records(): Array<Record>;
12
- get recordIds(): Array<string> | undefined;
13
- get length(): number;
14
- isAllRecords(): boolean;
15
- isEmpty(): boolean;
16
- }
@@ -1,39 +0,0 @@
1
- import { SelectionMode } from "./interfaces/dataUnit.js";
2
- export class SelectionInfo {
3
- constructor(records, mode = SelectionMode.SOME_RECORDS, total, filters, sort) {
4
- this._records = records;
5
- this._total = total;
6
- this.mode = mode;
7
- this.filters = filters;
8
- this.sort = sort;
9
- }
10
- get records() {
11
- if (this.isAllRecords()) {
12
- if (this.getAllRecords != undefined) {
13
- return this.getAllRecords();
14
- }
15
- throw new Error("Erro interno: Impossível retornar os registros selecionados numa seleção virtual.");
16
- }
17
- return this._records;
18
- }
19
- get recordIds() {
20
- const records = this.records;
21
- if (records == undefined) {
22
- return undefined;
23
- }
24
- return records.map(record => record.__record__id__);
25
- }
26
- get length() {
27
- if (this.isAllRecords()) {
28
- return this._total || 0;
29
- }
30
- return this.records == undefined ? 0 : this.records.length;
31
- }
32
- isAllRecords() {
33
- return this.mode === SelectionMode.ALL_RECORDS;
34
- }
35
- isEmpty() {
36
- return this.length === 0;
37
- }
38
- }
39
- //# sourceMappingURL=SelectionInfo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectionInfo.js","sourceRoot":"","sources":["../../src/dataunit/SelectionInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGjE,MAAM,OAAO,aAAa;IAStB,YAAY,OAAsB,EAAE,OAAsB,aAAa,CAAC,YAAY,EAAE,KAAc,EAAE,OAAuB,EAAE,IAAkB;QAC7I,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,IAAW,OAAO;QACd,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE;YACrB,IAAI,IAAI,CAAC,aAAa,IAAI,SAAS,EAAE;gBACjC,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;aAC/B;YACD,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC,CAAC;SACxG;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,IAAW,SAAS;QAEhB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE7B,IAAI,OAAO,IAAI,SAAS,EAAE;YACtB,OAAO,SAAS,CAAC;SACpB;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACxD,CAAC;IAED,IAAW,MAAM;QACb,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE;YACrB,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;SAC3B;QACD,OAAO,IAAI,CAAC,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,OAAyB,CAAC,MAAM,CAAC;IAClF,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,WAAW,CAAC;IACnD,CAAC;IAEM,OAAO;QACV,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;IAC7B,CAAC;CACJ"}
@@ -1,61 +0,0 @@
1
- import { Filter } from "../metadata/UnitMetadata.js";
2
- import { DataUnitAction, ExecutionContext } from "../state/action/DataUnitAction.js";
3
- export interface LoadDataParams {
4
- quickFilter?: QuickFilter;
5
- executionCtx?: ExecutionContext;
6
- checkLastFilter?: boolean;
7
- source?: string;
8
- selectFirstRecord?: boolean;
9
- keepSelection?: boolean;
10
- }
11
- export interface DUActionInterceptor {
12
- interceptAction(action: DataUnitAction): DataUnitAction | Promise<DataUnitAction>;
13
- }
14
- export interface Record {
15
- __record__id__: string;
16
- __record__label__?: string;
17
- __parent__record__id__?: string;
18
- __owner__dataunit__name__?: string;
19
- [key: string]: any;
20
- }
21
- export interface SavedRecord extends Record {
22
- __old__id__?: string;
23
- }
24
- export declare enum ChangeOperation {
25
- INSERT = "INSERT",
26
- COPY = "COPY",
27
- UPDATE = "UPDATE",
28
- DELETE = "DELETE"
29
- }
30
- export interface WaitingChange {
31
- waitmessage: string;
32
- blocking: boolean;
33
- promise?: Promise<any>;
34
- }
35
- export interface PageRequest {
36
- limit: number;
37
- offset: number;
38
- quickFilter?: QuickFilter;
39
- }
40
- export interface QuickFilter {
41
- term: string;
42
- fields?: Array<string>;
43
- filter?: Filter;
44
- }
45
- export interface PageResponse {
46
- limit: number;
47
- offset: number;
48
- total: number;
49
- hasMore: boolean;
50
- records: Array<Record>;
51
- }
52
- export declare enum SelectionMode {
53
- ALL_RECORDS = "ALL_RECORDS",
54
- SOME_RECORDS = "SOME_RECORDS"
55
- }
56
- export type DataUnitEventOptions = {
57
- [key: string]: any;
58
- };
59
- export type HideFieldOptions = {
60
- visibleOnConfig: boolean;
61
- };
@@ -1,13 +0,0 @@
1
- export var ChangeOperation;
2
- (function (ChangeOperation) {
3
- ChangeOperation["INSERT"] = "INSERT";
4
- ChangeOperation["COPY"] = "COPY";
5
- ChangeOperation["UPDATE"] = "UPDATE";
6
- ChangeOperation["DELETE"] = "DELETE";
7
- })(ChangeOperation || (ChangeOperation = {}));
8
- export var SelectionMode;
9
- (function (SelectionMode) {
10
- SelectionMode["ALL_RECORDS"] = "ALL_RECORDS";
11
- SelectionMode["SOME_RECORDS"] = "SOME_RECORDS";
12
- })(SelectionMode || (SelectionMode = {}));
13
- //# sourceMappingURL=dataUnit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataUnit.js","sourceRoot":"","sources":["../../../src/dataunit/interfaces/dataUnit.ts"],"names":[],"mappings":"AA4BA,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACvB,oCAAiB,CAAA;IACjB,gCAAa,CAAA;IACb,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;AACrB,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AA4BD,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,4CAA2B,CAAA;IAC3B,8CAA6B,CAAA;AACjC,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
@@ -1,77 +0,0 @@
1
- import { ChangeOperation, Record } from "./interfaces/dataUnit.js";
2
-
3
- /***
4
- * `Change`: Dados que representam uma alteração.
5
- */
6
- export class Change {
7
-
8
- public dataUnit: string;
9
- public record: Record;
10
- public sourceId: string | undefined;
11
- public updatingFields: any;
12
-
13
- private _operation: ChangeOperation;
14
-
15
- constructor(dataUnit: string, record: Record, updates: any, operation: ChangeOperation, sourceId?: string) {
16
- this.dataUnit = dataUnit;
17
- this.record = record;
18
- this.sourceId = sourceId;
19
- this.updatingFields = updates;
20
- this._operation = operation;
21
- }
22
-
23
- /**
24
- *
25
- * Obtém o tipo de operação que está sendo realizada.
26
- *
27
- * @returns - Ação que está sendo executada.
28
- *
29
- */
30
- public get operation(): string {
31
- return this._operation.toString();
32
- }
33
-
34
- /**
35
- *
36
- * Retorna se o DataUnit está em uma operação de inserção.
37
- *
38
- * @returns - Verdadeiro se a operação for de inserção.
39
- *
40
- */
41
- public isInsert(): boolean {
42
- return this._operation === ChangeOperation.INSERT;
43
- }
44
-
45
- /**
46
- *
47
- * Retorna se o DataUnit está em uma operação de cópia.
48
- *
49
- * @returns - Verdadeiro se a operação for de cópia.
50
- *
51
- */
52
- public isCopy(): boolean {
53
- return this._operation === ChangeOperation.COPY;
54
- }
55
-
56
- /**
57
- *
58
- * Retorna se o DataUnit está em uma operação de deleção.
59
- *
60
- * @returns - Verdadeiro se a operação for de deleção.
61
- *
62
- */
63
- public isDelete(): boolean {
64
- return this._operation === ChangeOperation.DELETE;
65
- }
66
-
67
- /**
68
- *
69
- * Retorna se o DataUnit está em uma operação de atualização.
70
- *
71
- * @returns - Verdadeiro se a operação for de atualização.
72
- *
73
- */
74
- public isUpdate(): boolean {
75
- return this._operation === ChangeOperation.UPDATE;
76
- }
77
- }