tsdf 12.7.0 → 12.8.0
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/main.cjs +37 -5
- package/dist/main.d.cts +3 -1
- package/dist/main.d.ts +3 -1
- package/dist/main.js +36 -5
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/main.ts
|
|
21
21
|
var main_exports = {};
|
|
22
22
|
__export(main_exports, {
|
|
23
|
+
getCacheId: () => getCacheId,
|
|
23
24
|
newTSDFCollectionStore: () => newTSDFCollectionStore,
|
|
24
25
|
newTSDFDocumentStore: () => newTSDFDocumentStore,
|
|
25
26
|
newTSDFListQueryStore: () => newTSDFListQueryStore,
|
|
@@ -645,16 +646,46 @@ function isObject(value) {
|
|
|
645
646
|
}
|
|
646
647
|
|
|
647
648
|
// src/utils/getCacheId.ts
|
|
648
|
-
function getCacheId(input) {
|
|
649
|
-
|
|
649
|
+
function getCacheId(input, maxDepth = 3) {
|
|
650
|
+
if (typeof input === "string")
|
|
651
|
+
return String(input);
|
|
652
|
+
if (!input || typeof input !== "object")
|
|
653
|
+
return `#$${input}$#`;
|
|
654
|
+
return JSON.stringify(sortValues(input, maxDepth, 0));
|
|
650
655
|
}
|
|
651
|
-
function
|
|
652
|
-
|
|
656
|
+
function sortValues(input, maxDepth, depth) {
|
|
657
|
+
if (depth >= maxDepth)
|
|
658
|
+
return input;
|
|
659
|
+
if (Array.isArray(input)) {
|
|
660
|
+
return input.map((v) => sortValues(v, maxDepth, depth + 1));
|
|
661
|
+
}
|
|
662
|
+
if (isObject(input)) {
|
|
663
|
+
return orderedProps(input, (v) => sortValues(v, maxDepth, depth + 1));
|
|
664
|
+
}
|
|
665
|
+
return input;
|
|
666
|
+
}
|
|
667
|
+
var emptyObject = {};
|
|
668
|
+
function orderedProps(obj, mapValue) {
|
|
669
|
+
const keys = Object.keys(obj);
|
|
670
|
+
if (keys.length === 0)
|
|
671
|
+
return emptyObject;
|
|
672
|
+
if (keys.length === 1) {
|
|
673
|
+
const value = obj[keys[0]];
|
|
674
|
+
if (value === void 0)
|
|
675
|
+
return emptyObject;
|
|
676
|
+
return { [keys[0]]: mapValue(value) };
|
|
677
|
+
}
|
|
678
|
+
const mappedValues = filterAndMap(keys.sort(), (k, ignore) => {
|
|
653
679
|
const value = obj[k];
|
|
654
680
|
if (value === void 0)
|
|
655
681
|
return ignore;
|
|
656
|
-
return { [k]:
|
|
682
|
+
return { [k]: mapValue(value) };
|
|
657
683
|
});
|
|
684
|
+
if (mappedValues.length === 0)
|
|
685
|
+
return emptyObject;
|
|
686
|
+
if (mappedValues.length === 1)
|
|
687
|
+
return mappedValues[0];
|
|
688
|
+
return mappedValues;
|
|
658
689
|
}
|
|
659
690
|
|
|
660
691
|
// src/collectionStore.ts
|
|
@@ -2284,6 +2315,7 @@ function useListItemIsLoading({
|
|
|
2284
2315
|
}
|
|
2285
2316
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2286
2317
|
0 && (module.exports = {
|
|
2318
|
+
getCacheId,
|
|
2287
2319
|
newTSDFCollectionStore,
|
|
2288
2320
|
newTSDFDocumentStore,
|
|
2289
2321
|
newTSDFListQueryStore,
|
package/dist/main.d.cts
CHANGED
|
@@ -350,4 +350,6 @@ declare function useListItemIsLoading({ isLoading, isRefetching, isNotFound, loa
|
|
|
350
350
|
loadItemFallback: () => void;
|
|
351
351
|
}): boolean;
|
|
352
352
|
|
|
353
|
-
|
|
353
|
+
declare function getCacheId(input: unknown, maxDepth?: number): string;
|
|
354
|
+
|
|
355
|
+
export { CollectionInitialStateItem, FetchListFnReturn, FetchListFnReturnItem, ListQueryStoreInitialData, OnCollectionItemInvalidate, OnDocumentInvalidate, OnListQueryInvalidate, OnListQueryItemInvalidate, TSDFCollectionStore, TSDFDocumentStore, TSDFDocumentStoreState, TSDFItemQuery, TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, TSFDListQuery, TSFDListQueryState, TSFDListQueryStore, TSFDUseCollectionItemReturn, TSFDUseListItemReturn, TSFDUseListQueryReturn, ValidPayload, ValidStoreState, getCacheId, newTSDFCollectionStore, newTSDFDocumentStore, newTSDFListQueryStore, useListItemIsLoading };
|
package/dist/main.d.ts
CHANGED
|
@@ -350,4 +350,6 @@ declare function useListItemIsLoading({ isLoading, isRefetching, isNotFound, loa
|
|
|
350
350
|
loadItemFallback: () => void;
|
|
351
351
|
}): boolean;
|
|
352
352
|
|
|
353
|
-
|
|
353
|
+
declare function getCacheId(input: unknown, maxDepth?: number): string;
|
|
354
|
+
|
|
355
|
+
export { CollectionInitialStateItem, FetchListFnReturn, FetchListFnReturnItem, ListQueryStoreInitialData, OnCollectionItemInvalidate, OnDocumentInvalidate, OnListQueryInvalidate, OnListQueryItemInvalidate, TSDFCollectionStore, TSDFDocumentStore, TSDFDocumentStoreState, TSDFItemQuery, TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, TSFDListQuery, TSFDListQueryState, TSFDListQueryStore, TSFDUseCollectionItemReturn, TSFDUseListItemReturn, TSFDUseListQueryReturn, ValidPayload, ValidStoreState, getCacheId, newTSDFCollectionStore, newTSDFDocumentStore, newTSDFListQueryStore, useListItemIsLoading };
|
package/dist/main.js
CHANGED
|
@@ -616,16 +616,46 @@ function isObject(value) {
|
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
// src/utils/getCacheId.ts
|
|
619
|
-
function getCacheId(input) {
|
|
620
|
-
|
|
619
|
+
function getCacheId(input, maxDepth = 3) {
|
|
620
|
+
if (typeof input === "string")
|
|
621
|
+
return String(input);
|
|
622
|
+
if (!input || typeof input !== "object")
|
|
623
|
+
return `#$${input}$#`;
|
|
624
|
+
return JSON.stringify(sortValues(input, maxDepth, 0));
|
|
621
625
|
}
|
|
622
|
-
function
|
|
623
|
-
|
|
626
|
+
function sortValues(input, maxDepth, depth) {
|
|
627
|
+
if (depth >= maxDepth)
|
|
628
|
+
return input;
|
|
629
|
+
if (Array.isArray(input)) {
|
|
630
|
+
return input.map((v) => sortValues(v, maxDepth, depth + 1));
|
|
631
|
+
}
|
|
632
|
+
if (isObject(input)) {
|
|
633
|
+
return orderedProps(input, (v) => sortValues(v, maxDepth, depth + 1));
|
|
634
|
+
}
|
|
635
|
+
return input;
|
|
636
|
+
}
|
|
637
|
+
var emptyObject = {};
|
|
638
|
+
function orderedProps(obj, mapValue) {
|
|
639
|
+
const keys = Object.keys(obj);
|
|
640
|
+
if (keys.length === 0)
|
|
641
|
+
return emptyObject;
|
|
642
|
+
if (keys.length === 1) {
|
|
643
|
+
const value = obj[keys[0]];
|
|
644
|
+
if (value === void 0)
|
|
645
|
+
return emptyObject;
|
|
646
|
+
return { [keys[0]]: mapValue(value) };
|
|
647
|
+
}
|
|
648
|
+
const mappedValues = filterAndMap(keys.sort(), (k, ignore) => {
|
|
624
649
|
const value = obj[k];
|
|
625
650
|
if (value === void 0)
|
|
626
651
|
return ignore;
|
|
627
|
-
return { [k]:
|
|
652
|
+
return { [k]: mapValue(value) };
|
|
628
653
|
});
|
|
654
|
+
if (mappedValues.length === 0)
|
|
655
|
+
return emptyObject;
|
|
656
|
+
if (mappedValues.length === 1)
|
|
657
|
+
return mappedValues[0];
|
|
658
|
+
return mappedValues;
|
|
629
659
|
}
|
|
630
660
|
|
|
631
661
|
// src/collectionStore.ts
|
|
@@ -2254,6 +2284,7 @@ function useListItemIsLoading({
|
|
|
2254
2284
|
return isLoading || isNotFound && (isRefetching || !!willBeRefetched);
|
|
2255
2285
|
}
|
|
2256
2286
|
export {
|
|
2287
|
+
getCacheId,
|
|
2257
2288
|
newTSDFCollectionStore,
|
|
2258
2289
|
newTSDFDocumentStore,
|
|
2259
2290
|
newTSDFListQueryStore,
|