@warp-drive/core 5.6.0-alpha.17 → 5.6.0-alpha.5

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 (219) hide show
  1. package/README.md +7 -8
  2. package/declarations/index.d.ts +3 -14
  3. package/declarations/index.d.ts.map +1 -0
  4. package/declarations/request/-private/context.d.ts +35 -34
  5. package/declarations/request/-private/context.d.ts.map +1 -0
  6. package/declarations/request/-private/debug.d.ts +3 -2
  7. package/declarations/request/-private/debug.d.ts.map +1 -0
  8. package/declarations/request/-private/fetch.d.ts +36 -24
  9. package/declarations/request/-private/fetch.d.ts.map +1 -0
  10. package/declarations/request/-private/future.d.ts +4 -3
  11. package/declarations/request/-private/future.d.ts.map +1 -0
  12. package/declarations/request/-private/manager.d.ts +132 -159
  13. package/declarations/request/-private/manager.d.ts.map +1 -0
  14. package/declarations/request/-private/promise-cache.d.ts +13 -21
  15. package/declarations/request/-private/promise-cache.d.ts.map +1 -0
  16. package/declarations/request/-private/types.d.ts +123 -124
  17. package/declarations/request/-private/types.d.ts.map +1 -0
  18. package/declarations/request/-private/utils.d.ts +9 -8
  19. package/declarations/request/-private/utils.d.ts.map +1 -0
  20. package/declarations/request.d.ts +433 -5
  21. package/declarations/request.d.ts.map +1 -0
  22. package/declarations/types/-private.d.ts +8 -16
  23. package/declarations/types/-private.d.ts.map +1 -0
  24. package/declarations/types/cache/aliases.d.ts +1 -11
  25. package/declarations/types/cache/aliases.d.ts.map +1 -0
  26. package/declarations/types/cache/change.d.ts +5 -4
  27. package/declarations/types/cache/change.d.ts.map +1 -0
  28. package/declarations/types/cache/mutations.d.ts +28 -51
  29. package/declarations/types/cache/mutations.d.ts.map +1 -0
  30. package/declarations/types/cache/operations.d.ts +47 -60
  31. package/declarations/types/cache/operations.d.ts.map +1 -0
  32. package/declarations/types/cache/relationship.d.ts +9 -11
  33. package/declarations/types/cache/relationship.d.ts.map +1 -0
  34. package/declarations/types/cache.d.ts +484 -495
  35. package/declarations/types/cache.d.ts.map +1 -0
  36. package/declarations/types/graph.d.ts +40 -31
  37. package/declarations/types/graph.d.ts.map +1 -0
  38. package/declarations/types/identifier.d.ts +82 -83
  39. package/declarations/types/identifier.d.ts.map +1 -0
  40. package/declarations/types/json/raw.d.ts +2 -1
  41. package/declarations/types/json/raw.d.ts.map +1 -0
  42. package/declarations/types/params.d.ts +5 -4
  43. package/declarations/types/params.d.ts.map +1 -0
  44. package/declarations/types/record.d.ts +76 -117
  45. package/declarations/types/record.d.ts.map +1 -0
  46. package/declarations/types/record.type-test.d.ts +2 -0
  47. package/declarations/types/record.type-test.d.ts.map +1 -0
  48. package/declarations/types/request.d.ts +266 -289
  49. package/declarations/types/request.d.ts.map +1 -0
  50. package/declarations/types/request.type-test.d.ts +2 -0
  51. package/declarations/types/request.type-test.d.ts.map +1 -0
  52. package/declarations/types/runtime.d.ts +9 -8
  53. package/declarations/types/runtime.d.ts.map +1 -0
  54. package/declarations/types/schema/concepts.d.ts +13 -19
  55. package/declarations/types/schema/concepts.d.ts.map +1 -0
  56. package/declarations/types/schema/fields.d.ts +1741 -1712
  57. package/declarations/types/schema/fields.d.ts.map +1 -0
  58. package/declarations/types/schema/fields.type-test.d.ts +1 -0
  59. package/declarations/types/schema/fields.type-test.d.ts.map +1 -0
  60. package/declarations/types/spec/document.d.ts +22 -28
  61. package/declarations/types/spec/document.d.ts.map +1 -0
  62. package/declarations/types/spec/error.d.ts +17 -16
  63. package/declarations/types/spec/error.d.ts.map +1 -0
  64. package/declarations/types/spec/json-api-raw.d.ts +102 -102
  65. package/declarations/types/spec/json-api-raw.d.ts.map +1 -0
  66. package/declarations/types/symbols.d.ts +75 -74
  67. package/declarations/types/symbols.d.ts.map +1 -0
  68. package/declarations/types/utils.d.ts +5 -5
  69. package/declarations/types/utils.d.ts.map +1 -0
  70. package/declarations/types.d.ts +7 -10
  71. package/declarations/types.d.ts.map +1 -0
  72. package/dist/{context-COmAnXUQ.js → context-DE5sFezZ.js} +2 -2
  73. package/dist/context-DE5sFezZ.js.map +1 -0
  74. package/dist/index.js +104 -37
  75. package/dist/index.js.map +1 -0
  76. package/dist/request.js +1 -1
  77. package/dist/request.js.map +1 -0
  78. package/dist/types/-private.js +3 -3
  79. package/dist/types/-private.js.map +1 -0
  80. package/dist/types/cache/aliases.js.map +1 -0
  81. package/dist/types/cache/change.js.map +1 -0
  82. package/dist/types/cache/mutations.js.map +1 -0
  83. package/dist/types/cache/operations.js.map +1 -0
  84. package/dist/types/cache/relationship.js.map +1 -0
  85. package/dist/types/cache.js.map +1 -0
  86. package/dist/types/graph.js.map +1 -0
  87. package/dist/types/identifier.js.map +1 -0
  88. package/dist/types/json/raw.js.map +1 -0
  89. package/dist/types/params.js.map +1 -0
  90. package/dist/types/record.js +1 -1
  91. package/dist/types/record.js.map +1 -0
  92. package/dist/types/request.js +2 -2
  93. package/dist/types/request.js.map +1 -0
  94. package/dist/types/runtime.js +1 -1
  95. package/dist/types/runtime.js.map +1 -0
  96. package/dist/types/schema/concepts.js.map +1 -0
  97. package/dist/types/schema/fields.js +41 -8
  98. package/dist/types/schema/fields.js.map +1 -0
  99. package/dist/types/schema/fields.type-test.js.map +1 -0
  100. package/dist/types/spec/document.js.map +1 -0
  101. package/dist/types/spec/error.js.map +1 -0
  102. package/dist/types/spec/json-api-raw.js.map +1 -0
  103. package/dist/types/symbols.js +3 -3
  104. package/dist/types/symbols.js.map +1 -0
  105. package/dist/types/utils.js.map +1 -0
  106. package/dist/types.js.map +1 -0
  107. package/package.json +8 -11
  108. package/cjs-dist/addon-shim.cjs +0 -1
  109. package/cjs-dist/cjs-set-config.cjs +0 -1
  110. package/declarations/build-config/babel-macros.d.ts +0 -1
  111. package/declarations/build-config/canary-features.d.ts +0 -1
  112. package/declarations/build-config/debugging.d.ts +0 -1
  113. package/declarations/build-config/deprecations.d.ts +0 -1
  114. package/declarations/build-config/env.d.ts +0 -1
  115. package/declarations/build-config/macros.d.ts +0 -1
  116. package/declarations/build-config.d.ts +0 -1
  117. package/declarations/configure.d.ts +0 -7
  118. package/declarations/graph/-private/-diff.d.ts +0 -32
  119. package/declarations/graph/-private/-edge-definition.d.ts +0 -148
  120. package/declarations/graph/-private/-state.d.ts +0 -96
  121. package/declarations/graph/-private/-utils.d.ts +0 -31
  122. package/declarations/graph/-private/coerce-id.d.ts +0 -10
  123. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +0 -18
  124. package/declarations/graph/-private/edges/collection.d.ts +0 -39
  125. package/declarations/graph/-private/edges/implicit.d.ts +0 -43
  126. package/declarations/graph/-private/edges/resource.d.ts +0 -24
  127. package/declarations/graph/-private/graph.d.ts +0 -90
  128. package/declarations/graph/-private/normalize-link.d.ts +0 -8
  129. package/declarations/graph/-private/operations/add-to-related-records.d.ts +0 -4
  130. package/declarations/graph/-private/operations/merge-identifier.d.ts +0 -3
  131. package/declarations/graph/-private/operations/remove-from-related-records.d.ts +0 -4
  132. package/declarations/graph/-private/operations/replace-related-record.d.ts +0 -3
  133. package/declarations/graph/-private/operations/replace-related-records.d.ts +0 -62
  134. package/declarations/graph/-private/operations/update-relationship.d.ts +0 -13
  135. package/declarations/graph/-private.d.ts +0 -13
  136. package/declarations/reactive/-private/document.d.ts +0 -146
  137. package/declarations/reactive/-private/fields/compute.d.ts +0 -43
  138. package/declarations/reactive/-private/fields/extension.d.ts +0 -8
  139. package/declarations/reactive/-private/fields/managed-array.d.ts +0 -22
  140. package/declarations/reactive/-private/fields/managed-object.d.ts +0 -21
  141. package/declarations/reactive/-private/fields/many-array-manager.d.ts +0 -19
  142. package/declarations/reactive/-private/hooks.d.ts +0 -5
  143. package/declarations/reactive/-private/record.d.ts +0 -64
  144. package/declarations/reactive/-private/schema.d.ts +0 -271
  145. package/declarations/reactive/-private/symbols.d.ts +0 -36
  146. package/declarations/reactive/-private.d.ts +0 -1
  147. package/declarations/reactive.d.ts +0 -4
  148. package/declarations/store/-private/cache-handler/handler.d.ts +0 -62
  149. package/declarations/store/-private/cache-handler/types.d.ts +0 -98
  150. package/declarations/store/-private/cache-handler/utils.d.ts +0 -32
  151. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  152. package/declarations/store/-private/caches/identifier-cache.d.ts +0 -304
  153. package/declarations/store/-private/caches/instance-cache.d.ts +0 -65
  154. package/declarations/store/-private/caches/resource-utils.d.ts +0 -9
  155. package/declarations/store/-private/debug/utils.d.ts +0 -6
  156. package/declarations/store/-private/default-cache-policy.d.ts +0 -384
  157. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
  158. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
  159. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +0 -25
  160. package/declarations/store/-private/managers/cache-manager.d.ts +0 -443
  161. package/declarations/store/-private/managers/notification-manager.d.ts +0 -98
  162. package/declarations/store/-private/managers/record-array-manager.d.ts +0 -97
  163. package/declarations/store/-private/network/request-cache.d.ts +0 -107
  164. package/declarations/store/-private/new-core-tmp/promise-state.d.ts +0 -263
  165. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +0 -176
  166. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +0 -169
  167. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +0 -35
  168. package/declarations/store/-private/new-core-tmp/request-state.d.ts +0 -277
  169. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +0 -261
  170. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  171. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  172. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +0 -126
  173. package/declarations/store/-private/store-service.d.ts +0 -1605
  174. package/declarations/store/-private/utils/coerce-id.d.ts +0 -10
  175. package/declarations/store/-private/utils/construct-resource.d.ts +0 -6
  176. package/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
  177. package/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
  178. package/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
  179. package/declarations/store/-private.d.ts +0 -31
  180. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +0 -99
  181. package/declarations/store/-types/q/ds-model.d.ts +0 -21
  182. package/declarations/store/-types/q/identifier.d.ts +0 -20
  183. package/declarations/store/-types/q/record-instance.d.ts +0 -23
  184. package/declarations/store/-types/q/schema-service.d.ts +0 -354
  185. package/declarations/store/-types/q/store.d.ts +0 -32
  186. package/declarations/store.d.ts +0 -1
  187. package/declarations/utils/string.d.ts +0 -48
  188. package/dist/build-config/babel-macros.js +0 -1
  189. package/dist/build-config/canary-features.js +0 -1
  190. package/dist/build-config/debugging.js +0 -1
  191. package/dist/build-config/deprecations.js +0 -1
  192. package/dist/build-config/env.js +0 -1
  193. package/dist/build-config/macros.js +0 -1
  194. package/dist/build-config.js +0 -1
  195. package/dist/configure-B48bFHOl.js +0 -181
  196. package/dist/configure.js +0 -1
  197. package/dist/graph/-private.js +0 -3372
  198. package/dist/handler-C2T-IyJK.js +0 -339
  199. package/dist/reactive/-private.js +0 -1
  200. package/dist/reactive.js +0 -1988
  201. package/dist/request-state-CjLph1LP.js +0 -8139
  202. package/dist/store/-private.js +0 -3
  203. package/dist/store.js +0 -545
  204. package/dist/symbols-SIstXMLI.js +0 -44
  205. package/dist/utils/string.js +0 -92
  206. package/logos/NCC-1701-a-blue.svg +0 -4
  207. package/logos/NCC-1701-a-gold.svg +0 -4
  208. package/logos/NCC-1701-a-gold_100.svg +0 -1
  209. package/logos/NCC-1701-a-gold_base-64.txt +0 -1
  210. package/logos/NCC-1701-a.svg +0 -4
  211. package/logos/README.md +0 -4
  212. package/logos/docs-badge.svg +0 -2
  213. package/logos/ember-data-logo-dark.svg +0 -12
  214. package/logos/ember-data-logo-light.svg +0 -12
  215. package/logos/github-header.svg +0 -444
  216. package/logos/social1.png +0 -0
  217. package/logos/social2.png +0 -0
  218. package/logos/warp-drive-logo-dark.svg +0 -4
  219. package/logos/warp-drive-logo-gold.svg +0 -4
@@ -1,148 +0,0 @@
1
- import type { StableRecordIdentifier } from "../../types.js";
2
- import type { CollectionField, FieldSchema, LegacyBelongsToField, LegacyHasManyField, ResourceField } from "../../types/schema/fields.js";
3
- import type { Graph } from "./graph.js";
4
- export type EdgeCache = Record<string, Record<string, EdgeDefinition | null>>;
5
- export type RelationshipField = LegacyBelongsToField | LegacyHasManyField | ResourceField | CollectionField;
6
- export type RelationshipFieldKind = RelationshipField["kind"];
7
- export type CollectionKind = "hasMany" | "collection";
8
- export type ResourceKind = "belongsTo" | "resource";
9
- export declare const RELATIONSHIP_KINDS: string[];
10
- export declare function isLegacyField(field: FieldSchema): field is LegacyBelongsToField | LegacyHasManyField;
11
- export declare function isRelationshipField(field: FieldSchema): field is RelationshipField;
12
- export declare function temporaryConvertToLegacy(field: ResourceField | CollectionField): LegacyBelongsToField | LegacyHasManyField;
13
- /**
14
- *
15
- * Given RHS (Right Hand Side)
16
- *
17
- * ```ts
18
- * class User extends Model {
19
- * @hasMany('animal', { async: false, inverse: 'owner' }) pets;
20
- * }
21
- * ```
22
- *
23
- * Given LHS (Left Hand Side)
24
- *
25
- * ```ts
26
- * class Animal extends Model {
27
- * @belongsTo('user', { async: false, inverse: 'pets' }) owner;
28
- * }
29
- * ```
30
- *
31
- * The UpgradedMeta for the RHS would be:
32
- *
33
- * ```ts
34
- * {
35
- * kind: 'hasMany',
36
- * key: 'pets',
37
- * type: 'animal',
38
- * isAsync: false,
39
- * isImplicit: false,
40
- * isCollection: true,
41
- * isPolymorphic: false,
42
- * inverseKind: 'belongsTo',
43
- * inverseKey: 'owner',
44
- * inverseType: 'user',
45
- * inverseIsAsync: false,
46
- * inverseIsImplicit: false,
47
- * inverseIsCollection: false,
48
- * inverseIsPolymorphic: false,
49
- * }
50
- * ```
51
- *
52
- * The UpgradeMeta for the LHS would be:
53
- *
54
- * ```ts
55
- * {
56
- * kind: 'belongsTo',
57
- * key: 'owner',
58
- * type: 'user',
59
- * isAsync: false,
60
- * isImplicit: false,
61
- * isCollection: false,
62
- * isPolymorphic: false,
63
- * inverseKind: 'hasMany',
64
- * inverseKey: 'pets',
65
- * inverseType: 'animal',
66
- * inverseIsAsync: false,
67
- * inverseIsImplicit: false,
68
- * inverseIsCollection: true,
69
- * inverseIsPolymorphic: false,
70
- * }
71
- * ```
72
- *
73
- *
74
- * @class UpgradedMeta
75
- * @internal
76
- */
77
- export interface UpgradedMeta {
78
- kind: "implicit" | RelationshipFieldKind;
79
- /**
80
- * The field name on `this` record
81
- *
82
- * @internal
83
- */
84
- key: string;
85
- /**
86
- * The `type` of the related record
87
- *
88
- * @internal
89
- */
90
- type: string;
91
- isAsync: boolean;
92
- isImplicit: boolean;
93
- isCollection: boolean;
94
- isPolymorphic: boolean;
95
- resetOnRemoteUpdate: boolean;
96
- isLinksMode: boolean;
97
- inverseKind: "implicit" | RelationshipFieldKind;
98
- /**
99
- * The field name on the opposing record
100
- * @internal
101
- */
102
- inverseKey: string;
103
- /**
104
- * The `type` of `this` record
105
- * @internal
106
- */
107
- inverseType: string;
108
- inverseIsAsync: boolean;
109
- inverseIsImplicit: boolean;
110
- inverseIsCollection: boolean;
111
- inverseIsPolymorphic: boolean;
112
- inverseIsLinksMode: boolean;
113
- }
114
- export interface EdgeDefinition {
115
- lhs_key: string;
116
- lhs_modelNames: string[];
117
- lhs_baseModelName: string;
118
- lhs_relationshipName: string;
119
- lhs_definition: UpgradedMeta;
120
- lhs_isPolymorphic: boolean;
121
- rhs_key: string;
122
- rhs_modelNames: string[];
123
- rhs_baseModelName: string;
124
- rhs_relationshipName: string;
125
- rhs_definition: UpgradedMeta | null;
126
- rhs_isPolymorphic: boolean;
127
- hasInverse: boolean;
128
- /**
129
- * Whether this relationship points back at the same type.
130
- *
131
- * If the relationship is polymorphic, this will be true if
132
- * it points back at the same abstract type.
133
- *
134
- * @internal
135
- */
136
- isSelfReferential: boolean;
137
- /**
138
- * If this is a reflexive relationship, this is true
139
- * if the relationship also points back at the same
140
- * field.
141
- *
142
- * @internal
143
- */
144
- isReflexive: boolean;
145
- }
146
- export declare function isLHS(info: EdgeDefinition, type: string, key: string): boolean;
147
- export declare function isRHS(info: EdgeDefinition, type: string, key: string): boolean;
148
- export declare function upgradeDefinition(graph: Graph, identifier: StableRecordIdentifier, propertyName: string, isImplicit?: boolean): EdgeDefinition | null;
@@ -1,96 +0,0 @@
1
- export interface RelationshipState {
2
- /*
3
- This flag indicates whether we should consider the content
4
- of this relationship "known".
5
-
6
- If we have no relationship knowledge, and the relationship
7
- is `async`, we will attempt to fetch the relationship on
8
- access if it is also stale.
9
-
10
- Snapshot uses this to tell the difference between unknown
11
- (`undefined`) or empty (`null`). The reason for this is that
12
- we wouldn't want to serialize unknown relationships as `null`
13
- as that might overwrite remote state.
14
-
15
- All relationships for a newly created (`store.createRecord()`) are
16
- considered known (`hasReceivedData === true`).
17
-
18
- true when
19
- => we receive a push with either new data or explicit empty (`[]` or `null`)
20
- => the relationship is a belongsTo and we have received data from
21
- the other side.
22
-
23
- false when
24
- => we have received no signal about what data belongs in this relationship
25
- => the relationship is a hasMany and we have only received data from
26
- the other side.
27
- */
28
- hasReceivedData: boolean;
29
- /*
30
- Flag that indicates whether an empty relationship is explicitly empty
31
- (signaled by push giving us an empty array or null relationship)
32
- e.g. an API response has told us that this relationship is empty.
33
-
34
- Thus far, it does not appear that we actually need this flag; however,
35
- @runspired has found it invaluable when debugging relationship tests
36
- to determine whether (and why if so) we are in an incorrect state.
37
-
38
- true when
39
- => we receive a push with explicit empty (`[]` or `null`)
40
- => we have received no signal about what data belongs in this relationship
41
- => on initial create (as no signal is known yet)
42
-
43
- false at all other times
44
- */
45
- isEmpty: boolean;
46
- /*
47
- This flag indicates whether we should
48
- re-fetch the relationship the next time
49
- it is accessed.
50
-
51
- The difference between this flag and `shouldForceReload`
52
- is in how we treat the presence of partially missing data:
53
- - for a forced reload, we will reload the link or EVERY record
54
- - for a stale reload, we will reload the link (if present) else only MISSING records
55
-
56
- Ideally these flags could be merged, but because we don't give the
57
- request layer the option of deciding how to resolve the data being queried
58
- we are forced to differentiate for now.
59
-
60
- It is also possible for a relationship to remain stale after a forced reload; however,
61
- in this case `state.hasFailedLoadAttempt` ought to be `true`.
62
-
63
- false when
64
- => cache.isNew(identifier) on initial setup
65
- => a previously triggered request has resolved
66
- => we get relationship data via push
67
-
68
- true when
69
- => !cache.isNew(identifier) on initial setup
70
- => an inverse has been unloaded
71
- => we get a new link for the relationship
72
-
73
- TODO @runspired unskip the acceptance tests and fix these flags
74
- */
75
- isStale: boolean;
76
- hasFailedLoadAttempt: boolean;
77
- /*
78
- This flag forces fetch. `true` for a single request once `reload()`
79
- has been called `false` at all other times.
80
- */
81
- shouldForceReload: boolean;
82
- /*
83
- This flag indicates whether we should
84
- **partially** re-fetch the relationship the
85
- next time it is accessed.
86
-
87
- false when
88
- => initial setup
89
- => a previously triggered request has resolved
90
-
91
- true when
92
- => an inverse has been unloaded
93
- */
94
- hasDematerializedInverse: boolean;
95
- }
96
- export declare function createState(): RelationshipState;
@@ -1,31 +0,0 @@
1
- import type { Store } from "../../store/-private.js";
2
- import type { CacheCapabilitiesManager } from "../../types.js";
3
- import type { UpdateResourceRelationshipOperation } from "../../types/cache/operations.js";
4
- import type { UpdateRelationshipOperation } from "../../types/graph.js";
5
- import type { StableRecordIdentifier } from "../../types/identifier.js";
6
- import type { ResourceIdentifierObject } from "../../types/spec/json-api-raw.js";
7
- import type { UpgradedMeta } from "./-edge-definition.js";
8
- import type { CollectionEdge } from "./edges/collection.js";
9
- import type { ImplicitEdge } from "./edges/implicit.js";
10
- import type { ResourceEdge } from "./edges/resource.js";
11
- import type { Graph, GraphEdge } from "./graph.js";
12
- export declare function getStore(wrapper: CacheCapabilitiesManager | {
13
- _store: Store;
14
- }): Store;
15
- export declare function expandingGet<T>(cache: Record<string, Record<string, T>>, key1: string, key2: string): T | undefined;
16
- export declare function expandingSet<T>(cache: Record<string, Record<string, T>>, key1: string, key2: string, value: T): void;
17
- export declare function assertValidRelationshipPayload(graph: Graph, op: UpdateRelationshipOperation | UpdateResourceRelationshipOperation): void;
18
- export declare function isNew(identifier: StableRecordIdentifier): boolean;
19
- export declare function isBelongsTo(relationship: GraphEdge): relationship is ResourceEdge;
20
- export declare function isImplicit(relationship: GraphEdge): relationship is ImplicitEdge;
21
- export declare function isHasMany(relationship: GraphEdge): relationship is CollectionEdge;
22
- export declare function forAllRelatedIdentifiers(rel: GraphEdge, cb: (identifier: StableRecordIdentifier) => void): void;
23
- /*
24
- Removes the given identifier from BOTH remote AND local state.
25
-
26
- This method is useful when either a deletion or a rollback on a new record
27
- needs to entirely purge itself from an inverse relationship.
28
- */
29
- export declare function removeIdentifierCompletelyFromRelationship(graph: Graph, relationship: GraphEdge, value: StableRecordIdentifier, silenceNotifications?: boolean): void;
30
- export declare function notifyChange(graph: Graph, relationship: CollectionEdge | ResourceEdge): void;
31
- export declare function assertRelationshipData(store: Store, identifier: StableRecordIdentifier, data: ResourceIdentifierObject, meta: UpgradedMeta): void;
@@ -1,10 +0,0 @@
1
- // Used by the store to normalize IDs entering the store. Despite the fact
2
- // that developers may provide IDs as numbers (e.g., `store.findRecord('person', 1)`),
3
- // it is important that internally we use strings, since IDs may be serialized
4
- // and lose type information. For example, Ember's router may put a record's
5
- // ID into the URL, and if we later try to deserialize that URL and find the
6
- // corresponding record, we will not know if it is a string or a number.
7
- type Coercable = string | number | boolean | null | undefined | symbol;
8
- export declare function coerceId(id: Coercable): string | null;
9
- export declare function ensureStringId(id: Coercable): string;
10
- export {};
@@ -1,18 +0,0 @@
1
- import type { CacheCapabilitiesManager } from "../../../types.js";
2
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
3
- import { type UpgradedMeta } from "../-edge-definition.js";
4
- /*
5
- Assert that `addedRecord` has a valid type so it can be added to the
6
- relationship of the `record`.
7
-
8
- The assert basically checks if the `addedRecord` can be added to the
9
- relationship (specified via `relationshipMeta`) of the `record`.
10
-
11
- This utility should only be used internally, as both record parameters must
12
- be stable record identifiers and the `relationshipMeta` needs to be the meta
13
- information about the relationship, retrieved via
14
- `record.relationshipFor(key)`.
15
- */
16
- declare let assertPolymorphicType: (parentIdentifier: StableRecordIdentifier, parentDefinition: UpgradedMeta, addedIdentifier: StableRecordIdentifier, store: CacheCapabilitiesManager) => void;
17
- declare let assertInheritedSchema: (definition: UpgradedMeta, type: string) => void;
18
- export { assertPolymorphicType, assertInheritedSchema };
@@ -1,39 +0,0 @@
1
- import type { CollectionRelationship } from "../../../types/cache/relationship.js";
2
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
3
- import type { Links, Meta, PaginationLinks } from "../../../types/spec/json-api-raw.js";
4
- import type { UpgradedMeta } from "../-edge-definition.js";
5
- import type { RelationshipState } from "../-state.js";
6
- export interface CollectionEdge {
7
- definition: UpgradedMeta;
8
- identifier: StableRecordIdentifier;
9
- state: RelationshipState;
10
- remoteMembers: Set<StableRecordIdentifier>;
11
- remoteState: StableRecordIdentifier[];
12
- additions: Set<StableRecordIdentifier> | null;
13
- removals: Set<StableRecordIdentifier> | null;
14
- meta: Meta | null;
15
- links: Links | PaginationLinks | null;
16
- localState: StableRecordIdentifier[] | null;
17
- /**
18
- * Whether the localState for this edge is out-of-sync
19
- * with the remoteState.
20
- *
21
- * if state.hasReceivedData=false we are also
22
- * not dirty since there is nothing to sync with.
23
- *
24
- */
25
- isDirty: boolean;
26
- transactionRef: number;
27
- /**
28
- * Whether data for this edge has been accessed at least once
29
- * via `graph.getData`
30
- *
31
- */
32
- accessed: boolean;
33
- _diff?: {
34
- add: Set<StableRecordIdentifier>;
35
- del: Set<StableRecordIdentifier>;
36
- };
37
- }
38
- export declare function createCollectionEdge(definition: UpgradedMeta, identifier: StableRecordIdentifier): CollectionEdge;
39
- export declare function legacyGetCollectionRelationshipData(source: CollectionEdge, getRemoteState: boolean): CollectionRelationship;
@@ -1,43 +0,0 @@
1
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
2
- import type { UpgradedMeta } from "../-edge-definition.js";
3
- export type ImplicitMeta = UpgradedMeta & {
4
- kind: "implicit";
5
- isImplicit: true;
6
- };
7
- /**
8
- Implicit relationships are relationships which have not been declared but the inverse side exists on
9
- another record somewhere
10
-
11
- For example consider the following two models
12
-
13
- ::: code-group
14
-
15
- ```js [./models/comment.js]
16
- import { Model, attr } from '@warp-drive/legacy/model';
17
-
18
- export default class Comment extends Model {
19
- @attr text;
20
- }
21
- ```
22
-
23
- ```js [./models/post.js]
24
- import { Model, attr, hasMany } from '@warp-drive/legacy/model';
25
-
26
- export default class Post extends Model {
27
- @attr title;
28
- @hasMany('comment', { async: true, inverse: null }) comments;
29
- }
30
- ```
31
-
32
- :::
33
-
34
- Then we would have a implicit 'post' relationship for the comment record in order
35
- to be do things like remove the comment from the post if the comment were to be deleted.
36
- */
37
- export interface ImplicitEdge {
38
- definition: ImplicitMeta;
39
- identifier: StableRecordIdentifier;
40
- localMembers: Set<StableRecordIdentifier>;
41
- remoteMembers: Set<StableRecordIdentifier>;
42
- }
43
- export declare function createImplicitEdge(definition: ImplicitMeta, identifier: StableRecordIdentifier): ImplicitEdge;
@@ -1,24 +0,0 @@
1
- import type { ResourceRelationship } from "../../../types/cache/relationship.js";
2
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
3
- import type { Links, Meta, PaginationLinks } from "../../../types/spec/json-api-raw.js";
4
- import type { UpgradedMeta } from "../-edge-definition.js";
5
- import type { RelationshipState } from "../-state.js";
6
- /**
7
- * Stores the data for one side of a "single" resource relationship.
8
- *
9
- * @class ResourceEdge
10
- * @internal
11
- */
12
- export interface ResourceEdge {
13
- definition: UpgradedMeta;
14
- identifier: StableRecordIdentifier;
15
- state: RelationshipState;
16
- localState: StableRecordIdentifier | null;
17
- remoteState: StableRecordIdentifier | null;
18
- meta: Meta | null;
19
- links: Links | PaginationLinks | null;
20
- transactionRef: number;
21
- accessed: boolean;
22
- }
23
- export declare function createResourceEdge(definition: UpgradedMeta, identifier: StableRecordIdentifier): ResourceEdge;
24
- export declare function legacyGetResourceRelationshipData(source: ResourceEdge, getRemoteState: boolean): ResourceRelationship;
@@ -1,90 +0,0 @@
1
- import type { CacheCapabilitiesManager, StableRecordIdentifier } from "../../types.js";
2
- import type { RelationshipDiff } from "../../types/cache.js";
3
- import type { MergeOperation } from "../../types/cache/operations.js";
4
- import type { CollectionRelationship, ResourceRelationship } from "../../types/cache/relationship.js";
5
- import type { DeleteRecordOperation, LocalRelationshipOperation, RemoteRelationshipOperation } from "../../types/graph.js";
6
- import type { EdgeCache, UpgradedMeta } from "./-edge-definition.js";
7
- import { type CollectionEdge } from "./edges/collection.js";
8
- import type { ImplicitEdge } from "./edges/implicit.js";
9
- import { type ResourceEdge } from "./edges/resource.js";
10
- export type GraphEdge = ImplicitEdge | CollectionEdge | ResourceEdge;
11
- export declare const Graphs: Map<CacheCapabilitiesManager, Graph>;
12
- type PendingOps = {
13
- belongsTo?: Map<string, Map<string, RemoteRelationshipOperation[]>>;
14
- hasMany?: Map<string, Map<string, RemoteRelationshipOperation[]>>;
15
- deletions: DeleteRecordOperation[];
16
- };
17
- /*
18
- * Graph acts as the cache for relationship data. It allows for
19
- * us to ask about and update relationships for a given Identifier
20
- * without requiring other objects for that Identifier to be
21
- * instantiated (such as `RecordData` or a `Record`)
22
- *
23
- * This also allows for us to make more substantive changes to relationships
24
- * with increasingly minor alterations to other portions of the internals
25
- * over time.
26
- *
27
- * The graph is made up of nodes and edges. Each unique identifier gets
28
- * its own node, which is a dictionary with a list of that node's edges
29
- * (or connections) to other nodes. In `Model` terms, a node represents a
30
- * record instance, with each key (an edge) in the dictionary correlating
31
- * to either a `hasMany` or `belongsTo` field on that record instance.
32
- *
33
- * The value for each key, or `edge` is the identifier(s) the node relates
34
- * to in the graph from that key.
35
- */
36
- export declare class Graph {
37
- _definitionCache: EdgeCache;
38
- _metaCache: Record<string, Record<string, UpgradedMeta>>;
39
- _potentialPolymorphicTypes: Record<string, Record<string, boolean>>;
40
- identifiers: Map<StableRecordIdentifier, Record<string, GraphEdge>>;
41
- store: CacheCapabilitiesManager;
42
- isDestroyed: boolean;
43
- _willSyncRemote: boolean;
44
- _willSyncLocal: boolean;
45
- silenceNotifications: boolean;
46
- _pushedUpdates: PendingOps;
47
- _updatedRelationships: Set<CollectionEdge>;
48
- _transaction: number | null;
49
- _removing: StableRecordIdentifier | null;
50
- constructor(store: CacheCapabilitiesManager);
51
- has(identifier: StableRecordIdentifier, propertyName: string): boolean;
52
- getDefinition(identifier: StableRecordIdentifier, propertyName: string): UpgradedMeta;
53
- get(identifier: StableRecordIdentifier, propertyName: string): GraphEdge;
54
- getData(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
55
- getRemoteData(identifier: StableRecordIdentifier, propertyName: string): ResourceRelationship | CollectionRelationship;
56
- /*
57
- * Allows for the graph to dynamically discover polymorphic connections
58
- * without needing to walk prototype chains.
59
- *
60
- * Used by edges when an added `type` does not match the expected `type`
61
- * for that edge.
62
- *
63
- * Currently we assert before calling this. For a public API we will want
64
- * to call out to the schema manager to ask if we should consider these
65
- * types as equivalent for a given relationship.
66
- */
67
- registerPolymorphicType(type1: string, type2: string): void;
68
- isReleasable(identifier: StableRecordIdentifier): boolean;
69
- unload(identifier: StableRecordIdentifier, silenceNotifications?: boolean): void;
70
- _isDirty(identifier: StableRecordIdentifier, field: string): boolean;
71
- getChanged(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
72
- hasChanged(identifier: StableRecordIdentifier): boolean;
73
- rollback(identifier: StableRecordIdentifier): string[];
74
- remove(identifier: StableRecordIdentifier): void;
75
- /*
76
- * Remote state changes
77
- */
78
- push(op: RemoteRelationshipOperation): void;
79
- /*
80
- * Local state changes
81
- */
82
- update(op: RemoteRelationshipOperation | MergeOperation, isRemote: true): void;
83
- update(op: LocalRelationshipOperation, isRemote?: false): void;
84
- _scheduleLocalSync(relationship: CollectionEdge): void;
85
- _flushRemoteQueue(): void;
86
- _addToTransaction(relationship: CollectionEdge | ResourceEdge): void;
87
- _flushLocalQueue(): void;
88
- destroy(): void;
89
- }
90
- export {};
@@ -1,8 +0,0 @@
1
- import type { Link, LinkObject } from "../../types/spec/json-api-raw.js";
2
- /*
3
- This method normalizes a link to an "links object". If the passed link is
4
- already an object it's returned without any modifications.
5
-
6
- See http://jsonapi.org/format/#document-links for more information.
7
- */
8
- export default function _normalizeLink(link: Link): LinkObject | null;
@@ -1,4 +0,0 @@
1
- import type { AddToResourceRelationshipMutation } from "../../../types/cache/mutations.js";
2
- import type { AddToResourceRelationshipOperation } from "../../../types/cache/operations.js";
3
- import type { Graph } from "../graph.js";
4
- export default function addToRelatedRecords(graph: Graph, op: AddToResourceRelationshipOperation | AddToResourceRelationshipMutation, isRemote: boolean): void;
@@ -1,3 +0,0 @@
1
- import type { MergeOperation } from "../../../types/cache/operations.js";
2
- import type { Graph, GraphEdge } from "../graph.js";
3
- export declare function mergeIdentifier(graph: Graph, op: MergeOperation, relationships: Record<string, GraphEdge>): void;
@@ -1,4 +0,0 @@
1
- import type { RemoveFromResourceRelationshipMutation } from "../../../types/cache/mutations.js";
2
- import type { RemoveFromResourceRelationshipOperation } from "../../../types/cache/operations.js";
3
- import type { Graph } from "../graph.js";
4
- export default function removeFromRelatedRecords(graph: Graph, op: RemoveFromResourceRelationshipOperation | RemoveFromResourceRelationshipMutation, isRemote: boolean): void;
@@ -1,3 +0,0 @@
1
- import type { ReplaceRelatedRecordOperation } from "../../../types/graph.js";
2
- import type { Graph } from "../graph.js";
3
- export default function replaceRelatedRecord(graph: Graph, op: ReplaceRelatedRecordOperation, isRemote?: boolean): void;
@@ -1,62 +0,0 @@
1
- import type { StableRecordIdentifier } from "../../../types.js";
2
- import type { ReplaceRelatedRecordsOperation } from "../../../types/graph.js";
3
- import type { Graph } from "../graph.js";
4
- /*
5
- case many:1
6
- ========
7
- In a bi-directional graph with Many:1 edges, adding a value
8
- results in up-to 3 discrete value transitions, while removing
9
- a value is only 2 transitions.
10
-
11
- For adding C to A
12
- If: A <<-> B, C <->> D is the initial state,
13
- and: B <->> A <<-> C, D is the final state
14
-
15
- then we would undergo the following transitions.
16
-
17
- add C to A
18
- remove C from D
19
- add A to C
20
-
21
- For removing B from A
22
- If: A <<-> B, C <->> D is the initial state,
23
- and: A, B, C <->> D is the final state
24
-
25
- then we would undergo the following transitions.
26
-
27
- remove B from A
28
- remove A from B
29
-
30
- case many:many
31
- ===========
32
- In a bi-directional graph with Many:Many edges, adding or
33
- removing a value requires only 2 value transitions.
34
-
35
- For Adding
36
- If: A<<->>B, C<<->>D is the initial state (double arrows representing the many side)
37
- And: D<<->>C<<->>A<<->>B is the final state
38
-
39
- Then we would undergo two transitions.
40
-
41
- add C to A.
42
- add A to C
43
-
44
- For Removing
45
- If: A<<->>B, C<<->>D is the initial state (double arrows representing the many side)
46
- And: A, B, C<<->>D is the final state
47
-
48
- Then we would undergo two transitions.
49
-
50
- remove B from A
51
- remove A from B
52
-
53
- case many:?
54
- ========
55
- In a uni-directional graph with Many:? edges (modeled in WarpDrive with `inverse:null`) with
56
- artificial (implicit) inverses, replacing a value results in 2 discrete value transitions.
57
- This is because a Many:? relationship is effectively Many:Many.
58
- */
59
- export default function replaceRelatedRecords(graph: Graph, op: ReplaceRelatedRecordsOperation, isRemote: boolean): void;
60
- export declare function addToInverse(graph: Graph, identifier: StableRecordIdentifier, key: string, value: StableRecordIdentifier, isRemote: boolean): void;
61
- export declare function notifyInverseOfPotentialMaterialization(graph: Graph, identifier: StableRecordIdentifier, key: string, value: StableRecordIdentifier, isRemote: boolean): void;
62
- export declare function removeFromInverse(graph: Graph, identifier: StableRecordIdentifier, key: string, value: StableRecordIdentifier, isRemote: boolean): void;
@@ -1,13 +0,0 @@
1
- import type { Store } from "../../../index.js";
2
- import type { StableRecordIdentifier } from "../../../types.js";
3
- import type { UpdateResourceRelationshipOperation } from "../../../types/cache/operations.js";
4
- import type { UpdateRelationshipOperation } from "../../../types/graph.js";
5
- import type { ExistingResourceIdentifierObject, NewResourceIdentifierObject } from "../../../types/spec/json-api-raw.js";
6
- import type { Graph } from "../graph.js";
7
- type IdentifierCache = Store["identifierCache"];
8
- /*
9
- Updates the "canonical" or "remote" state of a relationship, replacing any existing
10
- state and blowing away any local changes (excepting new records).
11
- */
12
- export default function updateRelationshipOperation(graph: Graph, op: UpdateRelationshipOperation | UpdateResourceRelationshipOperation): void;
13
- export declare function upgradeIdentifiers(arr: (ExistingResourceIdentifierObject | NewResourceIdentifierObject | StableRecordIdentifier)[], cache: IdentifierCache): StableRecordIdentifier[];
@@ -1,13 +0,0 @@
1
- import type { Store } from "../index.js";
2
- import type { CacheCapabilitiesManager } from "../types.js";
3
- import { Graph } from "./-private/graph.js";
4
- export { isBelongsTo } from "./-private/-utils.js";
5
- export type { CollectionEdge } from "./-private/edges/collection.js";
6
- export type { ResourceEdge } from "./-private/edges/resource.js";
7
- export type { ImplicitEdge } from "./-private/edges/implicit.js";
8
- export type { GraphEdge } from "./-private/graph.js";
9
- export type { UpgradedMeta } from "./-private/-edge-definition.js";
10
- export type { Graph };
11
- export declare function peekGraph(store: CacheCapabilitiesManager | Store): Graph | undefined;
12
- export type peekGraph = typeof peekGraph;
13
- export declare function graphFor(store: CacheCapabilitiesManager | Store): Graph;