@flowlist/js-core 4.0.7-beta.0 → 4.0.9-beta.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.
Files changed (59) hide show
  1. package/dist/chunk-6WOZNOYJ.mjs +79 -0
  2. package/dist/chunk-6WOZNOYJ.mjs.map +1 -0
  3. package/dist/chunk-BTOUHSDU.mjs +91 -0
  4. package/dist/chunk-BTOUHSDU.mjs.map +1 -0
  5. package/dist/chunk-C4BWSFWU.mjs +74 -0
  6. package/dist/chunk-C4BWSFWU.mjs.map +1 -0
  7. package/dist/chunk-KIQOUUEZ.mjs +3 -0
  8. package/dist/chunk-KIQOUUEZ.mjs.map +1 -0
  9. package/dist/chunk-LF6DOBID.mjs +248 -0
  10. package/dist/chunk-LF6DOBID.mjs.map +1 -0
  11. package/dist/chunk-OKKMFSGF.mjs +253 -0
  12. package/dist/chunk-OKKMFSGF.mjs.map +1 -0
  13. package/dist/chunk-PP7QTJDR.mjs +37 -0
  14. package/dist/chunk-PP7QTJDR.mjs.map +1 -0
  15. package/dist/constants.d.mts +33 -0
  16. package/dist/constants.d.ts +33 -0
  17. package/dist/constants.js +39 -0
  18. package/dist/constants.js.map +1 -0
  19. package/dist/constants.mjs +3 -0
  20. package/dist/constants.mjs.map +1 -0
  21. package/dist/core.d.mts +19 -0
  22. package/dist/core.d.ts +19 -0
  23. package/dist/core.js +446 -0
  24. package/dist/core.js.map +1 -0
  25. package/dist/core.mjs +5 -0
  26. package/dist/core.mjs.map +1 -0
  27. package/dist/index.d.mts +6 -291
  28. package/dist/index.d.ts +6 -291
  29. package/dist/index.global.js +386 -478
  30. package/dist/index.global.js.map +1 -1
  31. package/dist/index.js +386 -478
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +7 -842
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/mutations/core.d.mts +10 -0
  36. package/dist/mutations/core.d.ts +10 -0
  37. package/dist/mutations/core.js +130 -0
  38. package/dist/mutations/core.js.map +1 -0
  39. package/dist/mutations/core.mjs +5 -0
  40. package/dist/mutations/core.mjs.map +1 -0
  41. package/dist/mutations/extended.d.mts +10 -0
  42. package/dist/mutations/extended.d.ts +10 -0
  43. package/dist/mutations/extended.js +172 -0
  44. package/dist/mutations/extended.js.map +1 -0
  45. package/dist/mutations/extended.mjs +5 -0
  46. package/dist/mutations/extended.mjs.map +1 -0
  47. package/dist/mutations/index.d.mts +14 -0
  48. package/dist/mutations/index.d.ts +14 -0
  49. package/dist/mutations/index.js +379 -0
  50. package/dist/mutations/index.js.map +1 -0
  51. package/dist/mutations/index.mjs +8 -0
  52. package/dist/mutations/index.mjs.map +1 -0
  53. package/dist/types.d.mts +140 -0
  54. package/dist/types.d.ts +140 -0
  55. package/dist/types.js +4 -0
  56. package/dist/types.js.map +1 -0
  57. package/dist/types.mjs +3 -0
  58. package/dist/types.mjs.map +1 -0
  59. package/package.json +67 -1
package/dist/index.js CHANGED
@@ -1,14 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var __defProp = Object.defineProperty;
4
- var __export = (target, all) => {
5
- for (var name in all)
6
- __defProp(target, name, { get: all[name], enumerable: true });
7
- };
8
-
9
- // src/enum.ts
3
+ // src/constants.ts
10
4
  var FETCH_TYPE_ARRAY = ["jump", "sinceId", "page", "seenIds", "auto"];
11
- var enum_default = {
5
+ var constants_default = {
12
6
  SETTER_TYPE: {
13
7
  RESET: 0,
14
8
  MERGE: 1
@@ -40,83 +34,63 @@ var enum_default = {
40
34
  DEFAULT_UNIQUE_KEY_NAME: "id"
41
35
  };
42
36
 
43
- // src/utils.ts
44
- var utils_exports = {};
45
- __export(utils_exports, {
46
- combineArrayData: () => combineArrayData,
47
- computeMatchedItemIndex: () => computeMatchedItemIndex,
48
- computeResultLength: () => computeResultLength,
49
- generateDefaultField: () => generateDefaultField,
50
- generateFieldName: () => generateFieldName,
51
- generateRequestParams: () => generateRequestParams,
52
- getObjectDeepValue: () => getObjectDeepValue,
53
- getResultAsArray: () => getResultAsArray,
54
- isArray: () => isArray,
55
- isKeyMap: () => isKeyMap,
56
- isKeyMapArray: () => isKeyMapArray,
57
- isObjectKey: () => isObjectKey,
58
- isObjectKeyArray: () => isObjectKeyArray,
59
- isObjectResult: () => isObjectResult,
60
- isResultObject: () => isResultObject,
61
- searchValueByKey: () => searchValueByKey,
62
- setReactivityField: () => setReactivityField,
63
- stableSerialize: () => stableSerialize,
64
- toObjectKey: () => toObjectKey,
65
- updateArrayItem: () => updateArrayItem,
66
- updateObjectDeepValue: () => updateObjectDeepValue
67
- });
37
+ // src/_internal/utils.ts
68
38
  var isArray = (data) => Array.isArray(data);
69
- var isResultObject = (data) => !isArray(data) && typeof data === "object" && data !== null;
70
39
  var isObjectKey = (value) => typeof value === "string" || typeof value === "number";
71
40
  var isKeyMap = (value) => typeof value === "object" && value !== null && !isArray(value);
72
41
  var isKeyMapArray = (value) => isArray(value) && value.every((item) => typeof item === "object" && item !== null);
73
42
  var isObjectKeyArray = (value) => isArray(value) && value.every((item) => typeof item === "string" || typeof item === "number");
74
43
  var stableSerialize = (value) => {
75
- if (value === null || typeof value !== "object") {
76
- return String(value);
77
- }
44
+ if (value === null || typeof value !== "object") return String(value);
78
45
  try {
79
- if (isArray(value)) {
80
- return JSON.stringify(value);
81
- }
82
- if (isKeyMap(value)) {
83
- const keys = Object.keys(value).sort();
84
- const obj = {};
85
- const len = keys.length;
86
- for (let i = 0; i < len; i++) {
87
- const k = keys[i];
88
- obj[k] = value[k];
89
- }
90
- return JSON.stringify(obj);
91
- }
92
- return "[Unsupported Object]";
46
+ if (isArray(value)) return JSON.stringify(value);
47
+ return JSON.stringify(
48
+ Object.fromEntries(
49
+ Object.entries(value).sort(
50
+ ([a], [b]) => a.localeCompare(b)
51
+ )
52
+ )
53
+ );
93
54
  } catch {
94
- return "[Circular Object/Value]";
55
+ return "[Circular]";
56
+ }
57
+ };
58
+ var getObjectDeepValue = (field, keys) => {
59
+ if (!keys || isArray(keys) && keys.length === 0) return field;
60
+ const keysArr = isArray(keys) ? keys : keys.split(".");
61
+ let cur = field;
62
+ for (let i = 0; i < keysArr.length; i++) {
63
+ if (cur == null || typeof cur !== "object") return void 0;
64
+ cur = cur[keysArr[i]];
95
65
  }
66
+ return cur;
67
+ };
68
+ var updateObjectDeepValue = (field, changeKey, value) => {
69
+ const keys = changeKey.split(".");
70
+ const lastKey = keys.pop();
71
+ if (!lastKey) return;
72
+ let current = field;
73
+ for (const key of keys) {
74
+ if (current[key] == null || typeof current[key] !== "object") {
75
+ current[key] = {};
76
+ }
77
+ if (!isKeyMap(current[key])) return;
78
+ current = current[key];
79
+ }
80
+ current[lastKey] = value;
96
81
  };
97
82
  var extractUniqueKey = (item, uniqueKey) => {
98
83
  if (!isKeyMap(item)) return void 0;
99
84
  const val = item[uniqueKey];
100
- if (isObjectKey(val)) {
101
- return val;
102
- }
85
+ if (isObjectKey(val)) return val;
103
86
  if (uniqueKey.includes(".")) {
104
87
  const deepVal = getObjectDeepValue(item, uniqueKey);
105
- if (isObjectKey(deepVal)) {
106
- return deepVal;
107
- }
88
+ if (isObjectKey(deepVal)) return deepVal;
108
89
  }
109
90
  return void 0;
110
91
  };
111
- var isObjectResult = (data) => {
112
- if (typeof data !== "object" || data === null) {
113
- return false;
114
- }
115
- return !Object.prototype.hasOwnProperty.call(data, "result");
116
- };
117
92
  var generateDefaultField = (opts = {}) => ({
118
93
  result: [],
119
- // 默认为空数组,但强制转换为泛型 T
120
94
  noMore: false,
121
95
  nothing: false,
122
96
  loading: false,
@@ -127,68 +101,33 @@ var generateDefaultField = (opts = {}) => ({
127
101
  total: 0,
128
102
  ...opts
129
103
  });
130
- var generateFieldName = ({
131
- func,
132
- query
133
- }) => {
134
- let result = func.id;
135
- if (!query) {
136
- return result;
137
- }
138
- const queryObj = query;
139
- const filteredKeys = Object.keys(queryObj).filter((key) => !func.paramsIgnore.includes(key)).sort();
140
- const len = filteredKeys.length;
141
- for (let i = 0; i < len; i++) {
142
- const key = filteredKeys[i];
143
- const value = queryObj[key];
144
- let safeValue;
145
- if (typeof value === "object" && value !== null) {
146
- safeValue = stableSerialize(value);
147
- } else {
148
- safeValue = String(value);
149
- }
150
- const encoded = encodeURIComponent(safeValue);
151
- result += `-${key}-${encoded}`;
104
+ var computeMatchedItemIndex = (itemId, fieldArr, changingKey) => {
105
+ const stringId = String(itemId);
106
+ for (let i = 0; i < fieldArr.length; i++) {
107
+ const item = fieldArr[i];
108
+ if (!isKeyMap(item)) continue;
109
+ const val = getObjectDeepValue(item, changingKey);
110
+ if (String(val) === stringId) return i;
152
111
  }
153
- return result;
112
+ return -1;
154
113
  };
155
- var getObjectDeepValue = (field, keys) => {
156
- if (!keys || isArray(keys) && keys.length === 0) {
157
- return field;
158
- }
159
- const keysArr = isArray(keys) ? keys : keys.split(".");
160
- let result = field;
161
- const len = keysArr.length;
162
- for (let i = 0; i < len; i++) {
163
- if (result == null || typeof result !== "object") {
164
- return void 0;
165
- }
166
- result = result[keysArr[i]];
167
- }
168
- return result;
114
+ var computeResultLength = (data) => {
115
+ if (isArray(data)) return data.length;
116
+ return 0;
169
117
  };
170
- var updateObjectDeepValue = (field, changeKey, value) => {
171
- if (!changeKey) return;
172
- const keys = changeKey.split(".");
173
- const lastKey = keys.pop();
174
- if (!lastKey) return;
175
- let current = field;
176
- const len = keys.length;
177
- for (let i = 0; i < len; i++) {
178
- const key = keys[i];
179
- const currentVal = current[key];
180
- if (currentVal == null || typeof currentVal !== "object") {
181
- current[key] = {};
182
- }
183
- const next = current[key];
184
- if (isKeyMap(next)) {
185
- current = next;
186
- } else {
187
- return;
188
- }
189
- }
190
- if (current != null && typeof current === "object") {
191
- current[lastKey] = value;
118
+ var toObjectKey = (id) => {
119
+ if (id === void 0) return void 0;
120
+ if (isObjectKey(id)) return id;
121
+ if (isObjectKeyArray(id) && id.length > 0) return id[0];
122
+ return void 0;
123
+ };
124
+ var getResultAsArray = (field) => {
125
+ const result = field[constants_default.FIELD_DATA.RESULT_KEY];
126
+ return isArray(result) ? result : null;
127
+ };
128
+ var updateArrayItem = (arr, index, updater) => {
129
+ if (index >= 0 && index < arr.length && isKeyMap(arr[index])) {
130
+ arr[index] = updater(arr[index]);
192
131
  }
193
132
  };
194
133
  var searchValueByKey = (result, id, key) => {
@@ -196,237 +135,154 @@ var searchValueByKey = (result, id, key) => {
196
135
  const index = computeMatchedItemIndex(id, result, key);
197
136
  return index >= 0 ? result[index] : void 0;
198
137
  }
199
- if (isResultObject(result)) {
200
- return result[String(id)];
201
- }
138
+ if (isKeyMap(result)) return result[String(id)];
202
139
  return void 0;
203
140
  };
204
- var computeMatchedItemIndex = (itemId, fieldArr, changingKey) => {
205
- const stringifiedItemId = String(itemId);
206
- const len = fieldArr.length;
207
- for (let i = 0; i < len; i++) {
208
- const item = fieldArr[i];
209
- if (!isKeyMap(item)) continue;
210
- const itemValue = getObjectDeepValue(item, changingKey);
211
- if (String(itemValue) === stringifiedItemId) {
212
- return i;
213
- }
214
- }
215
- return -1;
216
- };
217
141
  var combineArrayData = (fieldArray, value, changingKey) => {
218
- const fieldArrayMap = /* @__PURE__ */ new Map();
219
- const arrLen = fieldArray.length;
220
- for (let i = 0; i < arrLen; i++) {
142
+ const indexMap = /* @__PURE__ */ new Map();
143
+ for (let i = 0; i < fieldArray.length; i++) {
221
144
  const item = fieldArray[i];
222
145
  if (!isKeyMap(item)) continue;
223
146
  const id = getObjectDeepValue(item, changingKey);
224
- if (id !== void 0) {
225
- fieldArrayMap.set(String(id), i);
226
- }
147
+ if (id !== void 0) indexMap.set(String(id), i);
227
148
  }
149
+ const mergeItem = (uniqueId, col) => {
150
+ const index = indexMap.get(uniqueId);
151
+ if (index !== void 0 && isKeyMap(fieldArray[index])) {
152
+ fieldArray[index] = { ...fieldArray[index], ...col };
153
+ }
154
+ };
228
155
  if (isArray(value)) {
229
- const valLen = value.length;
230
- for (let i = 0; i < valLen; i++) {
231
- const col = value[i];
156
+ for (const col of value) {
232
157
  if (!isKeyMap(col)) continue;
233
- const stringifyId = String(getObjectDeepValue(col, changingKey));
234
- const index = fieldArrayMap.get(stringifyId);
235
- if (index !== void 0) {
236
- const existingItem = fieldArray[index];
237
- if (isKeyMap(existingItem)) {
238
- Object.assign(existingItem, col);
239
- }
240
- }
158
+ mergeItem(String(getObjectDeepValue(col, changingKey)), col);
241
159
  }
242
160
  } else if (isKeyMap(value)) {
243
- const entries = Object.entries(value);
244
- const entLen = entries.length;
245
- for (let i = 0; i < entLen; i++) {
246
- const [uniqueId, col] = entries[i];
247
- if (!isKeyMap(col)) continue;
248
- const index = fieldArrayMap.get(uniqueId);
249
- if (index !== void 0) {
250
- const existingItem = fieldArray[index];
251
- if (isKeyMap(existingItem)) {
252
- Object.assign(existingItem, col);
253
- }
254
- }
161
+ for (const [uniqueId, col] of Object.entries(value)) {
162
+ if (isKeyMap(col)) mergeItem(uniqueId, col);
255
163
  }
256
164
  }
257
165
  };
258
166
  var setReactivityField = (field, key, value, type, insertBefore) => {
259
167
  const fieldAny = field;
260
- if (type === enum_default.FETCH_TYPE.PAGINATION) {
168
+ if (type === constants_default.FETCH_TYPE.PAGINATION) {
261
169
  fieldAny[key] = value;
262
170
  return;
263
171
  }
264
- if (key !== enum_default.FIELD_DATA.RESULT_KEY) {
172
+ if (key !== constants_default.FIELD_DATA.RESULT_KEY) {
265
173
  if (isArray(value)) {
266
- const current = fieldAny[key];
267
- const currentArr = isArray(current) ? current : [];
268
- const newValue = insertBefore ? [...value, ...currentArr] : [...currentArr, ...value];
269
- fieldAny[key] = newValue;
174
+ const current = isArray(fieldAny[key]) ? fieldAny[key] : [];
175
+ fieldAny[key] = insertBefore ? [...value, ...current] : [...current, ...value];
270
176
  } else {
271
177
  fieldAny[key] = value;
272
178
  }
273
179
  return;
274
180
  }
275
- const resultField = field.result;
276
- const valueObj = value;
277
181
  if (isArray(value)) {
278
- const currentArr = isArray(resultField) ? resultField : [];
279
- const valueArr = value;
280
- if (insertBefore) {
281
- if (valueArr.length === 0) return;
282
- if (currentArr.length === 0) {
283
- field.result = valueArr;
284
- return;
285
- }
286
- field.result = valueArr.concat(currentArr);
287
- } else {
288
- if (valueArr.length === 0) return;
289
- if (currentArr.length === 0) {
290
- field.result = valueArr;
291
- return;
292
- }
293
- field.result = currentArr.concat(valueArr);
182
+ if (value.length === 0) return;
183
+ const current = isArray(field.result) ? field.result : [];
184
+ if (current.length === 0) {
185
+ field.result = value;
186
+ return;
294
187
  }
188
+ field.result = insertBefore ? [...value, ...current] : [...current, ...value];
295
189
  return;
296
190
  }
297
- let target = resultField;
298
- if (isArray(resultField)) {
299
- target = {};
300
- field.result = target;
301
- } else if (typeof resultField !== "object" || resultField === null) {
191
+ const valueObj = value;
192
+ let target = field.result;
193
+ if (isArray(field.result) || typeof field.result !== "object" || field.result === null) {
302
194
  target = {};
303
195
  field.result = target;
304
196
  }
305
- const keys = Object.keys(valueObj);
306
- const len = keys.length;
307
- for (let i = 0; i < len; i++) {
308
- const subKey = keys[i];
197
+ for (const subKey of Object.keys(valueObj)) {
309
198
  const existing = target[subKey];
310
199
  const incoming = valueObj[subKey];
311
- if (existing !== void 0) {
312
- if (insertBefore) {
313
- target[subKey] = isArray(incoming) && isArray(existing) ? [...incoming, ...existing] : incoming;
314
- } else {
315
- target[subKey] = isArray(existing) && isArray(incoming) ? [...existing, ...incoming] : incoming;
316
- }
200
+ if (existing !== void 0 && isArray(existing) && isArray(incoming)) {
201
+ target[subKey] = insertBefore ? [...incoming, ...existing] : [...existing, ...incoming];
317
202
  } else {
318
203
  target[subKey] = incoming;
319
204
  }
320
205
  }
321
206
  };
322
- var computeResultLength = (data) => {
323
- if (isArray(data)) {
324
- return data.length;
325
- }
326
- if (isKeyMap(data)) {
327
- let acc = 0;
328
- const values = Object.values(data);
329
- const len = values.length;
330
- for (let i = 0; i < len; i++) {
331
- const val = values[i];
332
- if (isArray(val)) {
333
- acc += val.length;
334
- }
335
- }
336
- return acc;
337
- }
338
- return 0;
339
- };
340
207
  var getSeenIdsString = (arr, uniqueKey) => {
341
208
  if (!isArray(arr)) return "";
342
209
  const ids = [];
343
- const len = arr.length;
344
- for (let i = 0; i < len; i++) {
345
- const id = extractUniqueKey(arr[i], uniqueKey);
346
- if (id !== void 0) {
347
- ids.push(id);
348
- }
210
+ for (const item of arr) {
211
+ const id = extractUniqueKey(item, uniqueKey);
212
+ if (id !== void 0) ids.push(id);
349
213
  }
350
214
  return ids.join(",");
351
215
  };
352
216
  var generateRequestParams = ({
353
217
  field,
354
- uniqueKey = enum_default.DEFAULT_UNIQUE_KEY_NAME,
218
+ uniqueKey = constants_default.DEFAULT_UNIQUE_KEY_NAME,
355
219
  query = {},
356
220
  is_up = false,
357
221
  type
358
222
  }) => {
359
223
  const result = { ...query };
360
224
  const isFetched = field.fetched;
361
- const fieldResultAny = field.result;
362
- const getSafeObjectKey = (item) => {
363
- return extractUniqueKey(item, uniqueKey);
364
- };
225
+ const fieldResult = field.result;
226
+ const getSafeObjectKey = (item) => extractUniqueKey(item, uniqueKey);
365
227
  if (isFetched) {
366
- if (type === enum_default.FETCH_TYPE.AUTO) {
367
- if (isArray(fieldResultAny)) {
368
- result.seen_ids = getSeenIdsString(fieldResultAny, uniqueKey);
369
- const targetIndex = is_up ? 0 : fieldResultAny.length - 1;
370
- const targetItem = fieldResultAny[targetIndex];
371
- result.since_id = getSafeObjectKey(targetItem);
372
- }
373
- result.is_up = is_up ? 1 : 0;
374
- result.page = typeof query.page === "number" ? query.page : field.page + 1;
375
- } else if (type === enum_default.FETCH_TYPE.HAS_LOADED_IDS) {
376
- if (isArray(fieldResultAny)) {
377
- result.seen_ids = getSeenIdsString(fieldResultAny, uniqueKey);
378
- }
379
- } else if (type === enum_default.FETCH_TYPE.SINCE_FIRST_OR_END_ID) {
380
- if (isArray(fieldResultAny)) {
381
- const targetIndex = is_up ? 0 : fieldResultAny.length - 1;
382
- const targetItem = fieldResultAny[targetIndex];
383
- result.since_id = getSafeObjectKey(targetItem);
384
- }
385
- result.is_up = is_up ? 1 : 0;
386
- } else if (type === enum_default.FETCH_TYPE.PAGINATION) {
387
- result.page = typeof query.page === "number" ? query.page : void 0;
388
- } else if (type === enum_default.FETCH_TYPE.SCROLL_LOAD_MORE) {
389
- result.page = field.page + 1;
228
+ switch (type) {
229
+ case constants_default.FETCH_TYPE.AUTO:
230
+ if (isArray(fieldResult)) {
231
+ result.seen_ids = getSeenIdsString(fieldResult, uniqueKey);
232
+ result.since_id = getSafeObjectKey(
233
+ fieldResult[is_up ? 0 : fieldResult.length - 1]
234
+ );
235
+ }
236
+ result.is_up = is_up ? 1 : 0;
237
+ result.page = typeof query.page === "number" ? query.page : field.page + 1;
238
+ break;
239
+ case constants_default.FETCH_TYPE.HAS_LOADED_IDS:
240
+ if (isArray(fieldResult)) {
241
+ result.seen_ids = getSeenIdsString(fieldResult, uniqueKey);
242
+ }
243
+ break;
244
+ case constants_default.FETCH_TYPE.SINCE_FIRST_OR_END_ID:
245
+ if (isArray(fieldResult)) {
246
+ result.since_id = getSafeObjectKey(
247
+ fieldResult[is_up ? 0 : fieldResult.length - 1]
248
+ );
249
+ }
250
+ result.is_up = is_up ? 1 : 0;
251
+ break;
252
+ case constants_default.FETCH_TYPE.PAGINATION:
253
+ result.page = typeof query.page === "number" ? query.page : void 0;
254
+ break;
255
+ case constants_default.FETCH_TYPE.SCROLL_LOAD_MORE:
256
+ result.page = field.page + 1;
257
+ break;
390
258
  }
391
259
  } else {
392
- if (type === enum_default.FETCH_TYPE.AUTO) {
393
- result.seen_ids = "";
394
- result.since_id = isObjectKey(query.sinceId) ? query.sinceId : "";
395
- result.is_up = is_up ? 1 : 0;
396
- result.page = typeof query.page === "number" ? query.page : field.page || 1;
397
- } else if (type === enum_default.FETCH_TYPE.HAS_LOADED_IDS) {
398
- result.seen_ids = "";
399
- } else if (type === enum_default.FETCH_TYPE.SINCE_FIRST_OR_END_ID) {
400
- result.since_id = isObjectKey(query.sinceId) ? query.sinceId : "";
401
- result.is_up = is_up ? 1 : 0;
402
- } else if (type === enum_default.FETCH_TYPE.PAGINATION) {
403
- result.page = typeof query.page === "number" ? query.page : field.page;
404
- } else if (type === enum_default.FETCH_TYPE.SCROLL_LOAD_MORE) {
405
- result.page = 1;
260
+ switch (type) {
261
+ case constants_default.FETCH_TYPE.AUTO:
262
+ result.seen_ids = "";
263
+ result.since_id = isObjectKey(query.sinceId) ? query.sinceId : "";
264
+ result.is_up = is_up ? 1 : 0;
265
+ result.page = typeof query.page === "number" ? query.page : field.page || 1;
266
+ break;
267
+ case constants_default.FETCH_TYPE.HAS_LOADED_IDS:
268
+ result.seen_ids = "";
269
+ break;
270
+ case constants_default.FETCH_TYPE.SINCE_FIRST_OR_END_ID:
271
+ result.since_id = isObjectKey(query.sinceId) ? query.sinceId : "";
272
+ result.is_up = is_up ? 1 : 0;
273
+ break;
274
+ case constants_default.FETCH_TYPE.PAGINATION:
275
+ result.page = typeof query.page === "number" ? query.page : field.page;
276
+ break;
277
+ case constants_default.FETCH_TYPE.SCROLL_LOAD_MORE:
278
+ result.page = 1;
279
+ break;
406
280
  }
407
281
  }
408
282
  return result;
409
283
  };
410
- var toObjectKey = (id) => {
411
- if (id === void 0) return void 0;
412
- if (isObjectKey(id)) return id;
413
- if (isObjectKeyArray(id) && id.length > 0) return id[0];
414
- return void 0;
415
- };
416
- var getResultAsArray = (field) => {
417
- const result = field[enum_default.FIELD_DATA.RESULT_KEY];
418
- return isArray(result) ? result : null;
419
- };
420
- var updateArrayItem = (arr, index, updater) => {
421
- if (index >= 0 && index < arr.length) {
422
- const item = arr[index];
423
- if (isKeyMap(item)) {
424
- arr[index] = updater(item);
425
- }
426
- }
427
- };
428
284
 
429
- // src/setters.ts
285
+ // src/_internal/setters.ts
430
286
  var SET_DATA = ({
431
287
  getter,
432
288
  setter,
@@ -445,7 +301,8 @@ var SET_DATA = ({
445
301
  const field = fieldData;
446
302
  let result;
447
303
  let extra;
448
- if (isObjectResult(data)) {
304
+ const hasResult = Object.prototype.hasOwnProperty.call(data, "result");
305
+ if (!hasResult) {
449
306
  result = data;
450
307
  field.nothing = false;
451
308
  field.fetched = true;
@@ -459,7 +316,7 @@ var SET_DATA = ({
459
316
  field.nothing = field.fetched ? false : isEmpty;
460
317
  field.fetched = true;
461
318
  field.total = apiResponse.total || 0;
462
- if (type === enum_default.FETCH_TYPE.PAGINATION) {
319
+ if (type === constants_default.FETCH_TYPE.PAGINATION) {
463
320
  field.noMore = false;
464
321
  field.page = +page;
465
322
  } else {
@@ -470,7 +327,7 @@ var SET_DATA = ({
470
327
  field.loading = false;
471
328
  setReactivityField(
472
329
  field,
473
- enum_default.FIELD_DATA.RESULT_KEY,
330
+ constants_default.FIELD_DATA.RESULT_KEY,
474
331
  result,
475
332
  type,
476
333
  insertBefore
@@ -478,7 +335,7 @@ var SET_DATA = ({
478
335
  if (extra !== void 0 && extra !== null) {
479
336
  setReactivityField(
480
337
  field,
481
- enum_default.FIELD_DATA.EXTRA_KEY,
338
+ constants_default.FIELD_DATA.EXTRA_KEY,
482
339
  extra,
483
340
  type,
484
341
  insertBefore
@@ -486,27 +343,22 @@ var SET_DATA = ({
486
343
  }
487
344
  setter({
488
345
  key: fieldName,
489
- type: enum_default.SETTER_TYPE.RESET,
346
+ type: constants_default.SETTER_TYPE.RESET,
490
347
  value: field,
491
- callback: () => {
492
- resolve();
493
- }
348
+ callback: () => resolve()
494
349
  });
495
350
  });
496
351
  };
497
352
  var SET_ERROR = ({ setter, fieldName, error }) => {
498
353
  setter({
499
354
  key: fieldName,
500
- type: enum_default.SETTER_TYPE.MERGE,
501
- value: {
502
- error,
503
- loading: false
504
- }
355
+ type: constants_default.SETTER_TYPE.MERGE,
356
+ value: { error, loading: false }
505
357
  });
506
358
  };
507
359
 
508
- // src/actions.ts
509
- var generateFieldName2 = ({
360
+ // src/core.ts
361
+ var generateFieldName = ({
510
362
  func,
511
363
  query
512
364
  }) => {
@@ -525,8 +377,8 @@ var createApi = (options) => {
525
377
  const fn = ((params) => options.fetcher(params));
526
378
  const metadata = {
527
379
  id: options.id,
528
- type: options.type || enum_default.FETCH_TYPE.SCROLL_LOAD_MORE,
529
- uniqueKey: options.uniqueKey || enum_default.DEFAULT_UNIQUE_KEY_NAME,
380
+ type: options.type || constants_default.FETCH_TYPE.SCROLL_LOAD_MORE,
381
+ uniqueKey: options.uniqueKey || constants_default.DEFAULT_UNIQUE_KEY_NAME,
530
382
  is_up: options.is_up || false,
531
383
  paramsIgnore: [
532
384
  "page",
@@ -547,11 +399,11 @@ var initState = ({
547
399
  opts
548
400
  }) => {
549
401
  return new Promise((resolve) => {
550
- const fieldName = generateFieldName2({ func, query });
402
+ const fieldName = generateFieldName({ func, query });
551
403
  if (getter(fieldName)) return resolve();
552
404
  setter({
553
405
  key: fieldName,
554
- type: enum_default.SETTER_TYPE.RESET,
406
+ type: constants_default.SETTER_TYPE.RESET,
555
407
  value: generateDefaultField(opts),
556
408
  callback: () => resolve()
557
409
  });
@@ -564,7 +416,7 @@ var initData = ({
564
416
  query,
565
417
  callback
566
418
  }) => new Promise((resolve, reject) => {
567
- const fieldName = generateFieldName2({ func, query });
419
+ const fieldName = generateFieldName({ func, query });
568
420
  const fieldData = getter(fieldName);
569
421
  const doRefresh = !!query?.__refresh__;
570
422
  const needReset = !!query?.__reload__;
@@ -598,7 +450,7 @@ var initData = ({
598
450
  if (directlyLoadData) {
599
451
  setter({
600
452
  key: fieldName,
601
- type: enum_default.SETTER_TYPE.RESET,
453
+ type: constants_default.SETTER_TYPE.RESET,
602
454
  value: generateDefaultField(),
603
455
  callback: commitData
604
456
  });
@@ -615,7 +467,7 @@ var initData = ({
615
467
  } else {
616
468
  setter({
617
469
  key: fieldName,
618
- type: enum_default.SETTER_TYPE.RESET,
470
+ type: constants_default.SETTER_TYPE.RESET,
619
471
  value: { ...generateDefaultField(), loading: true, error: null },
620
472
  callback: executeFetch
621
473
  });
@@ -629,15 +481,15 @@ var loadMore = ({
629
481
  errorRetry,
630
482
  callback
631
483
  }) => new Promise((resolve, reject) => {
632
- const fieldName = generateFieldName2({ func, query });
484
+ const fieldName = generateFieldName({ func, query });
633
485
  const fieldData = getter(fieldName);
634
486
  if (!fieldData || fieldData.loading || fieldData.nothing) return resolve();
635
487
  if (fieldData.noMore && !errorRetry) return resolve();
636
488
  const type = func.type;
637
- if (type === enum_default.FETCH_TYPE.PAGINATION && query?.page != null && Number(query.page) === fieldData.page) {
489
+ if (type === constants_default.FETCH_TYPE.PAGINATION && query?.page != null && Number(query.page) === fieldData.page) {
638
490
  return resolve();
639
491
  }
640
- const loadingState = type === enum_default.FETCH_TYPE.PAGINATION ? { loading: true, error: null, result: [], extra: null } : { loading: true, error: null };
492
+ const loadingState = type === constants_default.FETCH_TYPE.PAGINATION ? { loading: true, error: null, result: [], extra: null } : { loading: true, error: null };
641
493
  const params = generateRequestParams({
642
494
  field: fieldData,
643
495
  uniqueKey: func.uniqueKey,
@@ -648,7 +500,7 @@ var loadMore = ({
648
500
  if (fieldData.extra) params.extra = fieldData.extra;
649
501
  setter({
650
502
  key: fieldName,
651
- type: enum_default.SETTER_TYPE.MERGE,
503
+ type: constants_default.SETTER_TYPE.MERGE,
652
504
  value: loadingState,
653
505
  callback: () => {
654
506
  func(params).then((data) => {
@@ -671,183 +523,239 @@ var loadMore = ({
671
523
  }
672
524
  });
673
525
  });
674
- var updateState = ({
675
- getter,
676
- setter,
677
- func,
678
- query,
679
- method,
680
- id,
681
- value,
682
- changeKey
683
- }) => {
684
- return new Promise((resolve, reject) => {
685
- const fieldName = generateFieldName2({ func, query });
686
- const fieldData = getter(fieldName);
687
- if (!fieldData) {
688
- reject(new Error(`Field ${fieldName} not found.`));
689
- return;
526
+
527
+ // src/mutations/core.ts
528
+ var pushHandler = (ctx) => {
529
+ if (!isArray(ctx.resultArray)) return;
530
+ return {
531
+ modifyValue: isArray(ctx.value) ? [...ctx.resultArray, ...ctx.value] : [...ctx.resultArray, ctx.value]
532
+ };
533
+ };
534
+ var unshiftHandler = (ctx) => {
535
+ if (!isArray(ctx.resultArray)) return;
536
+ return {
537
+ modifyValue: isArray(ctx.value) ? [...ctx.value, ...ctx.resultArray] : [ctx.value, ...ctx.resultArray]
538
+ };
539
+ };
540
+ var deleteHandler = (ctx) => {
541
+ if (!isKeyMapArray(ctx.resultArray)) return;
542
+ const objectKeyId = toObjectKey(ctx._id);
543
+ if (objectKeyId !== void 0) {
544
+ const matchedIndex = computeMatchedItemIndex(
545
+ objectKeyId,
546
+ ctx.resultArray,
547
+ ctx._uniqueKey
548
+ );
549
+ if (matchedIndex >= 0) {
550
+ const newArray = [...ctx.resultArray];
551
+ newArray.splice(matchedIndex, 1);
552
+ return { modifyValue: newArray };
690
553
  }
691
- if (fieldData.page === -1) {
692
- resolve(null);
693
- return;
554
+ }
555
+ if (isObjectKeyArray(ctx._id)) {
556
+ const idSet = new Set(ctx._id);
557
+ return {
558
+ modifyValue: ctx.resultArray.filter((item) => {
559
+ const itemKey = getObjectDeepValue(item, ctx._uniqueKey);
560
+ return typeof itemKey !== "string" && typeof itemKey !== "number" ? true : !idSet.has(itemKey);
561
+ })
562
+ };
563
+ }
564
+ return void 0;
565
+ };
566
+ var mergeHandler = (ctx) => {
567
+ const objectKeyId = toObjectKey(ctx._id);
568
+ if (objectKeyId === void 0 || !ctx.resultArray || !isKeyMap(ctx.value))
569
+ return;
570
+ const matchedIndex = computeMatchedItemIndex(
571
+ objectKeyId,
572
+ ctx.resultArray,
573
+ ctx._uniqueKey
574
+ );
575
+ updateArrayItem(ctx.resultArray, matchedIndex, (item) => ({
576
+ ...item,
577
+ ...ctx.value
578
+ }));
579
+ };
580
+ var resetHandler = (ctx) => {
581
+ if (ctx._changeKey === constants_default.FIELD_DATA.RESULT_KEY && isKeyMapArray(ctx.value)) {
582
+ ctx.newFieldData.result = ctx.value;
583
+ } else if (ctx._changeKey === constants_default.FIELD_DATA.EXTRA_KEY && isKeyMap(ctx.value)) {
584
+ ctx.newFieldData.extra = ctx.value;
585
+ }
586
+ };
587
+ var coreMutations = {
588
+ [constants_default.CHANGE_TYPE.RESULT_ADD_AFTER]: pushHandler,
589
+ [constants_default.CHANGE_TYPE.RESULT_ADD_BEFORE]: unshiftHandler,
590
+ [constants_default.CHANGE_TYPE.RESULT_REMOVE_BY_ID]: deleteHandler,
591
+ [constants_default.CHANGE_TYPE.RESULT_ITEM_MERGE]: mergeHandler,
592
+ [constants_default.CHANGE_TYPE.RESET_FIELD]: resetHandler
593
+ };
594
+
595
+ // src/mutations/extended.ts
596
+ var searchHandler = (ctx) => {
597
+ const objectKeyId = toObjectKey(ctx._id);
598
+ if (objectKeyId === void 0) return;
599
+ const searchResult = ctx.resultArray ? searchValueByKey(ctx.resultArray, objectKeyId, ctx._uniqueKey) : void 0;
600
+ return { resolved: searchResult };
601
+ };
602
+ var updateKVHandler = (ctx) => {
603
+ const objectKeyId = toObjectKey(ctx._id);
604
+ if (objectKeyId === void 0 || !ctx.resultArray) return;
605
+ const matchedIndex = computeMatchedItemIndex(
606
+ objectKeyId,
607
+ ctx.resultArray,
608
+ ctx._uniqueKey
609
+ );
610
+ if (matchedIndex >= 0 && isKeyMap(ctx.resultArray[matchedIndex])) {
611
+ const newItem = { ...ctx.resultArray[matchedIndex] };
612
+ updateObjectDeepValue(newItem, ctx._changeKey, ctx.value);
613
+ ctx.resultArray[matchedIndex] = newItem;
614
+ }
615
+ };
616
+ var insertBeforeHandler = (ctx) => {
617
+ const objectKeyId = toObjectKey(ctx._id);
618
+ if (!isArray(ctx.resultArray) || objectKeyId === void 0) return void 0;
619
+ const matchedIndex = computeMatchedItemIndex(
620
+ objectKeyId,
621
+ ctx.resultArray,
622
+ ctx._uniqueKey
623
+ );
624
+ if (matchedIndex >= 0) {
625
+ const newArray = [...ctx.resultArray];
626
+ newArray.splice(matchedIndex, 0, ctx.value);
627
+ return { modifyValue: newArray };
628
+ }
629
+ return void 0;
630
+ };
631
+ var insertAfterHandler = (ctx) => {
632
+ const objectKeyId = toObjectKey(ctx._id);
633
+ if (!isArray(ctx.resultArray) || objectKeyId === void 0) return void 0;
634
+ const matchedIndex = computeMatchedItemIndex(
635
+ objectKeyId,
636
+ ctx.resultArray,
637
+ ctx._uniqueKey
638
+ );
639
+ if (matchedIndex >= 0) {
640
+ const newArray = [...ctx.resultArray];
641
+ newArray.splice(matchedIndex + 1, 0, ctx.value);
642
+ return { modifyValue: newArray };
643
+ }
644
+ return void 0;
645
+ };
646
+ var patchHandler = (ctx) => {
647
+ if (!isKeyMapArray(ctx.resultArray)) return;
648
+ const newArray = [...ctx.resultArray];
649
+ if (isKeyMapArray(ctx.value)) {
650
+ combineArrayData(newArray, ctx.value, ctx._uniqueKey);
651
+ } else if (isKeyMap(ctx.value)) {
652
+ const valueAsRecord = {};
653
+ for (const [k, v] of Object.entries(ctx.value)) {
654
+ if (isKeyMap(v)) valueAsRecord[k] = v;
694
655
  }
695
- const _id = id;
696
- const _uniqueKey = func.uniqueKey || enum_default.DEFAULT_UNIQUE_KEY_NAME;
697
- const _changeKey = changeKey || enum_default.FIELD_DATA.RESULT_KEY;
698
- const beforeLength = computeResultLength(
699
- fieldData[enum_default.FIELD_DATA.RESULT_KEY]
700
- );
701
- const newFieldData = { ...fieldData };
702
- const resultArray = getResultAsArray(newFieldData);
703
- if (method === enum_default.CHANGE_TYPE.SEARCH_FIELD) {
704
- const objectKeyId = toObjectKey(_id);
705
- if (objectKeyId === void 0) {
706
- reject(new Error("ID is required for SEARCH_FIELD."));
656
+ combineArrayData(newArray, valueAsRecord, ctx._uniqueKey);
657
+ }
658
+ return { modifyValue: newArray };
659
+ };
660
+ var extendedMutations = {
661
+ [constants_default.CHANGE_TYPE.SEARCH_FIELD]: searchHandler,
662
+ [constants_default.CHANGE_TYPE.RESULT_UPDATE_KV]: updateKVHandler,
663
+ [constants_default.CHANGE_TYPE.RESULT_INSERT_TO_BEFORE]: insertBeforeHandler,
664
+ [constants_default.CHANGE_TYPE.RESULT_INSERT_TO_AFTER]: insertAfterHandler,
665
+ [constants_default.CHANGE_TYPE.RESULT_LIST_MERGE]: patchHandler
666
+ };
667
+
668
+ // src/mutations/index.ts
669
+ var allMutations = {
670
+ ...coreMutations,
671
+ ...extendedMutations
672
+ };
673
+ var createUpdateState = (handlers = allMutations) => {
674
+ return ({
675
+ getter,
676
+ setter,
677
+ func,
678
+ query,
679
+ method,
680
+ id,
681
+ value,
682
+ changeKey
683
+ }) => {
684
+ return new Promise((resolve, reject) => {
685
+ const fieldName = generateFieldName({ func, query });
686
+ const fieldData = getter(fieldName);
687
+ if (!fieldData) {
688
+ reject(new Error(`Field ${fieldName} not found.`));
707
689
  return;
708
690
  }
709
- const searchResult = resultArray ? searchValueByKey(resultArray, objectKeyId, _uniqueKey) : void 0;
710
- resolve(searchResult);
711
- return;
712
- } else if (method === enum_default.CHANGE_TYPE.RESULT_UPDATE_KV) {
713
- const objectKeyId = toObjectKey(_id);
714
- if (objectKeyId === void 0) {
715
- reject(new Error("ID is required for RESULT_UPDATE_KV."));
691
+ if (fieldData.page === -1) {
692
+ resolve(null);
716
693
  return;
717
694
  }
695
+ const _uniqueKey = func.uniqueKey || constants_default.DEFAULT_UNIQUE_KEY_NAME;
696
+ const _changeKey = changeKey || constants_default.FIELD_DATA.RESULT_KEY;
697
+ const beforeLength = computeResultLength(
698
+ fieldData[constants_default.FIELD_DATA.RESULT_KEY]
699
+ );
700
+ const newFieldData = { ...fieldData };
701
+ let resultArray = getResultAsArray(fieldData);
718
702
  if (resultArray) {
719
- const matchedIndex = computeMatchedItemIndex(
720
- objectKeyId,
721
- resultArray,
722
- _uniqueKey
723
- );
724
- if (matchedIndex >= 0 && isKeyMap(resultArray[matchedIndex])) {
725
- updateObjectDeepValue(resultArray[matchedIndex], _changeKey, value);
726
- }
703
+ resultArray = [...resultArray];
704
+ newFieldData.result = resultArray;
727
705
  }
728
- resolve(null);
729
- } else if (method === enum_default.CHANGE_TYPE.RESULT_ITEM_MERGE) {
730
- const objectKeyId = toObjectKey(_id);
731
- if (objectKeyId === void 0) {
732
- reject(new Error("ID is required for RESULT_ITEM_MERGE."));
706
+ const handler = handlers[method];
707
+ if (!handler) {
708
+ resolve(null);
733
709
  return;
734
710
  }
735
- if (resultArray && isKeyMap(value)) {
736
- const matchedIndex = computeMatchedItemIndex(
737
- objectKeyId,
738
- resultArray,
739
- _uniqueKey
740
- );
741
- updateArrayItem(resultArray, matchedIndex, (item) => ({
742
- ...item,
743
- ...value
744
- }));
745
- }
746
- resolve(null);
747
- } else if (method === enum_default.CHANGE_TYPE.RESET_FIELD) {
748
- if (_changeKey === enum_default.FIELD_DATA.RESULT_KEY && isKeyMapArray(value)) {
749
- newFieldData.result = value;
750
- } else if (_changeKey === enum_default.FIELD_DATA.EXTRA_KEY && isKeyMap(value)) {
751
- newFieldData.extra = value;
752
- }
753
- resolve(null);
754
- } else {
755
- let modifyValue;
756
- if (_changeKey === enum_default.FIELD_DATA.RESULT_KEY) {
757
- modifyValue = newFieldData.result;
758
- } else if (_changeKey === enum_default.FIELD_DATA.EXTRA_KEY) {
759
- modifyValue = newFieldData.extra;
760
- } else {
761
- modifyValue = getObjectDeepValue(newFieldData, _changeKey);
762
- }
763
- if (modifyValue == null) {
764
- modifyValue = [];
765
- }
766
- const objectKeyId = toObjectKey(_id);
767
- const matchedIndex = objectKeyId !== void 0 && isKeyMapArray(modifyValue) ? computeMatchedItemIndex(objectKeyId, modifyValue, _uniqueKey) : -1;
768
- switch (method) {
769
- case enum_default.CHANGE_TYPE.RESULT_ADD_AFTER:
770
- if (isArray(modifyValue)) {
771
- modifyValue = isArray(value) ? [...modifyValue, ...value] : [...modifyValue, value];
772
- }
773
- break;
774
- case enum_default.CHANGE_TYPE.RESULT_ADD_BEFORE:
775
- if (isArray(modifyValue)) {
776
- modifyValue = isArray(value) ? [...value, ...modifyValue] : [value, ...modifyValue];
777
- }
778
- break;
779
- case enum_default.CHANGE_TYPE.RESULT_REMOVE_BY_ID:
780
- if (isKeyMapArray(modifyValue)) {
781
- if (matchedIndex >= 0) {
782
- modifyValue.splice(matchedIndex, 1);
783
- } else if (isObjectKeyArray(_id)) {
784
- const idSet = new Set(_id);
785
- modifyValue = modifyValue.filter((item) => {
786
- const itemKey = getObjectDeepValue(item, _uniqueKey);
787
- return !isObjectKey(itemKey) || !idSet.has(itemKey);
788
- });
789
- }
790
- }
791
- break;
792
- case enum_default.CHANGE_TYPE.RESULT_INSERT_TO_BEFORE:
793
- if (isArray(modifyValue) && matchedIndex >= 0) {
794
- modifyValue.splice(matchedIndex, 0, value);
795
- }
796
- break;
797
- case enum_default.CHANGE_TYPE.RESULT_INSERT_TO_AFTER:
798
- if (isArray(modifyValue) && matchedIndex >= 0) {
799
- modifyValue.splice(matchedIndex + 1, 0, value);
800
- }
801
- break;
802
- case enum_default.CHANGE_TYPE.RESULT_LIST_MERGE:
803
- if (isKeyMapArray(modifyValue)) {
804
- if (isKeyMapArray(value)) {
805
- combineArrayData(modifyValue, value, _uniqueKey);
806
- } else if (isKeyMap(value)) {
807
- const valueAsRecord = {};
808
- for (const [k, v] of Object.entries(value)) {
809
- if (isKeyMap(v)) {
810
- valueAsRecord[k] = v;
811
- }
812
- }
813
- combineArrayData(modifyValue, valueAsRecord, _uniqueKey);
814
- }
815
- }
816
- break;
817
- default:
818
- resolve(null);
711
+ const ctx = {
712
+ resultArray,
713
+ newFieldData,
714
+ _id: id,
715
+ _uniqueKey,
716
+ _changeKey,
717
+ value
718
+ };
719
+ const handlerResult = handler(ctx);
720
+ if (handlerResult) {
721
+ if ("resolved" in handlerResult) {
722
+ resolve(handlerResult.resolved);
819
723
  return;
724
+ }
725
+ if ("modifyValue" in handlerResult && handlerResult.modifyValue !== void 0) {
726
+ const modifyValue = handlerResult.modifyValue;
727
+ if (_changeKey === constants_default.FIELD_DATA.RESULT_KEY && isKeyMapArray(modifyValue)) {
728
+ newFieldData.result = modifyValue;
729
+ } else if (_changeKey === constants_default.FIELD_DATA.EXTRA_KEY && isKeyMap(modifyValue)) {
730
+ newFieldData.extra = modifyValue;
731
+ }
732
+ }
820
733
  }
821
- if (_changeKey === enum_default.FIELD_DATA.RESULT_KEY && isKeyMapArray(modifyValue)) {
822
- newFieldData.result = modifyValue;
823
- } else if (_changeKey === enum_default.FIELD_DATA.EXTRA_KEY && isKeyMap(modifyValue)) {
824
- newFieldData.extra = modifyValue;
825
- }
826
- resolve(null);
827
- }
828
- const afterLength = computeResultLength(
829
- newFieldData[enum_default.FIELD_DATA.RESULT_KEY]
830
- );
831
- newFieldData.total = newFieldData.total + afterLength - beforeLength;
832
- newFieldData.nothing = afterLength === 0;
833
- setter({
834
- key: fieldName,
835
- type: enum_default.SETTER_TYPE.RESET,
836
- value: newFieldData,
837
- callback: () => {
838
- resolve(null);
839
- }
734
+ const afterLength = computeResultLength(
735
+ newFieldData[constants_default.FIELD_DATA.RESULT_KEY]
736
+ );
737
+ newFieldData.total = newFieldData.total + afterLength - beforeLength;
738
+ newFieldData.nothing = afterLength === 0;
739
+ setter({
740
+ key: fieldName,
741
+ type: constants_default.SETTER_TYPE.RESET,
742
+ value: newFieldData,
743
+ callback: () => resolve(null)
744
+ });
840
745
  });
841
- });
746
+ };
842
747
  };
748
+ var updateState = createUpdateState();
843
749
 
844
- exports.ENUM = enum_default;
750
+ exports.ENUM = constants_default;
751
+ exports.coreMutations = coreMutations;
845
752
  exports.createApi = createApi;
846
- exports.generateFieldName = generateFieldName2;
753
+ exports.createUpdateState = createUpdateState;
754
+ exports.extendedMutations = extendedMutations;
755
+ exports.generateFieldName = generateFieldName;
847
756
  exports.initData = initData;
848
757
  exports.initState = initState;
849
758
  exports.loadMore = loadMore;
850
759
  exports.updateState = updateState;
851
- exports.utils = utils_exports;
852
760
  //# sourceMappingURL=index.js.map
853
761
  //# sourceMappingURL=index.js.map