@warp-drive/core 5.6.0-beta.1 → 5.6.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/declarations/graph/-private/-diff.d.ts +7 -20
  2. package/declarations/graph/-private/-edge-definition.d.ts +3 -12
  3. package/declarations/graph/-private/-state.d.ts +2 -2
  4. package/declarations/graph/-private/-utils.d.ts +5 -5
  5. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
  6. package/declarations/graph/-private/edges/collection.d.ts +10 -10
  7. package/declarations/graph/-private/edges/implicit.d.ts +5 -5
  8. package/declarations/graph/-private/edges/resource.d.ts +6 -7
  9. package/declarations/graph/-private/graph.d.ts +17 -15
  10. package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
  11. package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
  12. package/declarations/index.d.ts +1 -1
  13. package/declarations/reactive/-private/default-mode.d.ts +73 -0
  14. package/declarations/reactive/-private/document.d.ts +11 -27
  15. package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
  16. package/declarations/reactive/-private/fields/managed-array.d.ts +7 -10
  17. package/declarations/reactive/-private/fields/managed-object.d.ts +7 -9
  18. package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
  19. package/declarations/reactive/-private/hooks.d.ts +2 -2
  20. package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
  21. package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
  22. package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
  23. package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
  24. package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
  25. package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
  26. package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
  27. package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
  28. package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
  29. package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
  30. package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
  31. package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
  32. package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
  33. package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
  34. package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
  35. package/declarations/reactive/-private/record.d.ts +44 -33
  36. package/declarations/reactive/-private/schema.d.ts +50 -66
  37. package/declarations/reactive/-private/symbols.d.ts +2 -7
  38. package/declarations/reactive/-private.d.ts +1 -1
  39. package/declarations/reactive.d.ts +278 -1
  40. package/declarations/request/-private/context.d.ts +3 -5
  41. package/declarations/request/-private/fetch.d.ts +2 -0
  42. package/declarations/request/-private/manager.d.ts +24 -28
  43. package/declarations/request/-private/types.d.ts +22 -23
  44. package/declarations/request/-private/utils.d.ts +44 -2
  45. package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
  46. package/declarations/store/-private/cache-handler/types.d.ts +10 -10
  47. package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
  48. package/declarations/store/-private/caches/instance-cache.d.ts +22 -27
  49. package/declarations/store/-private/debug/utils.d.ts +1 -0
  50. package/declarations/store/-private/default-cache-policy.d.ts +25 -38
  51. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
  52. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
  53. package/declarations/store/-private/managers/cache-manager.d.ts +46 -95
  54. package/declarations/store/-private/managers/notification-manager.d.ts +30 -43
  55. package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
  56. package/declarations/store/-private/network/request-cache.d.ts +21 -24
  57. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  58. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
  59. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
  60. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
  61. package/declarations/store/-private/new-core-tmp/request-state.d.ts +133 -37
  62. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -133
  63. package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
  64. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
  65. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
  66. package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
  67. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
  68. package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
  69. package/declarations/store/-private/store-service.d.ts +167 -872
  70. package/declarations/store/-private.d.ts +14 -10
  71. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  72. package/declarations/store/-types/q/identifier.d.ts +9 -6
  73. package/declarations/store/-types/q/record-instance.d.ts +0 -1
  74. package/declarations/store/-types/q/schema-service.d.ts +64 -40
  75. package/declarations/store/-types/q/store.d.ts +6 -7
  76. package/declarations/store/deprecated/-private.d.ts +224 -0
  77. package/declarations/store/deprecated/store.d.ts +787 -0
  78. package/declarations/types/-private.d.ts +1 -1
  79. package/declarations/types/cache/aliases.d.ts +2 -2
  80. package/declarations/types/cache/change.d.ts +2 -2
  81. package/declarations/types/cache/mutations.d.ts +13 -13
  82. package/declarations/types/cache/operations.d.ts +115 -32
  83. package/declarations/types/cache/relationship.d.ts +4 -4
  84. package/declarations/types/cache.d.ts +51 -115
  85. package/declarations/types/graph.d.ts +12 -12
  86. package/declarations/types/identifier.d.ts +52 -76
  87. package/declarations/types/params.d.ts +2 -3
  88. package/declarations/types/request.d.ts +69 -42
  89. package/declarations/types/schema/concepts.d.ts +2 -2
  90. package/declarations/types/schema/fields.d.ts +391 -14
  91. package/declarations/types/spec/document.d.ts +6 -6
  92. package/declarations/types/spec/json-api-raw.d.ts +6 -8
  93. package/declarations/types.d.ts +2 -1
  94. package/declarations/utils/string.d.ts +2 -2
  95. package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
  96. package/dist/configure.js +1 -1
  97. package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
  98. package/dist/graph/-private.js +137 -144
  99. package/dist/index.js +25 -14
  100. package/dist/reactive/-private.js +1 -1
  101. package/dist/reactive.js +337 -1422
  102. package/dist/{request-state-CjLph1LP.js → request-state-C955e0AL.js} +8352 -5912
  103. package/dist/request.js +1 -1
  104. package/dist/store/-private.js +2 -3
  105. package/dist/store.js +32 -44
  106. package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
  107. package/dist/types/-private.js +1 -1
  108. package/dist/types/identifier.js +19 -45
  109. package/dist/types/request.js +45 -3
  110. package/dist/types/schema/fields.js +23 -2
  111. package/dist/utils/string.js +2 -2
  112. package/package.json +10 -10
  113. package/declarations/reactive/-private/fields/compute.d.ts +0 -43
  114. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  115. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
  116. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
  117. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  118. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  119. package/declarations/store/-types/q/ds-model.d.ts +0 -21
  120. package/dist/handler-C2T-IyJK.js +0 -339
package/dist/request.js CHANGED
@@ -1 +1 @@
1
- export { c as createDeferred, g as getPromiseResult, s as setPromiseResult } from "./context-COmAnXUQ.js";
1
+ export { c as createDeferred, g as getPromiseResult, s as setPromiseResult } from "./context-C_7OLieY.js";
@@ -1,3 +1,2 @@
1
- export { C as CollectionRecordArray, D as DISPOSE, I as LiveArray, M as MUTATE, R as RecordArrayManager, l as RelatedCollection, d as SOURCE, A as Signals, S as Store, j as StoreMap, _ as _clearCaches, n as _deprecatingNormalize, b as coerceId, c as constructResource, G as consumeInternalSignal, t as createRequestSubscription, z as defineNonEnumerableSignal, y as defineSignal, e as ensureStringId, x as entangleSignal, f as fastPush, w as gate, H as getOrCreateInternalSignal, q as getPromiseState, u as getRequestState, a as isDocumentIdentifier, i as isStableIdentifier, m as log, o as logGroup, v as memoized, F as notifyInternalSignal, p as peekCache, B as peekInternalSignal, r as recordIdentifierFor, g as removeRecordDataFor, k as setCacheFor, h as setRecordIdentifier, s as storeFor, E as withSignalStore } from "../request-state-CjLph1LP.js";
2
- export { C as CacheHandler } from "../handler-C2T-IyJK.js";
3
- export { A as ARRAY_SIGNAL, O as OBJECT_SIGNAL, c as createMemo, w as waitFor } from "../configure-B48bFHOl.js";
1
+ export { C as CacheHandler, D as DISPOSE, R as RecordArrayManager, E as Signals, S as Store, k as StoreMap, _ as _clearCaches, n as _deprecatingNormalize, h as assertPrivateCapabilities, d as assertPrivateStore, b as coerceId, c as constructResource, J as consumeInternalSignal, G as createInternalMemo, l as createLegacyManyArray, q as createRequestSubscription, A as defineGate, B as defineNonEnumerableSignal, z as defineSignal, e as ensureStringId, y as entangleInitiallyStaleSignal, x as entangleSignal, f as fastPush, w as gate, K as getOrCreateInternalSignal, p as getPromiseState, t as getRequestState, g as isPrivateStore, a as isRequestKey, i as isResourceKey, m as log, o as logGroup, v as memoized, I as notifyInternalSignal, F as peekInternalSignal, r as recordIdentifierFor, j as setRecordIdentifier, u as signal, s as storeFor, H as withSignalStore } from "../request-state-C955e0AL.js";
2
+ export { A as ARRAY_SIGNAL, O as OBJECT_SIGNAL, w as waitFor } from "../configure-C3x8YXzL.js";
package/dist/store.js CHANGED
@@ -94,7 +94,7 @@ function parseCacheControlValue(stringToParse) {
94
94
  }
95
95
  return parsedValue;
96
96
  }
97
- function isExpired(identifier, request, config) {
97
+ function isExpired(cacheKey, request, config) {
98
98
  const {
99
99
  constraints
100
100
  } = config;
@@ -104,7 +104,7 @@ function isExpired(identifier, request, config) {
104
104
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
105
105
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
106
106
  // eslint-disable-next-line no-console
107
- console.log(`CachePolicy: ${identifier.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because constraints.isExpired returned ${result}`);
107
+ console.log(`CachePolicy: ${cacheKey.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because constraints.isExpired returned ${result}`);
108
108
  }
109
109
  }
110
110
  return result;
@@ -117,7 +117,7 @@ function isExpired(identifier, request, config) {
117
117
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
118
118
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
119
119
  // eslint-disable-next-line no-console
120
- console.log(`CachePolicy: ${identifier.lid} is EXPIRED because no headers were provided`);
120
+ console.log(`CachePolicy: ${cacheKey.lid} is EXPIRED because no headers were provided`);
121
121
  }
122
122
  }
123
123
 
@@ -138,7 +138,7 @@ function isExpired(identifier, request, config) {
138
138
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
139
139
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
140
140
  // eslint-disable-next-line no-console
141
- console.log(`CachePolicy: ${identifier.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the time set by X-WarpDrive-Expires header is ${result ? 'in the past' : 'in the future'}`);
141
+ console.log(`CachePolicy: ${cacheKey.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the time set by X-WarpDrive-Expires header is ${result ? 'in the past' : 'in the future'}`);
142
142
  }
143
143
  }
144
144
  return result;
@@ -174,7 +174,7 @@ function isExpired(identifier, request, config) {
174
174
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
175
175
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
176
176
  // eslint-disable-next-line no-console
177
- console.log(`CachePolicy: ${identifier.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the time set by Cache-Control header is ${result ? 'in the past' : 'in the future'}`);
177
+ console.log(`CachePolicy: ${cacheKey.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the time set by Cache-Control header is ${result ? 'in the past' : 'in the future'}`);
178
178
  }
179
179
  }
180
180
  return result;
@@ -192,7 +192,7 @@ function isExpired(identifier, request, config) {
192
192
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
193
193
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
194
194
  // eslint-disable-next-line no-console
195
- console.log(`CachePolicy: ${identifier.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the time set by Expires header is ${result ? 'in the past' : 'in the future'}`);
195
+ console.log(`CachePolicy: ${cacheKey.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the time set by Expires header is ${result ? 'in the past' : 'in the future'}`);
196
196
  }
197
197
  }
198
198
  return result;
@@ -205,7 +205,7 @@ function isExpired(identifier, request, config) {
205
205
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
206
206
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
207
207
  // eslint-disable-next-line no-console
208
- console.log(`CachePolicy: ${identifier.lid} is EXPIRED because no Date header was provided`);
208
+ console.log(`CachePolicy: ${cacheKey.lid} is EXPIRED because no Date header was provided`);
209
209
  }
210
210
  }
211
211
  return true;
@@ -222,7 +222,7 @@ function isExpired(identifier, request, config) {
222
222
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
223
223
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
224
224
  // eslint-disable-next-line no-console
225
- console.log(`CachePolicy: ${identifier.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the apiCacheHardExpires time since the response's Date header is ${result ? 'in the past' : 'in the future'}`);
225
+ console.log(`CachePolicy: ${cacheKey.lid} is ${result ? 'EXPIRED' : 'NOT expired'} because the apiCacheHardExpires time since the response's Date header is ${result ? 'in the past' : 'in the future'}`);
226
226
  }
227
227
  }
228
228
  return result;
@@ -263,7 +263,7 @@ function isExpired(identifier, request, config) {
263
263
  * request for that type is successful.
264
264
  *
265
265
  * For this to work, the `createRecord` request must include the `cacheOptions.types` array
266
- * with the types that should be invalidated, or its request should specify the identifiers
266
+ * with the types that should be invalidated, or its request should specify the ResourceKeys
267
267
  * of the records that are being created via `records`. Providing both is valid.
268
268
  *
269
269
  * > [!NOTE]
@@ -352,22 +352,20 @@ class DefaultCachePolicy {
352
352
  }
353
353
 
354
354
  /**
355
- * Invalidate a request by its identifier for a given store instance.
355
+ * Invalidate a request by its CacheKey for the given store instance.
356
356
  *
357
357
  * While the store argument may seem redundant, the CachePolicy
358
358
  * is designed to be shared across multiple stores / forks
359
359
  * of the store.
360
360
  *
361
361
  * ```ts
362
- * store.lifetimes.invalidateRequest(store, identifier);
362
+ * store.lifetimes.invalidateRequest(store, cacheKey);
363
363
  * ```
364
364
  *
365
365
  * @public
366
- * @param {StableDocumentIdentifier} identifier
367
- * @param {Store} store
368
366
  */
369
- invalidateRequest(identifier, store) {
370
- this._getStore(store).invalidated.add(identifier);
367
+ invalidateRequest(cacheKey, store) {
368
+ this._getStore(store).invalidated.add(cacheKey);
371
369
  }
372
370
 
373
371
  /**
@@ -386,8 +384,6 @@ class DefaultCachePolicy {
386
384
  * ```
387
385
  *
388
386
  * @public
389
- * @param {String} type
390
- * @param {Store} store
391
387
  */
392
388
  invalidateRequestsForType(type, store) {
393
389
  const storeCache = this._getStore(store);
@@ -397,7 +393,8 @@ class DefaultCachePolicy {
397
393
  // TODO batch notifications
398
394
  set.forEach(id => {
399
395
  storeCache.invalidated.add(id);
400
- notifications.notify(id, 'invalidated');
396
+ // @ts-expect-error
397
+ notifications.notify(id, 'invalidated', null);
401
398
  });
402
399
  }
403
400
  }
@@ -413,13 +410,8 @@ class DefaultCachePolicy {
413
410
  * This method should not be invoked directly by consumers.
414
411
  *
415
412
  * @public
416
- * @param {ImmutableRequestInfo} request
417
- * @param {ImmutableResponse} response
418
- * @param {Store} store
419
- * @param {StableDocumentIdentifier | null} identifier
420
- * @return {void}
421
413
  */
422
- didRequest(request, response, identifier, store) {
414
+ didRequest(request, response, cacheKey, store) {
423
415
  // if this is a successful createRecord request, invalidate the cacheKey for the type
424
416
  if (request.op === 'createRecord') {
425
417
  const statusNumber = response?.status ?? 0;
@@ -436,15 +428,15 @@ class DefaultCachePolicy {
436
428
 
437
429
  // add this document's cacheKey to a map for all associated types
438
430
  // it is recommended to only use this for queries
439
- } else if (identifier && request.cacheOptions?.types?.length) {
431
+ } else if (cacheKey && request.cacheOptions?.types?.length) {
440
432
  const storeCache = this._getStore(store);
441
433
  request.cacheOptions?.types.forEach(type => {
442
434
  const set = storeCache.types.get(type);
443
435
  if (set) {
444
- set.add(identifier);
445
- storeCache.invalidated.delete(identifier);
436
+ set.add(cacheKey);
437
+ storeCache.invalidated.delete(cacheKey);
446
438
  } else {
447
- storeCache.types.set(type, new Set([identifier]));
439
+ storeCache.types.set(type, new Set([cacheKey]));
448
440
  }
449
441
  });
450
442
  }
@@ -462,28 +454,26 @@ class DefaultCachePolicy {
462
454
  * and the cache will be updated before returning the response.
463
455
  *
464
456
  * @public
465
- * @param {StableDocumentIdentifier} identifier
466
- * @param {Store} store
467
- * @return {Boolean} true if the request is considered hard expired
457
+ * @return true if the request is considered hard expired
468
458
  */
469
- isHardExpired(identifier, store) {
459
+ isHardExpired(cacheKey, store) {
470
460
  // if we are explicitly invalidated, we are hard expired
471
461
  const storeCache = this._getStore(store);
472
- if (storeCache.invalidated.has(identifier)) {
462
+ if (storeCache.invalidated.has(cacheKey)) {
473
463
  return true;
474
464
  }
475
465
  const cache = store.cache;
476
- const cached = cache.peekRequest(identifier);
466
+ const cached = cache.peekRequest(cacheKey);
477
467
  if (!cached?.response) {
478
468
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
479
469
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
480
470
  // eslint-disable-next-line no-console
481
- console.log(`CachePolicy: ${identifier.lid} is EXPIRED because no cache entry was found`);
471
+ console.log(`CachePolicy: ${cacheKey.lid} is EXPIRED because no cache entry was found`);
482
472
  }
483
473
  }
484
474
  return true;
485
475
  }
486
- return isExpired(identifier, cached, this.config);
476
+ return isExpired(cacheKey, cached, this.config);
487
477
  }
488
478
 
489
479
  /**
@@ -497,25 +487,23 @@ class DefaultCachePolicy {
497
487
  * request is made to update the cache via the configured request handlers.
498
488
  *
499
489
  * @public
500
- * @param {StableDocumentIdentifier} identifier
501
- * @param {Store} store
502
- * @return {Boolean} true if the request is considered soft expired
490
+ * @return true if the request is considered soft expired
503
491
  */
504
- isSoftExpired(identifier, store) {
492
+ isSoftExpired(cacheKey, store) {
505
493
  if (macroCondition(getGlobalConfig().WarpDrive.env.TESTING)) {
506
494
  if (!this.config.disableTestOptimization) {
507
495
  return false;
508
496
  }
509
497
  }
510
498
  const cache = store.cache;
511
- const cached = cache.peekRequest(identifier);
499
+ const cached = cache.peekRequest(cacheKey);
512
500
  if (cached?.response) {
513
501
  const date = cached.response.headers.get('date');
514
502
  if (!date) {
515
503
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
516
504
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
517
505
  // eslint-disable-next-line no-console
518
- console.log(`CachePolicy: ${identifier.lid} is STALE because no date header was found`);
506
+ console.log(`CachePolicy: ${cacheKey.lid} is STALE because no date header was found`);
519
507
  }
520
508
  }
521
509
  return true;
@@ -527,7 +515,7 @@ class DefaultCachePolicy {
527
515
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
528
516
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
529
517
  // eslint-disable-next-line no-console
530
- console.log(`CachePolicy: ${identifier.lid} is ${result ? 'STALE' : 'NOT stale'}. Expiration time: ${deadline}, now: ${now}`);
518
+ console.log(`CachePolicy: ${cacheKey.lid} is ${result ? 'STALE' : 'NOT stale'}. Expiration time: ${deadline}, now: ${now}`);
531
519
  }
532
520
  }
533
521
  return result;
@@ -536,7 +524,7 @@ class DefaultCachePolicy {
536
524
  if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_CACHE_POLICY)) {
537
525
  if (getGlobalConfig().WarpDrive.debug.LOG_CACHE_POLICY || globalThis.getWarpDriveRuntimeConfig().debug.LOG_CACHE_POLICY) {
538
526
  // eslint-disable-next-line no-console
539
- console.log(`CachePolicy: ${identifier.lid} is STALE because no cache entry was found`);
527
+ console.log(`CachePolicy: ${cacheKey.lid} is STALE because no cache entry was found`);
540
528
  }
541
529
  }
542
530
  return true;
@@ -32,13 +32,8 @@ import { getOrSetGlobal } from './types/-private.js';
32
32
  // debugging DX and as a safe way to provide an intimate contract on public objects.
33
33
 
34
34
  const SOURCE = getOrSetGlobal('SOURCE', Symbol('#source'));
35
- getOrSetGlobal('MUTATE', Symbol('#update'));
36
35
  const Destroy = getOrSetGlobal('Destroy', Symbol.dispose || Symbol.for('Dispose'));
37
- const Identifier = getOrSetGlobal('Identifier', Symbol('Identifier'));
38
- const Editable = getOrSetGlobal('Editable', Symbol('Editable'));
39
- const Parent = getOrSetGlobal('Parent', Symbol('Parent'));
40
36
  const Checkout = getOrSetGlobal('Checkout', Symbol('Checkout'));
41
- const Legacy = getOrSetGlobal('Legacy', Symbol('Legacy'));
42
- const EmbeddedPath = getOrSetGlobal('EmbeddedPath', Symbol('EmbeddedPath'));
43
- const EmbeddedField = getOrSetGlobal('EmbeddedField', Symbol('EmbeddedField'));
44
- export { Checkout as C, Destroy as D, Editable as E, Identifier as I, Legacy as L, Parent as P, SOURCE as S, EmbeddedPath as a, EmbeddedField as b };
37
+ const Commit = getOrSetGlobal('Commit', Symbol('Commit'));
38
+ const Context = getOrSetGlobal('Context', Symbol('Context'));
39
+ export { Context as C, Destroy as D, SOURCE as S, Checkout as a, Commit as b };
@@ -1,6 +1,6 @@
1
1
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
2
2
  const name = "@warp-drive/core";
3
- const version = "5.6.0-beta.1";
3
+ const version = "5.6.0-beta.2";
4
4
 
5
5
  // in testing mode, we utilize globals to ensure only one copy exists of
6
6
  // these maps, due to bugs in ember-auto-import
@@ -2,7 +2,7 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
2
2
 
3
3
  // provided for additional debuggability
4
4
  const DEBUG_CLIENT_ORIGINATED = Symbol('record-originated-on-client');
5
- const DEBUG_IDENTIFIER_BUCKET = Symbol('identifier-bucket');
5
+ const DEBUG_KEY_TYPE = Symbol('key-type');
6
6
  const DEBUG_STALE_CACHE_OWNER = Symbol('warpDriveStaleCache');
7
7
  function ProdSymbol(str, debugStr) {
8
8
  return macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? Symbol(debugStr) : str;
@@ -12,78 +12,52 @@ function ProdSymbol(str, debugStr) {
12
12
  const CACHE_OWNER = ProdSymbol('__$co', 'CACHE_OWNER');
13
13
 
14
14
  /**
15
- * An Identifier specific to a record which may or may not
16
- * be present in the cache.
15
+ * A referentially stable object with a unique string (lid) that can be used
16
+ * as a reference to request data in the cache.
17
17
  *
18
- * The absence of an `id` DOES NOT indicate that this
19
- * Identifier is for a new client-created record as it
20
- * may also indicate that it was generated for a secondary
21
- * index and the primary `id` index is not yet known.
18
+ * Only requests that are assigned a RequestKey are retrievable/replayable from
19
+ * the cache, though requests without RequestKeys may still update cache state.
22
20
  *
23
- * @internal
21
+ * @public
24
22
  */
25
23
 
24
+ /** @deprecated use {@link RequestKey} */
25
+
26
26
  /**
27
- * Used when an Identifier is known to be the stable version
28
- *
29
- * @internal
27
+ * Used when an ResourceKey is known to be the stable version
30
28
  */
31
29
 
32
30
  /**
33
- * Used when a StableRecordIdentifier was not created locally as part
31
+ * Used when a ResourceKey was not created locally as part
34
32
  * of a call to store.createRecord
35
33
  *
36
- * Distinguishing between this Identifier and one for a client created
37
- * record that was created with an ID is generally speaking not possible
34
+ * Distinguishing between this ResourceKey and one for a client created
35
+ * resource that was created with an ID is generally speaking not possible
38
36
  * at runtime, so anything with an ID typically narrows to this.
39
- *
40
- * @internal
41
37
  */
42
38
 
39
+ /** @deprecated use {@link PersistedResourceKey} */
40
+
43
41
  /**
44
- * Used when a StableRecordIdentifier was created locally
42
+ * Used when a ResourceKey was created locally
45
43
  * (by a call to store.createRecord).
46
44
  *
47
- * It is possible in rare circumstances to have a StableRecordIdentifier
45
+ * It is possible in rare circumstances to have a ResourceKey
48
46
  * that is not for a new record but does not have an ID. This would
49
47
  * happen if a user intentionally created one for use with a secondary-index
50
48
  * prior to the record having been fully loaded.
51
- *
52
- * @internal
53
49
  */
54
50
 
55
51
  /**
56
52
  * A referentially stable object with a unique string (lid) that can be used
57
53
  * as a reference to data in the cache.
58
54
  *
59
- * Every record instance has a unique identifier, and identifiers may refer
55
+ * Every resource has a unique ResourceKey, and ResourceKeys may refer
60
56
  * to data that has never been loaded (for instance, in an async relationship).
61
57
  *
62
- * @class StableRecordIdentifier
63
58
  * @public
64
59
  */
65
60
 
66
- /**
67
- * A string representing a unique identity.
68
- *
69
- * @property lid
70
- * @type {String}
71
- * @public
72
- */
73
- /**
74
- * the primary resource `type` or `modelName` this identity belongs to.
75
- *
76
- * @property type
77
- * @type {String}
78
- * @public
79
- */
80
- /**
81
- * the primary id for the record this identity belongs to. `null`
82
- * if not yet assigned an id.
83
- *
84
- * @property id
85
- * @type {String | null}
86
- * @public
87
- */
61
+ /** @deprecated use {@link ResourceKey} */
88
62
 
89
- export { CACHE_OWNER, DEBUG_CLIENT_ORIGINATED, DEBUG_IDENTIFIER_BUCKET, DEBUG_STALE_CACHE_OWNER };
63
+ export { CACHE_OWNER, DEBUG_CLIENT_ORIGINATED, DEBUG_KEY_TYPE, DEBUG_STALE_CACHE_OWNER };
@@ -1,4 +1,7 @@
1
1
  import { getOrSetUniversal, getOrSetGlobal } from './-private.js';
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
+
2
5
  const SkipCache = getOrSetUniversal('SkipCache', Symbol.for('wd:skip-cache'));
3
6
  const EnableHydration = getOrSetUniversal('EnableHydration', Symbol.for('wd:enable-hydration'));
4
7
  const IS_FUTURE = getOrSetGlobal('IS_FUTURE', Symbol('IS_FUTURE'));
@@ -10,16 +13,55 @@ const STRUCTURED = getOrSetGlobal('DOC', Symbol('DOC'));
10
13
  */
11
14
 
12
15
  /**
13
- * JavaScript's native Request class.
16
+ * When a handler chain resolves, it returns an object
17
+ * containing the original request, the response set by the handler
18
+ * chain (if any), and the processed content.
19
+ */
20
+
21
+ /**
22
+ * When a handler chain rejects, it throws an Error that maintains the
23
+ * `{ request, response, content }` shape but is also an Error instance
24
+ * itself.
25
+ *
26
+ * If using the error originates from the {@link Fetch | Fetch Handler}
27
+ * the error will be a {@link FetchError}
28
+ */
29
+
30
+ /**
31
+ * A union of the resolve/reject data types for a request.
32
+ *
33
+ * See the docs for:
34
+ *
35
+ * - {@link StructuredDataDocument} (resolved/successful requests)
36
+ * - {@link StructuredErrorDocument} (rejected/failed requests)
37
+ */
38
+
39
+ /**
40
+ * The {@link RequestInit} interface accepted by the native {@link fetch} API.
14
41
  *
15
42
  * WarpDrive provides our own typings due to incompleteness in the native typings.
16
43
  *
44
+ * @privateRemarks
45
+ * - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)
46
+ * - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)
47
+ * - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)
48
+ *
17
49
  */
18
50
 
19
51
  /**
20
- * Extends JavaScript's native {@link Request} object with additional
21
- * properties specific to the RequestManager's capabilities.
52
+ * Extends JavaScript's native {@link fetch} {@link NativeRequestInit | RequestInit} with additional
53
+ * properties specific to the {@link RequestManager | RequestManager's} capabilities.
54
+ *
55
+ * This interface is used to define the shape of a request that can be made via
56
+ * either the {@link RequestManager.request} or {@link Store.request} methods.
57
+ *
58
+ * @privateRemarks
59
+ * - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)
60
+ * - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)
61
+ * - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)
22
62
  *
63
+ * @public
64
+ * @since 4.12
23
65
  */
24
66
 
25
67
  /**
@@ -1,3 +1,11 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
+
5
+ /**
6
+ * Options signature for Legacy Attributes.
7
+ */
8
+
1
9
  /**
2
10
  * A generic "field" that can be used to define
3
11
  * primitive value fields.
@@ -132,7 +140,7 @@
132
140
  * perform those itself.
133
141
  *
134
142
  * A schema-array can declare its "key" value to be `@hash` if
135
- * a schema-object has such a field.
143
+ * the schema-objects it contains have such a field.
136
144
  *
137
145
  * Only one hash field is permittable per schema-object, and
138
146
  * it should be placed in the `ResourceSchema`'s `@id` field
@@ -186,11 +194,13 @@
186
194
  /**
187
195
  * Represents a field whose value is an object
188
196
  * with a well-defined structure described by
189
- * a non-resource schema.
197
+ * a schema-object (a non-resource schema).
190
198
  *
191
199
  * If the object's structure is not well-defined,
192
200
  * use 'object' instead.
193
201
  *
202
+ * By default, a SchemaObject within
203
+ *
194
204
  * @public
195
205
  */
196
206
 
@@ -374,6 +384,17 @@
374
384
  * @public
375
385
  */
376
386
 
387
+ /**
388
+ * A union of all possible LegacyMode and PolarisMode
389
+ * field schemas that represent data that could be in
390
+ * the cache.
391
+ *
392
+ * In other words this will not include types like alias
393
+ * fields, local fields, or derived fields.
394
+ *
395
+ * @public
396
+ */
397
+
377
398
  /**
378
399
  * A union of all possible field schemas that can be
379
400
  * used in an ObjectSchema.
@@ -19,7 +19,7 @@ const DEFAULT_MAX_CACHE_SIZE = 10_000;
19
19
  * and by `@warp-drive/utilities/string`. It is not intended
20
20
  * for use outside of these modules at this time.
21
21
  *
22
- * @internal
22
+ * @private
23
23
  */
24
24
  class LRUCache {
25
25
  // debug stats
@@ -84,7 +84,7 @@ const STRING_DASHERIZE_CACHE = new LRUCache(key => key.replace(STRING_DECAMELIZE
84
84
  * This version is only in this location to support a deprecated
85
85
  * behavior in the core package and will be removed in a future.
86
86
  *
87
- * @internal
87
+ * @private
88
88
  */
89
89
  function dasherize(str) {
90
90
  return STRING_DASHERIZE_CACHE.get(str);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warp-drive/core",
3
- "version": "5.6.0-beta.1",
3
+ "version": "5.6.0-beta.2",
4
4
  "description": "Core package for WarpDrive | All the Universal Basics",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -36,19 +36,19 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@embroider/macros": "^1.16.12",
40
- "@warp-drive/build-config": "5.6.0-beta.2"
39
+ "@embroider/macros": "^1.18.1",
40
+ "@warp-drive/build-config": "5.6.0-beta.3"
41
41
  },
42
42
  "devDependencies": {
43
- "@babel/core": "^7.26.10",
44
- "@babel/plugin-transform-typescript": "^7.27.0",
45
- "@babel/preset-typescript": "^7.27.0",
46
- "@warp-drive/internal-config": "5.6.0-beta.2",
43
+ "@babel/core": "^7.28.0",
44
+ "@babel/plugin-transform-typescript": "^7.28.0",
45
+ "@babel/preset-typescript": "^7.27.1",
46
+ "@warp-drive/internal-config": "5.6.0-beta.3",
47
47
  "decorator-transforms": "^2.3.0",
48
- "ember-source": "~6.3.0",
48
+ "ember-source": "~6.6.0",
49
49
  "expect-type": "^1.2.1",
50
- "typescript": "^5.8.3",
51
- "vite": "^7.0.0"
50
+ "typescript": "^5.9.2",
51
+ "vite": "^7.1.3"
52
52
  },
53
53
  "volta": {
54
54
  "extends": "../../package.json"
@@ -1,43 +0,0 @@
1
- import type { Store, StoreRequestInput } from "../../../index.js";
2
- import type { Future } from "../../../request.js";
3
- import { RelatedCollection as ManyArray } from "../../../store/-private.js";
4
- import type { Cache } from "../../../types/cache.js";
5
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
6
- import type { ArrayField, DerivedField, FieldSchema, GenericField, LegacyHasManyField, LocalField, ObjectField, SchemaArrayField, SchemaObjectField } from "../../../types/schema/fields.js";
7
- import type { Links } from "../../../types/spec/json-api-raw.js";
8
- import { RecordStore } from "../../../types/symbols.js";
9
- import { ReactiveResource } from "../record.js";
10
- import type { SchemaService } from "../schema.js";
11
- import { Parent } from "../symbols.js";
12
- import { ManagedArray } from "./managed-array.js";
13
- import { ManagedObject } from "./managed-object.js";
14
- export declare const ManagedArrayMap: Map<ReactiveResource, Map<string, ManagedArray | ManyArray>>;
15
- export declare const ManagedObjectMap: Map<ReactiveResource, Map<string, ManagedObject | ReactiveResource>>;
16
- export declare function computeLocal(record: typeof Proxy<ReactiveResource>, field: LocalField, prop: string): unknown;
17
- export declare function peekManagedArray(record: ReactiveResource, field: FieldSchema): ManyArray | ManagedArray | undefined;
18
- export declare function peekManagedObject(record: ReactiveResource, field: ObjectField): ManagedObject | undefined;
19
- export declare function peekManagedObject(record: ReactiveResource, field: SchemaObjectField): ReactiveResource | undefined;
20
- export declare function computeField(schema: SchemaService, cache: Cache, record: ReactiveResource, identifier: StableRecordIdentifier, field: GenericField, prop: string | string[], editable: boolean): unknown;
21
- export declare function computeArray(store: Store, schema: SchemaService, cache: Cache, record: ReactiveResource, identifier: StableRecordIdentifier, field: ArrayField | SchemaArrayField, path: string[], editable: boolean, legacy: boolean): ManagedArray | null;
22
- export declare function computeObject(schema: SchemaService, cache: Cache, record: ReactiveResource, identifier: StableRecordIdentifier, field: ObjectField, path: string[], editable: boolean, legacy: boolean): ManagedObject | null;
23
- export declare function computeSchemaObject(store: Store, cache: Cache, record: ReactiveResource, identifier: StableRecordIdentifier, field: SchemaObjectField, path: string[], legacy: boolean, editable: boolean): ReactiveResource | null;
24
- export declare function computeAttribute(cache: Cache, identifier: StableRecordIdentifier, prop: string, editable: boolean): unknown;
25
- export declare function computeDerivation(schema: SchemaService, record: ReactiveResource, identifier: StableRecordIdentifier, field: DerivedField, prop: string): unknown;
26
- interface ResourceRelationship<T extends ReactiveResource = ReactiveResource> {
27
- lid: string;
28
- [Parent]: ReactiveResource;
29
- [RecordStore]: Store;
30
- name: string;
31
- data: T | null;
32
- links: Links;
33
- meta: Record<string, unknown>;
34
- }
35
- // TODO probably this should just be a Document
36
- // but its separate until we work out the lid situation
37
- declare class ResourceRelationship<T extends ReactiveResource = ReactiveResource> {
38
- constructor(store: Store, cache: Cache, parent: ReactiveResource, identifier: StableRecordIdentifier, field: FieldSchema, name: string, editable: boolean);
39
- fetch(options?: StoreRequestInput<T, T>): Future<T>;
40
- }
41
- export declare function computeResource<T extends ReactiveResource>(store: Store, cache: Cache, parent: ReactiveResource, identifier: StableRecordIdentifier, field: FieldSchema, prop: string, editable: boolean): ResourceRelationship<T>;
42
- export declare function computeHasMany(store: Store, schema: SchemaService, cache: Cache, record: ReactiveResource, identifier: StableRecordIdentifier, field: LegacyHasManyField, path: string[], editable: boolean, legacy: boolean): ManyArray | null;
43
- export {};
@@ -1,12 +0,0 @@
1
- import type { Cache } from "../../../types/cache.js";
2
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
3
- import type { OpaqueRecordInstance } from "../../-types/q/record-instance.js";
4
- /*
5
- * Returns the Cache instance associated with a given
6
- * Model or Identifier
7
- */
8
- export declare const CacheForIdentifierCache: Map<unknown, Cache>;
9
- export declare function setCacheFor(identifier: StableRecordIdentifier | OpaqueRecordInstance, cache: Cache): void;
10
- export declare function removeRecordDataFor(identifier: StableRecordIdentifier | OpaqueRecordInstance): void;
11
- export declare function peekCache(instance: StableRecordIdentifier): Cache | null;
12
- export declare function peekCache(instance: OpaqueRecordInstance): Cache;