@hf-chimera/store 0.0.8 → 0.0.10

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 (42) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/adapters/react.cjs +3 -2
  3. package/dist/adapters/react.d.cts +2 -2
  4. package/dist/adapters/react.d.ts +2 -2
  5. package/dist/adapters/react.js +3 -2
  6. package/dist/adapters/react.js.map +1 -1
  7. package/dist/defaults-Bg1kIemd.cjs +371 -0
  8. package/dist/defaults-CLUQg2zK.js +210 -0
  9. package/dist/defaults-CLUQg2zK.js.map +1 -0
  10. package/dist/defaults.cjs +21 -0
  11. package/dist/defaults.d.cts +59 -0
  12. package/dist/defaults.d.cts.map +1 -0
  13. package/dist/defaults.d.ts +59 -0
  14. package/dist/defaults.d.ts.map +1 -0
  15. package/dist/defaults.js +13 -0
  16. package/dist/defaults.js.map +1 -0
  17. package/dist/{index-DgwhyIVQ.d.cts → index-BcCVbW9M.d.cts} +21 -4
  18. package/dist/index-BcCVbW9M.d.cts.map +1 -0
  19. package/dist/{index-kFATKhTP.d.ts → index-O42il7qa.d.ts} +21 -4
  20. package/dist/index-O42il7qa.d.ts.map +1 -0
  21. package/dist/{index-CqYNg3Vx.d.ts → index-aFqSzWq5.d.ts} +2 -2
  22. package/dist/{index-CqYNg3Vx.d.ts.map → index-aFqSzWq5.d.ts.map} +1 -1
  23. package/dist/{index-Mu4KG7Z7.d.cts → index-sjIP2TCu.d.cts} +2 -2
  24. package/dist/{index-Mu4KG7Z7.d.cts.map → index-sjIP2TCu.d.cts.map} +1 -1
  25. package/dist/index.cjs +13 -12
  26. package/dist/index.d.cts +2 -2
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +2 -1
  29. package/dist/{qb-DHuihkTp.js → qb-DNcihcMP.js} +2 -2
  30. package/dist/{qb-DHuihkTp.js.map → qb-DNcihcMP.js.map} +1 -1
  31. package/dist/{qb-Cg4Q_DkJ.cjs → qb-pl8eUjYV.cjs} +1 -1
  32. package/dist/qb.cjs +3 -2
  33. package/dist/qb.d.cts +2 -2
  34. package/dist/qb.d.ts +2 -2
  35. package/dist/qb.js +3 -2
  36. package/dist/{src-Bx-gbHfm.js → src-BTo-wGWx.js} +3 -209
  37. package/dist/src-BTo-wGWx.js.map +1 -0
  38. package/dist/{src-u2_wgi_K.cjs → src-FCZZKq4W.cjs} +47 -320
  39. package/package.json +6 -1
  40. package/dist/index-DgwhyIVQ.d.cts.map +0 -1
  41. package/dist/index-kFATKhTP.d.ts.map +0 -1
  42. package/dist/src-Bx-gbHfm.js.map +0 -1
@@ -1,15 +1,7 @@
1
+ const require_defaults = require('./defaults-Bg1kIemd.cjs');
1
2
 
2
- //#region src/shared/errors.ts
3
- var ChimeraError = class extends Error {};
4
- var ChimeraInternalError = class extends ChimeraError {
5
- constructor(message, options) {
6
- super(`${message}\nIf you have this bug, feel free to create an issue in https://github.com/hf-chimera/store/issues`, options);
7
- }
8
- };
9
-
10
- //#endregion
11
3
  //#region src/filter/errors.ts
12
- var ChimeraFilterError = class extends ChimeraError {};
4
+ var ChimeraFilterError = class extends require_defaults.ChimeraError {};
13
5
  var ChimeraFilterOperatorError = class extends ChimeraFilterError {
14
6
  constructor(operator, message) {
15
7
  super(`Operator "${operator}" ${message}`);
@@ -151,7 +143,7 @@ const compileConjunction = (config, { kind, operations }) => {
151
143
  switch (operation.type) {
152
144
  case ChimeraOperatorSymbol: return compileOperator(config, operation);
153
145
  case ChimeraConjunctionSymbol: return compileConjunction(config, operation);
154
- default: throw new ChimeraInternalError(`Invalid filter operation ${operation.type}`);
146
+ default: throw new require_defaults.ChimeraInternalError(`Invalid filter operation ${operation.type}`);
155
147
  }
156
148
  }).filter(Boolean);
157
149
  return (entity) => conjunction(compiledOperations.map((op) => () => op(entity)));
@@ -192,7 +184,7 @@ const simplifyConjunction = ({ kind, operations }) => {
192
184
  switch (op.type) {
193
185
  case ChimeraOperatorSymbol: return simplifyOperator(op);
194
186
  case ChimeraConjunctionSymbol: return simplifyConjunction(op);
195
- default: throw new ChimeraInternalError(`Invalid filter operation ${op.type}`);
187
+ default: throw new require_defaults.ChimeraInternalError(`Invalid filter operation ${op.type}`);
196
188
  }
197
189
  }).filter(Boolean).sort((a, b) => compareSimplifiedOperation(a, b)),
198
190
  type: ChimeraConjunctionSymbol
@@ -239,16 +231,6 @@ const isFilterSubset = (candidate, target, getOperatorKey) => {
239
231
  return isConjunctionSubset(candidate, target, getOperatorKey);
240
232
  };
241
233
 
242
- //#endregion
243
- //#region src/order/errors.ts
244
- var ChimeraOrderError = class extends ChimeraError {};
245
- var ChimeraOrderTypeError = class extends ChimeraOrderError {};
246
- var ChimeraOrderTypeComparisonError = class extends ChimeraOrderTypeError {
247
- constructor(a, b) {
248
- super(`Unsupported comparison "${a}"(${typeof a}[${a != null ? a.constructor.name : a}]) with "${b}"(${typeof b}[${b != null ? b.constructor.name : b}])`);
249
- }
250
- };
251
-
252
234
  //#endregion
253
235
  //#region src/order/types.ts
254
236
  let ChimeraOrderNulls = /* @__PURE__ */ function(ChimeraOrderNulls$1) {
@@ -443,106 +425,6 @@ const IN_PROGRESS_STATES = [
443
425
  ChimeraQueryFetchingState.Deleting
444
426
  ];
445
427
 
446
- //#endregion
447
- //#region src/query/errors.ts
448
- const formatDeepErrorMessage = (message, cause) => `${message}: ${cause instanceof Error ? `\n ${cause.stack}` : cause}`;
449
- var ChimeraQueryError = class extends ChimeraError {
450
- entityName;
451
- constructor(entityName, message, options) {
452
- super(message, options);
453
- this.entityName = entityName;
454
- }
455
- };
456
- var ChimeraQueryIdMismatchError = class extends ChimeraQueryError {
457
- old;
458
- new;
459
- constructor(entityName, oldId, newId) {
460
- super(entityName, `
461
- Can't update "${entityName}" item if the change updates it's [id] (changed from "${oldId}" to "${newId}").
462
- If such an update should not be an error, update <idGetter> field in "${entityName}" entity config to make Chimera get the [id] value properly.
463
- `.trim());
464
- this.old = oldId;
465
- this.new = newId;
466
- }
467
- };
468
- var ChimeraQueryNotSpecifiedError = class extends ChimeraQueryError {
469
- methodName;
470
- constructor(entityName, methodName) {
471
- super(entityName, `<${methodName}> for entity "${entityName}" was not specified`);
472
- this.methodName = methodName;
473
- }
474
- };
475
- var ChimeraQueryTrustError = class extends ChimeraQueryError {
476
- constructor(entityName, description) {
477
- super(entityName, `
478
- DO NOT IGNORE THIS ERROR OR YOUR PROD MAY BREAK!
479
-
480
- Looks like your "${entityName}" query provider ${description}
481
-
482
- By default Chimera tend to trust external query provider to avoid extra data processing.
483
- If it is not your case, set field "trustQuery" to "false" in config defaults or for specific entity.
484
- This error visible only if "devMode" is "true".
485
- If you'll ignore it, your production may fail, because Chimera won't check the data correctness.
486
- `.trim());
487
- }
488
- };
489
- var ChimeraQueryTrustIdMismatchError = class extends ChimeraQueryTrustError {
490
- old;
491
- new;
492
- constructor(entityName, oldId, newId) {
493
- super(entityName, `
494
- returned an item with [id] that not matches with the [id] of item that was updated (changed from "${oldId}" to "${newId}").
495
- If it is not an error, update <idGetter> field in "${entityName}" entity config to make Chimera get the [id] value properly.
496
- `.trim());
497
- this.old = oldId;
498
- this.new = newId;
499
- }
500
- };
501
- var ChimeraQueryTrustFetchedCollectionError = class extends ChimeraQueryTrustError {
502
- old;
503
- new;
504
- constructor(entityName, input, output) {
505
- super(entityName, "returned not properly sorted or ordered collection.");
506
- this.old = input;
507
- this.new = output;
508
- }
509
- };
510
- var ChimeraQueryFetchingError = class extends ChimeraQueryError {
511
- constructor(entityName, cause) {
512
- super(entityName, formatDeepErrorMessage("Something went wrong", cause), { cause });
513
- }
514
- };
515
- var ChimeraQueryDeletingError = class extends ChimeraQueryError {
516
- constructor(entityName, cause) {
517
- super(entityName, formatDeepErrorMessage("Something went wrong", cause), { cause });
518
- }
519
- };
520
- var ChimeraQueryNotReadyError = class extends ChimeraQueryError {
521
- constructor(entityName) {
522
- super(entityName, "Unable to get unready value.");
523
- }
524
- };
525
- var ChimeraQueryDeletedItemError = class extends ChimeraQueryError {
526
- constructor(entityName, id) {
527
- super(entityName, `Unable to updated deleted item with [id] "${id}."`);
528
- }
529
- };
530
- var ChimeraQueryUnsuccessfulDeletionError = class extends ChimeraQueryError {
531
- constructor(entityName, id) {
532
- super(entityName, `Item with [id] "${id}" was not deleted.`);
533
- }
534
- };
535
- var ChimeraQueryAlreadyRunningError = class extends ChimeraQueryError {
536
- constructor(entityName, status) {
537
- super(entityName, `Unable to operate query. Other process already running ${status}.`);
538
- }
539
- };
540
- var ChimeraQueryNotCreatedError = class extends ChimeraQueryError {
541
- constructor(entityName) {
542
- super(entityName, "Unable to operate not created item.");
543
- }
544
- };
545
-
546
428
  //#endregion
547
429
  //#region src/query/ChimeraCollectionQuery.ts
548
430
  var ChimeraCollectionQuery = class extends ChimeraEventEmitter {
@@ -559,14 +441,14 @@ var ChimeraCollectionQuery = class extends ChimeraEventEmitter {
559
441
  queueMicrotask(() => super.emit(event, arg));
560
442
  }
561
443
  emit() {
562
- throw new ChimeraInternalError("External events dispatching is not supported.");
444
+ throw new require_defaults.ChimeraInternalError("External events dispatching is not supported.");
563
445
  }
564
446
  #prepareRequestParams() {
565
447
  return { controller: new AbortController() };
566
448
  }
567
449
  #readyItems(internalMessage) {
568
450
  if (this.#items) return this.#items;
569
- throw internalMessage ? new ChimeraInternalError(internalMessage) : new ChimeraQueryNotReadyError(this.#config.name);
451
+ throw internalMessage ? new require_defaults.ChimeraInternalError(internalMessage) : new require_defaults.ChimeraQueryNotReadyError(this.#config.name);
570
452
  }
571
453
  #addItem(item) {
572
454
  const items = this.#readyItems("Trying to update not ready collection");
@@ -655,7 +537,7 @@ var ChimeraCollectionQuery = class extends ChimeraEventEmitter {
655
537
  if (!this.#config.trustQuery) return prepared;
656
538
  if (this.#config.devMode) {
657
539
  for (let i = 0; i < input.length; i++) if (input[i] !== prepared[i]) {
658
- console.warn(new ChimeraQueryTrustFetchedCollectionError(this.#config.name, input, prepared));
540
+ console.warn(new require_defaults.ChimeraQueryTrustFetchedCollectionError(this.#config.name, input, prepared));
659
541
  break;
660
542
  }
661
543
  }
@@ -675,7 +557,7 @@ var ChimeraCollectionQuery = class extends ChimeraEventEmitter {
675
557
  this.#setNewItems(this.#validate(response.data));
676
558
  this.#state = ChimeraQueryFetchingState.Fetched;
677
559
  return response;
678
- }).catch((error) => this.#setError(error, new ChimeraQueryFetchingError(this.#config.name, error))), controller);
560
+ }).catch((error) => this.#setError(error, new require_defaults.ChimeraQueryFetchingError(this.#config.name, error))), controller);
679
561
  }
680
562
  constructor(config, params, existingItems, order, filter, alreadyValid) {
681
563
  super();
@@ -774,7 +656,7 @@ var ChimeraCollectionQuery = class extends ChimeraEventEmitter {
774
656
  */
775
657
  refetch(force = false) {
776
658
  if (!force && this.#promise && [ChimeraQueryFetchingState.Fetching, ChimeraQueryFetchingState.Refetching].includes(this.#state)) return this.#promise;
777
- if (!force && [ChimeraQueryFetchingState.Updating, ChimeraQueryFetchingState.Deleting].includes(this.#state)) throw new ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
659
+ if (!force && [ChimeraQueryFetchingState.Updating, ChimeraQueryFetchingState.Deleting].includes(this.#state)) throw new require_defaults.ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
778
660
  this.#state = ChimeraQueryFetchingState.Refetching;
779
661
  const { controller } = this.#prepareRequestParams();
780
662
  return this.#setPromise(this.#watchPromise(makeCancellablePromise(this.#config.collectionFetcher(this.#params, { signal: controller.signal }), controller), controller));
@@ -837,13 +719,13 @@ var ChimeraCollectionQuery = class extends ChimeraEventEmitter {
837
719
  return response;
838
720
  }
839
721
  if (id !== newId) {
840
- this.#config.devMode && this.#config.trustQuery && console.warn(new ChimeraQueryTrustIdMismatchError(this.#config.name, id, newId));
722
+ this.#config.devMode && this.#config.trustQuery && console.warn(new require_defaults.ChimeraQueryTrustIdMismatchError(this.#config.name, id, newId));
841
723
  if (!this.#config.trustQuery) {
842
724
  success && this.#emit("selfItemDeleted", {
843
725
  id: newId,
844
726
  instance: this
845
727
  });
846
- throw new ChimeraQueryTrustIdMismatchError(this.#config.name, id, newId);
728
+ throw new require_defaults.ChimeraQueryTrustIdMismatchError(this.#config.name, id, newId);
847
729
  }
848
730
  }
849
731
  if (success) {
@@ -854,11 +736,11 @@ var ChimeraCollectionQuery = class extends ChimeraEventEmitter {
854
736
  });
855
737
  return response;
856
738
  }
857
- const error = new ChimeraQueryUnsuccessfulDeletionError(this.#config.name, id);
739
+ const error = new require_defaults.ChimeraQueryUnsuccessfulDeletionError(this.#config.name, id);
858
740
  this.#state = ChimeraQueryFetchingState.ReErrored;
859
741
  this.#lastError = error;
860
742
  throw error;
861
- }, (error) => this.#setError(error, new ChimeraQueryDeletingError(this.#config.name, error)));
743
+ }, (error) => this.#setError(error, new require_defaults.ChimeraQueryDeletingError(this.#config.name, error)));
862
744
  }
863
745
  /**
864
746
  * Delete a list of items by their [id]s
@@ -875,14 +757,14 @@ var ChimeraCollectionQuery = class extends ChimeraEventEmitter {
875
757
  instance: this
876
758
  });
877
759
  } else {
878
- const error = new ChimeraQueryUnsuccessfulDeletionError(this.#config.name, newId);
760
+ const error = new require_defaults.ChimeraQueryUnsuccessfulDeletionError(this.#config.name, newId);
879
761
  this.#state = ChimeraQueryFetchingState.ReErrored;
880
762
  this.#lastError = error;
881
763
  throw error;
882
764
  }
883
765
  });
884
766
  return response;
885
- }, (error) => this.#setError(error, new ChimeraQueryDeletingError(this.#config.name, error)));
767
+ }, (error) => this.#setError(error, new require_defaults.ChimeraQueryDeletingError(this.#config.name, error)));
886
768
  }
887
769
  /**
888
770
  * Create new item using partial data
@@ -898,7 +780,7 @@ var ChimeraCollectionQuery = class extends ChimeraEventEmitter {
898
780
  item: data
899
781
  });
900
782
  return response;
901
- }, (error) => this.#setError(error, new ChimeraQueryFetchingError(this.#config.name, error)));
783
+ }, (error) => this.#setError(error, new require_defaults.ChimeraQueryFetchingError(this.#config.name, error)));
902
784
  }
903
785
  /**
904
786
  * Create multiple items using partial data
@@ -915,7 +797,7 @@ var ChimeraCollectionQuery = class extends ChimeraEventEmitter {
915
797
  });
916
798
  });
917
799
  return response;
918
- }, (error) => this.#setError(error, new ChimeraQueryFetchingError(this.#config.name, error)));
800
+ }, (error) => this.#setError(error, new require_defaults.ChimeraQueryFetchingError(this.#config.name, error)));
919
801
  }
920
802
  /**
921
803
  * Standard Array API without mutations
@@ -1009,7 +891,7 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1009
891
  queueMicrotask(() => super.emit(event, arg));
1010
892
  }
1011
893
  emit() {
1012
- throw new ChimeraInternalError("External events dispatching is not supported.");
894
+ throw new require_defaults.ChimeraInternalError("External events dispatching is not supported.");
1013
895
  }
1014
896
  #prepareRequestParams() {
1015
897
  return { controller: new AbortController() };
@@ -1021,10 +903,10 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1021
903
  }
1022
904
  #readyItem(internalMessage) {
1023
905
  if (this.#item) return this.#item;
1024
- throw internalMessage ? new ChimeraInternalError(internalMessage) : new ChimeraQueryNotReadyError(this.#config.name);
906
+ throw internalMessage ? new require_defaults.ChimeraInternalError(internalMessage) : new require_defaults.ChimeraQueryNotReadyError(this.#config.name);
1025
907
  }
1026
908
  #mutableItem(internalMessage) {
1027
- if (this.#state === ChimeraQueryFetchingState.Deleted) throw internalMessage ? new ChimeraInternalError(internalMessage) : new ChimeraQueryDeletedItemError(this.#config.name, this.#params.id);
909
+ if (this.#state === ChimeraQueryFetchingState.Deleted) throw internalMessage ? new require_defaults.ChimeraInternalError(internalMessage) : new require_defaults.ChimeraQueryDeletedItemError(this.#config.name, this.#params.id);
1028
910
  return this.#readyItem(internalMessage);
1029
911
  }
1030
912
  #setMutable(item) {
@@ -1089,21 +971,21 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1089
971
  });
1090
972
  this.#state = ChimeraQueryFetchingState.Fetched;
1091
973
  } else {
1092
- this.#config.devMode && this.#config.trustQuery && console.warn(new ChimeraQueryTrustIdMismatchError(this.#config.name, localId, newId));
1093
- if (!this.#config.trustQuery) throw new ChimeraQueryTrustIdMismatchError(this.#config.name, localId, newId);
974
+ this.#config.devMode && this.#config.trustQuery && console.warn(new require_defaults.ChimeraQueryTrustIdMismatchError(this.#config.name, localId, newId));
975
+ if (!this.#config.trustQuery) throw new require_defaults.ChimeraQueryTrustIdMismatchError(this.#config.name, localId, newId);
1094
976
  this.#setNewItem(data);
1095
977
  this.#params.id = newId;
1096
978
  this.#state = ChimeraQueryFetchingState.Fetched;
1097
979
  }
1098
980
  return { data };
1099
- }).catch((error) => this.#setError(error, new ChimeraQueryFetchingError(this.#config.name, error))), controller);
981
+ }).catch((error) => this.#setError(error, new require_defaults.ChimeraQueryFetchingError(this.#config.name, error))), controller);
1100
982
  }
1101
983
  #updateItem(newItem) {
1102
984
  const newId = this.#idGetter(newItem);
1103
985
  const oldId = this.#idGetter(this.#readyItem(`Trying to update not ready item (${this.#config.name}[${this.#params.id}])`));
1104
986
  if (newId !== oldId && !this.#config.trustQuery) {
1105
987
  this.#resetMutable();
1106
- throw new ChimeraQueryIdMismatchError(this.#config.name, oldId, newId);
988
+ throw new require_defaults.ChimeraQueryIdMismatchError(this.#config.name, oldId, newId);
1107
989
  }
1108
990
  this.#state = ChimeraQueryFetchingState.Updating;
1109
991
  const { controller } = this.#prepareRequestParams();
@@ -1120,8 +1002,8 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1120
1002
  }
1121
1003
  const localId = this.#params.id;
1122
1004
  if (localId !== id) {
1123
- this.#config.devMode && this.#config.trustQuery && console.warn(new ChimeraQueryTrustIdMismatchError(this.#config.name, localId, id));
1124
- if (!this.#config.trustQuery) throw new ChimeraQueryTrustIdMismatchError(this.#config.name, localId, id);
1005
+ this.#config.devMode && this.#config.trustQuery && console.warn(new require_defaults.ChimeraQueryTrustIdMismatchError(this.#config.name, localId, id));
1006
+ if (!this.#config.trustQuery) throw new require_defaults.ChimeraQueryTrustIdMismatchError(this.#config.name, localId, id);
1125
1007
  }
1126
1008
  if (success) {
1127
1009
  this.#deleteItem();
@@ -1130,13 +1012,13 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1130
1012
  instance: this
1131
1013
  });
1132
1014
  } else {
1133
- const error = new ChimeraQueryUnsuccessfulDeletionError(this.#config.name, this.#params.id);
1015
+ const error = new require_defaults.ChimeraQueryUnsuccessfulDeletionError(this.#config.name, this.#params.id);
1134
1016
  this.#state = ChimeraQueryFetchingState.ReErrored;
1135
1017
  this.#lastError = error;
1136
1018
  throw error;
1137
1019
  }
1138
1020
  return { result };
1139
- }, (error) => this.#setError(error, new ChimeraQueryDeletingError(this.#config.name, error)))));
1021
+ }, (error) => this.#setError(error, new require_defaults.ChimeraQueryDeletingError(this.#config.name, error)))));
1140
1022
  }
1141
1023
  constructor(config, params, existingItem, toCreateItem) {
1142
1024
  super();
@@ -1152,7 +1034,7 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1152
1034
  this.#setItem(item);
1153
1035
  if (config.devMode && this.#idGetter(item) !== params.id) {
1154
1036
  this.#state = ChimeraQueryFetchingState.Errored;
1155
- throw new ChimeraInternalError(`Invalid item query [id] (changed from "${params.id}" to "${this.#idGetter(item)}")`);
1037
+ throw new require_defaults.ChimeraInternalError(`Invalid item query [id] (changed from "${params.id}" to "${this.#idGetter(item)}")`);
1156
1038
  }
1157
1039
  this.#state = ChimeraQueryFetchingState.Prefetched;
1158
1040
  } else if (toCreateItem) {
@@ -1241,8 +1123,8 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1241
1123
  */
1242
1124
  refetch(force = false) {
1243
1125
  if (!force && this.#promise && [ChimeraQueryFetchingState.Fetching, ChimeraQueryFetchingState.Refetching].includes(this.#state)) return this.#promise;
1244
- if (this.#state === ChimeraQueryFetchingState.Creating) throw new ChimeraQueryNotCreatedError(this.#config.name);
1245
- if (!force && [ChimeraQueryFetchingState.Updating, ChimeraQueryFetchingState.Deleting].includes(this.#state)) throw new ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
1126
+ if (this.#state === ChimeraQueryFetchingState.Creating) throw new require_defaults.ChimeraQueryNotCreatedError(this.#config.name);
1127
+ if (!force && [ChimeraQueryFetchingState.Updating, ChimeraQueryFetchingState.Deleting].includes(this.#state)) throw new require_defaults.ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
1246
1128
  this.#state = ChimeraQueryFetchingState.Refetching;
1247
1129
  const { controller } = this.#prepareRequestParams();
1248
1130
  return this.#setPromise(this.#watchPromise(makeCancellablePromise(this.#config.itemFetcher(this.#params, { signal: controller.signal }), controller), controller));
@@ -1254,12 +1136,12 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1254
1136
  * @throws {ChimeraQueryAlreadyRunningError} If deleting or updating already in progress
1255
1137
  */
1256
1138
  update(newItem, force = false) {
1257
- if (this.#state === ChimeraQueryFetchingState.Creating) throw new ChimeraQueryNotCreatedError(this.#config.name);
1139
+ if (this.#state === ChimeraQueryFetchingState.Creating) throw new require_defaults.ChimeraQueryNotCreatedError(this.#config.name);
1258
1140
  if (!force && [
1259
1141
  ChimeraQueryFetchingState.Fetching,
1260
1142
  ChimeraQueryFetchingState.Refetching,
1261
1143
  ChimeraQueryFetchingState.Deleting
1262
- ].includes(this.#state)) throw new ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
1144
+ ].includes(this.#state)) throw new require_defaults.ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
1263
1145
  this.#mutableItem();
1264
1146
  return this.#updateItem(newItem);
1265
1147
  }
@@ -1272,12 +1154,12 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1272
1154
  * @throws {ChimeraQueryAlreadyRunningError} If deleting or updating already in progress
1273
1155
  */
1274
1156
  mutate(mutator, force = false) {
1275
- if (this.#state === ChimeraQueryFetchingState.Creating) throw new ChimeraQueryNotCreatedError(this.#config.name);
1157
+ if (this.#state === ChimeraQueryFetchingState.Creating) throw new require_defaults.ChimeraQueryNotCreatedError(this.#config.name);
1276
1158
  if (!force && [
1277
1159
  ChimeraQueryFetchingState.Fetching,
1278
1160
  ChimeraQueryFetchingState.Refetching,
1279
1161
  ChimeraQueryFetchingState.Deleting
1280
- ].includes(this.#state)) throw new ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
1162
+ ].includes(this.#state)) throw new require_defaults.ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
1281
1163
  const item = deepObjectClone(this.#mutableItem());
1282
1164
  return this.#updateItem(mutator(item) ?? item);
1283
1165
  }
@@ -1287,12 +1169,12 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1287
1169
  * @throws {ChimeraQueryAlreadyRunningError} If deleting or updating already in progress
1288
1170
  */
1289
1171
  commit(force = false) {
1290
- if (this.#state === ChimeraQueryFetchingState.Creating) throw new ChimeraQueryNotCreatedError(this.#config.name);
1172
+ if (this.#state === ChimeraQueryFetchingState.Creating) throw new require_defaults.ChimeraQueryNotCreatedError(this.#config.name);
1291
1173
  if (!force && [
1292
1174
  ChimeraQueryFetchingState.Fetching,
1293
1175
  ChimeraQueryFetchingState.Refetching,
1294
1176
  ChimeraQueryFetchingState.Deleting
1295
- ].includes(this.#state)) throw new ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
1177
+ ].includes(this.#state)) throw new require_defaults.ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
1296
1178
  this.#mutableItem();
1297
1179
  return this.#updateItem(this.#mutable);
1298
1180
  }
@@ -1304,12 +1186,12 @@ var ChimeraItemQuery = class extends ChimeraEventEmitter {
1304
1186
  * @throws {ChimeraQueryAlreadyRunningError} If deleting or updating already in progress
1305
1187
  */
1306
1188
  delete(force = false) {
1307
- if (this.#state === ChimeraQueryFetchingState.Creating) throw new ChimeraQueryNotCreatedError(this.#config.name);
1189
+ if (this.#state === ChimeraQueryFetchingState.Creating) throw new require_defaults.ChimeraQueryNotCreatedError(this.#config.name);
1308
1190
  if (!force && [
1309
1191
  ChimeraQueryFetchingState.Fetching,
1310
1192
  ChimeraQueryFetchingState.Refetching,
1311
1193
  ChimeraQueryFetchingState.Updating
1312
- ].includes(this.#state)) throw new ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
1194
+ ].includes(this.#state)) throw new require_defaults.ChimeraQueryAlreadyRunningError(this.#config.name, this.#state);
1313
1195
  return this.#requestDelete();
1314
1196
  }
1315
1197
  toJSON() {
@@ -1330,7 +1212,7 @@ var ChimeraWeakValueMap = class extends ChimeraEventEmitter {
1330
1212
  queueMicrotask(() => super.emit(event, arg));
1331
1213
  }
1332
1214
  emit() {
1333
- throw new ChimeraInternalError("External events dispatching is not supported.");
1215
+ throw new require_defaults.ChimeraInternalError("External events dispatching is not supported.");
1334
1216
  }
1335
1217
  #scheduleCleanup() {
1336
1218
  if (this.#cleanupScheduled) return;
@@ -1496,95 +1378,6 @@ var ChimeraWeakValueMap = class extends ChimeraEventEmitter {
1496
1378
  }
1497
1379
  };
1498
1380
 
1499
- //#endregion
1500
- //#region src/debug/defaults.ts
1501
- const chimeraDefaultDebugConfig = {
1502
- devMode: false,
1503
- logs: "info",
1504
- name: "chimera"
1505
- };
1506
-
1507
- //#endregion
1508
- //#region src/filter/defaults.ts
1509
- const getKeyFromOperation = (operator) => JSON.stringify(operator);
1510
- const chimeraDefaultGetKeyFromFilter = (filter) => JSON.stringify(filter);
1511
- const chimeraDefaultFilterOperators = {
1512
- contains: (a, b) => {
1513
- if (typeof a === "string") return a.includes(b);
1514
- if (Array.isArray(a)) return Array.isArray(b) ? b.every((v) => a.includes(v)) : a.includes(b);
1515
- return false;
1516
- },
1517
- endsWith: (a, b) => a.endsWith(b),
1518
- startsWith: (a, b) => a.startsWith(b),
1519
- eq: (a, b) => a === b,
1520
- gt: (a, b) => a > b,
1521
- gte: (a, b) => a >= b,
1522
- in: (a, b) => (Array.isArray(a) ? a : [a]).some((v) => b.includes(v)),
1523
- lt: (a, b) => a < b,
1524
- lte: (a, b) => a <= b,
1525
- neq: (a, b) => a !== b,
1526
- notIn: (a, b) => (Array.isArray(a) ? a : [a]).every((v) => !b.includes(v))
1527
- };
1528
- const chimeraDefaultFilterConfig = {
1529
- getFilterKey: chimeraDefaultGetKeyFromFilter,
1530
- getOperatorKey: getKeyFromOperation,
1531
- operators: chimeraDefaultFilterOperators
1532
- };
1533
-
1534
- //#endregion
1535
- //#region src/order/defaults.ts
1536
- const chimeraDefaultComparator = (a, b) => {
1537
- let result = 0;
1538
- if (typeof a === "string" && typeof b === "string") result = a.localeCompare(b);
1539
- else if (typeof a === "number" && typeof b === "number" || typeof a === "boolean" && typeof b === "boolean") result = a - b;
1540
- else if (a instanceof Date && b instanceof Date) result = a.getTime() - b.getTime();
1541
- else if (a == null || b == null) result = a == b ? 0 : a == null ? -1 : 1;
1542
- else throw new ChimeraOrderTypeComparisonError(a, b);
1543
- return result;
1544
- };
1545
- const chimeraDefaultKeyFromOrder = (order) => JSON.stringify(order);
1546
- const chimeraDefaultOrderConfig = {
1547
- getKey: chimeraDefaultKeyFromOrder,
1548
- primitiveComparator: chimeraDefaultComparator
1549
- };
1550
-
1551
- //#endregion
1552
- //#region src/query/defaults.ts
1553
- const chimeraDefaultQueryConfig = {
1554
- defaults: {
1555
- batchedCreator: (entity) => {
1556
- throw new ChimeraQueryNotSpecifiedError(entity, "batchedCreator");
1557
- },
1558
- batchedDeleter: (entity) => {
1559
- throw new ChimeraQueryNotSpecifiedError(entity, "batchedDeleter");
1560
- },
1561
- batchedUpdater: (entity) => {
1562
- throw new ChimeraQueryNotSpecifiedError(entity, "batchedUpdater");
1563
- },
1564
- collectionFetcher: (entity) => {
1565
- throw new ChimeraQueryNotSpecifiedError(entity, "collectionFetcher");
1566
- },
1567
- idGetter: (entity) => {
1568
- throw new ChimeraQueryNotSpecifiedError(entity, "idGetter");
1569
- },
1570
- itemCreator: (entity) => {
1571
- throw new ChimeraQueryNotSpecifiedError(entity, "itemCreator");
1572
- },
1573
- itemDeleter: (entity) => {
1574
- throw new ChimeraQueryNotSpecifiedError(entity, "itemDeleter");
1575
- },
1576
- itemFetcher: (entity) => {
1577
- throw new ChimeraQueryNotSpecifiedError(entity, "itemFetcher");
1578
- },
1579
- itemUpdater: (entity) => {
1580
- throw new ChimeraQueryNotSpecifiedError(entity, "itemUpdater");
1581
- },
1582
- trustQuery: true,
1583
- updateDebounceTimeout: 0
1584
- },
1585
- entities: {}
1586
- };
1587
-
1588
1381
  //#endregion
1589
1382
  //#region src/store/ChimeraEntityRepository.ts
1590
1383
  var ChimeraEntityRepository = class extends ChimeraEventEmitter {
@@ -1599,7 +1392,7 @@ var ChimeraEntityRepository = class extends ChimeraEventEmitter {
1599
1392
  queueMicrotask(() => super.emit(event, arg));
1600
1393
  }
1601
1394
  emit() {
1602
- throw new ChimeraInternalError("External events dispatching is not supported.");
1395
+ throw new require_defaults.ChimeraInternalError("External events dispatching is not supported.");
1603
1396
  }
1604
1397
  #registerUpdate(item, skipItem) {
1605
1398
  const id = this.#idGetter(item);
@@ -1767,7 +1560,7 @@ var ChimeraStore = class extends ChimeraEventEmitter {
1767
1560
  queueMicrotask(() => super.emit(event, arg));
1768
1561
  }
1769
1562
  emit() {
1770
- throw new ChimeraInternalError("External events dispatching is not supported.");
1563
+ throw new require_defaults.ChimeraInternalError("External events dispatching is not supported.");
1771
1564
  }
1772
1565
  #addRepository(entityName) {
1773
1566
  const repo = this.#reposMap[entityName] = new ChimeraEntityRepository(this.#queryConfig[entityName], this.#filterConfig, this.#orderConfig);
@@ -1782,11 +1575,11 @@ var ChimeraStore = class extends ChimeraEventEmitter {
1782
1575
  super();
1783
1576
  this.#initialConfig = deepObjectFreeze(deepObjectClone(config));
1784
1577
  const { query: queryConfig, order: orderConfig, filter: filterConfig, debug: debugConfig } = config;
1785
- this.#filterConfig = deepObjectAssign(deepObjectClone(chimeraDefaultFilterConfig), filterConfig ?? {});
1786
- this.#orderConfig = deepObjectAssign(deepObjectClone(chimeraDefaultOrderConfig), orderConfig ?? {});
1787
- this.#debugConfig = deepObjectAssign(deepObjectClone(chimeraDefaultDebugConfig), debugConfig ?? {});
1788
- const query = deepObjectAssign(deepObjectClone(chimeraDefaultQueryConfig), queryConfig?.defaults ?? {});
1789
- this.#queryConfig = Object.fromEntries(Object.entries(queryConfig?.entities ?? chimeraDefaultQueryConfig.entities).map(([key, value]) => [key, {
1578
+ this.#filterConfig = deepObjectAssign(deepObjectClone(require_defaults.chimeraDefaultFilterConfig), filterConfig ?? {});
1579
+ this.#orderConfig = deepObjectAssign(deepObjectClone(require_defaults.chimeraDefaultOrderConfig), orderConfig ?? {});
1580
+ this.#debugConfig = deepObjectAssign(deepObjectClone(require_defaults.chimeraDefaultDebugConfig), debugConfig ?? {});
1581
+ const query = deepObjectAssign(deepObjectClone(require_defaults.chimeraDefaultQueryConfig), queryConfig?.defaults ?? {});
1582
+ this.#queryConfig = Object.fromEntries(Object.entries(queryConfig?.entities ?? require_defaults.chimeraDefaultQueryConfig.entities).map(([key, value]) => [key, {
1790
1583
  batchedCreator: value.batchedCreator ? value.batchedCreator : (...args) => query.batchedCreator(key, ...args),
1791
1584
  batchedDeleter: value.batchedDeleter ? value.batchedDeleter : (...args) => query.batchedDeleter(key, ...args),
1792
1585
  batchedUpdater: value.batchedUpdater ? value.batchedUpdater : (...args) => query.batchedUpdater(key, ...args),
@@ -1885,12 +1678,6 @@ Object.defineProperty(exports, 'ChimeraCollectionQuery', {
1885
1678
  return ChimeraCollectionQuery;
1886
1679
  }
1887
1680
  });
1888
- Object.defineProperty(exports, 'ChimeraError', {
1889
- enumerable: true,
1890
- get: function () {
1891
- return ChimeraError;
1892
- }
1893
- });
1894
1681
  Object.defineProperty(exports, 'ChimeraFilterError', {
1895
1682
  enumerable: true,
1896
1683
  get: function () {
@@ -1909,84 +1696,24 @@ Object.defineProperty(exports, 'ChimeraFilterOperatorNotFoundError', {
1909
1696
  return ChimeraFilterOperatorNotFoundError;
1910
1697
  }
1911
1698
  });
1912
- Object.defineProperty(exports, 'ChimeraInternalError', {
1913
- enumerable: true,
1914
- get: function () {
1915
- return ChimeraInternalError;
1916
- }
1917
- });
1918
1699
  Object.defineProperty(exports, 'ChimeraItemQuery', {
1919
1700
  enumerable: true,
1920
1701
  get: function () {
1921
1702
  return ChimeraItemQuery;
1922
1703
  }
1923
1704
  });
1924
- Object.defineProperty(exports, 'ChimeraOrderError', {
1925
- enumerable: true,
1926
- get: function () {
1927
- return ChimeraOrderError;
1928
- }
1929
- });
1930
1705
  Object.defineProperty(exports, 'ChimeraOrderNulls', {
1931
1706
  enumerable: true,
1932
1707
  get: function () {
1933
1708
  return ChimeraOrderNulls;
1934
1709
  }
1935
1710
  });
1936
- Object.defineProperty(exports, 'ChimeraOrderTypeComparisonError', {
1937
- enumerable: true,
1938
- get: function () {
1939
- return ChimeraOrderTypeComparisonError;
1940
- }
1941
- });
1942
- Object.defineProperty(exports, 'ChimeraOrderTypeError', {
1943
- enumerable: true,
1944
- get: function () {
1945
- return ChimeraOrderTypeError;
1946
- }
1947
- });
1948
- Object.defineProperty(exports, 'ChimeraQueryError', {
1949
- enumerable: true,
1950
- get: function () {
1951
- return ChimeraQueryError;
1952
- }
1953
- });
1954
1711
  Object.defineProperty(exports, 'ChimeraQueryFetchingState', {
1955
1712
  enumerable: true,
1956
1713
  get: function () {
1957
1714
  return ChimeraQueryFetchingState;
1958
1715
  }
1959
1716
  });
1960
- Object.defineProperty(exports, 'ChimeraQueryIdMismatchError', {
1961
- enumerable: true,
1962
- get: function () {
1963
- return ChimeraQueryIdMismatchError;
1964
- }
1965
- });
1966
- Object.defineProperty(exports, 'ChimeraQueryNotSpecifiedError', {
1967
- enumerable: true,
1968
- get: function () {
1969
- return ChimeraQueryNotSpecifiedError;
1970
- }
1971
- });
1972
- Object.defineProperty(exports, 'ChimeraQueryTrustError', {
1973
- enumerable: true,
1974
- get: function () {
1975
- return ChimeraQueryTrustError;
1976
- }
1977
- });
1978
- Object.defineProperty(exports, 'ChimeraQueryTrustFetchedCollectionError', {
1979
- enumerable: true,
1980
- get: function () {
1981
- return ChimeraQueryTrustFetchedCollectionError;
1982
- }
1983
- });
1984
- Object.defineProperty(exports, 'ChimeraQueryTrustIdMismatchError', {
1985
- enumerable: true,
1986
- get: function () {
1987
- return ChimeraQueryTrustIdMismatchError;
1988
- }
1989
- });
1990
1717
  Object.defineProperty(exports, 'ChimeraStore', {
1991
1718
  enumerable: true,
1992
1719
  get: function () {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "hewston",
3
3
  "name": "@hf-chimera/store",
4
4
  "description": "Cross-end reactivity API",
5
- "version": "0.0.8",
5
+ "version": "0.0.10",
6
6
  "license": "MIT",
7
7
  "keywords": [
8
8
  "state-management",
@@ -27,6 +27,11 @@
27
27
  "require": "./dist/index.cjs",
28
28
  "import": "./dist/index.js"
29
29
  },
30
+ "./defaults": {
31
+ "types": "./dist/defaults.d.ts",
32
+ "require": "./dist/defaults.cjs",
33
+ "import": "./dist/defaults.js"
34
+ },
30
35
  "./qb": {
31
36
  "types": "./dist/qb.d.ts",
32
37
  "require": "./dist/qb.cjs",