@sankhyalabs/core 1.0.62 → 1.0.65

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.
@@ -2,10 +2,14 @@ import { ActionReducer, StateAction } from "../StateManager.js";
2
2
  import StateManager from "../StateManager.js";
3
3
  declare class SelectionReducerImpl implements ActionReducer {
4
4
  sliceName: string;
5
- reduce(stateManager: StateManager, currentState: Array<string>, action: StateAction): Array<string> | undefined;
5
+ reduce(stateManager: StateManager, currentState: SelectionState, action: StateAction): SelectionState | undefined;
6
6
  }
7
7
  export declare const SelectionReducer: SelectionReducerImpl;
8
8
  export declare const getSelection: (stateManager: StateManager) => Array<string>;
9
9
  export declare const hasNext: (stateManager: StateManager) => boolean;
10
10
  export declare const hasPrevious: (stateManager: StateManager) => boolean;
11
+ interface SelectionState {
12
+ currentSelection: Array<string>;
13
+ lastSelection?: Array<string>;
14
+ }
11
15
  export {};
@@ -8,13 +8,14 @@ class SelectionReducerImpl {
8
8
  switch (action.type) {
9
9
  case Action.RECORDS_ADDED:
10
10
  case Action.RECORDS_COPIED:
11
- return action.payload.map((r) => r.__record__id__);
11
+ return { currentSelection: action.payload.map((r) => r.__record__id__), lastSelection: currentState === null || currentState === void 0 ? void 0 : currentState.currentSelection };
12
12
  case Action.DATA_SAVED:
13
- return updateSavedIds(stateManager, action.payload.records);
13
+ return { currentSelection: updateSavedIds(stateManager, action.payload.records) };
14
14
  case Action.RECORDS_REMOVED:
15
15
  const removed = action.payload.records;
16
16
  if (currentState && removed) {
17
- const record = currentState.filter(recordId => !removed.includes(recordId));
17
+ const currentSelection = currentState.currentSelection;
18
+ const record = currentSelection.filter(recordId => !removed.includes(recordId));
18
19
  if (record.length === 0) {
19
20
  const currentRecords = getCurrentRecords(stateManager);
20
21
  let removedIndex = action.payload.removedIndex.slice(-1)[0];
@@ -32,22 +33,23 @@ class SelectionReducerImpl {
32
33
  currentIndex++;
33
34
  });
34
35
  }
35
- return record;
36
+ return { currentSelection: record };
36
37
  }
37
38
  return currentState;
38
39
  case Action.NEXT_SELECTED:
39
40
  case Action.PREVIOUS_SELECTED:
40
41
  const currentRecords = getCurrentRecords(stateManager);
42
+ const currentSelection = currentState === null || currentState === void 0 ? void 0 : currentState.currentSelection;
41
43
  if (currentRecords && currentRecords.size > 0) {
42
44
  let index;
43
- if (!currentState || currentState.length === 0) {
45
+ if (!currentState || currentSelection.length === 0) {
44
46
  index = action.type === Action.PREVIOUS_SELECTED ? 0 : Math.min(1, currentRecords.size);
45
47
  }
46
48
  else {
47
- index = getItemIndex(currentState[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
49
+ index = getItemIndex(currentSelection[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
48
50
  }
49
51
  if (index < currentRecords.size && index >= 0) {
50
- return [Array.from(currentRecords.values())[index].__record__id__];
52
+ return { currentSelection: [Array.from(currentRecords.values())[index].__record__id__] };
51
53
  }
52
54
  }
53
55
  return undefined;
@@ -63,17 +65,21 @@ class SelectionReducerImpl {
63
65
  selectionById.push(records[i].__record__id__);
64
66
  }
65
67
  });
66
- return selectionById;
68
+ return { currentSelection: selectionById };
67
69
  }
68
70
  }
69
- return selectionSource;
71
+ return { currentSelection: selectionSource };
72
+ case Action.EDITION_CANCELED:
73
+ if (currentState === null || currentState === void 0 ? void 0 : currentState.lastSelection) {
74
+ return { currentSelection: currentState.lastSelection };
75
+ }
70
76
  }
71
77
  return currentState;
72
78
  }
73
79
  }
74
80
  export const SelectionReducer = new SelectionReducerImpl();
75
81
  export const getSelection = (stateManager) => {
76
- let selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
82
+ let selection = getCurrentSelection(stateManager);
77
83
  const currentRecords = Array.from((getCurrentRecords(stateManager) || new Map()).keys());
78
84
  if (selection) {
79
85
  selection = selection.filter(id => currentRecords.includes(id));
@@ -86,7 +92,7 @@ export const getSelection = (stateManager) => {
86
92
  export const hasNext = (stateManager) => {
87
93
  const records = getCurrentRecords(stateManager);
88
94
  if (records) {
89
- const selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
95
+ const selection = getCurrentSelection(stateManager);
90
96
  if (!selection || selection.length === 0) {
91
97
  return records.size > 0;
92
98
  }
@@ -97,7 +103,7 @@ export const hasNext = (stateManager) => {
97
103
  export const hasPrevious = (stateManager) => {
98
104
  const records = getCurrentRecords(stateManager);
99
105
  if (records) {
100
- const selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
106
+ const selection = getCurrentSelection(stateManager);
101
107
  if (!selection || selection.length === 0) {
102
108
  return false;
103
109
  }
@@ -125,4 +131,8 @@ function updateSavedIds(stateManager, savedRecords) {
125
131
  }
126
132
  return currentSelection;
127
133
  }
134
+ function getCurrentSelection(stateManager) {
135
+ var _a;
136
+ return (_a = stateManager.select(SelectionReducer.sliceName, (state) => state)) === null || _a === void 0 ? void 0 : _a.currentSelection;
137
+ }
128
138
  //# sourceMappingURL=SelectionSlice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionSlice.js","sourceRoot":"","sources":["../../../../src/dataunit/state/slice/SelectionSlice.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,MAAM,oBAAoB;IAA1B;QAEW,cAAS,GAAW,iBAAiB,CAAC;IAkFjD,CAAC;IAhFU,MAAM,CAAC,YAA0B,EAAE,YAA2B,EAAE,MAAmB;QAEtF,QAAQ,MAAM,CAAC,IAAI,EAAE;YAEjB,KAAK,MAAM,CAAC,aAAa,CAAC;YAC1B,KAAK,MAAM,CAAC,cAAc;gBACtB,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAS,EAAC,EAAE,CAAA,CAAC,CAAC,cAAc,CAAC,CAAC;YAC7D,KAAK,MAAM,CAAC,UAAU;gBAClB,OAAO,cAAc,CAAC,YAAY,EAAE,MAAM,C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AAO,MAAA,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAqB,EAAE,EAAE,CAAC,KAAK,CAAC,0CAAE,gBAAgB,CAAC;AAC/G,CAAC"}
package/dist/index.d.ts CHANGED
@@ -18,4 +18,5 @@ import ObjectUtils from "./utils/ObjectUtils.js";
18
18
  import WarningException from "./exceptions/WarningException.js";
19
19
  import WaitingChangeException from "./exceptions/WaitingChangeException.js";
20
20
  import ErrorException from "./exceptions/ErrorException.js";
21
- export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, Record, SavedRecord, DataType, UnitMetadata, FieldDescriptor, UserInterface, DataUnitAction, Action, Change, Sort, Filter, ChangeOperation, DUActionInterceptor, ApplicationContext, WaitingChange, PageRequest, QuickFilter, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, };
21
+ import { ErrorTracking } from "./traking/ErrorTraking.js";
22
+ export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, Record, SavedRecord, DataType, UnitMetadata, FieldDescriptor, UserInterface, DataUnitAction, Action, Change, Sort, Filter, ChangeOperation, DUActionInterceptor, ApplicationContext, WaitingChange, PageRequest, QuickFilter, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking };
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ import ObjectUtils from "./utils/ObjectUtils.js";
18
18
  import WarningException from "./exceptions/WarningException.js";
19
19
  import WaitingChangeException from "./exceptions/WaitingChangeException.js";
20
20
  import ErrorException from "./exceptions/ErrorException.js";
21
+ import { ErrorTracking } from "./traking/ErrorTraking.js";
21
22
  /*Classes públicas no pacote*/
22
- export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataType, UserInterface, DataUnitAction, Action, Change, ChangeOperation, ApplicationContext, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, };
23
+ export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataType, UserInterface, DataUnitAction, Action, Change, ChangeOperation, ApplicationContext, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking };
23
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,QAAQ,EAAE,EAAsB,MAAM,EAAE,eAAe,EAA+D,MAAM,wBAAwB,CAAC;AAC5J,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAiC,aAAa,EAAgB,MAAM,qCAAqC,CAAC;AACjH,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,kBAAkB,MAAM,+BA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Aa,EAAgB,MAAM,qCAAqC,CAAC;AACjH,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,sBAAsB,MAAM,wCAAwC,CAAC;AAC5E,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,8BAA8B;AAC9B,OAAO,EACH,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,SAAS,EACT,aAAa,EACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,QAAQ,EAGR,QAAQ,EAGR,aAAa,EACb,cAAc,EACd,MAAM,EACN,MAAM,EAGN,eAAe,EAEf,kBAAkB,EAIlB,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,aAAa,EAChB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare class ErrorTracking {
2
+ static init(): void;
3
+ private static isInternalException;
4
+ }
@@ -0,0 +1,19 @@
1
+ import ErrorException from "../exceptions/ErrorException.js";
2
+ import WaitingChangeException from "../exceptions/WaitingChangeException.js";
3
+ import WarningException from "../exceptions/WarningException.js";
4
+ export class ErrorTracking {
5
+ static init() {
6
+ const rollbar = window.Rollbar;
7
+ if (rollbar) {
8
+ rollbar.configure({
9
+ checkIgnore: function (isUncaught, args, payload) {
10
+ return args[1] ? ErrorTracking.isInternalException(args[1]) : false;
11
+ }
12
+ });
13
+ }
14
+ }
15
+ static isInternalException(error) {
16
+ return (error instanceof ErrorException || error instanceof WaitingChangeException || error instanceof WarningException);
17
+ }
18
+ }
19
+ //# sourceMappingURL=ErrorTraking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorTraking.js","sourceRoot":"","sources":["../../src/traking/ErrorTraking.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,iCAAiC,CAAC;AAC7D,OAAO,sBAAsB,MAAM,yCAAyC,CAAC;AAC7E,OAAO,gBAAgB,MAAM,mCAAmC,CAAC;AAEjE,MAAM,OAAO,aAAa;IACf,MAAM,CAAC,IAAI;QACd,MAAM,OAAO,GAAI,MAAc,CAAC,OAAO,CAAC;QACxC,IAAG,OAAO,EAAC;YACP,OAAO,CAAC,SAAS,CAAC;gBACd,WAAW,EAAE,UAAS,UAAkB,EAAE,IAAe,EAAE,OAAW;oBAClE,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;gBACxE,CAAC;aACJ,CAAC,CAAC;SACN;IACL,CAAC;IAEO,MAAM,CAAC,mBAAmB,CAAC,KAAS;QACxC,OAAO,CAAC,KAAK,YAAY,cAAc,IAAI,KAAK,YAAY,sBAAsB,IAAI,KAAK,YAAY,gBAAgB,CAAC,CAAC;IAC7H,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/core",
3
- "version": "1.0.62",
3
+ "version": "1.0.65",
4
4
  "description": "Modulo core JavaScript da Sankhya.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -8,20 +8,21 @@ class SelectionReducerImpl implements ActionReducer {
8
8
 
9
9
  public sliceName: string = "hist::selection";
10
10
 
11
- public reduce(stateManager: StateManager, currentState: Array<string>, action: StateAction): Array<string>|undefined {
11
+ public reduce(stateManager: StateManager, currentState: SelectionState, action: StateAction): SelectionState|undefined {
12
12
 
13
13
  switch (action.type) {
14
14
 
15
15
  case Action.RECORDS_ADDED:
16
16
  case Action.RECORDS_COPIED:
17
- return action.payload.map((r: Record)=>r.__record__id__);
17
+ return {currentSelection: action.payload.map((r: Record)=>r.__record__id__), lastSelection: currentState?.currentSelection};
18
18
  case Action.DATA_SAVED:
19
- return updateSavedIds(stateManager, action.payload.records);
19
+ return {currentSelection: updateSavedIds(stateManager, action.payload.records)};
20
20
  case Action.RECORDS_REMOVED:
21
21
  const removed: Array<string> = action.payload.records;
22
22
 
23
23
  if (currentState && removed) {
24
- const record = currentState.filter(recordId => !removed.includes(recordId));
24
+ const currentSelection = currentState.currentSelection;
25
+ const record = currentSelection.filter(recordId => !removed.includes(recordId));
25
26
 
26
27
  if(record.length === 0) {
27
28
  const currentRecords = getCurrentRecords(stateManager);
@@ -42,9 +43,7 @@ class SelectionReducerImpl implements ActionReducer {
42
43
  })
43
44
 
44
45
  }
45
-
46
- return record;
47
-
46
+ return {currentSelection: record};
48
47
  }
49
48
  return currentState;
50
49
 
@@ -52,15 +51,16 @@ class SelectionReducerImpl implements ActionReducer {
52
51
  case Action.PREVIOUS_SELECTED:
53
52
 
54
53
  const currentRecords = getCurrentRecords(stateManager);
54
+ const currentSelection = currentState?.currentSelection;
55
55
  if (currentRecords && currentRecords.size > 0) {
56
56
  let index: number;
57
- if (!currentState || currentState.length === 0) {
57
+ if (!currentState || currentSelection.length === 0) {
58
58
  index = action.type === Action.PREVIOUS_SELECTED ? 0 : Math.min(1, currentRecords.size);
59
59
  } else {
60
- index = getItemIndex(currentState[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
60
+ index = getItemIndex(currentSelection[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
61
61
  }
62
62
  if (index < currentRecords.size && index >= 0) {
63
- return [Array.from(currentRecords.values())[index].__record__id__];
63
+ return { currentSelection: [Array.from(currentRecords.values())[index].__record__id__] };
64
64
  }
65
65
  }
66
66
 
@@ -79,11 +79,15 @@ class SelectionReducerImpl implements ActionReducer {
79
79
  selectionById.push(records[i].__record__id__);
80
80
  }
81
81
  });
82
- return selectionById;
82
+ return {currentSelection: selectionById};
83
83
  }
84
84
  }
85
85
 
86
- return selectionSource;
86
+ return {currentSelection: selectionSource };
87
+ case Action.EDITION_CANCELED:
88
+ if(currentState?.lastSelection){
89
+ return { currentSelection: currentState.lastSelection };
90
+ }
87
91
  }
88
92
 
89
93
  return currentState;
@@ -93,7 +97,7 @@ class SelectionReducerImpl implements ActionReducer {
93
97
  export const SelectionReducer = new SelectionReducerImpl();
94
98
 
95
99
  export const getSelection = (stateManager: StateManager): Array<string> => {
96
- let selection: Array<string> = stateManager.select(SelectionReducer.sliceName, (state: Array<string>) => state);
100
+ let selection: Array<string> = getCurrentSelection(stateManager);
97
101
  const currentRecords = Array.from((getCurrentRecords(stateManager)||new Map()).keys());
98
102
 
99
103
  if(selection){
@@ -110,7 +114,7 @@ export const getSelection = (stateManager: StateManager): Array<string> => {
110
114
  export const hasNext = (stateManager: StateManager): boolean => {
111
115
  const records = getCurrentRecords(stateManager);
112
116
  if (records) {
113
- const selection = stateManager.select(SelectionReducer.sliceName, (state: Array<string>) => state);
117
+ const selection = getCurrentSelection(stateManager);
114
118
  if (!selection || selection.length === 0) {
115
119
  return records.size > 0;
116
120
  }
@@ -122,7 +126,7 @@ export const hasNext = (stateManager: StateManager): boolean => {
122
126
  export const hasPrevious = (stateManager: StateManager): boolean => {
123
127
  const records = getCurrentRecords(stateManager);
124
128
  if (records) {
125
- const selection = stateManager.select(SelectionReducer.sliceName, (state: Array<string>) => state);
129
+ const selection = getCurrentSelection(stateManager);
126
130
  if (!selection || selection.length === 0) {
127
131
  return false;
128
132
  }
@@ -150,4 +154,12 @@ function updateSavedIds(stateManager:StateManager, savedRecords:Array<SavedRecor
150
154
  return newSelection;
151
155
  }
152
156
  return currentSelection;
157
+ }
158
+
159
+ function getCurrentSelection(stateManager: StateManager):Array<string>{
160
+ return stateManager.select(SelectionReducer.sliceName, (state: SelectionState) => state)?.currentSelection;
161
+ }
162
+ interface SelectionState{
163
+ currentSelection: Array<string>;
164
+ lastSelection?: Array<string>;
153
165
  }
package/src/index.ts CHANGED
@@ -18,6 +18,7 @@ import ObjectUtils from "./utils/ObjectUtils.js";
18
18
  import WarningException from "./exceptions/WarningException.js";
19
19
  import WaitingChangeException from "./exceptions/WaitingChangeException.js";
20
20
  import ErrorException from "./exceptions/ErrorException.js";
21
+ import { ErrorTracking } from "./traking/ErrorTraking.js";
21
22
 
22
23
  /*Classes públicas no pacote*/
23
24
  export {
@@ -54,4 +55,5 @@ export {
54
55
  WarningException,
55
56
  WaitingChangeException,
56
57
  ErrorException,
58
+ ErrorTracking
57
59
  };
@@ -0,0 +1,20 @@
1
+ import ErrorException from "../exceptions/ErrorException.js";
2
+ import WaitingChangeException from "../exceptions/WaitingChangeException.js";
3
+ import WarningException from "../exceptions/WarningException.js";
4
+
5
+ export class ErrorTracking {
6
+ public static init(){
7
+ const rollbar = (window as any).Rollbar;
8
+ if(rollbar){
9
+ rollbar.configure({
10
+ checkIgnore: function(isUncaught:boolean, args:Array<any>, payload:any) {
11
+ return args[1] ? ErrorTracking.isInternalException(args[1]) : false;
12
+ }
13
+ });
14
+ }
15
+ }
16
+
17
+ private static isInternalException(error:any):boolean{
18
+ return (error instanceof ErrorException || error instanceof WaitingChangeException || error instanceof WarningException);
19
+ }
20
+ }