@iamjulianacosta/mobx-data 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +366 -0
  3. package/dist/CacheHandler-BTU_rYkv.js +208 -0
  4. package/dist/CacheHandler-BTU_rYkv.js.map +1 -0
  5. package/dist/CacheHandler-CXgY9IJo.cjs +2 -0
  6. package/dist/CacheHandler-CXgY9IJo.cjs.map +1 -0
  7. package/dist/EmbeddedRecordsMixin-CBvqNdgC.cjs +2 -0
  8. package/dist/EmbeddedRecordsMixin-CBvqNdgC.cjs.map +1 -0
  9. package/dist/EmbeddedRecordsMixin-VoHluHCT.js +261 -0
  10. package/dist/EmbeddedRecordsMixin-VoHluHCT.js.map +1 -0
  11. package/dist/JsonApiSerializer-CC5HXp4b.js +194 -0
  12. package/dist/JsonApiSerializer-CC5HXp4b.js.map +1 -0
  13. package/dist/JsonApiSerializer-CKB02AgP.cjs +2 -0
  14. package/dist/JsonApiSerializer-CKB02AgP.cjs.map +1 -0
  15. package/dist/MemoryAdapter-Bx1e7ndV.js +123 -0
  16. package/dist/MemoryAdapter-Bx1e7ndV.js.map +1 -0
  17. package/dist/MemoryAdapter-D1cTyydm.cjs +2 -0
  18. package/dist/MemoryAdapter-D1cTyydm.cjs.map +1 -0
  19. package/dist/ODataAdapter-C4IHK4BK.js +157 -0
  20. package/dist/ODataAdapter-C4IHK4BK.js.map +1 -0
  21. package/dist/ODataAdapter-DyyF1sdA.cjs +2 -0
  22. package/dist/ODataAdapter-DyyF1sdA.cjs.map +1 -0
  23. package/dist/RestAdapter-B4aRvs4m.js +355 -0
  24. package/dist/RestAdapter-B4aRvs4m.js.map +1 -0
  25. package/dist/RestAdapter-CJOwTsKK.cjs +2 -0
  26. package/dist/RestAdapter-CJOwTsKK.cjs.map +1 -0
  27. package/dist/SchemaService-DZwkFgZu.js +102 -0
  28. package/dist/SchemaService-DZwkFgZu.js.map +1 -0
  29. package/dist/SchemaService-Di_yjVzU.cjs +2 -0
  30. package/dist/SchemaService-Di_yjVzU.cjs.map +1 -0
  31. package/dist/Serializer-95gi5edy.cjs +2 -0
  32. package/dist/Serializer-95gi5edy.cjs.map +1 -0
  33. package/dist/Serializer-FxJbsZ50.js +139 -0
  34. package/dist/Serializer-FxJbsZ50.js.map +1 -0
  35. package/dist/Store-BdwMrbDi.cjs +2 -0
  36. package/dist/Store-BdwMrbDi.cjs.map +1 -0
  37. package/dist/Store-CZ7Z-Nme.js +912 -0
  38. package/dist/Store-CZ7Z-Nme.js.map +1 -0
  39. package/dist/adapter/Adapter.d.ts +146 -0
  40. package/dist/adapter/Adapter.d.ts.map +1 -0
  41. package/dist/adapter/MemoryAdapter.d.ts +44 -0
  42. package/dist/adapter/MemoryAdapter.d.ts.map +1 -0
  43. package/dist/adapter/RestAdapter.d.ts +57 -0
  44. package/dist/adapter/RestAdapter.d.ts.map +1 -0
  45. package/dist/adapter/index.cjs +2 -0
  46. package/dist/adapter/index.cjs.map +1 -0
  47. package/dist/adapter/index.d.ts +4 -0
  48. package/dist/adapter/index.d.ts.map +1 -0
  49. package/dist/adapter/index.js +8 -0
  50. package/dist/adapter/index.js.map +1 -0
  51. package/dist/date-Bj4O2W1F.js +107 -0
  52. package/dist/date-Bj4O2W1F.js.map +1 -0
  53. package/dist/date-CRCe-9gf.cjs +2 -0
  54. package/dist/date-CRCe-9gf.cjs.map +1 -0
  55. package/dist/decorators-HQ1KnRdh.cjs +2 -0
  56. package/dist/decorators-HQ1KnRdh.cjs.map +1 -0
  57. package/dist/decorators-Zr35qr6A.js +50 -0
  58. package/dist/decorators-Zr35qr6A.js.map +1 -0
  59. package/dist/index.cjs +2 -0
  60. package/dist/index.cjs.map +1 -0
  61. package/dist/index.d.ts +10 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +52 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/json-api/JsonApiAdapter.d.ts +38 -0
  66. package/dist/json-api/JsonApiAdapter.d.ts.map +1 -0
  67. package/dist/json-api/JsonApiSerializer.d.ts +73 -0
  68. package/dist/json-api/JsonApiSerializer.d.ts.map +1 -0
  69. package/dist/json-api/index.cjs +2 -0
  70. package/dist/json-api/index.cjs.map +1 -0
  71. package/dist/json-api/index.d.ts +3 -0
  72. package/dist/json-api/index.d.ts.map +1 -0
  73. package/dist/json-api/index.js +6 -0
  74. package/dist/json-api/index.js.map +1 -0
  75. package/dist/model/Errors.d.ts +46 -0
  76. package/dist/model/Errors.d.ts.map +1 -0
  77. package/dist/model/Model.d.ts +226 -0
  78. package/dist/model/Model.d.ts.map +1 -0
  79. package/dist/model/Snapshot.d.ts +72 -0
  80. package/dist/model/Snapshot.d.ts.map +1 -0
  81. package/dist/model/StateMachine.d.ts +45 -0
  82. package/dist/model/StateMachine.d.ts.map +1 -0
  83. package/dist/model/index.cjs +2 -0
  84. package/dist/model/index.cjs.map +1 -0
  85. package/dist/model/index.d.ts +6 -0
  86. package/dist/model/index.d.ts.map +1 -0
  87. package/dist/model/index.js +11 -0
  88. package/dist/model/index.js.map +1 -0
  89. package/dist/model/relationships.d.ts +182 -0
  90. package/dist/model/relationships.d.ts.map +1 -0
  91. package/dist/odata/ODataAdapter.d.ts +67 -0
  92. package/dist/odata/ODataAdapter.d.ts.map +1 -0
  93. package/dist/odata/index.cjs +2 -0
  94. package/dist/odata/index.cjs.map +1 -0
  95. package/dist/odata/index.d.ts +2 -0
  96. package/dist/odata/index.d.ts.map +1 -0
  97. package/dist/odata/index.js +5 -0
  98. package/dist/odata/index.js.map +1 -0
  99. package/dist/relationships-B55LBaCW.cjs +2 -0
  100. package/dist/relationships-B55LBaCW.cjs.map +1 -0
  101. package/dist/relationships-BEXANmWg.js +821 -0
  102. package/dist/relationships-BEXANmWg.js.map +1 -0
  103. package/dist/request/CacheHandler.d.ts +50 -0
  104. package/dist/request/CacheHandler.d.ts.map +1 -0
  105. package/dist/request/FetchHandler.d.ts +41 -0
  106. package/dist/request/FetchHandler.d.ts.map +1 -0
  107. package/dist/request/RequestManager.d.ts +52 -0
  108. package/dist/request/RequestManager.d.ts.map +1 -0
  109. package/dist/request/index.cjs +2 -0
  110. package/dist/request/index.cjs.map +1 -0
  111. package/dist/request/index.d.ts +5 -0
  112. package/dist/request/index.d.ts.map +1 -0
  113. package/dist/request/index.js +7 -0
  114. package/dist/request/index.js.map +1 -0
  115. package/dist/request/types.d.ts +111 -0
  116. package/dist/request/types.d.ts.map +1 -0
  117. package/dist/schema/SchemaService.d.ts +58 -0
  118. package/dist/schema/SchemaService.d.ts.map +1 -0
  119. package/dist/schema/decorators.d.ts +50 -0
  120. package/dist/schema/decorators.d.ts.map +1 -0
  121. package/dist/schema/index.cjs +2 -0
  122. package/dist/schema/index.cjs.map +1 -0
  123. package/dist/schema/index.d.ts +4 -0
  124. package/dist/schema/index.d.ts.map +1 -0
  125. package/dist/schema/index.js +13 -0
  126. package/dist/schema/index.js.map +1 -0
  127. package/dist/schema/types.d.ts +61 -0
  128. package/dist/schema/types.d.ts.map +1 -0
  129. package/dist/serializer/EmbeddedRecordsMixin.d.ts +80 -0
  130. package/dist/serializer/EmbeddedRecordsMixin.d.ts.map +1 -0
  131. package/dist/serializer/JsonSerializer.d.ts +52 -0
  132. package/dist/serializer/JsonSerializer.d.ts.map +1 -0
  133. package/dist/serializer/RestSerializer.d.ts +43 -0
  134. package/dist/serializer/RestSerializer.d.ts.map +1 -0
  135. package/dist/serializer/Serializer.d.ts +202 -0
  136. package/dist/serializer/Serializer.d.ts.map +1 -0
  137. package/dist/serializer/index.cjs +2 -0
  138. package/dist/serializer/index.cjs.map +1 -0
  139. package/dist/serializer/index.d.ts +5 -0
  140. package/dist/serializer/index.d.ts.map +1 -0
  141. package/dist/serializer/index.js +9 -0
  142. package/dist/serializer/index.js.map +1 -0
  143. package/dist/store/IdentityMap.d.ts +53 -0
  144. package/dist/store/IdentityMap.d.ts.map +1 -0
  145. package/dist/store/RecordArray.d.ts +114 -0
  146. package/dist/store/RecordArray.d.ts.map +1 -0
  147. package/dist/store/Store.d.ts +395 -0
  148. package/dist/store/Store.d.ts.map +1 -0
  149. package/dist/store/index.cjs +2 -0
  150. package/dist/store/index.cjs.map +1 -0
  151. package/dist/store/index.d.ts +5 -0
  152. package/dist/store/index.d.ts.map +1 -0
  153. package/dist/store/index.js +8 -0
  154. package/dist/store/index.js.map +1 -0
  155. package/dist/transforms/Transform.d.ts +49 -0
  156. package/dist/transforms/Transform.d.ts.map +1 -0
  157. package/dist/transforms/boolean.d.ts +26 -0
  158. package/dist/transforms/boolean.d.ts.map +1 -0
  159. package/dist/transforms/date.d.ts +22 -0
  160. package/dist/transforms/date.d.ts.map +1 -0
  161. package/dist/transforms/index.cjs +2 -0
  162. package/dist/transforms/index.cjs.map +1 -0
  163. package/dist/transforms/index.d.ts +6 -0
  164. package/dist/transforms/index.d.ts.map +1 -0
  165. package/dist/transforms/index.js +9 -0
  166. package/dist/transforms/index.js.map +1 -0
  167. package/dist/transforms/number.d.ts +17 -0
  168. package/dist/transforms/number.d.ts.map +1 -0
  169. package/dist/transforms/string.d.ts +18 -0
  170. package/dist/transforms/string.d.ts.map +1 -0
  171. package/dist/types-C9NB2gRj.js +7 -0
  172. package/dist/types-C9NB2gRj.js.map +1 -0
  173. package/dist/types-uWOXMPWW.cjs +2 -0
  174. package/dist/types-uWOXMPWW.cjs.map +1 -0
  175. package/package.json +140 -0
  176. package/src/adapter/Adapter.ts +320 -0
  177. package/src/adapter/MemoryAdapter.ts +216 -0
  178. package/src/adapter/RestAdapter.ts +248 -0
  179. package/src/adapter/index.ts +7 -0
  180. package/src/index.ts +17 -0
  181. package/src/json-api/JsonApiAdapter.ts +93 -0
  182. package/src/json-api/JsonApiSerializer.ts +245 -0
  183. package/src/json-api/index.ts +2 -0
  184. package/src/model/Errors.ts +100 -0
  185. package/src/model/Model.ts +683 -0
  186. package/src/model/Snapshot.ts +162 -0
  187. package/src/model/StateMachine.ts +149 -0
  188. package/src/model/index.ts +20 -0
  189. package/src/model/relationships.ts +484 -0
  190. package/src/odata/ODataAdapter.ts +245 -0
  191. package/src/odata/index.ts +1 -0
  192. package/src/request/CacheHandler.ts +125 -0
  193. package/src/request/FetchHandler.ts +119 -0
  194. package/src/request/RequestManager.ts +112 -0
  195. package/src/request/index.ts +4 -0
  196. package/src/request/types.ts +139 -0
  197. package/src/schema/SchemaService.ts +161 -0
  198. package/src/schema/decorators.ts +162 -0
  199. package/src/schema/index.ts +3 -0
  200. package/src/schema/types.ts +66 -0
  201. package/src/serializer/EmbeddedRecordsMixin.ts +257 -0
  202. package/src/serializer/JsonSerializer.ts +173 -0
  203. package/src/serializer/RestSerializer.ts +138 -0
  204. package/src/serializer/Serializer.ts +397 -0
  205. package/src/serializer/index.ts +15 -0
  206. package/src/store/IdentityMap.ts +110 -0
  207. package/src/store/RecordArray.ts +210 -0
  208. package/src/store/Store.ts +1391 -0
  209. package/src/store/index.ts +11 -0
  210. package/src/transforms/Transform.ts +52 -0
  211. package/src/transforms/boolean.ts +57 -0
  212. package/src/transforms/date.ts +48 -0
  213. package/src/transforms/index.ts +5 -0
  214. package/src/transforms/number.ts +42 -0
  215. package/src/transforms/string.ts +35 -0
@@ -0,0 +1,61 @@
1
+ /** Shape of a single `@attr` decoration on a model class property. */
2
+ export interface AttributeDef {
3
+ /** Property name on the model class. */
4
+ name: string;
5
+ /** Registered transform type (e.g. `'string'`, `'number'`), or `null` for pass-through. */
6
+ type: string | null;
7
+ /** Extra options passed by the decorator (default value, etc.). */
8
+ options: AttributeOptions;
9
+ /** Discriminant – always `true`; used to narrow union types. */
10
+ isAttribute: true;
11
+ }
12
+ /** Options accepted by the `@attr` decorator. */
13
+ export interface AttributeOptions {
14
+ /** Static value or factory function called when the attribute has no server value. */
15
+ defaultValue?: unknown | (() => unknown);
16
+ /** Arbitrary custom options forwarded to the transform. */
17
+ [key: string]: unknown;
18
+ }
19
+ /** Identifies the direction of a relationship from the owning model's perspective. */
20
+ export type RelationshipKind = 'belongsTo' | 'hasMany';
21
+ /** Shape of a single `@belongsTo` / `@hasMany` decoration on a model class property. */
22
+ export interface RelationshipDef {
23
+ /** Property name on the model class. */
24
+ name: string;
25
+ /** Direction from the owning model's perspective. */
26
+ kind: RelationshipKind;
27
+ /** `modelName` of the related model. */
28
+ type: string;
29
+ /** Normalised options (async, inverse, polymorphic, …). */
30
+ options: RelationshipOptions;
31
+ /** Discriminant – always `true`; used to narrow union types. */
32
+ isRelationship: true;
33
+ }
34
+ /** Options accepted by `@belongsTo` and `@hasMany` decorators. */
35
+ export interface RelationshipOptions {
36
+ /**
37
+ * When `true` the relationship proxy returns an `AsyncBelongsTo` / `AsyncHasMany`
38
+ * that must be awaited before the related record(s) are available.
39
+ */
40
+ async?: boolean;
41
+ /**
42
+ * Name of the inverse property on the related model.
43
+ * Set to `null` to explicitly opt out of inverse tracking.
44
+ */
45
+ inverse?: string | null;
46
+ /** When `true` the relationship can point to records of multiple model types. */
47
+ polymorphic?: boolean;
48
+ /** Arbitrary custom options. */
49
+ [key: string]: unknown;
50
+ }
51
+ /** Attribute definitions keyed by property name. */
52
+ export type AttributeDefinitionsMap = Map<string, AttributeDef>;
53
+ /** Relationship definitions keyed by property name. */
54
+ export type RelationshipDefinitionsMap = Map<string, RelationshipDef>;
55
+ /** Reflect-metadata key used to store attribute definitions on a prototype. */
56
+ export declare const ATTRIBUTES_META_KEY: unique symbol;
57
+ /** Reflect-metadata key used to store relationship definitions on a prototype. */
58
+ export declare const RELATIONSHIPS_META_KEY: unique symbol;
59
+ /** Reflect-metadata key used to store the registered model name on a class. */
60
+ export declare const MODEL_NAME_META_KEY: unique symbol;
61
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/schema/types.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,2FAA2F;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C;AACxE,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,eAAgC,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Mixin that adds support for embedded (nested) records in REST payloads.
3
+ *
4
+ * Apply with:
5
+ * ```ts
6
+ * class PostSerializer extends EmbeddedRecordsMixin(RestSerializer) {
7
+ * attrs = {
8
+ * comments: { embedded: 'always' },
9
+ * author: { embedded: 'always', serialize: 'records' },
10
+ * };
11
+ * }
12
+ * ```
13
+ *
14
+ * ## How it works
15
+ *
16
+ * ### Deserialization
17
+ * When `embedded: 'always'` is set for a relationship, `normalize()` intercepts
18
+ * the raw payload before passing it to `super.normalize()`:
19
+ * - For `hasMany`: replaces the nested array with a plain id array and queues
20
+ * each nested object as an `included` resource.
21
+ * - For `belongsTo`: replaces the nested object with the extracted id and
22
+ * queues the nested object as an `included` resource.
23
+ *
24
+ * Queued resources are collected during `normalizeResponse()` and appended to
25
+ * `document.included` so the `Store` can push them into the identity map.
26
+ *
27
+ * ### Serialization
28
+ * When `serialize: 'records'` is set, `serializeHasMany` / `serializeBelongsTo`
29
+ * write the full related record(s) into the payload instead of just ids.
30
+ *
31
+ * ## Configuration
32
+ *
33
+ * Each entry in `attrs` is an `EmbeddedAttrConfig`:
34
+ * - `embedded: 'always'` — enable embedded deserialization.
35
+ * - `serialize: 'records'` — write full records on serialize.
36
+ * - `serialize: 'ids'` — write id array on serialize (default).
37
+ * - `serialize: false` — omit relationship from serialized payload.
38
+ * - `deserialize: 'records'` — same as `embedded: 'always'`.
39
+ * - `deserialize: false` — ignore this relationship during normalization.
40
+ */
41
+ import type { RelationshipDef } from '@mobx-data/schema';
42
+ import type { ModelClassMeta, NormalizeRequestType, NormalizedDocument, NormalizedResource, SerializerSnapshot } from './Serializer.js';
43
+ /** Per-relationship embedding configuration. */
44
+ export interface EmbeddedAttrConfig {
45
+ /** `'always'` to deserialize embedded records; `'never'` to skip. */
46
+ embedded?: 'always' | 'never';
47
+ /** `'records'` to serialize full objects; `'ids'` for ids only; `false` to omit. */
48
+ serialize?: 'records' | 'ids' | false;
49
+ /** `'records'` to deserialize embedded objects; `'ids'` for plain ids; `false` to skip. */
50
+ deserialize?: 'records' | 'ids' | false;
51
+ }
52
+ /** Map of relationship name → embedding config. */
53
+ export interface EmbeddedRecordsAttrs {
54
+ [key: string]: EmbeddedAttrConfig;
55
+ }
56
+ /**
57
+ * The minimal serializer interface required by the mixin.
58
+ * Any class extending `JsonSerializer` satisfies this.
59
+ */
60
+ export interface JsonSerializerLike {
61
+ attrs?: EmbeddedRecordsAttrs;
62
+ primaryKey: string;
63
+ normalize(store: unknown, modelClass: ModelClassMeta, payload: unknown, prop?: string): NormalizedResource | null;
64
+ normalizeResponse(store: unknown, modelClass: ModelClassMeta, payload: unknown, id: string | null, requestType: NormalizeRequestType): NormalizedDocument;
65
+ serialize(snapshot: SerializerSnapshot, options?: {
66
+ includeId?: boolean;
67
+ }): Record<string, unknown>;
68
+ serializeHasMany(snapshot: SerializerSnapshot, json: Record<string, unknown>, relationship: RelationshipDef): void;
69
+ serializeBelongsTo(snapshot: SerializerSnapshot, json: Record<string, unknown>, relationship: RelationshipDef): void;
70
+ keyForAttribute(key: string): string;
71
+ keyForRelationship(key: string): string;
72
+ }
73
+ type Constructor<T> = new (...args: any[]) => T;
74
+ /**
75
+ * Returns a new class that extends `Base` with embedded-record support.
76
+ * `Base` must be (or extend) `JsonSerializer`.
77
+ */
78
+ export declare function EmbeddedRecordsMixin<TBase extends Constructor<JsonSerializerLike>>(Base: TBase): TBase;
79
+ export {};
80
+ //# sourceMappingURL=EmbeddedRecordsMixin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbeddedRecordsMixin.d.ts","sourceRoot":"","sources":["../../src/serializer/EmbeddedRecordsMixin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;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,EAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,YAAY,EAAE,eAAe,GAC5B,IAAI,CAAC;IACR,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzC;AAGD,KAAK,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,SAAS,WAAW,CAAC,kBAAkB,CAAC,EAC7C,IAAI,EAAE,KAAK,GAAG,KAAK,CAgJpB"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Flat-JSON serializer for simple REST APIs.
3
+ *
4
+ * `JsonSerializer` expects payloads to be plain JSON objects or arrays with
5
+ * no root-key wrapping. It is the lowest-level concrete serializer and the
6
+ * base that `RestSerializer` extends.
7
+ *
8
+ * Normalization:
9
+ * - Array payload → `{ data: [NormalizedResource, …] }`
10
+ * - Object payload → `{ data: NormalizedResource }`
11
+ * - `null` / `undefined` → `{ data: null }`
12
+ *
13
+ * Serialization:
14
+ * - Iterates `@attr` → writes via `serializeAttribute`
15
+ * - Iterates `@belongsTo` / `@hasMany` → writes via `serializeBelongsTo` /
16
+ * `serializeHasMany`
17
+ *
18
+ * `normalizeResponse` automatically dispatches to the correct per-operation
19
+ * hook (`normalizeFindRecordResponse`, etc.) when a subclass overrides them.
20
+ * If no override exists it falls through to `_buildDocument`.
21
+ */
22
+ import { Serializer, type ModelClassMeta, type NormalizeRequestType, type NormalizedDocument, type NormalizedResource, type SerializerSnapshot } from './Serializer.js';
23
+ export declare class JsonSerializer extends Serializer {
24
+ static dispatchMethodName(requestType: NormalizeRequestType): keyof Serializer | null;
25
+ /**
26
+ * Normalizes a single flat JSON object into a `NormalizedResource`.
27
+ * Returns `null` for absent or non-object payloads.
28
+ */
29
+ normalize(_store: unknown, modelClass: ModelClassMeta, payload: unknown, _prop?: string): NormalizedResource | null;
30
+ /**
31
+ * Entry point for normalization.
32
+ *
33
+ * Checks whether a subclass has overridden the relevant per-operation hook
34
+ * (e.g. `normalizeFindRecordResponse`). If so, calls it; otherwise falls
35
+ * through to `_buildDocument`.
36
+ */
37
+ normalizeResponse(store: unknown, modelClass: ModelClassMeta, payload: unknown, id: string | null, requestType: NormalizeRequestType): NormalizedDocument;
38
+ /**
39
+ * Builds a `NormalizedDocument` from a raw payload.
40
+ * Arrays are normalized item by item; plain objects are normalized as a
41
+ * single resource.
42
+ */
43
+ protected _buildDocument(store: unknown, modelClass: ModelClassMeta, payload: unknown, _id: string | null, _requestType: NormalizeRequestType): NormalizedDocument;
44
+ /**
45
+ * Serializes a snapshot to a flat JSON object.
46
+ * Includes `id` when `options.includeId` is `true`.
47
+ */
48
+ serialize(snapshot: SerializerSnapshot, options?: {
49
+ includeId?: boolean;
50
+ }): Record<string, unknown>;
51
+ }
52
+ //# sourceMappingURL=JsonSerializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonSerializer.d.ts","sourceRoot":"","sources":["../../src/serializer/JsonSerializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AAEzB,qBACa,cAAe,SAAQ,UAAU;IAC5C,MAAM,CAAC,kBAAkB,CACvB,WAAW,EAAE,oBAAoB,GAChC,MAAM,UAAU,GAAG,IAAI;IAqB1B;;;OAGG;IACM,SAAS,CAChB,MAAM,EAAE,OAAO,EACf,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,MAAM,GACb,kBAAkB,GAAG,IAAI;IAuB5B;;;;;;OAMG;IACM,iBAAiB,CACxB,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,MAAM,GAAG,IAAI,EACjB,WAAW,EAAE,oBAAoB,GAChC,kBAAkB;IAqBrB;;;;OAIG;IACH,SAAS,CAAC,cAAc,CACtB,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,YAAY,EAAE,oBAAoB,GACjC,kBAAkB;IAcrB;;;OAGG;IACM,SAAS,CAChB,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAiB3B"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * REST serializer for root-key payloads with optional sideloading.
3
+ *
4
+ * `RestSerializer` expects the primary data to be wrapped under a root key
5
+ * that matches either the singular or plural model name:
6
+ *
7
+ * ```json
8
+ * { "post": { "id": "1", "title": "Hello" } }
9
+ * { "posts": [{ "id": "1", … }, { "id": "2", … }] }
10
+ * ```
11
+ *
12
+ * Any additional keys in the payload are treated as sideloaded (compound)
13
+ * data. `meta` and `links` keys are reserved and forwarded to the document.
14
+ *
15
+ * Sideloaded types are inferred from the payload key via `modelNameFromPayloadKey`
16
+ * (default: singularization).
17
+ *
18
+ * Extends `JsonSerializer` so it inherits flat `normalize` and `serialize`
19
+ * behaviour and only overrides document-level parsing via `_buildDocument`.
20
+ */
21
+ import { type ModelClassMeta, type NormalizeRequestType, type NormalizedDocument } from './Serializer.js';
22
+ import { JsonSerializer } from './JsonSerializer.js';
23
+ export declare class RestSerializer extends JsonSerializer {
24
+ /**
25
+ * Returns the plural payload key for a model name.
26
+ * e.g. `'post'` → `'posts'`
27
+ */
28
+ payloadKeyFromModelName(modelName: string): string;
29
+ /**
30
+ * Returns the model name for a payload root key.
31
+ * e.g. `'posts'` → `'post'`
32
+ */
33
+ modelNameFromPayloadKey(key: string): string;
34
+ /**
35
+ * Builds a `NormalizedDocument` from a root-key REST payload.
36
+ *
37
+ * - Looks for the model data under the singular or plural root key.
38
+ * - Treats every other non-reserved key as a sideloaded type.
39
+ * - Preserves `meta` and `links` from the root.
40
+ */
41
+ protected _buildDocument(store: unknown, modelClass: ModelClassMeta, payload: unknown, _id: string | null, _requestType: NormalizeRequestType): NormalizedDocument;
42
+ }
43
+ //# sourceMappingURL=RestSerializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestSerializer.d.ts","sourceRoot":"","sources":["../../src/serializer/RestSerializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EAExB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,qBACa,cAAe,SAAQ,cAAc;IAChD;;;OAGG;IACH,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIlD;;;OAGG;IACH,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI5C;;;;;;OAMG;cACgB,cAAc,CAC/B,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,YAAY,EAAE,oBAAoB,GACjC,kBAAkB;CA2EtB"}
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Abstract base class for all serializers.
3
+ *
4
+ * A serializer translates between the raw wire format returned by an adapter
5
+ * and the normalized document format consumed by the `Store`. It also
6
+ * converts a record `Snapshot` back into a wire-format payload for create /
7
+ * update requests.
8
+ *
9
+ * ## Normalization pipeline
10
+ *
11
+ * ```
12
+ * raw payload
13
+ * → normalizeResponse() (dispatches to the per-operation override)
14
+ * → normalizeFindRecordResponse() / normalizeQueryResponse() / …
15
+ * → normalize() (normalizes a single resource hash)
16
+ * → extractId()
17
+ * → extractAttributes()
18
+ * → extractRelationships()
19
+ * → NormalizedDocument
20
+ * ```
21
+ *
22
+ * ## Serialization pipeline
23
+ *
24
+ * ```
25
+ * Snapshot
26
+ * → serialize()
27
+ * → serializeAttribute() (for each @attr)
28
+ * → serializeBelongsTo() (for each @belongsTo)
29
+ * → serializeHasMany() (for each @hasMany)
30
+ * → wire payload object
31
+ * ```
32
+ *
33
+ * Subclasses (`JsonSerializer`, `RestSerializer`, `JsonApiSerializer`) override
34
+ * selected methods to handle their specific wire formats.
35
+ */
36
+ import type { AttributeDef, RelationshipDef } from '@mobx-data/schema';
37
+ /** Union of all request types that trigger a normalization call. */
38
+ export type NormalizeRequestType = 'findRecord' | 'findAll' | 'findBelongsTo' | 'findHasMany' | 'findMany' | 'query' | 'queryRecord' | 'createRecord' | 'updateRecord' | 'deleteRecord';
39
+ /**
40
+ * Normalized representation of a single server resource.
41
+ * This is the internal format understood by the `Store`.
42
+ */
43
+ export interface NormalizedResource {
44
+ /** Model name. */
45
+ type: string;
46
+ /** Server-assigned id, or `null` for new records. */
47
+ id: string | null;
48
+ /** Flat attribute map keyed by property name. */
49
+ attributes?: Record<string, unknown>;
50
+ /**
51
+ * Relationship references keyed by property name.
52
+ * Each value contains `data` — a single `{ type, id }` or an array of them.
53
+ */
54
+ relationships?: Record<string, {
55
+ data: {
56
+ type: string;
57
+ id: string;
58
+ } | Array<{
59
+ type: string;
60
+ id: string;
61
+ }> | null;
62
+ }>;
63
+ }
64
+ /**
65
+ * Top-level normalized document returned by `normalizeResponse`.
66
+ * Mirrors the JSON:API document structure but is also used for REST payloads.
67
+ */
68
+ export interface NormalizedDocument {
69
+ /** Primary resource(s), or `null` for empty responses. */
70
+ data: NormalizedResource | NormalizedResource[] | null;
71
+ /** Side-loaded or compound-document secondary resources. */
72
+ included?: NormalizedResource[];
73
+ /** Server-side metadata (pagination, total counts, etc.). */
74
+ meta?: Record<string, unknown>;
75
+ /** Pagination or related links. */
76
+ links?: Record<string, string>;
77
+ }
78
+ /**
79
+ * Snapshot-like interface consumed by `serialize` and the `serialize*` helpers.
80
+ * Serializers only read from snapshots; they never mutate records.
81
+ */
82
+ export interface SerializerSnapshot {
83
+ /** Server-assigned id, or `null` for new records. */
84
+ id: string | null;
85
+ /** Model name. */
86
+ modelName: string;
87
+ /** Returns the snapshot-time value for an attribute key. */
88
+ attr(key: string): unknown;
89
+ /** Returns the `belongsTo` reference (or just the id when `{ id: true }`). */
90
+ belongsTo(key: string, options?: {
91
+ id: boolean;
92
+ }): unknown;
93
+ /** Returns the `hasMany` references (or just ids when `{ ids: true }`). */
94
+ hasMany(key: string, options?: {
95
+ ids: boolean;
96
+ }): unknown;
97
+ /** Returns `{ [key]: [original, current] }` pairs for dirty attributes. */
98
+ changedAttributes(): Record<string, [unknown, unknown]>;
99
+ /** Iterates over all attribute definitions. */
100
+ eachAttribute(fn: (key: string, meta: AttributeDef) => void): void;
101
+ /** Iterates over all relationship definitions. */
102
+ eachRelationship(fn: (key: string, meta: RelationshipDef) => void): void;
103
+ /** Live record reference (treated as read-only in serializer context). */
104
+ record: unknown;
105
+ }
106
+ /** Minimal model class descriptor passed to serializer methods. */
107
+ export interface ModelClassMeta {
108
+ /** Registered model name. */
109
+ modelName: string;
110
+ /** Merged attribute definitions. */
111
+ attributes: Map<string, AttributeDef>;
112
+ /** Merged relationship definitions. */
113
+ relationships: Map<string, RelationshipDef>;
114
+ }
115
+ export declare abstract class Serializer {
116
+ /** Name of the field used as the primary key in raw payloads. Default: `'id'`. */
117
+ primaryKey: string;
118
+ /**
119
+ * Normalizes a single raw resource hash into a `NormalizedResource`.
120
+ * Returns `null` for absent or non-object payloads.
121
+ */
122
+ abstract normalize(store: unknown, modelClass: ModelClassMeta, payload: unknown, prop?: string): NormalizedResource | null;
123
+ /**
124
+ * Entry point for normalization. Dispatches to the appropriate
125
+ * `normalize*Response` method based on `requestType`, then builds the full
126
+ * `NormalizedDocument`.
127
+ */
128
+ abstract normalizeResponse(store: unknown, modelClass: ModelClassMeta, payload: unknown, id: string | null, requestType: NormalizeRequestType): NormalizedDocument;
129
+ /**
130
+ * Serializes a record snapshot into a plain object suitable for a create
131
+ * or update request body.
132
+ */
133
+ abstract serialize(snapshot: SerializerSnapshot, options?: {
134
+ includeId?: boolean;
135
+ }): Record<string, unknown>;
136
+ /** Called when normalizing a `findRecord` response. */
137
+ normalizeFindRecordResponse(store: unknown, modelClass: ModelClassMeta, payload: unknown, id: string | null, requestType: NormalizeRequestType): NormalizedDocument;
138
+ /** Called when normalizing a `findAll` response. */
139
+ normalizeFindAllResponse(store: unknown, modelClass: ModelClassMeta, payload: unknown, id: string | null, requestType: NormalizeRequestType): NormalizedDocument;
140
+ /** Called when normalizing a `query` response. */
141
+ normalizeQueryResponse(store: unknown, modelClass: ModelClassMeta, payload: unknown, id: string | null, requestType: NormalizeRequestType): NormalizedDocument;
142
+ /** Called when normalizing a `queryRecord` response. */
143
+ normalizeQueryRecordResponse(store: unknown, modelClass: ModelClassMeta, payload: unknown, id: string | null, requestType: NormalizeRequestType): NormalizedDocument;
144
+ /** Called when normalizing a `createRecord` response. */
145
+ normalizeCreateRecordResponse(store: unknown, modelClass: ModelClassMeta, payload: unknown, id: string | null, requestType: NormalizeRequestType): NormalizedDocument;
146
+ /** Called when normalizing an `updateRecord` response. */
147
+ normalizeUpdateRecordResponse(store: unknown, modelClass: ModelClassMeta, payload: unknown, id: string | null, requestType: NormalizeRequestType): NormalizedDocument;
148
+ /** Called when normalizing a `deleteRecord` response. */
149
+ normalizeDeleteRecordResponse(store: unknown, modelClass: ModelClassMeta, payload: unknown, id: string | null, requestType: NormalizeRequestType): NormalizedDocument;
150
+ /**
151
+ * Writes a single attribute value into `json`.
152
+ * Default: writes `snapshot.attr(key)` under the key returned by `keyForAttribute`.
153
+ */
154
+ serializeAttribute(snapshot: SerializerSnapshot, json: Record<string, unknown>, key: string, _attribute: AttributeDef): void;
155
+ /**
156
+ * Writes a `belongsTo` relationship id into `json`.
157
+ * Default: writes the related record's id (or `null`) under `keyForRelationship`.
158
+ */
159
+ serializeBelongsTo(snapshot: SerializerSnapshot, json: Record<string, unknown>, relationship: RelationshipDef): void;
160
+ /**
161
+ * Writes a `hasMany` relationship id array into `json`.
162
+ * Default: writes the array of related ids under `keyForRelationship`.
163
+ */
164
+ serializeHasMany(snapshot: SerializerSnapshot, json: Record<string, unknown>, relationship: RelationshipDef): void;
165
+ /**
166
+ * Extracts attribute values from a raw resource hash.
167
+ * Returns a map of `{ propertyName: value }` using `keyForAttribute` to
168
+ * locate the payload key.
169
+ */
170
+ extractAttributes(modelClass: ModelClassMeta, resourceHash: Record<string, unknown>): Record<string, unknown>;
171
+ /**
172
+ * Extracts relationship references from a raw resource hash.
173
+ *
174
+ * - `belongsTo`: raw id (string or number) → `{ data: { type, id } }`
175
+ * - `hasMany`: array of raw ids → `{ data: [{ type, id }, …] }`
176
+ *
177
+ * Returns only the relationships whose payload keys are present in `resourceHash`.
178
+ */
179
+ extractRelationships(modelClass: ModelClassMeta, resourceHash: Record<string, unknown>): NormalizedResource['relationships'];
180
+ /**
181
+ * Extracts the primary key from a raw resource hash.
182
+ * Returns `null` when the key is absent.
183
+ */
184
+ extractId(_modelClass: ModelClassMeta, resourceHash: Record<string, unknown>): string | null;
185
+ /**
186
+ * Extracts field-level validation errors from a server error payload.
187
+ * Default: looks for `{ errors: { field: string | string[] } }`.
188
+ * Returns an empty object when no recognisable error structure is found.
189
+ */
190
+ extractErrors(_store: unknown, _modelClass: ModelClassMeta, payload: unknown, _id: string | null): Record<string, string[]>;
191
+ /**
192
+ * Maps a camelCase property name to the payload key used by this format.
193
+ * Default: identity (no transformation).
194
+ */
195
+ keyForAttribute(key: string): string;
196
+ /**
197
+ * Maps a camelCase relationship name to the payload key used by this format.
198
+ * Default: identity (no transformation).
199
+ */
200
+ keyForRelationship(key: string): string;
201
+ }
202
+ //# sourceMappingURL=Serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Serializer.d.ts","sourceRoot":"","sources":["../../src/serializer/Serializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEvE,oEAAoE;AACpE,MAAM,MAAM,oBAAoB,GAC5B,YAAY,GACZ,SAAS,GACT,eAAe,GACf,aAAa,GACb,UAAU,GACV,OAAO,GACP,aAAa,GACb,cAAc,GACd,cAAc,GACd,cAAc,CAAC;AAEnB;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CACtB,MAAM,EACN;QACE,IAAI,EACF;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,GAC5B,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC,GACnC,IAAI,CAAC;KACR,CACA,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,GAAG,IAAI,CAAC;IACvD,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAChC,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA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,MAAM,EAAE,OAAO,CAAC,GACpC,kBAAkB,CAAC,eAAe,CAAC;IA4BtC;;;OAGG;IACH,SAAS,CACP,WAAW,EAAE,cAAc,EAC3B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,MAAM,GAAG,IAAI;IAQhB;;;;OAIG;IACH,aAAa,CACX,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,cAAc,EAC3B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,GAAG,IAAI,GACjB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAc3B;;;OAGG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIpC;;;OAGG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAGxC"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../Serializer-95gi5edy.cjs"),e=require("../EmbeddedRecordsMixin-CBvqNdgC.cjs");exports.Serializer=r.Serializer;exports.EmbeddedRecordsMixin=e.EmbeddedRecordsMixin;Object.defineProperty(exports,"JsonSerializer",{enumerable:!0,get:()=>e.JsonSerializer});Object.defineProperty(exports,"RestSerializer",{enumerable:!0,get:()=>e.RestSerializer});
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export { Serializer, type NormalizedDocument, type NormalizedResource, type NormalizeRequestType, type SerializerSnapshot, type ModelClassMeta, } from './Serializer.js';
2
+ export { RestSerializer } from './RestSerializer.js';
3
+ export { JsonSerializer } from './JsonSerializer.js';
4
+ export { EmbeddedRecordsMixin, type EmbeddedAttrConfig, type EmbeddedRecordsAttrs, } from './EmbeddedRecordsMixin.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/serializer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { S as i } from "../Serializer-FxJbsZ50.js";
2
+ import { E as s, J as o, R as d } from "../EmbeddedRecordsMixin-VoHluHCT.js";
3
+ export {
4
+ s as EmbeddedRecordsMixin,
5
+ o as JsonSerializer,
6
+ d as RestSerializer,
7
+ i as Serializer
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Two-level observable map that serves as the store's record cache.
3
+ *
4
+ * Records are stored in per-type buckets:
5
+ * ```
6
+ * buckets: Map<modelName, Map<id, Model>>
7
+ * ```
8
+ *
9
+ * The outer map is MobX-observable (shallow) so derived views like `peekAll`
10
+ * react when new type buckets are added. Each inner bucket is an observable
11
+ * map so computed properties that iterate records within a type react to
12
+ * additions and deletions.
13
+ *
14
+ * All mutating methods (`set`, `delete`, `clear`) are MobX `action`s so they
15
+ * batch observable updates correctly.
16
+ */
17
+ import type { Model } from '@mobx-data/model';
18
+ export declare class IdentityMap {
19
+ /** @internal */
20
+ readonly _buckets: Map<string, Map<string, Model>>;
21
+ constructor();
22
+ /**
23
+ * Returns the bucket for `modelName`, optionally creating it when absent.
24
+ * Internal helper — not part of the public API.
25
+ */
26
+ private bucket;
27
+ /** Adds or replaces the record with the given `id` under `modelName`. */
28
+ set(modelName: string, id: string, record: Model): void;
29
+ /**
30
+ * Returns the record for `modelName` + `id`, or `null` when not found.
31
+ */
32
+ get(modelName: string, id: string): Model | null;
33
+ /** Returns `true` when a record exists for `modelName` + `id`. */
34
+ has(modelName: string, id: string): boolean;
35
+ /**
36
+ * Removes the record for `modelName` + `id`.
37
+ * @returns `true` when the record existed and was deleted.
38
+ */
39
+ delete(modelName: string, id: string): boolean;
40
+ /** Returns all records stored under `modelName` as an array. */
41
+ all(modelName: string): Model[];
42
+ /**
43
+ * Clears all records for `modelName`, or all records across all types when
44
+ * `modelName` is omitted.
45
+ */
46
+ clear(modelName?: string): void;
47
+ /**
48
+ * Returns the number of records stored for `modelName`, or the total across
49
+ * all types when `modelName` is omitted.
50
+ */
51
+ size(modelName?: string): number;
52
+ }
53
+ //# sourceMappingURL=IdentityMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IdentityMap.d.ts","sourceRoot":"","sources":["../../src/store/IdentityMap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,WAAW;IACtB,gBAAgB;IAChB,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAa;;IAW/D;;;OAGG;IACH,OAAO,CAAC,MAAM;IASd,yEAAyE;IACzE,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI;IAKvD;;OAEG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI;IAIhD,kEAAkE;IAClE,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO;IAI3C;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO;IAI9C,gEAAgE;IAChE,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,EAAE;IAQ/B;;;OAGG;IACH,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAU/B;;;OAGG;IACH,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;CAUjC"}