@jwork-space/strapi-sdk 1.0.5 → 1.0.6
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.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -0
- package/dist/index.mjs +14 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -212,6 +212,8 @@ declare class StrapiSDK<T extends BaseModel> extends BaseAPI<T> {
|
|
|
212
212
|
findAndUpdate(data: T, optFilter: RequestOptions<T>, optPayload?: RequestOptions<T>, serializeOptionsPayload?: SerializeOptions): Promise<T | undefined>;
|
|
213
213
|
finOneEntity: (opt?: RequestOptions<T>) => Promise<T | null>;
|
|
214
214
|
upsert(data: T, opt?: RequestOptions<T>, serializeOptions?: SerializeOptions): Promise<T>;
|
|
215
|
+
invalidateQueries: (keys: (string | unknown[])[]) => () => Promise<void>;
|
|
216
|
+
invalidateListAll: () => () => Promise<void>;
|
|
215
217
|
}
|
|
216
218
|
|
|
217
219
|
type AnyObject = Record<string, any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -212,6 +212,8 @@ declare class StrapiSDK<T extends BaseModel> extends BaseAPI<T> {
|
|
|
212
212
|
findAndUpdate(data: T, optFilter: RequestOptions<T>, optPayload?: RequestOptions<T>, serializeOptionsPayload?: SerializeOptions): Promise<T | undefined>;
|
|
213
213
|
finOneEntity: (opt?: RequestOptions<T>) => Promise<T | null>;
|
|
214
214
|
upsert(data: T, opt?: RequestOptions<T>, serializeOptions?: SerializeOptions): Promise<T>;
|
|
215
|
+
invalidateQueries: (keys: (string | unknown[])[]) => () => Promise<void>;
|
|
216
|
+
invalidateListAll: () => () => Promise<void>;
|
|
215
217
|
}
|
|
216
218
|
|
|
217
219
|
type AnyObject = Record<string, any>;
|
package/dist/index.js
CHANGED
|
@@ -706,6 +706,20 @@ var StrapiSDK = class extends BaseAPI {
|
|
|
706
706
|
const list = data;
|
|
707
707
|
return list.length > 0 ? list[0] : null;
|
|
708
708
|
};
|
|
709
|
+
this.invalidateQueries = (keys) => {
|
|
710
|
+
const queryClient = (0, import_react_query.useQueryClient)();
|
|
711
|
+
return async () => {
|
|
712
|
+
if (!keys || keys.length === 0) return;
|
|
713
|
+
for (const key of keys) {
|
|
714
|
+
await queryClient.invalidateQueries({
|
|
715
|
+
queryKey: Array.isArray(key) ? key : [key]
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
};
|
|
720
|
+
this.invalidateListAll = () => {
|
|
721
|
+
return this.invalidateQueries([[this.endpoint, "listAll"]]);
|
|
722
|
+
};
|
|
709
723
|
this.config = {
|
|
710
724
|
onCreate: {
|
|
711
725
|
generateUID: config?.onCreate?.generateUID ?? true,
|
package/dist/index.mjs
CHANGED
|
@@ -657,6 +657,20 @@ var StrapiSDK = class extends BaseAPI {
|
|
|
657
657
|
const list = data;
|
|
658
658
|
return list.length > 0 ? list[0] : null;
|
|
659
659
|
};
|
|
660
|
+
this.invalidateQueries = (keys) => {
|
|
661
|
+
const queryClient = useQueryClient();
|
|
662
|
+
return async () => {
|
|
663
|
+
if (!keys || keys.length === 0) return;
|
|
664
|
+
for (const key of keys) {
|
|
665
|
+
await queryClient.invalidateQueries({
|
|
666
|
+
queryKey: Array.isArray(key) ? key : [key]
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
this.invalidateListAll = () => {
|
|
672
|
+
return this.invalidateQueries([[this.endpoint, "listAll"]]);
|
|
673
|
+
};
|
|
660
674
|
this.config = {
|
|
661
675
|
onCreate: {
|
|
662
676
|
generateUID: config?.onCreate?.generateUID ?? true,
|