@warp-drive/core 5.6.0-alpha.11

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 (337) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE.md +23 -0
  3. package/README.md +70 -0
  4. package/addon-main.cjs +5 -0
  5. package/cjs-dist/addon-shim.cjs +1 -0
  6. package/cjs-dist/cjs-set-config.cjs +1 -0
  7. package/declarations/build-config/babel-macros.d.ts +2 -0
  8. package/declarations/build-config/babel-macros.d.ts.map +1 -0
  9. package/declarations/build-config/canary-features.d.ts +2 -0
  10. package/declarations/build-config/canary-features.d.ts.map +1 -0
  11. package/declarations/build-config/debugging.d.ts +2 -0
  12. package/declarations/build-config/debugging.d.ts.map +1 -0
  13. package/declarations/build-config/deprecations.d.ts +2 -0
  14. package/declarations/build-config/deprecations.d.ts.map +1 -0
  15. package/declarations/build-config/env.d.ts +2 -0
  16. package/declarations/build-config/env.d.ts.map +1 -0
  17. package/declarations/build-config/macros.d.ts +2 -0
  18. package/declarations/build-config/macros.d.ts.map +1 -0
  19. package/declarations/build-config.d.ts +2 -0
  20. package/declarations/build-config.d.ts.map +1 -0
  21. package/declarations/configure.d.ts +8 -0
  22. package/declarations/configure.d.ts.map +1 -0
  23. package/declarations/graph/-private/-diff.d.ts +33 -0
  24. package/declarations/graph/-private/-diff.d.ts.map +1 -0
  25. package/declarations/graph/-private/-edge-definition.d.ts +149 -0
  26. package/declarations/graph/-private/-edge-definition.d.ts.map +1 -0
  27. package/declarations/graph/-private/-state.d.ts +10 -0
  28. package/declarations/graph/-private/-state.d.ts.map +1 -0
  29. package/declarations/graph/-private/-utils.d.ts +26 -0
  30. package/declarations/graph/-private/-utils.d.ts.map +1 -0
  31. package/declarations/graph/-private/coerce-id.d.ts +5 -0
  32. package/declarations/graph/-private/coerce-id.d.ts.map +1 -0
  33. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +7 -0
  34. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
  35. package/declarations/graph/-private/edges/collection.d.ts +40 -0
  36. package/declarations/graph/-private/edges/collection.d.ts.map +1 -0
  37. package/declarations/graph/-private/edges/implicit.d.ts +14 -0
  38. package/declarations/graph/-private/edges/implicit.d.ts.map +1 -0
  39. package/declarations/graph/-private/edges/resource.d.ts +25 -0
  40. package/declarations/graph/-private/edges/resource.d.ts.map +1 -0
  41. package/declarations/graph/-private/graph.d.ts +55 -0
  42. package/declarations/graph/-private/graph.d.ts.map +1 -0
  43. package/declarations/graph/-private/normalize-link.d.ts +3 -0
  44. package/declarations/graph/-private/normalize-link.d.ts.map +1 -0
  45. package/declarations/graph/-private/operations/add-to-related-records.d.ts +5 -0
  46. package/declarations/graph/-private/operations/add-to-related-records.d.ts.map +1 -0
  47. package/declarations/graph/-private/operations/merge-identifier.d.ts +4 -0
  48. package/declarations/graph/-private/operations/merge-identifier.d.ts.map +1 -0
  49. package/declarations/graph/-private/operations/remove-from-related-records.d.ts +5 -0
  50. package/declarations/graph/-private/operations/remove-from-related-records.d.ts.map +1 -0
  51. package/declarations/graph/-private/operations/replace-related-record.d.ts +4 -0
  52. package/declarations/graph/-private/operations/replace-related-record.d.ts.map +1 -0
  53. package/declarations/graph/-private/operations/replace-related-records.d.ts +8 -0
  54. package/declarations/graph/-private/operations/replace-related-records.d.ts.map +1 -0
  55. package/declarations/graph/-private/operations/update-relationship.d.ts +11 -0
  56. package/declarations/graph/-private/operations/update-relationship.d.ts.map +1 -0
  57. package/declarations/graph/-private.d.ts +14 -0
  58. package/declarations/graph/-private.d.ts.map +1 -0
  59. package/declarations/index.d.ts +15 -0
  60. package/declarations/index.d.ts.map +1 -0
  61. package/declarations/reactive/-private/document.d.ts +147 -0
  62. package/declarations/reactive/-private/document.d.ts.map +1 -0
  63. package/declarations/reactive/-private/fields/compute.d.ts +40 -0
  64. package/declarations/reactive/-private/fields/compute.d.ts.map +1 -0
  65. package/declarations/reactive/-private/fields/managed-array.d.ts +23 -0
  66. package/declarations/reactive/-private/fields/managed-array.d.ts.map +1 -0
  67. package/declarations/reactive/-private/fields/managed-object.d.ts +21 -0
  68. package/declarations/reactive/-private/fields/managed-object.d.ts.map +1 -0
  69. package/declarations/reactive/-private/fields/many-array-manager.d.ts +20 -0
  70. package/declarations/reactive/-private/fields/many-array-manager.d.ts.map +1 -0
  71. package/declarations/reactive/-private/hooks.d.ts +6 -0
  72. package/declarations/reactive/-private/hooks.d.ts.map +1 -0
  73. package/declarations/reactive/-private/record.d.ts +61 -0
  74. package/declarations/reactive/-private/record.d.ts.map +1 -0
  75. package/declarations/reactive/-private/schema.d.ts +180 -0
  76. package/declarations/reactive/-private/schema.d.ts.map +1 -0
  77. package/declarations/reactive/-private/symbols.d.ts +11 -0
  78. package/declarations/reactive/-private/symbols.d.ts.map +1 -0
  79. package/declarations/reactive/-private.d.ts +2 -0
  80. package/declarations/reactive/-private.d.ts.map +1 -0
  81. package/declarations/reactive.d.ts +5 -0
  82. package/declarations/reactive.d.ts.map +1 -0
  83. package/declarations/request/-private/context.d.ts +42 -0
  84. package/declarations/request/-private/context.d.ts.map +1 -0
  85. package/declarations/request/-private/debug.d.ts +5 -0
  86. package/declarations/request/-private/debug.d.ts.map +1 -0
  87. package/declarations/request/-private/fetch.d.ts +40 -0
  88. package/declarations/request/-private/fetch.d.ts.map +1 -0
  89. package/declarations/request/-private/future.d.ts +8 -0
  90. package/declarations/request/-private/future.d.ts.map +1 -0
  91. package/declarations/request/-private/manager.d.ts +160 -0
  92. package/declarations/request/-private/manager.d.ts.map +1 -0
  93. package/declarations/request/-private/promise-cache.d.ts +20 -0
  94. package/declarations/request/-private/promise-cache.d.ts.map +1 -0
  95. package/declarations/request/-private/types.d.ts +236 -0
  96. package/declarations/request/-private/types.d.ts.map +1 -0
  97. package/declarations/request/-private/utils.d.ts +16 -0
  98. package/declarations/request/-private/utils.d.ts.map +1 -0
  99. package/declarations/request.d.ts +6 -0
  100. package/declarations/request.d.ts.map +1 -0
  101. package/declarations/store/-private/cache-handler/handler.d.ts +57 -0
  102. package/declarations/store/-private/cache-handler/handler.d.ts.map +1 -0
  103. package/declarations/store/-private/cache-handler/types.d.ts +99 -0
  104. package/declarations/store/-private/cache-handler/types.d.ts.map +1 -0
  105. package/declarations/store/-private/cache-handler/utils.d.ts +32 -0
  106. package/declarations/store/-private/cache-handler/utils.d.ts.map +1 -0
  107. package/declarations/store/-private/caches/cache-utils.d.ts +9 -0
  108. package/declarations/store/-private/caches/cache-utils.d.ts.map +1 -0
  109. package/declarations/store/-private/caches/identifier-cache.d.ts +316 -0
  110. package/declarations/store/-private/caches/identifier-cache.d.ts.map +1 -0
  111. package/declarations/store/-private/caches/instance-cache.d.ts +65 -0
  112. package/declarations/store/-private/caches/instance-cache.d.ts.map +1 -0
  113. package/declarations/store/-private/caches/resource-utils.d.ts +10 -0
  114. package/declarations/store/-private/caches/resource-utils.d.ts.map +1 -0
  115. package/declarations/store/-private/debug/utils.d.ts +7 -0
  116. package/declarations/store/-private/debug/utils.d.ts.map +1 -0
  117. package/declarations/store/-private/default-cache-policy.d.ts +383 -0
  118. package/declarations/store/-private/default-cache-policy.d.ts.map +1 -0
  119. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +164 -0
  120. package/declarations/store/-private/legacy-model-support/record-reference.d.ts.map +1 -0
  121. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +17 -0
  122. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts.map +1 -0
  123. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +26 -0
  124. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts.map +1 -0
  125. package/declarations/store/-private/managers/cache-manager.d.ts +428 -0
  126. package/declarations/store/-private/managers/cache-manager.d.ts.map +1 -0
  127. package/declarations/store/-private/managers/notification-manager.d.ts +93 -0
  128. package/declarations/store/-private/managers/notification-manager.d.ts.map +1 -0
  129. package/declarations/store/-private/managers/record-array-manager.d.ts +98 -0
  130. package/declarations/store/-private/managers/record-array-manager.d.ts.map +1 -0
  131. package/declarations/store/-private/network/request-cache.d.ts +104 -0
  132. package/declarations/store/-private/network/request-cache.d.ts.map +1 -0
  133. package/declarations/store/-private/new-core-tmp/promise-state.d.ts +255 -0
  134. package/declarations/store/-private/new-core-tmp/promise-state.d.ts.map +1 -0
  135. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +93 -0
  136. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts.map +1 -0
  137. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +170 -0
  138. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts.map +1 -0
  139. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +30 -0
  140. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts.map +1 -0
  141. package/declarations/store/-private/new-core-tmp/request-state.d.ts +255 -0
  142. package/declarations/store/-private/new-core-tmp/request-state.d.ts.map +1 -0
  143. package/declarations/store/-private/record-arrays/identifier-array.d.ts +141 -0
  144. package/declarations/store/-private/record-arrays/identifier-array.d.ts.map +1 -0
  145. package/declarations/store/-private/record-arrays/many-array.d.ts +199 -0
  146. package/declarations/store/-private/record-arrays/many-array.d.ts.map +1 -0
  147. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +116 -0
  148. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts.map +1 -0
  149. package/declarations/store/-private/store-service.d.ts +1597 -0
  150. package/declarations/store/-private/store-service.d.ts.map +1 -0
  151. package/declarations/store/-private/store-service.type-test.d.ts +2 -0
  152. package/declarations/store/-private/store-service.type-test.d.ts.map +1 -0
  153. package/declarations/store/-private/utils/coerce-id.d.ts +5 -0
  154. package/declarations/store/-private/utils/coerce-id.d.ts.map +1 -0
  155. package/declarations/store/-private/utils/construct-resource.d.ts +7 -0
  156. package/declarations/store/-private/utils/construct-resource.d.ts.map +1 -0
  157. package/declarations/store/-private/utils/is-non-empty-string.d.ts +2 -0
  158. package/declarations/store/-private/utils/is-non-empty-string.d.ts.map +1 -0
  159. package/declarations/store/-private/utils/normalize-model-name.d.ts +2 -0
  160. package/declarations/store/-private/utils/normalize-model-name.d.ts.map +1 -0
  161. package/declarations/store/-private/utils/uuid-polyfill.d.ts +2 -0
  162. package/declarations/store/-private/utils/uuid-polyfill.d.ts.map +1 -0
  163. package/declarations/store/-private.d.ts +27 -0
  164. package/declarations/store/-private.d.ts.map +1 -0
  165. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +100 -0
  166. package/declarations/store/-types/q/cache-capabilities-manager.d.ts.map +1 -0
  167. package/declarations/store/-types/q/ds-model.d.ts +22 -0
  168. package/declarations/store/-types/q/ds-model.d.ts.map +1 -0
  169. package/declarations/store/-types/q/identifier.d.ts +21 -0
  170. package/declarations/store/-types/q/identifier.d.ts.map +1 -0
  171. package/declarations/store/-types/q/promise-proxies.d.ts +2 -0
  172. package/declarations/store/-types/q/promise-proxies.d.ts.map +1 -0
  173. package/declarations/store/-types/q/record-data-json-api.d.ts +31 -0
  174. package/declarations/store/-types/q/record-data-json-api.d.ts.map +1 -0
  175. package/declarations/store/-types/q/record-instance.d.ts +24 -0
  176. package/declarations/store/-types/q/record-instance.d.ts.map +1 -0
  177. package/declarations/store/-types/q/schema-service.d.ts +331 -0
  178. package/declarations/store/-types/q/schema-service.d.ts.map +1 -0
  179. package/declarations/store/-types/q/store.d.ts +35 -0
  180. package/declarations/store/-types/q/store.d.ts.map +1 -0
  181. package/declarations/store.d.ts +2 -0
  182. package/declarations/store.d.ts.map +1 -0
  183. package/declarations/types/-private.d.ts +14 -0
  184. package/declarations/types/-private.d.ts.map +1 -0
  185. package/declarations/types/cache/aliases.d.ts +2 -0
  186. package/declarations/types/cache/aliases.d.ts.map +1 -0
  187. package/declarations/types/cache/change.d.ts +7 -0
  188. package/declarations/types/cache/change.d.ts.map +1 -0
  189. package/declarations/types/cache/mutations.d.ts +39 -0
  190. package/declarations/types/cache/mutations.d.ts.map +1 -0
  191. package/declarations/types/cache/operations.d.ts +72 -0
  192. package/declarations/types/cache/operations.d.ts.map +1 -0
  193. package/declarations/types/cache/relationship.d.ts +14 -0
  194. package/declarations/types/cache/relationship.d.ts.map +1 -0
  195. package/declarations/types/cache.d.ts +492 -0
  196. package/declarations/types/cache.d.ts.map +1 -0
  197. package/declarations/types/graph.d.ts +48 -0
  198. package/declarations/types/graph.d.ts.map +1 -0
  199. package/declarations/types/identifier.d.ts +111 -0
  200. package/declarations/types/identifier.d.ts.map +1 -0
  201. package/declarations/types/json/raw.d.ts +7 -0
  202. package/declarations/types/json/raw.d.ts.map +1 -0
  203. package/declarations/types/params.d.ts +10 -0
  204. package/declarations/types/params.d.ts.map +1 -0
  205. package/declarations/types/record.d.ts +96 -0
  206. package/declarations/types/record.d.ts.map +1 -0
  207. package/declarations/types/record.type-test.d.ts +2 -0
  208. package/declarations/types/record.type-test.d.ts.map +1 -0
  209. package/declarations/types/request.d.ts +308 -0
  210. package/declarations/types/request.d.ts.map +1 -0
  211. package/declarations/types/request.type-test.d.ts +2 -0
  212. package/declarations/types/request.type-test.d.ts.map +1 -0
  213. package/declarations/types/runtime.d.ts +15 -0
  214. package/declarations/types/runtime.d.ts.map +1 -0
  215. package/declarations/types/schema/concepts.d.ts +17 -0
  216. package/declarations/types/schema/concepts.d.ts.map +1 -0
  217. package/declarations/types/schema/fields.d.ts +1674 -0
  218. package/declarations/types/schema/fields.d.ts.map +1 -0
  219. package/declarations/types/schema/fields.type-test.d.ts +2 -0
  220. package/declarations/types/schema/fields.type-test.d.ts.map +1 -0
  221. package/declarations/types/spec/document.d.ts +31 -0
  222. package/declarations/types/spec/document.d.ts.map +1 -0
  223. package/declarations/types/spec/error.d.ts +19 -0
  224. package/declarations/types/spec/error.d.ts.map +1 -0
  225. package/declarations/types/spec/json-api-raw.d.ts +142 -0
  226. package/declarations/types/spec/json-api-raw.d.ts.map +1 -0
  227. package/declarations/types/symbols.d.ts +79 -0
  228. package/declarations/types/symbols.d.ts.map +1 -0
  229. package/declarations/types/utils.d.ts +5 -0
  230. package/declarations/types/utils.d.ts.map +1 -0
  231. package/declarations/types.d.ts +12 -0
  232. package/declarations/types.d.ts.map +1 -0
  233. package/declarations/utils/string.d.ts +45 -0
  234. package/declarations/utils/string.d.ts.map +1 -0
  235. package/dist/build-config/babel-macros.js +1 -0
  236. package/dist/build-config/babel-macros.js.map +1 -0
  237. package/dist/build-config/canary-features.js +1 -0
  238. package/dist/build-config/canary-features.js.map +1 -0
  239. package/dist/build-config/debugging.js +1 -0
  240. package/dist/build-config/debugging.js.map +1 -0
  241. package/dist/build-config/deprecations.js +1 -0
  242. package/dist/build-config/deprecations.js.map +1 -0
  243. package/dist/build-config/env.js +1 -0
  244. package/dist/build-config/env.js.map +1 -0
  245. package/dist/build-config/macros.js +1 -0
  246. package/dist/build-config/macros.js.map +1 -0
  247. package/dist/build-config.js +1 -0
  248. package/dist/build-config.js.map +1 -0
  249. package/dist/configure-Bz49BEZQ.js +145 -0
  250. package/dist/configure-Bz49BEZQ.js.map +1 -0
  251. package/dist/configure.js +1 -0
  252. package/dist/configure.js.map +1 -0
  253. package/dist/context-DE5sFezZ.js +636 -0
  254. package/dist/context-DE5sFezZ.js.map +1 -0
  255. package/dist/graph/-private.js +3364 -0
  256. package/dist/graph/-private.js.map +1 -0
  257. package/dist/handler-DYUefHNU.js +339 -0
  258. package/dist/handler-DYUefHNU.js.map +1 -0
  259. package/dist/index.js +382 -0
  260. package/dist/index.js.map +1 -0
  261. package/dist/reactive/-private.js +1 -0
  262. package/dist/reactive/-private.js.map +1 -0
  263. package/dist/reactive.js +1802 -0
  264. package/dist/reactive.js.map +1 -0
  265. package/dist/request-state-Bv5CY_H0.js +7358 -0
  266. package/dist/request-state-Bv5CY_H0.js.map +1 -0
  267. package/dist/request.js +1 -0
  268. package/dist/request.js.map +1 -0
  269. package/dist/store/-private.js +3 -0
  270. package/dist/store/-private.js.map +1 -0
  271. package/dist/store.js +545 -0
  272. package/dist/store.js.map +1 -0
  273. package/dist/symbols-DyqeYQTe.js +44 -0
  274. package/dist/symbols-DyqeYQTe.js.map +1 -0
  275. package/dist/types/-private.js +79 -0
  276. package/dist/types/-private.js.map +1 -0
  277. package/dist/types/cache/aliases.js +0 -0
  278. package/dist/types/cache/aliases.js.map +1 -0
  279. package/dist/types/cache/change.js +0 -0
  280. package/dist/types/cache/change.js.map +1 -0
  281. package/dist/types/cache/mutations.js +0 -0
  282. package/dist/types/cache/mutations.js.map +1 -0
  283. package/dist/types/cache/operations.js +0 -0
  284. package/dist/types/cache/operations.js.map +1 -0
  285. package/dist/types/cache/relationship.js +0 -0
  286. package/dist/types/cache/relationship.js.map +1 -0
  287. package/dist/types/cache.js +0 -0
  288. package/dist/types/cache.js.map +1 -0
  289. package/dist/types/graph.js +0 -0
  290. package/dist/types/graph.js.map +1 -0
  291. package/dist/types/identifier.js +89 -0
  292. package/dist/types/identifier.js.map +1 -0
  293. package/dist/types/json/raw.js +0 -0
  294. package/dist/types/json/raw.js.map +1 -0
  295. package/dist/types/params.js +0 -0
  296. package/dist/types/params.js.map +1 -0
  297. package/dist/types/record.js +64 -0
  298. package/dist/types/record.js.map +1 -0
  299. package/dist/types/request.js +33 -0
  300. package/dist/types/request.js.map +1 -0
  301. package/dist/types/runtime.js +34 -0
  302. package/dist/types/runtime.js.map +1 -0
  303. package/dist/types/schema/concepts.js +0 -0
  304. package/dist/types/schema/concepts.js.map +1 -0
  305. package/dist/types/schema/fields.js +470 -0
  306. package/dist/types/schema/fields.js.map +1 -0
  307. package/dist/types/schema/fields.type-test.js +0 -0
  308. package/dist/types/schema/fields.type-test.js.map +1 -0
  309. package/dist/types/spec/document.js +0 -0
  310. package/dist/types/spec/document.js.map +1 -0
  311. package/dist/types/spec/error.js +0 -0
  312. package/dist/types/spec/error.js.map +1 -0
  313. package/dist/types/spec/json-api-raw.js +0 -0
  314. package/dist/types/spec/json-api-raw.js.map +1 -0
  315. package/dist/types/symbols.js +84 -0
  316. package/dist/types/symbols.js.map +1 -0
  317. package/dist/types/utils.js +0 -0
  318. package/dist/types/utils.js.map +1 -0
  319. package/dist/types.js +0 -0
  320. package/dist/types.js.map +1 -0
  321. package/dist/utils/string.js +92 -0
  322. package/dist/utils/string.js.map +1 -0
  323. package/logos/NCC-1701-a-blue.svg +4 -0
  324. package/logos/NCC-1701-a-gold.svg +4 -0
  325. package/logos/NCC-1701-a-gold_100.svg +1 -0
  326. package/logos/NCC-1701-a-gold_base-64.txt +1 -0
  327. package/logos/NCC-1701-a.svg +4 -0
  328. package/logos/README.md +4 -0
  329. package/logos/docs-badge.svg +2 -0
  330. package/logos/ember-data-logo-dark.svg +12 -0
  331. package/logos/ember-data-logo-light.svg +12 -0
  332. package/logos/github-header.svg +444 -0
  333. package/logos/social1.png +0 -0
  334. package/logos/social2.png +0 -0
  335. package/logos/warp-drive-logo-dark.svg +4 -0
  336. package/logos/warp-drive-logo-gold.svg +4 -0
  337. package/package.json +70 -0
@@ -0,0 +1,492 @@
1
+ import type { ResourceBlob } from './cache/aliases.ts';
2
+ import type { Change } from './cache/change.ts';
3
+ import type { Mutation } from './cache/mutations.ts';
4
+ import type { Operation } from './cache/operations.ts';
5
+ import type { CollectionRelationship, ResourceRelationship } from './cache/relationship.ts';
6
+ import type { StableDocumentIdentifier, StableRecordIdentifier } from './identifier.ts';
7
+ import type { Value } from './json/raw.ts';
8
+ import type { TypeFromInstanceOrString } from './record.ts';
9
+ import type { RequestContext, StructuredDataDocument, StructuredDocument } from './request.ts';
10
+ import type { ResourceDocument, SingleResourceDataDocument } from './spec/document.ts';
11
+ import type { ApiError } from './spec/error.ts';
12
+ /**
13
+ * A hash of changed attributes with the key being the attribute name and the value being an
14
+ * array of `[oldValue, newValue]`.
15
+ *
16
+ * @internal
17
+ */
18
+ export type ChangedAttributesHash = Record<string, [Value | undefined, Value]>;
19
+ export type RelationshipDiff = {
20
+ kind: 'collection';
21
+ remoteState: StableRecordIdentifier[];
22
+ additions: Set<StableRecordIdentifier>;
23
+ removals: Set<StableRecordIdentifier>;
24
+ localState: StableRecordIdentifier[];
25
+ reordered: boolean;
26
+ } | {
27
+ kind: 'resource';
28
+ remoteState: StableRecordIdentifier | null;
29
+ localState: StableRecordIdentifier | null;
30
+ };
31
+ /**
32
+ * The interface for WarpDrive Caches.
33
+ *
34
+ * A Cache handles in-memory storage of Document and Resource
35
+ * data.
36
+ *
37
+ * @class (Interface) Cache
38
+ * @public
39
+ */
40
+ export interface Cache {
41
+ /**
42
+ * The Cache Version that this implementation implements.
43
+ *
44
+ * @type {'2'}
45
+ * @public
46
+ * @property version
47
+ */
48
+ version: '2';
49
+ /**
50
+ * Cache the response to a request
51
+ *
52
+ * Unlike `store.push` which has UPSERT
53
+ * semantics, `put` has `replace` semantics similar to
54
+ * the `http` method `PUT`
55
+ *
56
+ * the individually cacheable resource data it may contain
57
+ * should upsert, but the document data surrounding it should
58
+ * fully replace any existing information
59
+ *
60
+ * Note that in order to support inserting arbitrary data
61
+ * to the cache that did not originate from a request `put`
62
+ * should expect to sometimes encounter a document with only
63
+ * a `content` member and therefor must not assume the existence
64
+ * of `request` and `response` on the document.
65
+ *
66
+ * @param {StructuredDocument} doc
67
+ * @return {ResourceDocument}
68
+ * @public
69
+ */
70
+ put<T>(doc: StructuredDocument<T> | {
71
+ content: T;
72
+ }): ResourceDocument;
73
+ /**
74
+ * Update the "remote" or "canonical" (persisted) state of the Cache
75
+ * by merging new information into the existing state.
76
+ *
77
+ * @public
78
+ * @param {Operation | Operation[]} op the operation(s) to perform
79
+ * @return {void}
80
+ */
81
+ patch(op: Operation | Operation[]): void;
82
+ /**
83
+ * Update the "local" or "current" (unpersisted) state of the Cache
84
+ *
85
+ * @param {Mutation} mutation
86
+ * @return {void}
87
+ * @public
88
+ */
89
+ mutate(mutation: Mutation): void;
90
+ /**
91
+ * Peek resource data from the Cache.
92
+ *
93
+ * In development, if the return value
94
+ * is JSON the return value
95
+ * will be deep-cloned and deep-frozen
96
+ * to prevent mutation thereby enforcing cache
97
+ * Immutability.
98
+ *
99
+ * This form of peek is useful for implementations
100
+ * that want to feed raw-data from cache to the UI
101
+ * or which want to interact with a blob of data
102
+ * directly from the presentation cache.
103
+ *
104
+ * An implementation might want to do this because
105
+ * de-referencing records which read from their own
106
+ * blob is generally safer because the record does
107
+ * not require retainining connections to the Store
108
+ * and Cache to present data on a per-field basis.
109
+ *
110
+ * This generally takes the place of `getAttr` as
111
+ * an API and may even take the place of `getRelationship`
112
+ * depending on implementation specifics, though this
113
+ * latter usage is less recommended due to the advantages
114
+ * of the Graph handling necessary entanglements and
115
+ * notifications for relational data.
116
+ *
117
+ * @public
118
+ * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
119
+ * @return {ResourceDocument | ResourceBlob | null} the known resource data
120
+ */
121
+ peek<T = unknown>(identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>): T | null;
122
+ peek(identifier: StableDocumentIdentifier): ResourceDocument | null;
123
+ /**
124
+ * Peek remote resource data from the Cache.
125
+ *
126
+ * This will give the data provided from the server without any local changes.
127
+ *
128
+ * In development, if the return value
129
+ * is JSON the return value
130
+ * will be deep-cloned and deep-frozen
131
+ * to prevent mutation thereby enforcing cache
132
+ * Immutability.
133
+ *
134
+ * This form of peek is useful for implementations
135
+ * that want to feed raw-data from cache to the UI
136
+ * or which want to interact with a blob of data
137
+ * directly from the presentation cache.
138
+ *
139
+ * An implementation might want to do this because
140
+ * de-referencing records which read from their own
141
+ * blob is generally safer because the record does
142
+ * not require retainining connections to the Store
143
+ * and Cache to present data on a per-field basis.
144
+ *
145
+ * This generally takes the place of `getAttr` as
146
+ * an API and may even take the place of `getRelationship`
147
+ * depending on implementation specifics, though this
148
+ * latter usage is less recommended due to the advantages
149
+ * of the Graph handling necessary entanglements and
150
+ * notifications for relational data.
151
+ *
152
+ * @public
153
+ * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
154
+ * @return {ResourceDocument | ResourceBlob | null} the known resource data
155
+ */
156
+ peekRemoteState<T = unknown>(identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>): T | null;
157
+ peekRemoteState(identifier: StableDocumentIdentifier): ResourceDocument | null;
158
+ /**
159
+ * Peek the Cache for the existing request data associated with
160
+ * a cacheable request
161
+ *
162
+ * This is effectively the reverse of `put` for a request in
163
+ * that it will return the the request, response, and content
164
+ * whereas `peek` will return just the `content`.
165
+ *
166
+ * @param {StableDocumentIdentifier}
167
+ * @return {StructuredDocument<ResourceDocument> | null}
168
+ * @public
169
+ */
170
+ peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null;
171
+ /**
172
+ * Push resource data from a remote source into the cache for this identifier
173
+ *
174
+ * @public
175
+ * @param identifier
176
+ * @param data
177
+ * @param hasRecord
178
+ * @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
179
+ */
180
+ upsert(identifier: StableRecordIdentifier, data: ResourceBlob, hasRecord: boolean): void | string[];
181
+ /**
182
+ * Create a fork of the cache from the current state.
183
+ *
184
+ * Applications should typically not call this method themselves,
185
+ * preferring instead to fork at the Store level, which will
186
+ * utilize this method to fork the cache.
187
+ *
188
+ * @public
189
+ * @return {Promise<Cache>}
190
+ */
191
+ fork(): Promise<Cache>;
192
+ /**
193
+ * Merge a fork back into a parent Cache.
194
+ *
195
+ * Applications should typically not call this method themselves,
196
+ * preferring instead to merge at the Store level, which will
197
+ * utilize this method to merge the caches.
198
+ *
199
+ * @param {Cache} cache
200
+ * @public
201
+ * @return {Promise<void>}
202
+ */
203
+ merge(cache: Cache): Promise<void>;
204
+ /**
205
+ * Generate the list of changes applied to all
206
+ * record in the store.
207
+ *
208
+ * Each individual resource or document that has
209
+ * been mutated should be described as an individual
210
+ * `Change` entry in the returned array.
211
+ *
212
+ * A `Change` is described by an object containing up to
213
+ * three properties: (1) the `identifier` of the entity that
214
+ * changed; (2) the `op` code of that change being one of
215
+ * `upsert` or `remove`, and if the op is `upsert` a `patch`
216
+ * containing the data to merge into the cache for the given
217
+ * entity.
218
+ *
219
+ * This `patch` is opaque to the Store but should be understood
220
+ * by the Cache and may expect to be utilized by an Adapter
221
+ * when generating data during a `save` operation.
222
+ *
223
+ * It is generally recommended that the `patch` contain only
224
+ * the updated state, ignoring fields that are unchanged
225
+ *
226
+ * ```ts
227
+ * interface Change {
228
+ * identifier: StableRecordIdentifier | StableDocumentIdentifier;
229
+ * op: 'upsert' | 'remove';
230
+ * patch?: unknown;
231
+ * }
232
+ * ```
233
+ *
234
+ * @public
235
+ */
236
+ diff(): Promise<Change[]>;
237
+ /**
238
+ * Serialize the entire contents of the Cache into a Stream
239
+ * which may be fed back into a new instance of the same Cache
240
+ * via `cache.hydrate`.
241
+ *
242
+ * @return {Promise<ReadableStream>}
243
+ * @public
244
+ */
245
+ dump(): Promise<ReadableStream<unknown>>;
246
+ /**
247
+ * hydrate a Cache from a Stream with content previously serialized
248
+ * from another instance of the same Cache, resolving when hydration
249
+ * is complete.
250
+ *
251
+ * This method should expect to be called both in the context of restoring
252
+ * the Cache during application rehydration after SSR **AND** at unknown
253
+ * times during the lifetime of an already booted application when it is
254
+ * desired to bulk-load additional information into the cache. This latter
255
+ * behavior supports optimizing pre/fetching of data for route transitions
256
+ * via data-only SSR modes.
257
+ *
258
+ * @param {ReadableStream} stream
259
+ * @return {Promise<void>}
260
+ * @public
261
+ */
262
+ hydrate(stream: ReadableStream<unknown>): Promise<void>;
263
+ /**
264
+ * [LIFECYCLE] Signal to the cache that a new record has been instantiated on the client
265
+ *
266
+ * It returns properties from options that should be set on the record during the create
267
+ * process. This return value behavior is deprecated.
268
+ *
269
+ * @public
270
+ * @param identifier
271
+ * @param createArgs
272
+ */
273
+ clientDidCreate(identifier: StableRecordIdentifier, createArgs?: Record<string, unknown>): Record<string, unknown>;
274
+ /**
275
+ * [LIFECYCLE] Signals to the cache that a resource
276
+ * will be part of a save transaction.
277
+ *
278
+ * @public
279
+ * @param identifier
280
+ */
281
+ willCommit(identifier: StableRecordIdentifier, context: RequestContext): void;
282
+ /**
283
+ * [LIFECYCLE] Signals to the cache that a resource
284
+ * was successfully updated as part of a save transaction.
285
+ *
286
+ * @public
287
+ * @param identifier - the primary identifier that was operated on
288
+ * @param data - a document in the cache format containing any updated data
289
+ * @return {SingleResourceDataDocument}
290
+ */
291
+ didCommit(identifier: StableRecordIdentifier, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
292
+ /**
293
+ * [LIFECYCLE] Signals to the cache that a resource
294
+ * was update via a save transaction failed.
295
+ *
296
+ * @public
297
+ * @param identifier
298
+ * @param errors
299
+ */
300
+ commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void;
301
+ /**
302
+ * [LIFECYCLE] Signals to the cache that all data for a resource
303
+ * should be cleared.
304
+ *
305
+ * This method is a candidate to become a mutation
306
+ *
307
+ * @public
308
+ * @param identifier
309
+ */
310
+ unloadRecord(identifier: StableRecordIdentifier): void;
311
+ /**
312
+ * Retrieve the data for an attribute from the cache
313
+ *
314
+ * @public
315
+ * @param identifier
316
+ * @param field
317
+ * @return {unknown}
318
+ */
319
+ getAttr(identifier: StableRecordIdentifier, field: string | string[]): Value | undefined;
320
+ /**
321
+ * Retrieve remote state without any local changes for a specific attribute
322
+ *
323
+ * @public
324
+ * @param identifier
325
+ * @param field
326
+ * @return {unknown}
327
+ */
328
+ getRemoteAttr(identifier: StableRecordIdentifier, field: string | string[]): Value | undefined;
329
+ /**
330
+ * Mutate the data for an attribute in the cache
331
+ *
332
+ * This method is a candidate to become a mutation
333
+ *
334
+ * @public
335
+ * @param identifier
336
+ * @param field
337
+ * @param value
338
+ */
339
+ setAttr(identifier: StableRecordIdentifier, field: string | string[], value: Value): void;
340
+ /**
341
+ * Query the cache for the changed attributes of a resource.
342
+ *
343
+ * Returns a map of field names to tuples of [old, new] values
344
+ *
345
+ * ```
346
+ * { <field>: [<old>, <new>] }
347
+ * ```
348
+ *
349
+ * @public
350
+ * @param identifier
351
+ * @return {Record<string, [unknown, unknown]>} `{ <field>: [<old>, <new>] }`
352
+ */
353
+ changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash;
354
+ /**
355
+ * Query the cache for whether any mutated attributes exist
356
+ *
357
+ * @public
358
+ * @param identifier
359
+ * @return {Boolean}
360
+ */
361
+ hasChangedAttrs(identifier: StableRecordIdentifier): boolean;
362
+ /**
363
+ * Tell the cache to discard any uncommitted mutations to attributes
364
+ *
365
+ * This method is a candidate to become a mutation
366
+ *
367
+ * @public
368
+ * @param identifier
369
+ * @return {String[]} the names of fields that were restored
370
+ */
371
+ rollbackAttrs(identifier: StableRecordIdentifier): string[];
372
+ /**
373
+ * Query the cache for the changes to relationships of a resource.
374
+ *
375
+ * Returns a map of relationship names to RelationshipDiff objects.
376
+ *
377
+ * ```ts
378
+ * type RelationshipDiff =
379
+ | {
380
+ kind: 'collection';
381
+ remoteState: StableRecordIdentifier[];
382
+ additions: Set<StableRecordIdentifier>;
383
+ removals: Set<StableRecordIdentifier>;
384
+ localState: StableRecordIdentifier[];
385
+ reordered: boolean;
386
+ }
387
+ | {
388
+ kind: 'resource';
389
+ remoteState: StableRecordIdentifier | null;
390
+ localState: StableRecordIdentifier | null;
391
+ };
392
+ ```
393
+ *
394
+ * @public
395
+ * @param {StableRecordIdentifier} identifier
396
+ * @return {Map<string, RelationshipDiff>}
397
+ */
398
+ changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
399
+ /**
400
+ * Query the cache for whether any mutated attributes exist
401
+ *
402
+ * @public
403
+ * @param {StableRecordIdentifier} identifier
404
+ * @return {Boolean}
405
+ */
406
+ hasChangedRelationships(identifier: StableRecordIdentifier): boolean;
407
+ /**
408
+ * Tell the cache to discard any uncommitted mutations to relationships.
409
+ *
410
+ * This will also discard the change on any appropriate inverses.
411
+ *
412
+ * This method is a candidate to become a mutation
413
+ *
414
+ * @public
415
+ * @param {StableRecordIdentifier} identifier
416
+ * @return {String[]} the names of relationships that were restored
417
+ */
418
+ rollbackRelationships(identifier: StableRecordIdentifier): string[];
419
+ /**
420
+ * Query the cache for the current state of a relationship property
421
+ *
422
+ * @public
423
+ * @param {StableRecordIdentifier} identifier
424
+ * @param {String} field
425
+ * @return resource relationship object
426
+ */
427
+ getRelationship(identifier: StableRecordIdentifier, field: string, isCollection?: boolean): ResourceRelationship | CollectionRelationship;
428
+ /**
429
+ * Query the cache for the server state of a relationship property without any local changes
430
+ *
431
+ * @public
432
+ * @param {StableRecordIdentifier} identifier
433
+ * @param {String} field
434
+ * @return resource relationship object
435
+ */
436
+ getRemoteRelationship(identifier: StableRecordIdentifier, field: string, isCollection?: boolean): ResourceRelationship | CollectionRelationship;
437
+ /**
438
+ * Update the cache state for the given resource to be marked
439
+ * as locally deleted, or remove such a mark.
440
+ *
441
+ * This method is a candidate to become a mutation
442
+ *
443
+ * @public
444
+ * @param identifier
445
+ * @param {Boolean} isDeleted
446
+ */
447
+ setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void;
448
+ /**
449
+ * Query the cache for any validation errors applicable to the given resource.
450
+ *
451
+ * @public
452
+ * @param identifier
453
+ * @return {JsonApiError[]}
454
+ */
455
+ getErrors(identifier: StableRecordIdentifier): ApiError[];
456
+ /**
457
+ * Query the cache for whether a given resource has any available data
458
+ *
459
+ * @public
460
+ * @param identifier
461
+ * @return {Boolean}
462
+ */
463
+ isEmpty(identifier: StableRecordIdentifier): boolean;
464
+ /**
465
+ * Query the cache for whether a given resource was created locally and not
466
+ * yet persisted.
467
+ *
468
+ * @public
469
+ * @param identifier
470
+ * @return {Boolean}
471
+ */
472
+ isNew(identifier: StableRecordIdentifier): boolean;
473
+ /**
474
+ * Query the cache for whether a given resource is marked as deleted (but not
475
+ * necessarily persisted yet).
476
+ *
477
+ * @public
478
+ * @param identifier
479
+ * @return {Boolean}
480
+ */
481
+ isDeleted(identifier: StableRecordIdentifier): boolean;
482
+ /**
483
+ * Query the cache for whether a given resource has been deleted and that deletion
484
+ * has also been persisted.
485
+ *
486
+ * @public
487
+ * @param identifier
488
+ * @return {Boolean}
489
+ */
490
+ isDeletionCommitted(identifier: StableRecordIdentifier): boolean;
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AG,IAAI,CAAC;IAE3E;;;;;;OAMG;IACH,SAAS,CAAC,UAAU,EAAE,sBAAsB,GAAG,QAAQ,EAAE,CAAC;IAE1D;;;;;;OAMG;IACH,OAAO,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO,CAAC;IAErD;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO,CAAC;IAEnD;;;;;;;OAOG;IACH,SAAS,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO,CAAC;IAEvD;;;;;;;OAOG;IACH,mBAAmB,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO,CAAC;CAClE"}
@@ -0,0 +1,48 @@
1
+ import type { AddToResourceRelationshipMutation as AddResourceMutation, RemoveFromResourceRelationshipMutation as RemoveResourceMutation } from './cache/mutations.ts';
2
+ import type { AddToResourceRelationshipOperation as AddResourceOperation, RemoveFromResourceRelationshipOperation as RemoveResourceOperation, UpdateResourceRelationshipOperation } from './cache/operations.ts';
3
+ import type { StableRecordIdentifier } from './identifier.ts';
4
+ import type { CollectionResourceRelationship, SingleResourceRelationship } from './spec/json-api-raw.ts';
5
+ export interface Operation {
6
+ op: string;
7
+ }
8
+ export interface UpdateRelationshipOperation {
9
+ op: 'updateRelationship';
10
+ record: StableRecordIdentifier;
11
+ field: string;
12
+ value: SingleResourceRelationship | CollectionResourceRelationship;
13
+ }
14
+ export interface DeleteRecordOperation {
15
+ op: 'deleteRecord';
16
+ record: StableRecordIdentifier;
17
+ isNew: boolean;
18
+ }
19
+ export interface UnknownOperation {
20
+ op: 'never';
21
+ record: StableRecordIdentifier;
22
+ field: string;
23
+ }
24
+ export interface ReplaceRelatedRecordOperation {
25
+ op: 'replaceRelatedRecord';
26
+ record: StableRecordIdentifier;
27
+ field: string;
28
+ value: StableRecordIdentifier | null;
29
+ prior?: StableRecordIdentifier;
30
+ index?: number;
31
+ }
32
+ export interface SortRelatedRecords {
33
+ op: 'sortRelatedRecords';
34
+ record: StableRecordIdentifier;
35
+ field: string;
36
+ value: StableRecordIdentifier[];
37
+ }
38
+ export interface ReplaceRelatedRecordsOperation {
39
+ op: 'replaceRelatedRecords';
40
+ record: StableRecordIdentifier;
41
+ field: string;
42
+ value: StableRecordIdentifier[];
43
+ prior?: StableRecordIdentifier[];
44
+ index?: number;
45
+ }
46
+ export type RemoteRelationshipOperation = UpdateResourceRelationshipOperation | UpdateRelationshipOperation | ReplaceRelatedRecordOperation | ReplaceRelatedRecordsOperation | RemoveResourceOperation | AddResourceOperation | DeleteRecordOperation | SortRelatedRecords;
47
+ export type LocalRelationshipOperation = ReplaceRelatedRecordsOperation | ReplaceRelatedRecordOperation | AddResourceMutation | RemoveResourceMutation | SortRelatedRecords;
48
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/types/graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iCAAiC,IAAI,mBAAmB,EACxD,sCAAsC,IAAI,sBAAsB,EACjE,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,kCAAkC,IAAI,oBAAoB,EAC1D,uCAAuC,IAAI,uBAAuB,EAClE,mCAAmC,EACpC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEzG,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,oBAAoB,CAAC;IACzB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,0BAA0B,GAAG,8BAA8B,CAAC;CACpE;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,cAAc,CAAC;IACnB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,6BAA6B;IAC5C,EAAE,EAAE,sBAAsB,CAAC;IAC3B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACrC,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,oBAAoB,CAAC;IACzB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,sBAAsB,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,8BAA8B;IAC7C,EAAE,EAAE,uBAAuB,CAAC;IAC5B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAChC,KAAK,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,2BAA2B,GACnC,mCAAmC,GACnC,2BAA2B,GAC3B,6BAA6B,GAC7B,8BAA8B,GAC9B,uBAAuB,GACvB,oBAAoB,GACpB,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB,MAAM,MAAM,0BAA0B,GAClC,8BAA8B,GAC9B,6BAA6B,GAC7B,mBAAmB,GACnB,sBAAsB,GACtB,kBAAkB,CAAC"}
@@ -0,0 +1,111 @@
1
+ export declare const DEBUG_CLIENT_ORIGINATED: unique symbol;
2
+ export declare const DEBUG_IDENTIFIER_BUCKET: unique symbol;
3
+ export declare const DEBUG_STALE_CACHE_OWNER: unique symbol;
4
+ export declare const CACHE_OWNER: '__$co';
5
+ export type IdentifierBucket = 'record' | 'document';
6
+ export interface Identifier {
7
+ lid: string;
8
+ clientId?: string;
9
+ }
10
+ export interface ExistingRecordIdentifier<T extends string = string> extends Identifier {
11
+ id: string;
12
+ type: T;
13
+ }
14
+ export interface NewRecordIdentifier<T extends string = string> extends Identifier {
15
+ id: string | null;
16
+ type: T;
17
+ }
18
+ export type StableDocumentIdentifier = {
19
+ lid: string;
20
+ };
21
+ export type RequestKey = StableDocumentIdentifier;
22
+ /**
23
+ * An Identifier specific to a record which may or may not
24
+ * be present in the cache.
25
+ *
26
+ * The absence of an `id` DOES NOT indicate that this
27
+ * Identifier is for a new client-created record as it
28
+ * may also indicate that it was generated for a secondary
29
+ * index and the primary `id` index is not yet known.
30
+ *
31
+ * @internal
32
+ */
33
+ export type RecordIdentifier<T extends string = string> = ExistingRecordIdentifier<T> | NewRecordIdentifier<T>;
34
+ /**
35
+ * Used when an Identifier is known to be the stable version
36
+ *
37
+ * @internal
38
+ */
39
+ export interface StableIdentifier extends Identifier {
40
+ [DEBUG_IDENTIFIER_BUCKET]?: string;
41
+ }
42
+ /**
43
+ * Used when a StableRecordIdentifier was not created locally as part
44
+ * of a call to store.createRecord
45
+ *
46
+ * Distinguishing between this Identifier and one for a client created
47
+ * record that was created with an ID is generally speaking not possible
48
+ * at runtime, so anything with an ID typically narrows to this.
49
+ *
50
+ * @internal
51
+ */
52
+ export interface StableExistingRecordIdentifier<T extends string = string> extends StableIdentifier {
53
+ id: string;
54
+ type: T;
55
+ [DEBUG_CLIENT_ORIGINATED]?: boolean;
56
+ [CACHE_OWNER]: number | undefined;
57
+ [DEBUG_STALE_CACHE_OWNER]?: number | undefined;
58
+ }
59
+ /**
60
+ * Used when a StableRecordIdentifier was created locally
61
+ * (by a call to store.createRecord).
62
+ *
63
+ * It is possible in rare circumstances to have a StableRecordIdentifier
64
+ * that is not for a new record but does not have an ID. This would
65
+ * happen if a user intentionally created one for use with a secondary-index
66
+ * prior to the record having been fully loaded.
67
+ *
68
+ * @internal
69
+ */
70
+ export interface StableNewRecordIdentifier<T extends string = string> extends StableIdentifier {
71
+ id: string | null;
72
+ type: T;
73
+ [DEBUG_CLIENT_ORIGINATED]?: boolean;
74
+ [CACHE_OWNER]: number | undefined;
75
+ [DEBUG_STALE_CACHE_OWNER]?: number | undefined;
76
+ }
77
+ /**
78
+ * A referentially stable object with a unique string (lid) that can be used
79
+ * as a reference to data in the cache.
80
+ *
81
+ * Every record instance has a unique identifier, and identifiers may refer
82
+ * to data that has never been loaded (for instance, in an async relationship).
83
+ *
84
+ * @class StableRecordIdentifier
85
+ * @public
86
+ */
87
+ /**
88
+ * A string representing a unique identity.
89
+ *
90
+ * @property lid
91
+ * @type {String}
92
+ * @public
93
+ */
94
+ /**
95
+ * the primary resource `type` or `modelName` this identity belongs to.
96
+ *
97
+ * @property type
98
+ * @type {String}
99
+ * @public
100
+ */
101
+ /**
102
+ * the primary id for the record this identity belongs to. `null`
103
+ * if not yet assigned an id.
104
+ *
105
+ * @property id
106
+ * @type {String | null}
107
+ * @public
108
+ */
109
+ export type StableRecordIdentifier<T extends string = string> = StableExistingRecordIdentifier<T> | StableNewRecordIdentifier<T>;
110
+ export type ResourceKey<T extends string = string> = StableRecordIdentifier<T>;
111
+ //# sourceMappingURL=identifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../src/types/identifier.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,EAAE,OAAO,MAA8C,CAAC;AAC5F,eAAO,MAAM,uBAAuB,EAAE,OAAO,MAAoC,CAAC;AAClF,eAAO,MAAM,uBAAuB,EAAE,OAAO,MAAsC,CAAC;AAOpF,eAAO,MAAM,WAAW,EAAE,OAA4C,CAAC;AAEvE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAErD,MAAM,WAAW,UAAU;IACzB,GAAG,EA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AAI,EAAE,CAAC,CAAC;IACR,CAAC,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC;IACpC,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,CAAC,uBAAuB,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChD;AAED;;;;;;;;;GASG;AAEH;;;;;;GAMG;AACH;;;;;;GAMG;AACH;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IACxD,8BAA8B,CAAC,CAAC,CAAC,GACjC,yBAAyB,CAAC,CAAC,CAAC,CAAC;AAEjC,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type PrimitiveValue = string | number | boolean | null;
2
+ export interface ObjectValue {
3
+ [key: string]: Value;
4
+ }
5
+ export type ArrayValue = Value[];
6
+ export type Value = PrimitiveValue | ArrayValue | ObjectValue;
7
+ //# sourceMappingURL=raw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../../../src/types/json/raw.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC9D,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;CACtB;AACD,MAAM,MAAM,UAAU,GAAG,KAAK,EAAE,CAAC;AAEjC,MAAM,MAAM,KAAK,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW,CAAC"}