@nexushub/client 1.1.11 → 1.1.13
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 +39 -43
- package/dist/index.js +39 -43
- package/dist/react.cjs +39 -43
- package/dist/react.js +39 -43
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -939,7 +939,7 @@ var ContentEngine = class {
|
|
|
939
939
|
);
|
|
940
940
|
if (this.config.debug && duration > 100) {
|
|
941
941
|
console.warn(
|
|
942
|
-
`[
|
|
942
|
+
`[NexusHub] \u26A0\uFE0F getPage("${slug}") took ${duration.toFixed(2)}ms`
|
|
943
943
|
);
|
|
944
944
|
}
|
|
945
945
|
return result;
|
|
@@ -976,7 +976,7 @@ var ContentEngine = class {
|
|
|
976
976
|
}
|
|
977
977
|
}
|
|
978
978
|
if (this.circuitBreaker.isOpen()) {
|
|
979
|
-
throw new Error("[
|
|
979
|
+
throw new Error("[NexusHub] Circuit open. API is unavailable.");
|
|
980
980
|
}
|
|
981
981
|
try {
|
|
982
982
|
await this.rateLimiter.checkLimit();
|
|
@@ -993,22 +993,21 @@ var ContentEngine = class {
|
|
|
993
993
|
return includeMetadata ? data : data.data;
|
|
994
994
|
} catch (error) {
|
|
995
995
|
this.circuitBreaker.recordFailure();
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
996
|
+
if (process.env.NODE_ENV === "development") {
|
|
997
|
+
try {
|
|
998
|
+
const local = await this.localCache.getPage(slug);
|
|
999
|
+
if (local) {
|
|
1000
|
+
return includeMetadata ? {
|
|
1001
|
+
data: local,
|
|
1002
|
+
metadata: {
|
|
1003
|
+
timestamp: Date.now(),
|
|
1004
|
+
expiresAt: Infinity,
|
|
1005
|
+
tags: []
|
|
1006
|
+
}
|
|
1007
|
+
} : local;
|
|
1008
|
+
}
|
|
1009
|
+
} catch {
|
|
1010
1010
|
}
|
|
1011
|
-
} catch {
|
|
1012
1011
|
}
|
|
1013
1012
|
throw this.normalizeError(error, `Failed to fetch page '${slug}'`);
|
|
1014
1013
|
}
|
|
@@ -1037,17 +1036,17 @@ var ContentEngine = class {
|
|
|
1037
1036
|
localCollection,
|
|
1038
1037
|
normalizedQuery
|
|
1039
1038
|
);
|
|
1040
|
-
return
|
|
1039
|
+
return result;
|
|
1041
1040
|
}
|
|
1042
1041
|
} catch {
|
|
1043
1042
|
}
|
|
1044
1043
|
}
|
|
1045
1044
|
if (this.circuitBreaker.isOpen()) {
|
|
1046
|
-
throw new Error("[
|
|
1045
|
+
throw new Error("[NexusHub] Circuit open. API is unavailable.");
|
|
1047
1046
|
}
|
|
1048
1047
|
try {
|
|
1049
1048
|
await this.rateLimiter.checkLimit();
|
|
1050
|
-
const
|
|
1049
|
+
const result = await this.backoff.execute(async () => {
|
|
1051
1050
|
return this.fetchCollection(
|
|
1052
1051
|
collectionId,
|
|
1053
1052
|
normalizedQuery,
|
|
@@ -1058,22 +1057,20 @@ var ContentEngine = class {
|
|
|
1058
1057
|
);
|
|
1059
1058
|
});
|
|
1060
1059
|
this.circuitBreaker.recordSuccess();
|
|
1061
|
-
return includeMetadata ?
|
|
1060
|
+
return includeMetadata ? result : result.data;
|
|
1062
1061
|
} catch (error) {
|
|
1063
1062
|
this.circuitBreaker.recordFailure();
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
return includeMetadata ? result : result;
|
|
1063
|
+
if (process.env.NODE_ENV === "development") {
|
|
1064
|
+
try {
|
|
1065
|
+
const localCollection = await this.localCache.getCollection(collectionId);
|
|
1066
|
+
if (localCollection) {
|
|
1067
|
+
return this.applyLocalQuery(
|
|
1068
|
+
localCollection,
|
|
1069
|
+
normalizedQuery
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
} catch {
|
|
1075
1073
|
}
|
|
1076
|
-
} catch {
|
|
1077
1074
|
}
|
|
1078
1075
|
throw this.normalizeError(
|
|
1079
1076
|
error,
|
|
@@ -1132,15 +1129,14 @@ var ContentEngine = class {
|
|
|
1132
1129
|
}
|
|
1133
1130
|
return data;
|
|
1134
1131
|
} catch (error) {
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1132
|
+
if (process.env.NODE_ENV === "development") {
|
|
1133
|
+
try {
|
|
1134
|
+
const localGlobals = await this.localCache.getGlobals();
|
|
1135
|
+
if (localGlobals) {
|
|
1136
|
+
return localGlobals;
|
|
1137
|
+
}
|
|
1138
|
+
} catch {
|
|
1142
1139
|
}
|
|
1143
|
-
} catch {
|
|
1144
1140
|
}
|
|
1145
1141
|
throw this.normalizeError(error, "Failed to fetch globals");
|
|
1146
1142
|
}
|
|
@@ -1291,7 +1287,7 @@ var ContentEngine = class {
|
|
|
1291
1287
|
};
|
|
1292
1288
|
}
|
|
1293
1289
|
writeCache(key, data, options) {
|
|
1294
|
-
const ttlSeconds = options.revalidate === false ?
|
|
1290
|
+
const ttlSeconds = options.revalidate === false ? 60 : Math.max(1, options.revalidate);
|
|
1295
1291
|
if (this.cacheStrategy === "memory") {
|
|
1296
1292
|
this.memoryCache.set(key, data, {
|
|
1297
1293
|
tags: options.tags,
|
|
@@ -1454,7 +1450,7 @@ var ContentEngine = class {
|
|
|
1454
1450
|
}
|
|
1455
1451
|
async fetchWithTimeout(url, options = {}) {
|
|
1456
1452
|
const {
|
|
1457
|
-
timeout = this.config.timeout ||
|
|
1453
|
+
timeout = this.config.timeout || 1e4,
|
|
1458
1454
|
tags = [],
|
|
1459
1455
|
revalidate,
|
|
1460
1456
|
forceRefresh = false,
|
package/dist/index.js
CHANGED
|
@@ -883,7 +883,7 @@ var ContentEngine = class {
|
|
|
883
883
|
);
|
|
884
884
|
if (this.config.debug && duration > 100) {
|
|
885
885
|
console.warn(
|
|
886
|
-
`[
|
|
886
|
+
`[NexusHub] \u26A0\uFE0F getPage("${slug}") took ${duration.toFixed(2)}ms`
|
|
887
887
|
);
|
|
888
888
|
}
|
|
889
889
|
return result;
|
|
@@ -920,7 +920,7 @@ var ContentEngine = class {
|
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
if (this.circuitBreaker.isOpen()) {
|
|
923
|
-
throw new Error("[
|
|
923
|
+
throw new Error("[NexusHub] Circuit open. API is unavailable.");
|
|
924
924
|
}
|
|
925
925
|
try {
|
|
926
926
|
await this.rateLimiter.checkLimit();
|
|
@@ -937,22 +937,21 @@ var ContentEngine = class {
|
|
|
937
937
|
return includeMetadata ? data : data.data;
|
|
938
938
|
} catch (error) {
|
|
939
939
|
this.circuitBreaker.recordFailure();
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
940
|
+
if (process.env.NODE_ENV === "development") {
|
|
941
|
+
try {
|
|
942
|
+
const local = await this.localCache.getPage(slug);
|
|
943
|
+
if (local) {
|
|
944
|
+
return includeMetadata ? {
|
|
945
|
+
data: local,
|
|
946
|
+
metadata: {
|
|
947
|
+
timestamp: Date.now(),
|
|
948
|
+
expiresAt: Infinity,
|
|
949
|
+
tags: []
|
|
950
|
+
}
|
|
951
|
+
} : local;
|
|
952
|
+
}
|
|
953
|
+
} catch {
|
|
954
954
|
}
|
|
955
|
-
} catch {
|
|
956
955
|
}
|
|
957
956
|
throw this.normalizeError(error, `Failed to fetch page '${slug}'`);
|
|
958
957
|
}
|
|
@@ -981,17 +980,17 @@ var ContentEngine = class {
|
|
|
981
980
|
localCollection,
|
|
982
981
|
normalizedQuery
|
|
983
982
|
);
|
|
984
|
-
return
|
|
983
|
+
return result;
|
|
985
984
|
}
|
|
986
985
|
} catch {
|
|
987
986
|
}
|
|
988
987
|
}
|
|
989
988
|
if (this.circuitBreaker.isOpen()) {
|
|
990
|
-
throw new Error("[
|
|
989
|
+
throw new Error("[NexusHub] Circuit open. API is unavailable.");
|
|
991
990
|
}
|
|
992
991
|
try {
|
|
993
992
|
await this.rateLimiter.checkLimit();
|
|
994
|
-
const
|
|
993
|
+
const result = await this.backoff.execute(async () => {
|
|
995
994
|
return this.fetchCollection(
|
|
996
995
|
collectionId,
|
|
997
996
|
normalizedQuery,
|
|
@@ -1002,22 +1001,20 @@ var ContentEngine = class {
|
|
|
1002
1001
|
);
|
|
1003
1002
|
});
|
|
1004
1003
|
this.circuitBreaker.recordSuccess();
|
|
1005
|
-
return includeMetadata ?
|
|
1004
|
+
return includeMetadata ? result : result.data;
|
|
1006
1005
|
} catch (error) {
|
|
1007
1006
|
this.circuitBreaker.recordFailure();
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
return includeMetadata ? result : result;
|
|
1007
|
+
if (process.env.NODE_ENV === "development") {
|
|
1008
|
+
try {
|
|
1009
|
+
const localCollection = await this.localCache.getCollection(collectionId);
|
|
1010
|
+
if (localCollection) {
|
|
1011
|
+
return this.applyLocalQuery(
|
|
1012
|
+
localCollection,
|
|
1013
|
+
normalizedQuery
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
} catch {
|
|
1019
1017
|
}
|
|
1020
|
-
} catch {
|
|
1021
1018
|
}
|
|
1022
1019
|
throw this.normalizeError(
|
|
1023
1020
|
error,
|
|
@@ -1076,15 +1073,14 @@ var ContentEngine = class {
|
|
|
1076
1073
|
}
|
|
1077
1074
|
return data;
|
|
1078
1075
|
} catch (error) {
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1076
|
+
if (process.env.NODE_ENV === "development") {
|
|
1077
|
+
try {
|
|
1078
|
+
const localGlobals = await this.localCache.getGlobals();
|
|
1079
|
+
if (localGlobals) {
|
|
1080
|
+
return localGlobals;
|
|
1081
|
+
}
|
|
1082
|
+
} catch {
|
|
1086
1083
|
}
|
|
1087
|
-
} catch {
|
|
1088
1084
|
}
|
|
1089
1085
|
throw this.normalizeError(error, "Failed to fetch globals");
|
|
1090
1086
|
}
|
|
@@ -1235,7 +1231,7 @@ var ContentEngine = class {
|
|
|
1235
1231
|
};
|
|
1236
1232
|
}
|
|
1237
1233
|
writeCache(key, data, options) {
|
|
1238
|
-
const ttlSeconds = options.revalidate === false ?
|
|
1234
|
+
const ttlSeconds = options.revalidate === false ? 60 : Math.max(1, options.revalidate);
|
|
1239
1235
|
if (this.cacheStrategy === "memory") {
|
|
1240
1236
|
this.memoryCache.set(key, data, {
|
|
1241
1237
|
tags: options.tags,
|
|
@@ -1398,7 +1394,7 @@ var ContentEngine = class {
|
|
|
1398
1394
|
}
|
|
1399
1395
|
async fetchWithTimeout(url, options = {}) {
|
|
1400
1396
|
const {
|
|
1401
|
-
timeout = this.config.timeout ||
|
|
1397
|
+
timeout = this.config.timeout || 1e4,
|
|
1402
1398
|
tags = [],
|
|
1403
1399
|
revalidate,
|
|
1404
1400
|
forceRefresh = false,
|
package/dist/react.cjs
CHANGED
|
@@ -865,7 +865,7 @@ var ContentEngine = class {
|
|
|
865
865
|
);
|
|
866
866
|
if (this.config.debug && duration > 100) {
|
|
867
867
|
console.warn(
|
|
868
|
-
`[
|
|
868
|
+
`[NexusHub] \u26A0\uFE0F getPage("${slug}") took ${duration.toFixed(2)}ms`
|
|
869
869
|
);
|
|
870
870
|
}
|
|
871
871
|
return result;
|
|
@@ -902,7 +902,7 @@ var ContentEngine = class {
|
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
904
|
if (this.circuitBreaker.isOpen()) {
|
|
905
|
-
throw new Error("[
|
|
905
|
+
throw new Error("[NexusHub] Circuit open. API is unavailable.");
|
|
906
906
|
}
|
|
907
907
|
try {
|
|
908
908
|
await this.rateLimiter.checkLimit();
|
|
@@ -919,22 +919,21 @@ var ContentEngine = class {
|
|
|
919
919
|
return includeMetadata ? data : data.data;
|
|
920
920
|
} catch (error) {
|
|
921
921
|
this.circuitBreaker.recordFailure();
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
922
|
+
if (process.env.NODE_ENV === "development") {
|
|
923
|
+
try {
|
|
924
|
+
const local = await this.localCache.getPage(slug);
|
|
925
|
+
if (local) {
|
|
926
|
+
return includeMetadata ? {
|
|
927
|
+
data: local,
|
|
928
|
+
metadata: {
|
|
929
|
+
timestamp: Date.now(),
|
|
930
|
+
expiresAt: Infinity,
|
|
931
|
+
tags: []
|
|
932
|
+
}
|
|
933
|
+
} : local;
|
|
934
|
+
}
|
|
935
|
+
} catch (e7) {
|
|
936
936
|
}
|
|
937
|
-
} catch (e7) {
|
|
938
937
|
}
|
|
939
938
|
throw this.normalizeError(error, `Failed to fetch page '${slug}'`);
|
|
940
939
|
}
|
|
@@ -963,17 +962,17 @@ var ContentEngine = class {
|
|
|
963
962
|
localCollection,
|
|
964
963
|
normalizedQuery
|
|
965
964
|
);
|
|
966
|
-
return
|
|
965
|
+
return result;
|
|
967
966
|
}
|
|
968
967
|
} catch (e8) {
|
|
969
968
|
}
|
|
970
969
|
}
|
|
971
970
|
if (this.circuitBreaker.isOpen()) {
|
|
972
|
-
throw new Error("[
|
|
971
|
+
throw new Error("[NexusHub] Circuit open. API is unavailable.");
|
|
973
972
|
}
|
|
974
973
|
try {
|
|
975
974
|
await this.rateLimiter.checkLimit();
|
|
976
|
-
const
|
|
975
|
+
const result = await this.backoff.execute(async () => {
|
|
977
976
|
return this.fetchCollection(
|
|
978
977
|
collectionId,
|
|
979
978
|
normalizedQuery,
|
|
@@ -984,22 +983,20 @@ var ContentEngine = class {
|
|
|
984
983
|
);
|
|
985
984
|
});
|
|
986
985
|
this.circuitBreaker.recordSuccess();
|
|
987
|
-
return includeMetadata ?
|
|
986
|
+
return includeMetadata ? result : result.data;
|
|
988
987
|
} catch (error) {
|
|
989
988
|
this.circuitBreaker.recordFailure();
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
return includeMetadata ? result : result;
|
|
989
|
+
if (process.env.NODE_ENV === "development") {
|
|
990
|
+
try {
|
|
991
|
+
const localCollection = await this.localCache.getCollection(collectionId);
|
|
992
|
+
if (localCollection) {
|
|
993
|
+
return this.applyLocalQuery(
|
|
994
|
+
localCollection,
|
|
995
|
+
normalizedQuery
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
} catch (e9) {
|
|
1001
999
|
}
|
|
1002
|
-
} catch (e9) {
|
|
1003
1000
|
}
|
|
1004
1001
|
throw this.normalizeError(
|
|
1005
1002
|
error,
|
|
@@ -1058,15 +1055,14 @@ var ContentEngine = class {
|
|
|
1058
1055
|
}
|
|
1059
1056
|
return data;
|
|
1060
1057
|
} catch (error) {
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1058
|
+
if (process.env.NODE_ENV === "development") {
|
|
1059
|
+
try {
|
|
1060
|
+
const localGlobals = await this.localCache.getGlobals();
|
|
1061
|
+
if (localGlobals) {
|
|
1062
|
+
return localGlobals;
|
|
1063
|
+
}
|
|
1064
|
+
} catch (e11) {
|
|
1068
1065
|
}
|
|
1069
|
-
} catch (e11) {
|
|
1070
1066
|
}
|
|
1071
1067
|
throw this.normalizeError(error, "Failed to fetch globals");
|
|
1072
1068
|
}
|
|
@@ -1217,7 +1213,7 @@ var ContentEngine = class {
|
|
|
1217
1213
|
};
|
|
1218
1214
|
}
|
|
1219
1215
|
writeCache(key, data, options) {
|
|
1220
|
-
const ttlSeconds = options.revalidate === false ?
|
|
1216
|
+
const ttlSeconds = options.revalidate === false ? 60 : Math.max(1, options.revalidate);
|
|
1221
1217
|
if (this.cacheStrategy === "memory") {
|
|
1222
1218
|
this.memoryCache.set(key, data, {
|
|
1223
1219
|
tags: options.tags,
|
|
@@ -1380,7 +1376,7 @@ var ContentEngine = class {
|
|
|
1380
1376
|
}
|
|
1381
1377
|
async fetchWithTimeout(url, options = {}) {
|
|
1382
1378
|
const {
|
|
1383
|
-
timeout = this.config.timeout ||
|
|
1379
|
+
timeout = this.config.timeout || 1e4,
|
|
1384
1380
|
tags = [],
|
|
1385
1381
|
revalidate,
|
|
1386
1382
|
forceRefresh = false,
|
package/dist/react.js
CHANGED
|
@@ -865,7 +865,7 @@ var ContentEngine = class {
|
|
|
865
865
|
);
|
|
866
866
|
if (this.config.debug && duration > 100) {
|
|
867
867
|
console.warn(
|
|
868
|
-
`[
|
|
868
|
+
`[NexusHub] \u26A0\uFE0F getPage("${slug}") took ${duration.toFixed(2)}ms`
|
|
869
869
|
);
|
|
870
870
|
}
|
|
871
871
|
return result;
|
|
@@ -902,7 +902,7 @@ var ContentEngine = class {
|
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
904
|
if (this.circuitBreaker.isOpen()) {
|
|
905
|
-
throw new Error("[
|
|
905
|
+
throw new Error("[NexusHub] Circuit open. API is unavailable.");
|
|
906
906
|
}
|
|
907
907
|
try {
|
|
908
908
|
await this.rateLimiter.checkLimit();
|
|
@@ -919,22 +919,21 @@ var ContentEngine = class {
|
|
|
919
919
|
return includeMetadata ? data : data.data;
|
|
920
920
|
} catch (error) {
|
|
921
921
|
this.circuitBreaker.recordFailure();
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
922
|
+
if (process.env.NODE_ENV === "development") {
|
|
923
|
+
try {
|
|
924
|
+
const local = await this.localCache.getPage(slug);
|
|
925
|
+
if (local) {
|
|
926
|
+
return includeMetadata ? {
|
|
927
|
+
data: local,
|
|
928
|
+
metadata: {
|
|
929
|
+
timestamp: Date.now(),
|
|
930
|
+
expiresAt: Infinity,
|
|
931
|
+
tags: []
|
|
932
|
+
}
|
|
933
|
+
} : local;
|
|
934
|
+
}
|
|
935
|
+
} catch {
|
|
936
936
|
}
|
|
937
|
-
} catch {
|
|
938
937
|
}
|
|
939
938
|
throw this.normalizeError(error, `Failed to fetch page '${slug}'`);
|
|
940
939
|
}
|
|
@@ -963,17 +962,17 @@ var ContentEngine = class {
|
|
|
963
962
|
localCollection,
|
|
964
963
|
normalizedQuery
|
|
965
964
|
);
|
|
966
|
-
return
|
|
965
|
+
return result;
|
|
967
966
|
}
|
|
968
967
|
} catch {
|
|
969
968
|
}
|
|
970
969
|
}
|
|
971
970
|
if (this.circuitBreaker.isOpen()) {
|
|
972
|
-
throw new Error("[
|
|
971
|
+
throw new Error("[NexusHub] Circuit open. API is unavailable.");
|
|
973
972
|
}
|
|
974
973
|
try {
|
|
975
974
|
await this.rateLimiter.checkLimit();
|
|
976
|
-
const
|
|
975
|
+
const result = await this.backoff.execute(async () => {
|
|
977
976
|
return this.fetchCollection(
|
|
978
977
|
collectionId,
|
|
979
978
|
normalizedQuery,
|
|
@@ -984,22 +983,20 @@ var ContentEngine = class {
|
|
|
984
983
|
);
|
|
985
984
|
});
|
|
986
985
|
this.circuitBreaker.recordSuccess();
|
|
987
|
-
return includeMetadata ?
|
|
986
|
+
return includeMetadata ? result : result.data;
|
|
988
987
|
} catch (error) {
|
|
989
988
|
this.circuitBreaker.recordFailure();
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
return includeMetadata ? result : result;
|
|
989
|
+
if (process.env.NODE_ENV === "development") {
|
|
990
|
+
try {
|
|
991
|
+
const localCollection = await this.localCache.getCollection(collectionId);
|
|
992
|
+
if (localCollection) {
|
|
993
|
+
return this.applyLocalQuery(
|
|
994
|
+
localCollection,
|
|
995
|
+
normalizedQuery
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
} catch {
|
|
1001
999
|
}
|
|
1002
|
-
} catch {
|
|
1003
1000
|
}
|
|
1004
1001
|
throw this.normalizeError(
|
|
1005
1002
|
error,
|
|
@@ -1058,15 +1055,14 @@ var ContentEngine = class {
|
|
|
1058
1055
|
}
|
|
1059
1056
|
return data;
|
|
1060
1057
|
} catch (error) {
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1058
|
+
if (process.env.NODE_ENV === "development") {
|
|
1059
|
+
try {
|
|
1060
|
+
const localGlobals = await this.localCache.getGlobals();
|
|
1061
|
+
if (localGlobals) {
|
|
1062
|
+
return localGlobals;
|
|
1063
|
+
}
|
|
1064
|
+
} catch {
|
|
1068
1065
|
}
|
|
1069
|
-
} catch {
|
|
1070
1066
|
}
|
|
1071
1067
|
throw this.normalizeError(error, "Failed to fetch globals");
|
|
1072
1068
|
}
|
|
@@ -1217,7 +1213,7 @@ var ContentEngine = class {
|
|
|
1217
1213
|
};
|
|
1218
1214
|
}
|
|
1219
1215
|
writeCache(key, data, options) {
|
|
1220
|
-
const ttlSeconds = options.revalidate === false ?
|
|
1216
|
+
const ttlSeconds = options.revalidate === false ? 60 : Math.max(1, options.revalidate);
|
|
1221
1217
|
if (this.cacheStrategy === "memory") {
|
|
1222
1218
|
this.memoryCache.set(key, data, {
|
|
1223
1219
|
tags: options.tags,
|
|
@@ -1380,7 +1376,7 @@ var ContentEngine = class {
|
|
|
1380
1376
|
}
|
|
1381
1377
|
async fetchWithTimeout(url, options = {}) {
|
|
1382
1378
|
const {
|
|
1383
|
-
timeout = this.config.timeout ||
|
|
1379
|
+
timeout = this.config.timeout || 1e4,
|
|
1384
1380
|
tags = [],
|
|
1385
1381
|
revalidate,
|
|
1386
1382
|
forceRefresh = false,
|