@warp-drive/core 5.8.0-alpha.9 → 5.8.0-beta.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 (258) hide show
  1. package/README.md +22 -38
  2. package/declarations/configure.d.ts +1 -1
  3. package/declarations/graph/-private/-edge-definition.d.ts +12 -2
  4. package/declarations/index.d.ts +14 -9
  5. package/declarations/reactive/-private/default-mode.d.ts +1 -1
  6. package/declarations/reactive/-private/fields/extension.d.ts +1 -1
  7. package/declarations/reactive/-private/fields/managed-array.d.ts +2 -2
  8. package/declarations/reactive/-private/fields/managed-object.d.ts +1 -1
  9. package/declarations/reactive/-private/record.d.ts +10 -1
  10. package/declarations/reactive/-private.d.ts +1 -0
  11. package/declarations/reactive.d.ts +11 -7
  12. package/declarations/request/-private/types.d.ts +1 -1
  13. package/declarations/signals/-leaked.d.ts +2 -0
  14. package/declarations/signals/-private.d.ts +6 -0
  15. package/declarations/{store/-private/new-core-tmp → signals}/promise-state.d.ts +1 -1
  16. package/declarations/{store/-private/new-core-tmp → signals}/request-state.d.ts +6 -6
  17. package/declarations/{store/-private/new-core-tmp → signals}/request-subscription.d.ts +4 -4
  18. package/declarations/store/-private/cache-handler/types.d.ts +2 -16
  19. package/declarations/store/-private/caches/instance-cache.d.ts +1 -1
  20. package/declarations/store/-private/managers/cache-manager.d.ts +1 -14
  21. package/declarations/store/-private/managers/notification-manager.d.ts +1 -1
  22. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +1 -1
  23. package/declarations/store/-private/record-arrays/resource-array.d.ts +1 -1
  24. package/declarations/store/-private/store-service.d.ts +2 -2
  25. package/declarations/store/-private.d.ts +0 -6
  26. package/declarations/store/deprecated/-private.d.ts +2 -2
  27. package/declarations/store/deprecated/store.d.ts +1 -1
  28. package/declarations/store.d.ts +1 -0
  29. package/declarations/types/cache.d.ts +2 -2
  30. package/declarations/types/record.d.ts +132 -0
  31. package/declarations/types/request.d.ts +22 -8
  32. package/declarations/types/schema/fields.d.ts +26 -13
  33. package/declarations/types/schema/schema-service.d.ts +4 -4
  34. package/declarations/types/spec/document.d.ts +34 -0
  35. package/dist/configure-DPUFCemT.js +1940 -0
  36. package/dist/configure.js +2 -1
  37. package/dist/{request-oqoLC9rz.js → future-BKkJJkj7.js} +1 -48
  38. package/dist/graph/-private.js +15 -5
  39. package/dist/{index-B1cSRj-N.js → index-CQP2NSqg.js} +63 -1812
  40. package/dist/index.js +5 -5
  41. package/dist/reactive/-private.js +1 -1
  42. package/dist/reactive.js +4 -129
  43. package/dist/request.js +49 -1
  44. package/dist/signals/-leaked.js +1 -0
  45. package/dist/store/-private.js +1 -2
  46. package/dist/symbols-3C1OkYtZ.js +39 -0
  47. package/dist/types/-private.js +1 -1
  48. package/dist/types/record.js +127 -0
  49. package/dist/types/request.js +11 -7
  50. package/dist/unpkg/dev/-leaked-Co0EI6Go.js +1939 -0
  51. package/dist/unpkg/dev/build-config/babel-macros.js +1 -0
  52. package/dist/unpkg/dev/build-config/canary-features.js +1 -0
  53. package/dist/unpkg/dev/build-config/debugging.js +1 -0
  54. package/dist/unpkg/dev/build-config/deprecations.js +1 -0
  55. package/dist/unpkg/dev/build-config/env.js +1 -0
  56. package/dist/unpkg/dev/build-config/macros.js +1 -0
  57. package/dist/unpkg/dev/build-config.js +1 -0
  58. package/dist/unpkg/dev/configure.js +1 -0
  59. package/dist/unpkg/dev/future-DFfOzSoe.js +672 -0
  60. package/dist/unpkg/dev/graph/-private.js +3132 -0
  61. package/dist/unpkg/dev/index-BzcBOnw9.js +9392 -0
  62. package/dist/unpkg/dev/index.js +6 -0
  63. package/dist/unpkg/dev/reactive/-private.js +1 -0
  64. package/dist/unpkg/dev/reactive.js +3 -0
  65. package/dist/unpkg/dev/request.js +49 -0
  66. package/dist/unpkg/dev/runtime-E1M51_-O.js +135 -0
  67. package/dist/unpkg/dev/signals/-leaked.js +1 -0
  68. package/dist/unpkg/dev/store/-private.js +55 -0
  69. package/dist/unpkg/dev/store.js +558 -0
  70. package/dist/unpkg/dev/types/-private.js +69 -0
  71. package/dist/unpkg/dev/types/cache/aliases.js +0 -0
  72. package/dist/unpkg/dev/types/cache/change.js +0 -0
  73. package/dist/unpkg/dev/types/cache/mutations.js +0 -0
  74. package/dist/unpkg/dev/types/cache/operations.js +0 -0
  75. package/dist/unpkg/dev/types/cache/relationship.js +0 -0
  76. package/dist/unpkg/dev/types/cache.js +0 -0
  77. package/dist/unpkg/dev/types/graph.js +0 -0
  78. package/dist/unpkg/dev/types/identifier.js +61 -0
  79. package/dist/unpkg/dev/types/json/raw.js +0 -0
  80. package/dist/unpkg/dev/types/params.js +0 -0
  81. package/dist/unpkg/dev/types/record.js +191 -0
  82. package/dist/unpkg/dev/types/request.js +77 -0
  83. package/dist/unpkg/dev/types/runtime.js +34 -0
  84. package/dist/unpkg/dev/types/schema/concepts.js +0 -0
  85. package/dist/unpkg/dev/types/schema/fields.js +505 -0
  86. package/dist/unpkg/dev/types/schema/fields.type-test.js +0 -0
  87. package/dist/unpkg/dev/types/schema/schema-service.js +0 -0
  88. package/dist/unpkg/dev/types/spec/document.js +0 -0
  89. package/dist/unpkg/dev/types/spec/error.js +0 -0
  90. package/dist/unpkg/dev/types/spec/json-api-raw.js +0 -0
  91. package/dist/unpkg/dev/types/symbols.js +84 -0
  92. package/dist/unpkg/dev/types/utils.js +0 -0
  93. package/dist/unpkg/dev/types.js +0 -0
  94. package/dist/unpkg/dev/utils/string.js +91 -0
  95. package/dist/unpkg/dev-deprecated/-leaked-DjMeRqdU.js +1939 -0
  96. package/dist/unpkg/dev-deprecated/-private-3C1OkYtZ.js +39 -0
  97. package/dist/unpkg/dev-deprecated/build-config/babel-macros.js +1 -0
  98. package/dist/unpkg/dev-deprecated/build-config/canary-features.js +1 -0
  99. package/dist/unpkg/dev-deprecated/build-config/debugging.js +1 -0
  100. package/dist/unpkg/dev-deprecated/build-config/deprecations.js +1 -0
  101. package/dist/unpkg/dev-deprecated/build-config/env.js +1 -0
  102. package/dist/unpkg/dev-deprecated/build-config/macros.js +1 -0
  103. package/dist/unpkg/dev-deprecated/build-config.js +1 -0
  104. package/dist/unpkg/dev-deprecated/configure.js +1 -0
  105. package/dist/unpkg/dev-deprecated/future-DFfOzSoe.js +672 -0
  106. package/dist/unpkg/dev-deprecated/graph/-private.js +3327 -0
  107. package/dist/unpkg/dev-deprecated/index-6TnTv-WG.js +10007 -0
  108. package/dist/unpkg/dev-deprecated/index.js +5 -0
  109. package/dist/unpkg/dev-deprecated/reactive/-private.js +1 -0
  110. package/dist/unpkg/dev-deprecated/reactive.js +3 -0
  111. package/dist/unpkg/dev-deprecated/request.js +49 -0
  112. package/dist/unpkg/dev-deprecated/runtime-DAu5b0IR.js +135 -0
  113. package/dist/unpkg/dev-deprecated/signals/-leaked.js +1 -0
  114. package/dist/unpkg/dev-deprecated/store/-private.js +1 -0
  115. package/dist/unpkg/dev-deprecated/store.js +558 -0
  116. package/dist/unpkg/dev-deprecated/types/-private.js +69 -0
  117. package/dist/unpkg/dev-deprecated/types/cache/aliases.js +0 -0
  118. package/dist/unpkg/dev-deprecated/types/cache/change.js +0 -0
  119. package/dist/unpkg/dev-deprecated/types/cache/mutations.js +0 -0
  120. package/dist/unpkg/dev-deprecated/types/cache/operations.js +0 -0
  121. package/dist/unpkg/dev-deprecated/types/cache/relationship.js +0 -0
  122. package/dist/unpkg/dev-deprecated/types/cache.js +0 -0
  123. package/dist/unpkg/dev-deprecated/types/graph.js +0 -0
  124. package/dist/unpkg/dev-deprecated/types/identifier.js +61 -0
  125. package/dist/unpkg/dev-deprecated/types/json/raw.js +0 -0
  126. package/dist/unpkg/dev-deprecated/types/params.js +0 -0
  127. package/dist/unpkg/dev-deprecated/types/record.js +191 -0
  128. package/dist/unpkg/dev-deprecated/types/request.js +77 -0
  129. package/dist/unpkg/dev-deprecated/types/runtime.js +34 -0
  130. package/dist/unpkg/dev-deprecated/types/schema/concepts.js +0 -0
  131. package/dist/unpkg/dev-deprecated/types/schema/fields.js +505 -0
  132. package/dist/unpkg/dev-deprecated/types/schema/fields.type-test.js +0 -0
  133. package/dist/unpkg/dev-deprecated/types/schema/schema-service.js +0 -0
  134. package/dist/unpkg/dev-deprecated/types/spec/document.js +0 -0
  135. package/dist/unpkg/dev-deprecated/types/spec/error.js +0 -0
  136. package/dist/unpkg/dev-deprecated/types/spec/json-api-raw.js +0 -0
  137. package/dist/unpkg/dev-deprecated/types/symbols.js +84 -0
  138. package/dist/unpkg/dev-deprecated/types/utils.js +0 -0
  139. package/dist/unpkg/dev-deprecated/types.js +0 -0
  140. package/dist/unpkg/dev-deprecated/utils/string.js +91 -0
  141. package/dist/unpkg/prod/-leaked-DUONXQDB.js +1676 -0
  142. package/dist/unpkg/prod/-private-sql1_mdx.js +39 -0
  143. package/dist/unpkg/prod/build-config/babel-macros.js +1 -0
  144. package/dist/unpkg/prod/build-config/canary-features.js +1 -0
  145. package/dist/unpkg/prod/build-config/debugging.js +1 -0
  146. package/dist/unpkg/prod/build-config/deprecations.js +1 -0
  147. package/dist/unpkg/prod/build-config/env.js +1 -0
  148. package/dist/unpkg/prod/build-config/macros.js +1 -0
  149. package/dist/unpkg/prod/build-config.js +1 -0
  150. package/dist/unpkg/prod/configure.js +2 -0
  151. package/dist/unpkg/prod/graph/-private.js +2235 -0
  152. package/dist/unpkg/prod/handler-EU_8ncB2.js +1619 -0
  153. package/dist/unpkg/prod/index.js +483 -0
  154. package/dist/unpkg/prod/promise-cache-DIT8Ypjq.js +19 -0
  155. package/dist/unpkg/prod/reactive/-private.js +1 -0
  156. package/dist/unpkg/prod/reactive.js +30 -0
  157. package/dist/unpkg/prod/request-BrJSCG6r.js +421 -0
  158. package/dist/unpkg/prod/request.js +2 -0
  159. package/dist/unpkg/prod/schema-BSkHyoWz.js +5219 -0
  160. package/dist/unpkg/prod/signals/-leaked.js +1 -0
  161. package/dist/unpkg/prod/store/-private.js +126 -0
  162. package/dist/unpkg/prod/store.js +437 -0
  163. package/dist/unpkg/prod/types/-private.js +49 -0
  164. package/dist/unpkg/prod/types/cache/aliases.js +0 -0
  165. package/dist/unpkg/prod/types/cache/change.js +0 -0
  166. package/dist/unpkg/prod/types/cache/mutations.js +0 -0
  167. package/dist/unpkg/prod/types/cache/operations.js +0 -0
  168. package/dist/unpkg/prod/types/cache/relationship.js +0 -0
  169. package/dist/unpkg/prod/types/cache.js +0 -0
  170. package/dist/unpkg/prod/types/graph.js +0 -0
  171. package/dist/unpkg/prod/types/identifier.js +61 -0
  172. package/dist/unpkg/prod/types/json/raw.js +0 -0
  173. package/dist/unpkg/prod/types/params.js +0 -0
  174. package/dist/unpkg/prod/types/record.js +191 -0
  175. package/dist/unpkg/prod/types/request.js +77 -0
  176. package/dist/unpkg/prod/types/runtime.js +34 -0
  177. package/dist/unpkg/prod/types/schema/concepts.js +0 -0
  178. package/dist/unpkg/prod/types/schema/fields.js +505 -0
  179. package/dist/unpkg/prod/types/schema/fields.type-test.js +0 -0
  180. package/dist/unpkg/prod/types/schema/schema-service.js +0 -0
  181. package/dist/unpkg/prod/types/spec/document.js +0 -0
  182. package/dist/unpkg/prod/types/spec/error.js +0 -0
  183. package/dist/unpkg/prod/types/spec/json-api-raw.js +0 -0
  184. package/dist/unpkg/prod/types/symbols.js +84 -0
  185. package/dist/unpkg/prod/types/utils.js +0 -0
  186. package/dist/unpkg/prod/types.js +0 -0
  187. package/dist/unpkg/prod/utils/string.js +72 -0
  188. package/dist/unpkg/prod-deprecated/-leaked-DRNv9VIX.js +1676 -0
  189. package/dist/unpkg/prod-deprecated/-private-3C1OkYtZ.js +39 -0
  190. package/dist/unpkg/prod-deprecated/build-config/babel-macros.js +1 -0
  191. package/dist/unpkg/prod-deprecated/build-config/canary-features.js +1 -0
  192. package/dist/unpkg/prod-deprecated/build-config/debugging.js +1 -0
  193. package/dist/unpkg/prod-deprecated/build-config/deprecations.js +1 -0
  194. package/dist/unpkg/prod-deprecated/build-config/env.js +1 -0
  195. package/dist/unpkg/prod-deprecated/build-config/macros.js +1 -0
  196. package/dist/unpkg/prod-deprecated/build-config.js +1 -0
  197. package/dist/unpkg/prod-deprecated/configure.js +2 -0
  198. package/dist/unpkg/prod-deprecated/graph/-private.js +2408 -0
  199. package/dist/unpkg/prod-deprecated/handler-CCIu4sQ3.js +334 -0
  200. package/dist/unpkg/prod-deprecated/hooks-Dv4Np0MY.js +26 -0
  201. package/dist/unpkg/prod-deprecated/index.js +483 -0
  202. package/dist/unpkg/prod-deprecated/promise-cache-DIT8Ypjq.js +19 -0
  203. package/dist/unpkg/prod-deprecated/reactive/-private.js +1 -0
  204. package/dist/unpkg/prod-deprecated/reactive.js +5 -0
  205. package/dist/unpkg/prod-deprecated/request-BrJSCG6r.js +421 -0
  206. package/dist/unpkg/prod-deprecated/request.js +2 -0
  207. package/dist/unpkg/prod-deprecated/schema-CJcjHv0E.js +6939 -0
  208. package/dist/unpkg/prod-deprecated/signals/-leaked.js +1 -0
  209. package/dist/unpkg/prod-deprecated/store/-private.js +88 -0
  210. package/dist/unpkg/prod-deprecated/store.js +437 -0
  211. package/dist/unpkg/prod-deprecated/types/-private.js +49 -0
  212. package/dist/unpkg/prod-deprecated/types/cache/aliases.js +0 -0
  213. package/dist/unpkg/prod-deprecated/types/cache/change.js +0 -0
  214. package/dist/unpkg/prod-deprecated/types/cache/mutations.js +0 -0
  215. package/dist/unpkg/prod-deprecated/types/cache/operations.js +0 -0
  216. package/dist/unpkg/prod-deprecated/types/cache/relationship.js +0 -0
  217. package/dist/unpkg/prod-deprecated/types/cache.js +0 -0
  218. package/dist/unpkg/prod-deprecated/types/graph.js +0 -0
  219. package/dist/unpkg/prod-deprecated/types/identifier.js +61 -0
  220. package/dist/unpkg/prod-deprecated/types/json/raw.js +0 -0
  221. package/dist/unpkg/prod-deprecated/types/params.js +0 -0
  222. package/dist/unpkg/prod-deprecated/types/record.js +191 -0
  223. package/dist/unpkg/prod-deprecated/types/request.js +77 -0
  224. package/dist/unpkg/prod-deprecated/types/runtime.js +34 -0
  225. package/dist/unpkg/prod-deprecated/types/schema/concepts.js +0 -0
  226. package/dist/unpkg/prod-deprecated/types/schema/fields.js +505 -0
  227. package/dist/unpkg/prod-deprecated/types/schema/fields.type-test.js +0 -0
  228. package/dist/unpkg/prod-deprecated/types/schema/schema-service.js +0 -0
  229. package/dist/unpkg/prod-deprecated/types/spec/document.js +0 -0
  230. package/dist/unpkg/prod-deprecated/types/spec/error.js +0 -0
  231. package/dist/unpkg/prod-deprecated/types/spec/json-api-raw.js +0 -0
  232. package/dist/unpkg/prod-deprecated/types/symbols.js +84 -0
  233. package/dist/unpkg/prod-deprecated/types/utils.js +0 -0
  234. package/dist/unpkg/prod-deprecated/types.js +0 -0
  235. package/dist/unpkg/prod-deprecated/utils/string.js +72 -0
  236. package/logos/README.md +2 -2
  237. package/logos/logo-yellow-slab.svg +1 -0
  238. package/logos/word-mark-black.svg +1 -0
  239. package/logos/word-mark-white.svg +1 -0
  240. package/package.json +11 -3
  241. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +0 -24
  242. package/dist/configure-C3x8YXzL.js +0 -181
  243. package/logos/NCC-1701-a-blue.svg +0 -4
  244. package/logos/NCC-1701-a-gold.svg +0 -4
  245. package/logos/NCC-1701-a-gold_100.svg +0 -1
  246. package/logos/NCC-1701-a-gold_base-64.txt +0 -1
  247. package/logos/NCC-1701-a.svg +0 -4
  248. package/logos/docs-badge.svg +0 -2
  249. package/logos/ember-data-logo-dark.svg +0 -12
  250. package/logos/ember-data-logo-light.svg +0 -12
  251. package/logos/social1.png +0 -0
  252. package/logos/social2.png +0 -0
  253. package/logos/warp-drive-logo-dark.svg +0 -4
  254. package/logos/warp-drive-logo-gold.svg +0 -4
  255. /package/declarations/{store/-private/new-core-tmp → signals}/reactivity/configure.d.ts +0 -0
  256. /package/declarations/{store/-private/new-core-tmp → signals}/reactivity/internal.d.ts +0 -0
  257. /package/declarations/{store/-private/new-core-tmp → signals}/reactivity/signal.d.ts +0 -0
  258. /package/dist/{symbols-sql1_mdx.js → unpkg/dev/-private-sql1_mdx.js} +0 -0
File without changes
File without changes
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Records may be anything, They don't even
3
+ * have to be objects.
4
+ *
5
+ * Whatever they are, if they have a Type
6
+ * property, that property will be used by WarpDrive
7
+ * and WarpDrive to provide better type safety and
8
+ * intellisense.
9
+ *
10
+ * @class TypedRecordInstance
11
+ */
12
+
13
+ /**
14
+ * A type utility that extracts the Type if available,
15
+ * otherwise it returns never.
16
+ *
17
+ */
18
+
19
+ /**
20
+ * A type utility that extracts the Type if available,
21
+ * otherwise it returns string
22
+ *
23
+ */
24
+
25
+ /**
26
+ * A Utility that extracts either resource types or resource paths from a TypedRecordInstance.
27
+ *
28
+ * Its limitations are mostly around its intentional non-recursiveness. It presumes that APIs which
29
+ * implement includes will not allow cyclical include paths, and will collapse includes by type.
30
+ *
31
+ * This follows closer to the JSON:API fields spec than to the includes spec in nature, but in
32
+ * practice it is so impracticle for an API to allow z-algo include paths that this is probably
33
+ * reasonable.
34
+ *
35
+ * We may need to revisit this in the future, opting to either make this restriction optional or
36
+ * to allow for other strategies.
37
+ *
38
+ * There's a 90% chance this particular implementation belongs being in the JSON:API package instead
39
+ * of core-types, but it's here for now.
40
+ *
41
+ */
42
+
43
+ /**
44
+ * A utility that provides the union of all ResourceName for all potential
45
+ * includes for the given TypedRecordInstance.
46
+ *
47
+ */
48
+
49
+ // ToPaths<ExpandIgnore<T, true>, false>;
50
+
51
+ /**
52
+ * A utility that provides the union type of all valid include paths for the given
53
+ * TypedRecordInstance.
54
+ *
55
+ * Cyclical paths are filtered out.
56
+ *
57
+ */
58
+
59
+ function createIncludeValidator() {
60
+ return function validateIncludes(includes) {
61
+ return includes;
62
+ };
63
+ }
64
+
65
+ /**
66
+ * A utility that takes two types, K and T, and produces a new type that is a "mask" of T based on K.
67
+ *
68
+ * That's a mouthful, so let's break it down:
69
+ *
70
+ * Let's say you have a User type and an Address type.
71
+ *
72
+ * ```ts
73
+ * interface Address {
74
+ * street: string;
75
+ * city: string;
76
+ * state: string;
77
+ * zip: string;
78
+ * }
79
+ *
80
+ * interface User {
81
+ * name: string;
82
+ * title: string;
83
+ * address: Address;
84
+ * }
85
+ * ```
86
+ *
87
+ * Now, imagine you want to load a preview of the user with some information about their address,
88
+ * but you don't want to load the entire user or address. You probably want to still ensure
89
+ * the type of the data you do load matches the underlying Address and User types, but doesn't
90
+ * include everything.
91
+ *
92
+ * If you did this manually, you might do something like this:
93
+ *
94
+ * ```ts
95
+ * interface UserPreview {
96
+ * name: string;
97
+ * address: AddressPreview;
98
+ * }
99
+ *
100
+ * interface AddressPreview {
101
+ * city: string;
102
+ * }
103
+ * ```
104
+ *
105
+ * From a TypeScript performance perspective, this is the best way to approach these preview
106
+ * types, but this is also tedious and error-prone, especially if the User or Address types change.
107
+ *
108
+ * For Address, we could create a validated type using `Pick`:
109
+ *
110
+ * ```ts
111
+ * type AddressPreview = Pick<Address, 'city'>;
112
+ * ```
113
+ *
114
+ * This ensures that if the Address type changes, our AddressPreview will still be valid.
115
+ * However, for UserPreview, we can't just use `Pick` because the `address` property is of type `Address`,
116
+ * not `AddressPreview`. This is where the `Mask` type comes in.
117
+ *
118
+ * With `Mask`, we define the `UserPreview` in two parts
119
+ * - first, we define the subset of fields we want to include from `User`, using `Pick` or an interface.
120
+ * - then, we use `Mask` to replace the related types of fields like Address with their more limited subset.
121
+ *
122
+ * Here's how we can do it:
123
+ *
124
+ * ```ts
125
+ * // First, we define the base of UserPreview with Pick
126
+ * type UserPreviewBase = Pick<User, 'name' | 'address'>;
127
+ * // Then, we use Mask to replace Address with AddressPreview
128
+ * type UserPreview = Mask<{ address: AddressPreview }, UserPreviewBase>;
129
+ * ```
130
+ *
131
+ * Now, `UserPreview` will have the `name` field from `User` and the `address` field will be of type `AddressPreview`.
132
+ * This way, if the `User` or `Address` types change, TypeScript will ensure that our `UserPreview` and `AddressPreview`
133
+ * types remain valid and consistent with the underlying types.
134
+ *
135
+ * But what if your app has data with massive interfaces such that the TypeScript performance of this
136
+ * approach becomes a problem? In that case, see {@link Validate}
137
+ */
138
+
139
+ /**
140
+ * A utility that takes two types, K and T, and ensures that K is a valid subset of T.
141
+ *
142
+ * That's a mouthful, so let's break it down:
143
+ *
144
+ * Let's say you have a User type and an Address type.
145
+ *
146
+ * ```ts
147
+ * interface Address {
148
+ * street: string;
149
+ * city: string;
150
+ * state: string;
151
+ * zip: string;
152
+ * }
153
+ *
154
+ * interface User {
155
+ * name: string;
156
+ * title: string;
157
+ * address: Address;
158
+ * }
159
+ * ```
160
+ *
161
+ * Now, imagine you want to load a preview of the user with some information about their address,
162
+ * but you don't want to load the entire user or address. You probably want to still ensure
163
+ * the type of the data you do load matches the underlying Address and User types, but doesn't
164
+ * include everything.
165
+ *
166
+ * You might do something like this:
167
+ *
168
+ * ```ts
169
+ * interface UserPreview {
170
+ * name: string;
171
+ * address: AddressPreview;
172
+ * }
173
+ *
174
+ * interface AddressPreview {
175
+ * city: string;
176
+ * }
177
+ * ```
178
+ *
179
+ * From a TypeScript performance perspective, this is the best way to approach these preview
180
+ * types, but this is also error-prone, especially if the User or Address types change.
181
+ *
182
+ * Validate can help ensure that your preview types remain valid.
183
+ *
184
+ * ```ts
185
+ * type IsValidUserPreview = Validate<UserPreview, User>; // This will be valid
186
+ * ```
187
+ *
188
+ * For help creating subsets of types, see {@link Mask}
189
+ */
190
+
191
+ export { createIncludeValidator };
@@ -0,0 +1,77 @@
1
+ import { getOrSetUniversal, getOrSetGlobal } from './-private.js';
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
+
5
+ const SkipCache = getOrSetUniversal('SkipCache', Symbol.for('wd:skip-cache'));
6
+ const EnableHydration = getOrSetUniversal('EnableHydration', Symbol.for('wd:enable-hydration'));
7
+ const IS_FUTURE = getOrSetGlobal('IS_FUTURE', Symbol('IS_FUTURE'));
8
+ const STRUCTURED = getOrSetGlobal('DOC', Symbol('DOC'));
9
+
10
+ /**
11
+ * Use these options to adjust {@link CacheHandler} behavior for a request
12
+ * via {@link RequestInfo.cacheOptions}.
13
+ *
14
+ */
15
+
16
+ /**
17
+ * When a {@link Future} resolves, it returns an object
18
+ * containing the original {@link RequestInfo | request},
19
+ * the {@link Response | response} set by the handler chain (if any), and
20
+ * the processed content.
21
+ */
22
+
23
+ /**
24
+ * When a {@link Future} rejects, it throws either an {@link Error}
25
+ * an {@link AggregateError} or a {@link DOMException} that maintains
26
+ * the `{ request, response, content }` shape but is also an Error instance
27
+ * itself.
28
+ *
29
+ * If using the error originates from the {@link Fetch | Fetch Handler}
30
+ * the error will be a {@link FetchError}
31
+ */
32
+
33
+ /**
34
+ * A union of the resolve/reject data types for the {@link Future}
35
+ * returned by {@link Store.request | request}
36
+ *
37
+ * See also the docs for:
38
+ *
39
+ * - {@link Future}
40
+ * - {@link StructuredDataDocument} (resolved/successful requests)
41
+ * - {@link StructuredErrorDocument} (rejected/failed requests)
42
+ */
43
+
44
+ /**
45
+ * The {@link RequestInit} interface accepted by the native {@link fetch} API.
46
+ *
47
+ * WarpDrive provides our own typings due to incompleteness in the native typings.
48
+ *
49
+ * @privateRemarks
50
+ * - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)
51
+ * - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)
52
+ * - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)
53
+ *
54
+ */
55
+
56
+ /**
57
+ * Extends JavaScript's native {@link fetch} {@link NativeRequestInit | RequestInit} with additional
58
+ * properties specific to the {@link RequestManager | RequestManager's} capabilities.
59
+ *
60
+ * This interface is used to define the shape of a request that can be made via
61
+ * either the {@link RequestManager.request} or {@link Store.request} methods.
62
+ *
63
+ * @privateRemarks
64
+ * - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)
65
+ * - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)
66
+ * - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)
67
+ *
68
+ * @public
69
+ * @since 4.12
70
+ */
71
+
72
+ /**
73
+ * Immutable version of {@link RequestInfo}. This is what is passed to handlers.
74
+ *
75
+ */
76
+
77
+ export { EnableHydration, IS_FUTURE, STRUCTURED, SkipCache };
@@ -0,0 +1,34 @@
1
+ import { getOrSetUniversal } from './-private.js';
2
+ const RuntimeConfig = getOrSetUniversal('WarpDriveRuntimeConfig', {
3
+ debug: {}
4
+ });
5
+ function trySessionStorage() {
6
+ // This works even when sessionStorage is not available.
7
+ // See https://github.com/warp-drive-data/warp-drive/issues/9784
8
+ try {
9
+ return globalThis.sessionStorage;
10
+ } catch {
11
+ return undefined;
12
+ }
13
+ }
14
+ const storage = trySessionStorage();
15
+ const settings = storage?.getItem('WarpDriveRuntimeConfig');
16
+ if (settings) {
17
+ Object.assign(RuntimeConfig, JSON.parse(settings));
18
+ }
19
+ function getRuntimeConfig() {
20
+ return RuntimeConfig;
21
+ }
22
+
23
+ /**
24
+ * Upserts the specified logging configuration into the runtime
25
+ * config.
26
+ *
27
+ * globalThis.setWarpDriveLogging({ LOG_CACHE: true } });
28
+ *
29
+ */
30
+ function setLogging(config) {
31
+ Object.assign(RuntimeConfig.debug, config);
32
+ storage?.setItem('WarpDriveRuntimeConfig', JSON.stringify(RuntimeConfig));
33
+ }
34
+ export { getRuntimeConfig, setLogging };
File without changes