@akanjs/store 0.9.59 → 0.9.60-canary.1
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.
|
@@ -623,11 +623,10 @@ const makeActions = (refName, slices) => {
|
|
|
623
623
|
const queryArgs = new Array(initArgLength).fill(null).map((_, i) => args[i]);
|
|
624
624
|
const defaultModel = (0, import_signal.immerify)(modelRef, { ...cnst.getDefault(), ...initForm.default ?? {} });
|
|
625
625
|
this.set({ [names.defaultModel]: defaultModel });
|
|
626
|
-
await this[namesOfSlice.refreshModel](
|
|
627
|
-
...initArgLength === argLength ? [...queryArgs, initForm] : queryArgs
|
|
628
|
-
);
|
|
626
|
+
await this[namesOfSlice.refreshModel]({ ...initForm, queryArgs });
|
|
629
627
|
},
|
|
630
|
-
[namesOfSlice.refreshModel]: async function(
|
|
628
|
+
[namesOfSlice.refreshModel]: async function(initForm = {}) {
|
|
629
|
+
const args = initForm.queryArgs ?? [];
|
|
631
630
|
const refreshArgLength = Math.min(args.length, argLength);
|
|
632
631
|
const currentState = this.get();
|
|
633
632
|
const existingQueryArgs = currentState[namesOfSlice.queryArgsOfModel];
|
|
@@ -635,7 +634,6 @@ const makeActions = (refName, slices) => {
|
|
|
635
634
|
...new Array(refreshArgLength).fill(null).map((_, i) => args[i]),
|
|
636
635
|
...existingQueryArgs.slice(refreshArgLength, argLength)
|
|
637
636
|
];
|
|
638
|
-
const initForm = args[argLength] ?? {};
|
|
639
637
|
const {
|
|
640
638
|
page = currentState[namesOfSlice.pageOfModel],
|
|
641
639
|
limit = currentState[namesOfSlice.limitOfModel],
|
|
@@ -610,11 +610,10 @@ const makeActions = (refName, slices) => {
|
|
|
610
610
|
const queryArgs = new Array(initArgLength).fill(null).map((_, i) => args[i]);
|
|
611
611
|
const defaultModel = immerify(modelRef, { ...cnst.getDefault(), ...initForm.default ?? {} });
|
|
612
612
|
this.set({ [names.defaultModel]: defaultModel });
|
|
613
|
-
await this[namesOfSlice.refreshModel](
|
|
614
|
-
...initArgLength === argLength ? [...queryArgs, initForm] : queryArgs
|
|
615
|
-
);
|
|
613
|
+
await this[namesOfSlice.refreshModel]({ ...initForm, queryArgs });
|
|
616
614
|
},
|
|
617
|
-
[namesOfSlice.refreshModel]: async function(
|
|
615
|
+
[namesOfSlice.refreshModel]: async function(initForm = {}) {
|
|
616
|
+
const args = initForm.queryArgs ?? [];
|
|
618
617
|
const refreshArgLength = Math.min(args.length, argLength);
|
|
619
618
|
const currentState = this.get();
|
|
620
619
|
const existingQueryArgs = currentState[namesOfSlice.queryArgsOfModel];
|
|
@@ -622,7 +621,6 @@ const makeActions = (refName, slices) => {
|
|
|
622
621
|
...new Array(refreshArgLength).fill(null).map((_, i) => args[i]),
|
|
623
622
|
...existingQueryArgs.slice(refreshArgLength, argLength)
|
|
624
623
|
];
|
|
625
|
-
const initForm = args[argLength] ?? {};
|
|
626
624
|
const {
|
|
627
625
|
page = currentState[namesOfSlice.pageOfModel],
|
|
628
626
|
limit = currentState[namesOfSlice.limitOfModel],
|
package/package.json
CHANGED
package/src/storeDecorators.d.ts
CHANGED
|
@@ -105,7 +105,6 @@ export interface NewOption {
|
|
|
105
105
|
type PartialOrNull<O> = {
|
|
106
106
|
[K in keyof O]?: O[K] | null;
|
|
107
107
|
};
|
|
108
|
-
type OptionalArgs<T extends any[]> = T extends [infer Head, ...infer Tail] ? [arg?: Head | null, ...OptionalArgs<Tail>] : [];
|
|
109
108
|
type BaseAction<T extends string, Input, Full extends {
|
|
110
109
|
id: string;
|
|
111
110
|
}, Light, _CapitalizedT extends string = Capitalize<T>, _CreateOption = CreateOption<Full>> = {
|
|
@@ -146,7 +145,9 @@ type SliceAction<T extends string, Input, Full extends {
|
|
|
146
145
|
}, Light, QueryArgs extends any[], Filter extends FilterInstance, _CapitalizedT extends string = Capitalize<T>, _Sort = ExtractSort<Filter>, _FetchInitFormWithFetchPolicy = FetchInitForm<Input, Full, Filter> & FetchPolicy> = {
|
|
147
146
|
[K in `init${_CapitalizedT}`]: (...args: [...args: QueryArgs, initForm?: _FetchInitFormWithFetchPolicy]) => Promise<void>;
|
|
148
147
|
} & {
|
|
149
|
-
[K in `refresh${_CapitalizedT}`]: (
|
|
148
|
+
[K in `refresh${_CapitalizedT}`]: (initForm?: _FetchInitFormWithFetchPolicy & {
|
|
149
|
+
queryArgs?: QueryArgs;
|
|
150
|
+
}) => Promise<void>;
|
|
150
151
|
} & {
|
|
151
152
|
[K in `select${_CapitalizedT}`]: (model: Light | Light[], options?: {
|
|
152
153
|
refresh?: boolean;
|