@katlux/providers 0.1.1-alpha.123 → 0.1.1-alpha.125

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/dist/index.cjs CHANGED
@@ -4020,7 +4020,8 @@ async function encryptRows(rows, encryption, apiUrl, idKey) {
4020
4020
  if (item && typeof item === "object") {
4021
4021
  for (let f = 0; f < fields.length; f++) {
4022
4022
  const val = item[fields[f]];
4023
- if (val !== void 0 && val !== null && !cipherProvider.isEncrypted(val)) {
4023
+ const isEnc = cipherProvider.isEncrypted?.(val) ?? CWebCryptoEncryptionProvider.isEncrypted(val);
4024
+ if (val !== void 0 && val !== null && !isEnc) {
4024
4025
  allEncrypted = false;
4025
4026
  break;
4026
4027
  }
@@ -4056,7 +4057,8 @@ async function encryptRowsChunked(rows, encryption, options, apiUrl, idKey, onCh
4056
4057
  if (item && typeof item === "object") {
4057
4058
  for (let f = 0; f < fields.length; f++) {
4058
4059
  const val = item[fields[f]];
4059
- if (val !== void 0 && val !== null && !cipherProvider.isEncrypted(val)) {
4060
+ const isEnc = cipherProvider.isEncrypted?.(val) ?? CWebCryptoEncryptionProvider.isEncrypted(val);
4061
+ if (val !== void 0 && val !== null && !isEnc) {
4060
4062
  allEncrypted = false;
4061
4063
  break;
4062
4064
  }
@@ -4831,7 +4833,7 @@ class CFlatClientDataProvider extends AEncryptedClientProvider {
4831
4833
  }
4832
4834
  if (this.pageSize <= 0) {
4833
4835
  this.pageData = this._rowMap;
4834
- } else {
4836
+ } else if (!this.isEncryptionEnabled) {
4835
4837
  const startIndex = (this.currentPage - 1) * this.pageSize;
4836
4838
  const endIndex = startIndex + this.pageSize;
4837
4839
  this.pageData = this._rowMap.slice(startIndex, endIndex);
@@ -6913,13 +6915,15 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
6913
6915
  try {
6914
6916
  if (this.apiUrl) {
6915
6917
  const nextPage = this.currentPage + 1;
6918
+ const shouldSkipDecryption = Boolean(this.encryption?.lazy ?? (this.encryption?.fields && this.encryption.fields.length > 0));
6916
6919
  await this.requestProvider.registerRequest(this.apiUrl, {
6917
6920
  query: {
6918
6921
  pageNumber: nextPage,
6919
6922
  pageSize: this.pageSize
6920
6923
  },
6921
6924
  deduplicate: this.deduplicate,
6922
- context: this.context
6925
+ context: this.context,
6926
+ skipDecryption: shouldSkipDecryption
6923
6927
  });
6924
6928
  if (this._lastDataReceivedPromise) {
6925
6929
  await this._lastDataReceivedPromise;
@@ -7853,7 +7857,33 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
7853
7857
  const filteredNodes = this._filteredNodesCache;
7854
7858
  this.filteredData = filteredNodes;
7855
7859
  const paginated = this.paginateNodes(filteredNodes);
7856
- this.pageData = paginated.map((node) => {
7860
+ if (this.pageSize <= 0) {
7861
+ this.pageData = paginated.map((node) => {
7862
+ const decrypted = this.isEncryptionEnabled ? this._decryptedNodeMap.get(node.id) : void 0;
7863
+ const nodeData = decrypted ? { ...node.data, ...decrypted } : node.data;
7864
+ return {
7865
+ ...nodeData,
7866
+ ...node,
7867
+ __treeNode: node
7868
+ };
7869
+ });
7870
+ } else if (!this.isEncryptionEnabled) {
7871
+ this.pageData = paginated.map((node) => {
7872
+ return {
7873
+ ...node.data,
7874
+ ...node,
7875
+ __treeNode: node
7876
+ };
7877
+ });
7878
+ }
7879
+ if (this.allData.length > 0) {
7880
+ this.initialLoad = false;
7881
+ }
7882
+ return;
7883
+ }
7884
+ const visible = this.visibleRows;
7885
+ if (this.pageSize <= 0) {
7886
+ this.pageData = visible.map((node) => {
7857
7887
  const decrypted = this.isEncryptionEnabled ? this._decryptedNodeMap.get(node.id) : void 0;
7858
7888
  const nodeData = decrypted ? { ...node.data, ...decrypted } : node.data;
7859
7889
  return {
@@ -7862,21 +7892,15 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
7862
7892
  __treeNode: node
7863
7893
  };
7864
7894
  });
7865
- if (this.allData.length > 0) {
7866
- this.initialLoad = false;
7867
- }
7868
- return;
7895
+ } else if (!this.isEncryptionEnabled) {
7896
+ this.pageData = visible.map((node) => {
7897
+ return {
7898
+ ...node.data,
7899
+ ...node,
7900
+ __treeNode: node
7901
+ };
7902
+ });
7869
7903
  }
7870
- const visible = this.visibleRows;
7871
- this.pageData = visible.map((node) => {
7872
- const decrypted = this.isEncryptionEnabled ? this._decryptedNodeMap.get(node.id) : void 0;
7873
- const nodeData = decrypted ? { ...node.data, ...decrypted } : node.data;
7874
- return {
7875
- ...nodeData,
7876
- ...node,
7877
- __treeNode: node
7878
- };
7879
- });
7880
7904
  if (this.allData.length > 0) {
7881
7905
  this.initialLoad = false;
7882
7906
  }
@@ -7936,7 +7960,7 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
7936
7960
  } else {
7937
7961
  this._allVisibleRowsCache = [];
7938
7962
  }
7939
- this.pageData = [...this._allVisibleRowsCache];
7963
+ this.pageData = [...this._allVisibleRowsCache ?? []];
7940
7964
  } else {
7941
7965
  this._allVisibleRowsCache = null;
7942
7966
  const startIndex = (this.currentPage - 1) * this.pageSize;
@@ -8049,8 +8073,9 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
8049
8073
  this.expandedNodes.add(nodeId);
8050
8074
  }
8051
8075
  this.updatePageData();
8052
- this.notify();
8053
- if (this.isEncryptionEnabled) {
8076
+ if (!this.isEncryptionEnabled) {
8077
+ this.notify();
8078
+ } else {
8054
8079
  this.loadPageData();
8055
8080
  }
8056
8081
  }
@@ -8061,8 +8086,9 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
8061
8086
  this._allVisibleRowsCache = null;
8062
8087
  this.expandedNodes.add(nodeId);
8063
8088
  this.updatePageData();
8064
- this.notify();
8065
- if (this.isEncryptionEnabled) {
8089
+ if (!this.isEncryptionEnabled) {
8090
+ this.notify();
8091
+ } else {
8066
8092
  this.loadPageData();
8067
8093
  }
8068
8094
  }
@@ -8073,8 +8099,9 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
8073
8099
  this._allVisibleRowsCache = null;
8074
8100
  this.expandedNodes.delete(nodeId);
8075
8101
  this.updatePageData();
8076
- this.notify();
8077
- if (this.isEncryptionEnabled) {
8102
+ if (!this.isEncryptionEnabled) {
8103
+ this.notify();
8104
+ } else {
8078
8105
  this.loadPageData();
8079
8106
  }
8080
8107
  }
@@ -8092,8 +8119,9 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
8092
8119
  const allIds = this._staticNodes.filter((n) => n.hasChildren).map((n) => n.id);
8093
8120
  this.expandedNodes = new Set(allIds);
8094
8121
  this.updatePageData();
8095
- this.notify();
8096
- if (this.isEncryptionEnabled) {
8122
+ if (!this.isEncryptionEnabled) {
8123
+ this.notify();
8124
+ } else {
8097
8125
  this.loadPageData();
8098
8126
  }
8099
8127
  }
@@ -8104,8 +8132,9 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
8104
8132
  this._allVisibleRowsCache = null;
8105
8133
  this.expandedNodes = /* @__PURE__ */ new Set();
8106
8134
  this.updatePageData();
8107
- this.notify();
8108
- if (this.isEncryptionEnabled) {
8135
+ if (!this.isEncryptionEnabled) {
8136
+ this.notify();
8137
+ } else {
8109
8138
  this.loadPageData();
8110
8139
  }
8111
8140
  }
package/dist/index.mjs CHANGED
@@ -4003,7 +4003,8 @@ async function encryptRows(rows, encryption, apiUrl, idKey) {
4003
4003
  if (item && typeof item === "object") {
4004
4004
  for (let f = 0; f < fields.length; f++) {
4005
4005
  const val = item[fields[f]];
4006
- if (val !== void 0 && val !== null && !cipherProvider.isEncrypted(val)) {
4006
+ const isEnc = cipherProvider.isEncrypted?.(val) ?? CWebCryptoEncryptionProvider.isEncrypted(val);
4007
+ if (val !== void 0 && val !== null && !isEnc) {
4007
4008
  allEncrypted = false;
4008
4009
  break;
4009
4010
  }
@@ -4039,7 +4040,8 @@ async function encryptRowsChunked(rows, encryption, options, apiUrl, idKey, onCh
4039
4040
  if (item && typeof item === "object") {
4040
4041
  for (let f = 0; f < fields.length; f++) {
4041
4042
  const val = item[fields[f]];
4042
- if (val !== void 0 && val !== null && !cipherProvider.isEncrypted(val)) {
4043
+ const isEnc = cipherProvider.isEncrypted?.(val) ?? CWebCryptoEncryptionProvider.isEncrypted(val);
4044
+ if (val !== void 0 && val !== null && !isEnc) {
4043
4045
  allEncrypted = false;
4044
4046
  break;
4045
4047
  }
@@ -4814,7 +4816,7 @@ class CFlatClientDataProvider extends AEncryptedClientProvider {
4814
4816
  }
4815
4817
  if (this.pageSize <= 0) {
4816
4818
  this.pageData = this._rowMap;
4817
- } else {
4819
+ } else if (!this.isEncryptionEnabled) {
4818
4820
  const startIndex = (this.currentPage - 1) * this.pageSize;
4819
4821
  const endIndex = startIndex + this.pageSize;
4820
4822
  this.pageData = this._rowMap.slice(startIndex, endIndex);
@@ -6896,13 +6898,15 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
6896
6898
  try {
6897
6899
  if (this.apiUrl) {
6898
6900
  const nextPage = this.currentPage + 1;
6901
+ const shouldSkipDecryption = Boolean(this.encryption?.lazy ?? (this.encryption?.fields && this.encryption.fields.length > 0));
6899
6902
  await this.requestProvider.registerRequest(this.apiUrl, {
6900
6903
  query: {
6901
6904
  pageNumber: nextPage,
6902
6905
  pageSize: this.pageSize
6903
6906
  },
6904
6907
  deduplicate: this.deduplicate,
6905
- context: this.context
6908
+ context: this.context,
6909
+ skipDecryption: shouldSkipDecryption
6906
6910
  });
6907
6911
  if (this._lastDataReceivedPromise) {
6908
6912
  await this._lastDataReceivedPromise;
@@ -7836,7 +7840,33 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
7836
7840
  const filteredNodes = this._filteredNodesCache;
7837
7841
  this.filteredData = filteredNodes;
7838
7842
  const paginated = this.paginateNodes(filteredNodes);
7839
- this.pageData = paginated.map((node) => {
7843
+ if (this.pageSize <= 0) {
7844
+ this.pageData = paginated.map((node) => {
7845
+ const decrypted = this.isEncryptionEnabled ? this._decryptedNodeMap.get(node.id) : void 0;
7846
+ const nodeData = decrypted ? { ...node.data, ...decrypted } : node.data;
7847
+ return {
7848
+ ...nodeData,
7849
+ ...node,
7850
+ __treeNode: node
7851
+ };
7852
+ });
7853
+ } else if (!this.isEncryptionEnabled) {
7854
+ this.pageData = paginated.map((node) => {
7855
+ return {
7856
+ ...node.data,
7857
+ ...node,
7858
+ __treeNode: node
7859
+ };
7860
+ });
7861
+ }
7862
+ if (this.allData.length > 0) {
7863
+ this.initialLoad = false;
7864
+ }
7865
+ return;
7866
+ }
7867
+ const visible = this.visibleRows;
7868
+ if (this.pageSize <= 0) {
7869
+ this.pageData = visible.map((node) => {
7840
7870
  const decrypted = this.isEncryptionEnabled ? this._decryptedNodeMap.get(node.id) : void 0;
7841
7871
  const nodeData = decrypted ? { ...node.data, ...decrypted } : node.data;
7842
7872
  return {
@@ -7845,21 +7875,15 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
7845
7875
  __treeNode: node
7846
7876
  };
7847
7877
  });
7848
- if (this.allData.length > 0) {
7849
- this.initialLoad = false;
7850
- }
7851
- return;
7878
+ } else if (!this.isEncryptionEnabled) {
7879
+ this.pageData = visible.map((node) => {
7880
+ return {
7881
+ ...node.data,
7882
+ ...node,
7883
+ __treeNode: node
7884
+ };
7885
+ });
7852
7886
  }
7853
- const visible = this.visibleRows;
7854
- this.pageData = visible.map((node) => {
7855
- const decrypted = this.isEncryptionEnabled ? this._decryptedNodeMap.get(node.id) : void 0;
7856
- const nodeData = decrypted ? { ...node.data, ...decrypted } : node.data;
7857
- return {
7858
- ...nodeData,
7859
- ...node,
7860
- __treeNode: node
7861
- };
7862
- });
7863
7887
  if (this.allData.length > 0) {
7864
7888
  this.initialLoad = false;
7865
7889
  }
@@ -7919,7 +7943,7 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
7919
7943
  } else {
7920
7944
  this._allVisibleRowsCache = [];
7921
7945
  }
7922
- this.pageData = [...this._allVisibleRowsCache];
7946
+ this.pageData = [...this._allVisibleRowsCache ?? []];
7923
7947
  } else {
7924
7948
  this._allVisibleRowsCache = null;
7925
7949
  const startIndex = (this.currentPage - 1) * this.pageSize;
@@ -8032,8 +8056,9 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
8032
8056
  this.expandedNodes.add(nodeId);
8033
8057
  }
8034
8058
  this.updatePageData();
8035
- this.notify();
8036
- if (this.isEncryptionEnabled) {
8059
+ if (!this.isEncryptionEnabled) {
8060
+ this.notify();
8061
+ } else {
8037
8062
  this.loadPageData();
8038
8063
  }
8039
8064
  }
@@ -8044,8 +8069,9 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
8044
8069
  this._allVisibleRowsCache = null;
8045
8070
  this.expandedNodes.add(nodeId);
8046
8071
  this.updatePageData();
8047
- this.notify();
8048
- if (this.isEncryptionEnabled) {
8072
+ if (!this.isEncryptionEnabled) {
8073
+ this.notify();
8074
+ } else {
8049
8075
  this.loadPageData();
8050
8076
  }
8051
8077
  }
@@ -8056,8 +8082,9 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
8056
8082
  this._allVisibleRowsCache = null;
8057
8083
  this.expandedNodes.delete(nodeId);
8058
8084
  this.updatePageData();
8059
- this.notify();
8060
- if (this.isEncryptionEnabled) {
8085
+ if (!this.isEncryptionEnabled) {
8086
+ this.notify();
8087
+ } else {
8061
8088
  this.loadPageData();
8062
8089
  }
8063
8090
  }
@@ -8075,8 +8102,9 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
8075
8102
  const allIds = this._staticNodes.filter((n) => n.hasChildren).map((n) => n.id);
8076
8103
  this.expandedNodes = new Set(allIds);
8077
8104
  this.updatePageData();
8078
- this.notify();
8079
- if (this.isEncryptionEnabled) {
8105
+ if (!this.isEncryptionEnabled) {
8106
+ this.notify();
8107
+ } else {
8080
8108
  this.loadPageData();
8081
8109
  }
8082
8110
  }
@@ -8087,8 +8115,9 @@ class CTreeClientDataProvider extends CFlatClientDataProvider {
8087
8115
  this._allVisibleRowsCache = null;
8088
8116
  this.expandedNodes = /* @__PURE__ */ new Set();
8089
8117
  this.updatePageData();
8090
- this.notify();
8091
- if (this.isEncryptionEnabled) {
8118
+ if (!this.isEncryptionEnabled) {
8119
+ this.notify();
8120
+ } else {
8092
8121
  this.loadPageData();
8093
8122
  }
8094
8123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/providers",
3
- "version": "0.1.1-alpha.123",
3
+ "version": "0.1.1-alpha.125",
4
4
  "description": "Core data calculation and caching providers for the Katlux ecosystem",
5
5
  "author": "Katlux",
6
6
  "license": "Apache-2.0",