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