@nexigen/entity-normalizer 0.1.1 → 0.1.2

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 (187) hide show
  1. package/dist/async/async-duck.d.ts +38 -0
  2. package/dist/async/async-duck.js +189 -0
  3. package/dist/async/async-duck.js.map +1 -0
  4. package/dist/async/create-duck.d.ts +2 -0
  5. package/dist/async/create-duck.js +6 -0
  6. package/dist/async/create-duck.js.map +1 -0
  7. package/dist/async/index.d.ts +1 -0
  8. package/dist/async/index.js +2 -0
  9. package/dist/async/index.js.map +1 -0
  10. package/dist/async/marker.d.ts +1 -0
  11. package/dist/async/marker.js +2 -0
  12. package/dist/async/marker.js.map +1 -0
  13. package/dist/async/public.d.ts +34 -0
  14. package/dist/async/public.js +2 -0
  15. package/dist/async/public.js.map +1 -0
  16. package/dist/async/retry.d.ts +3 -0
  17. package/dist/async/retry.js +36 -0
  18. package/dist/async/retry.js.map +1 -0
  19. package/dist/async/types.d.ts +24 -0
  20. package/dist/async/types.js +2 -0
  21. package/dist/async/types.js.map +1 -0
  22. package/dist/constants/time.d.ts +6 -0
  23. package/dist/constants/time.js +7 -0
  24. package/dist/constants/time.js.map +1 -0
  25. package/dist/constants/values.d.ts +1 -0
  26. package/dist/constants/values.js +2 -0
  27. package/dist/constants/values.js.map +1 -0
  28. package/dist/create/cleaner.d.ts +7 -0
  29. package/dist/create/cleaner.js +69 -0
  30. package/dist/create/cleaner.js.map +1 -0
  31. package/dist/create/create-store.d.ts +2 -0
  32. package/dist/create/create-store.js +5 -0
  33. package/dist/create/create-store.js.map +1 -0
  34. package/dist/create/extractor.d.ts +8 -0
  35. package/dist/create/extractor.js +64 -0
  36. package/dist/create/extractor.js.map +1 -0
  37. package/dist/create/index.d.ts +1 -0
  38. package/dist/create/index.js +2 -0
  39. package/dist/create/index.js.map +1 -0
  40. package/dist/create/manager.d.ts +9 -0
  41. package/dist/create/manager.js +39 -0
  42. package/dist/create/manager.js.map +1 -0
  43. package/dist/create/proxy.d.ts +11 -0
  44. package/dist/create/proxy.js +57 -0
  45. package/dist/create/proxy.js.map +1 -0
  46. package/dist/create/scanner.d.ts +19 -0
  47. package/dist/create/scanner.js +109 -0
  48. package/dist/create/scanner.js.map +1 -0
  49. package/dist/create/utils.d.ts +3 -0
  50. package/dist/create/utils.js +33 -0
  51. package/dist/create/utils.js.map +1 -0
  52. package/dist/create-store-hooks.d.ts +19 -0
  53. package/dist/create-store-hooks.js +23 -0
  54. package/dist/create-store-hooks.js.map +1 -0
  55. package/dist/di/index.d.ts +2 -0
  56. package/dist/di/index.js +3 -0
  57. package/dist/di/index.js.map +1 -0
  58. package/dist/di/register-root-store.d.ts +11 -0
  59. package/dist/di/register-root-store.js +23 -0
  60. package/dist/di/register-root-store.js.map +1 -0
  61. package/dist/entities/cleaner/bucket.d.ts +8 -0
  62. package/dist/entities/cleaner/bucket.js +31 -0
  63. package/dist/entities/cleaner/bucket.js.map +1 -0
  64. package/dist/entities/cleaner/index.d.ts +1 -0
  65. package/dist/entities/cleaner/index.js +2 -0
  66. package/dist/entities/cleaner/index.js.map +1 -0
  67. package/dist/entities/cleaner/store.d.ts +12 -0
  68. package/dist/entities/cleaner/store.js +73 -0
  69. package/dist/entities/cleaner/store.js.map +1 -0
  70. package/dist/entities/cleaner/walker.d.ts +6 -0
  71. package/dist/entities/cleaner/walker.js +34 -0
  72. package/dist/entities/cleaner/walker.js.map +1 -0
  73. package/dist/entities/collection/create-entity-collection.d.ts +9 -0
  74. package/dist/entities/collection/create-entity-collection.js +17 -0
  75. package/dist/entities/collection/create-entity-collection.js.map +1 -0
  76. package/dist/entities/collection/entity-collection.d.ts +49 -0
  77. package/dist/entities/collection/entity-collection.js +186 -0
  78. package/dist/entities/collection/entity-collection.js.map +1 -0
  79. package/dist/entities/collection/index.d.ts +3 -0
  80. package/dist/entities/collection/index.js +2 -0
  81. package/dist/entities/collection/index.js.map +1 -0
  82. package/dist/entities/collection/marker.d.ts +2 -0
  83. package/dist/entities/collection/marker.js +3 -0
  84. package/dist/entities/collection/marker.js.map +1 -0
  85. package/dist/entities/collection/multi-entity-collection.d.ts +24 -0
  86. package/dist/entities/collection/multi-entity-collection.js +95 -0
  87. package/dist/entities/collection/multi-entity-collection.js.map +1 -0
  88. package/dist/entities/collection/public.d.ts +50 -0
  89. package/dist/entities/collection/public.js +2 -0
  90. package/dist/entities/collection/public.js.map +1 -0
  91. package/dist/entities/collection/types.d.ts +39 -0
  92. package/dist/entities/collection/types.js +2 -0
  93. package/dist/entities/collection/types.js.map +1 -0
  94. package/dist/entities/constants.d.ts +4 -0
  95. package/dist/entities/constants.js +5 -0
  96. package/dist/entities/constants.js.map +1 -0
  97. package/dist/entities/create-entity-schema.d.ts +2 -0
  98. package/dist/entities/create-entity-schema.js +5 -0
  99. package/dist/entities/create-entity-schema.js.map +1 -0
  100. package/dist/entities/index.d.ts +4 -0
  101. package/dist/entities/index.js +5 -0
  102. package/dist/entities/index.js.map +1 -0
  103. package/dist/entities/normalize.d.ts +11 -0
  104. package/dist/entities/normalize.js +79 -0
  105. package/dist/entities/normalize.js.map +1 -0
  106. package/dist/entities/processor.d.ts +14 -0
  107. package/dist/entities/processor.js +156 -0
  108. package/dist/entities/processor.js.map +1 -0
  109. package/dist/entities/public.d.ts +102 -0
  110. package/dist/entities/public.js +7 -0
  111. package/dist/entities/public.js.map +1 -0
  112. package/dist/entities/record/create-entity-record.d.ts +15 -0
  113. package/dist/entities/record/create-entity-record.js +13 -0
  114. package/dist/entities/record/create-entity-record.js.map +1 -0
  115. package/dist/entities/record/entity-record.d.ts +37 -0
  116. package/dist/entities/record/entity-record.js +83 -0
  117. package/dist/entities/record/entity-record.js.map +1 -0
  118. package/dist/entities/record/index.d.ts +2 -0
  119. package/dist/entities/record/index.js +2 -0
  120. package/dist/entities/record/index.js.map +1 -0
  121. package/dist/entities/record/marker.d.ts +1 -0
  122. package/dist/entities/record/marker.js +2 -0
  123. package/dist/entities/record/marker.js.map +1 -0
  124. package/dist/entities/record/public.d.ts +25 -0
  125. package/dist/entities/record/public.js +2 -0
  126. package/dist/entities/record/public.js.map +1 -0
  127. package/dist/entities/record/types.d.ts +3 -0
  128. package/dist/entities/record/types.js +2 -0
  129. package/dist/entities/record/types.js.map +1 -0
  130. package/dist/entities/schema.d.ts +12 -0
  131. package/dist/entities/schema.js +31 -0
  132. package/dist/entities/schema.js.map +1 -0
  133. package/dist/entities/store.d.ts +22 -0
  134. package/dist/entities/store.js +154 -0
  135. package/dist/entities/store.js.map +1 -0
  136. package/dist/entities/types.d.ts +82 -0
  137. package/dist/entities/types.js +2 -0
  138. package/dist/entities/types.js.map +1 -0
  139. package/dist/index.d.ts +12 -0
  140. package/dist/index.js +13 -0
  141. package/dist/index.js.map +1 -0
  142. package/dist/root/RootStore.d.ts +24 -0
  143. package/dist/root/RootStore.js +134 -0
  144. package/dist/root/RootStore.js.map +1 -0
  145. package/dist/root/coreApi/create-core-api.d.ts +7 -0
  146. package/dist/root/coreApi/create-core-api.js +12 -0
  147. package/dist/root/coreApi/create-core-api.js.map +1 -0
  148. package/dist/root/coreApi/entities.d.ts +10 -0
  149. package/dist/root/coreApi/entities.js +57 -0
  150. package/dist/root/coreApi/entities.js.map +1 -0
  151. package/dist/root/coreApi/lifecycle.d.ts +5 -0
  152. package/dist/root/coreApi/lifecycle.js +9 -0
  153. package/dist/root/coreApi/lifecycle.js.map +1 -0
  154. package/dist/root/coreApi/public.d.ts +71 -0
  155. package/dist/root/coreApi/public.js +6 -0
  156. package/dist/root/coreApi/public.js.map +1 -0
  157. package/dist/root/coreApi/stores.d.ts +2 -0
  158. package/dist/root/coreApi/stores.js +31 -0
  159. package/dist/root/coreApi/stores.js.map +1 -0
  160. package/dist/root/coreApi/types.d.ts +68 -0
  161. package/dist/root/coreApi/types.js +2 -0
  162. package/dist/root/coreApi/types.js.map +1 -0
  163. package/dist/root/create-root-store.d.ts +3 -0
  164. package/dist/root/create-root-store.js +11 -0
  165. package/dist/root/create-root-store.js.map +1 -0
  166. package/dist/root/fallback.d.ts +2 -0
  167. package/dist/root/fallback.js +6 -0
  168. package/dist/root/fallback.js.map +1 -0
  169. package/dist/root/index.d.ts +3 -0
  170. package/dist/root/index.js +3 -0
  171. package/dist/root/index.js.map +1 -0
  172. package/dist/root/marker.d.ts +1 -0
  173. package/dist/root/marker.js +2 -0
  174. package/dist/root/marker.js.map +1 -0
  175. package/dist/root/public.d.ts +28 -0
  176. package/dist/root/public.js +2 -0
  177. package/dist/root/public.js.map +1 -0
  178. package/dist/root/types.d.ts +66 -0
  179. package/dist/root/types.js +2 -0
  180. package/dist/root/types.js.map +1 -0
  181. package/dist/utils/index.d.ts +1 -0
  182. package/dist/utils/index.js +2 -0
  183. package/dist/utils/index.js.map +1 -0
  184. package/dist/utils/throttle-by-time.d.ts +1 -0
  185. package/dist/utils/throttle-by-time.js +11 -0
  186. package/dist/utils/throttle-by-time.js.map +1 -0
  187. package/package.json +3 -2
@@ -0,0 +1,31 @@
1
+ export function createStoresAPI(stores = {}) {
2
+ return {
3
+ getSnapshot() {
4
+ const out = {};
5
+ Object.keys(stores).forEach(key => {
6
+ out[key] = stores[key]?.__getSnapshot?.();
7
+ });
8
+ return out;
9
+ },
10
+ getSnapshotByKey(key) {
11
+ return stores[key]?.__getSnapshot?.();
12
+ },
13
+ applySnapshot(snapshot) {
14
+ Object.keys(snapshot).forEach(key => {
15
+ stores[key]?.__applySnapshot?.(snapshot[key]);
16
+ });
17
+ },
18
+ applySnapshotByKey(key, snap) {
19
+ stores[key]?.__applySnapshot?.(snap);
20
+ },
21
+ resetAll() {
22
+ Object.values(stores).forEach(store => {
23
+ store?.resetStore?.();
24
+ });
25
+ },
26
+ resetByKey(key) {
27
+ stores[key]?.resetStore?.();
28
+ },
29
+ };
30
+ }
31
+ //# sourceMappingURL=stores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.js","sourceRoot":"","sources":["../../../src/root/coreApi/stores.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,eAAe,CAC7B,SAAwB,EAAE;IAE1B,OAAO;QACL,WAAW;YACT,MAAM,GAAG,GAAG,EAA6B,CAAC;YAEzC,MAAM,CAAC,IAAI,CAAC,MAAM,CAA0B,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBAC1D,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,aAAa,EAAE,EAAE,CAAC;YAC5C,CAAC,CAAC,CAAC;YAEH,OAAO,GAAG,CAAC;QACb,CAAC;QAED,gBAAgB,CACd,GAAM;YAEN,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,aAAa,EAAE,EAAE,CAAC;QACxC,CAAC;QAED,aAAa,CAAC,QAAiC;YAC5C,MAAM,CAAC,IAAI,CAAC,QAAQ,CAA0B,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBAC5D,MAAM,CAAC,GAAG,CAAC,EAAE,eAAe,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;YAChD,CAAC,CAAC,CAAC;QACL,CAAC;QAED,kBAAkB,CAChB,GAAM,EACN,IAAgC;YAEhC,MAAM,CAAC,GAAG,CAAC,EAAE,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;QAED,QAAQ;YACN,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACnC,KAAa,EAAE,UAAU,EAAE,EAAE,CAAC;YACjC,CAAC,CAAC,CAAC;QACL,CAAC;QAED,UAAU,CAA0B,GAAM;YACxC,MAAM,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,EAAE,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { EntityCollection, EntityProcessOptions, EntityRecord, TEntitiesStore } from '../../entities';
2
+ import type { EntityCleanerStore } from '../../entities/cleaner';
3
+ import type { MultiEntityCollection } from '../../entities/collection/public';
4
+ import type { EntityCollectionOptions } from '../../entities/collection/types';
5
+ import type { PersistenceNotifier, StoresSnapshot, TSchemaMap } from '../types';
6
+ export interface CoreAPIExtensions {
7
+ }
8
+ export type CoreInternalAPI = {
9
+ setPersistence(notifier: PersistenceNotifier): void;
10
+ };
11
+ export type CoreStoresAPI<TStores> = {
12
+ getSnapshot(): StoresSnapshot<TStores>;
13
+ getSnapshotByKey<K extends keyof TStores>(key: K): StoresSnapshot<TStores>[K];
14
+ applySnapshot(snapshot: StoresSnapshot<TStores>): void;
15
+ applySnapshotByKey<K extends keyof TStores>(key: K, snapshot: StoresSnapshot<TStores>[K]): void;
16
+ resetAll(): void;
17
+ resetByKey<K extends keyof TStores>(key: K): void;
18
+ };
19
+ export type CoreLifecycleAPI = {
20
+ isInitialized: boolean;
21
+ setInitialized(v: boolean): void;
22
+ };
23
+ export type CoreEntitiesAPI = {
24
+ createRecord<T extends {
25
+ id: string | number;
26
+ }, M>(options: {
27
+ entityKey: string;
28
+ recordId: string;
29
+ }): EntityRecord<T, M>;
30
+ createCollection<T extends {
31
+ id: string | number;
32
+ }, M>(options: EntityCollectionOptions<T>): EntityCollection<T, M>;
33
+ createMultiCollection<T extends {
34
+ id: string | number;
35
+ }, M>(options: EntityCollectionOptions<T>): MultiEntityCollection<T, M>;
36
+ process<TKey extends string, TDto>(options: EntityProcessOptions<TDto> & {
37
+ entityKey: TKey;
38
+ }): Array<string | number>;
39
+ hydrate(snapshot: Record<string, Record<string, any>> | null | undefined): void;
40
+ get<T extends string>(key: T, id: string | number): ReturnType<TEntitiesStore['getEntity']>;
41
+ getAll<T extends string>(key: T): ReturnType<TEntitiesStore['getAll']>;
42
+ getCount<T extends string>(key: T): number;
43
+ getSnapshot(): Record<string, any>;
44
+ getSchema<TKey extends string>(key: TKey): TSchemaMap[TKey];
45
+ };
46
+ export type CoreGCAPI = {
47
+ bootstrap(): void;
48
+ processOrphan(): void;
49
+ };
50
+ export type CoreAPI<TStores = {}> = CoreAPIExtensions & {
51
+ lifecycle: CoreLifecycleAPI;
52
+ entities: CoreEntitiesAPI;
53
+ stores: CoreStoresAPI<TStores>;
54
+ __internal: CoreInternalAPI;
55
+ };
56
+ export type CoreEntitiesDeps = {
57
+ entities: TEntitiesStore;
58
+ entitiesCleaner: EntityCleanerStore;
59
+ schemaMap: TSchemaMap;
60
+ getPersistence: () => PersistenceNotifier | undefined;
61
+ };
62
+ export type CoreStoresDeps<TStores extends Record<string, any>> = {
63
+ [K in keyof TStores]: InstanceType<TStores[K]>;
64
+ };
65
+ export type CoreLifecycleDeps = {
66
+ getIsInitialized: () => boolean;
67
+ setInitialized: (v: boolean) => void;
68
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/root/coreApi/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { RootStore } from './RootStore';
2
+ import type { CreateRootStoreConfig } from './public';
3
+ export declare function createRootStore<TApi, TSchemas extends Record<string, any>, TStores extends Record<string, any>, TServices extends Record<string, any>>(config: CreateRootStoreConfig<TApi, TSchemas, TStores, TServices>): RootStore<TApi, TSchemas, TStores, TServices>;
@@ -0,0 +1,11 @@
1
+ import { RootStore } from './RootStore';
2
+ export function createRootStore(config) {
3
+ return new RootStore({
4
+ api: config.api,
5
+ schemaMap: config.schemaMap,
6
+ stores: config.stores,
7
+ services: config.services,
8
+ plugins: config.plugins ?? [],
9
+ });
10
+ }
11
+ //# sourceMappingURL=create-root-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-root-store.js","sourceRoot":"","sources":["../../src/root/create-root-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,MAAM,UAAU,eAAe,CAK7B,MAAiE;IACjE,OAAO,IAAI,SAAS,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE;KAC9B,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { PersistenceNotifier } from './types';
2
+ export declare const noopPersistence: PersistenceNotifier;
@@ -0,0 +1,6 @@
1
+ export const noopPersistence = {
2
+ onEntitiesChanged() { },
3
+ onPointersChanged() { },
4
+ onStoreStateChanged() { },
5
+ };
6
+ //# sourceMappingURL=fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallback.js","sourceRoot":"","sources":["../../src/root/fallback.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAwB;IAClD,iBAAiB,KAAI,CAAC;IACtB,iBAAiB,KAAI,CAAC;IACtB,mBAAmB,KAAI,CAAC;CACzB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { createRootStore } from './create-root-store';
2
+ import type { StoreDeps } from './types';
3
+ export { createRootStore, type StoreDeps };
@@ -0,0 +1,3 @@
1
+ import { createRootStore } from './create-root-store';
2
+ export { createRootStore };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/root/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD,OAAO,EAAE,eAAe,EAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const SET_PERSISTENCE: unique symbol;
@@ -0,0 +1,2 @@
1
+ export const SET_PERSISTENCE = Symbol('SET_PERSISTENCE');
2
+ //# sourceMappingURL=marker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marker.js","sourceRoot":"","sources":["../../src/root/marker.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { PublicEntitySchema } from '../entities/public';
2
+ import type { CoreAPI } from './coreApi/types';
3
+ export type PublicSchemaMap = Record<string, PublicEntitySchema<any, any>>;
4
+ export type PublicStoreMap = Record<string, new (...args: any[]) => any>;
5
+ export type PublicServiceMap = Record<string, new (...args: any[]) => any>;
6
+ export interface CreateRootStoreConfig<TApi, TSchemas extends PublicSchemaMap, TStores extends PublicStoreMap, TServices extends PublicServiceMap> {
7
+ api: TApi;
8
+ schemaMap: TSchemas;
9
+ stores: TStores;
10
+ services: TServices;
11
+ plugins?: any[];
12
+ }
13
+ /**
14
+ * PUBLIC deps passed into Stores / Services
15
+ *
16
+ * Used like:
17
+ * constructor(deps: StoreDeps<{ stores: {...}, api: Api }>)
18
+ */
19
+ export type StoreDeps<C extends {
20
+ stores?: any;
21
+ api?: any;
22
+ services?: any;
23
+ }> = {
24
+ api: C['api'] extends undefined ? unknown : C['api'];
25
+ stores: C['stores'] extends undefined ? {} : C['stores'];
26
+ services: C['services'] extends undefined ? {} : C['services'];
27
+ core: CoreAPI<any>;
28
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.js","sourceRoot":"","sources":["../../src/root/public.ts"],"names":[],"mappings":""}
@@ -0,0 +1,66 @@
1
+ import type { AnySchema, TEntitiesStore } from '../entities';
2
+ import type { CoreAPI } from './coreApi/types';
3
+ import type { RootStore } from './RootStore';
4
+ export type DomainDeps<TStores = {}, TApi = any, TServices = {}, CoreAPI = {}> = {
5
+ api: TApi;
6
+ stores: TStores;
7
+ services: TServices;
8
+ core: CoreAPI;
9
+ };
10
+ export type RootStoreInstance<TApi = any, TSchemaMap extends Record<string, AnySchema> = any, TStores extends StoreClassMap<any, any> = any, TServices extends ServiceClassMap<any, any> = any> = RootStore<TApi, TSchemaMap, TStores, TServices>;
11
+ export type SystemDeps = {
12
+ getPersistence: () => PersistenceNotifier | undefined;
13
+ entities: TEntitiesStore;
14
+ };
15
+ export type StoreDepsCombined<TStores = {}, TApi = unknown, TServices = {}> = {
16
+ domain: DomainDeps<TStores, TApi, TServices>;
17
+ system: SystemDeps;
18
+ };
19
+ export type StoreClass<TDeps, TInstance> = new (deps: TDeps) => TInstance;
20
+ export type StoreClassMap<TDeps, TStoreClasses> = {
21
+ [K in keyof TStoreClasses]: StoreClass<TDeps, any>;
22
+ };
23
+ export type ServiceClassMap<TDeps, TServiceClasses> = {
24
+ [K in keyof TServiceClasses]: new (deps: TDeps) => any;
25
+ };
26
+ export type TSchemaMap = Record<string, AnySchema>;
27
+ export type RootStoreDeps<TApi, TSchemaMap extends Record<string, AnySchema>, TStoreClasses extends StoreClassMap<any, any>, TServiceClasses extends ServiceClassMap<any, any>> = {
28
+ api: TApi;
29
+ schemaMap: TSchemaMap;
30
+ stores: TStoreClasses;
31
+ services: TServiceClasses;
32
+ plugins?: RootStorePlugin[];
33
+ };
34
+ type DepsConfig = {
35
+ api?: any;
36
+ stores?: any;
37
+ services?: any;
38
+ };
39
+ type NormalizeDeps<C extends DepsConfig, CoreAPI> = DomainDeps<C['stores'] extends undefined ? {} : C['stores'], C['api'] extends undefined ? any : C['api'], C['services'] extends undefined ? {} : C['services'], CoreAPI>;
40
+ export type StoreDeps<C extends DepsConfig> = NormalizeDeps<C, CoreAPI<any>>;
41
+ export type StoreSnapshot = Record<string, any>;
42
+ export type StoresSnapshot<TStores> = {
43
+ [K in keyof TStores]?: StoreSnapshot;
44
+ };
45
+ export type Decorators = {
46
+ isRecord: (v: any) => boolean;
47
+ isCollection: (v: any) => boolean;
48
+ isMultiCollection: (v: any) => boolean;
49
+ };
50
+ export type RootStorePlugin<TConfig = unknown> = {
51
+ name: string;
52
+ config: TConfig;
53
+ setup(ctx: {
54
+ entities: any;
55
+ core: Record<string, any>;
56
+ config: TConfig;
57
+ domain: DomainDeps;
58
+ decorators: Decorators;
59
+ }): void;
60
+ };
61
+ export type PersistenceNotifier = {
62
+ onEntitiesChanged(): void;
63
+ onPointersChanged(): void;
64
+ onStoreStateChanged(): void;
65
+ };
66
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/root/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './throttle-by-time';
@@ -0,0 +1,2 @@
1
+ export * from './throttle-by-time';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function throttleByTime<T extends (...args: any[]) => void>(fn: T, interval: number): (...args: Parameters<T>) => void;
@@ -0,0 +1,11 @@
1
+ export function throttleByTime(fn, interval) {
2
+ let lastRun = 0;
3
+ return (...args) => {
4
+ const now = Date.now();
5
+ if (now - lastRun >= interval) {
6
+ lastRun = now;
7
+ fn(...args);
8
+ }
9
+ };
10
+ }
11
+ //# sourceMappingURL=throttle-by-time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"throttle-by-time.js","sourceRoot":"","sources":["../../src/utils/throttle-by-time.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAC5B,EAAK,EACL,QAAgB;IAEhB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,OAAO,CAAC,GAAG,IAAmB,EAAE,EAAE;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,IAAI,GAAG,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC9B,OAAO,GAAG,GAAG,CAAC;YACd,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexigen/entity-normalizer",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Reactive entity infrastructure for complex client applications, built on MobX.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,7 +15,8 @@
15
15
  "test": "jest",
16
16
  "test:watch": "jest --watch",
17
17
  "typecheck": "tsc --noEmit",
18
- "build": "tsc"
18
+ "build": "tsc",
19
+ "prepare": "husky install"
19
20
  },
20
21
  "lint-staged": {
21
22
  "*.{ts,tsx}": [