teamplay 0.4.0-alpha.35 → 0.4.0-alpha.36

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.
@@ -816,6 +816,11 @@ Async variant: no Suspense, returns `undefined` until ready.
816
816
  - they register a **query readiness check**:
817
817
  query ids must be materialized in DataTree, and each `collection.id` from ids must
818
818
  be visible in DataTree (or explicitly missing).
819
+ - for `$aggregate` queries, readiness is query-level:
820
+ DataTree must have `$queries.<hash>.docs` (array, including empty), or `extra`.
821
+ Aggregate rows are not required to exist as `collection.<id>` docs.
822
+ Presence of `$queries.<hash>.ids` alone does not mark aggregate readiness.
823
+ For Teamplay aggregation subscriptions, `$aggregations.<hash>` also marks readiness.
819
824
 
820
825
  ### Query Helpers
821
826
 
@@ -6,6 +6,7 @@ import { getRaw } from '../dataTree.js'
6
6
  import { getConnection } from '../connection.js'
7
7
  import { isCompatEnv } from '../compatEnv.js'
8
8
  import { hashQuery, QUERIES } from '../Query.js'
9
+ import { AGGREGATIONS } from '../Aggregation.js'
9
10
 
10
11
  const $root = getRootSignal({ rootId: GLOBAL_ROOT_ID, rootFunction: universal$ })
11
12
 
@@ -371,16 +372,26 @@ function registerBatchQueryReadinessCheck (collection, query) {
371
372
  if (!collection || !query || typeof query !== 'object') return
372
373
  const hash = hashQuery(collection, query)
373
374
  const idsSegments = [QUERIES, hash, 'ids']
375
+ const docsSegments = [QUERIES, hash, 'docs']
376
+ const extraSegments = [QUERIES, hash, 'extra']
377
+ const aggregationSegments = [AGGREGATIONS, hash]
378
+ const isAggregate = Array.isArray(query.$aggregate)
374
379
  promiseBatcher.addCheck({
375
380
  key: `query:${hash}`,
376
381
  type: 'query',
377
- details: { collection, hash, query },
378
- isReady: () => isQueryReady(collection, idsSegments),
382
+ details: { collection, hash, query, isAggregate },
383
+ isReady: () => isQueryReady(collection, idsSegments, docsSegments, extraSegments, aggregationSegments, isAggregate),
379
384
  getState: () => {
380
385
  const ids = getRaw(idsSegments)
386
+ const docs = getRaw(docsSegments)
387
+ const extra = getRaw(extraSegments)
388
+ const aggregation = getRaw(aggregationSegments)
381
389
  return {
382
390
  ids,
383
- docs: Array.isArray(ids)
391
+ queryDocs: docs,
392
+ extra,
393
+ aggregation,
394
+ idMaterialization: Array.isArray(ids)
384
395
  ? ids.map(id => ({
385
396
  id,
386
397
  raw: getRaw([collection, id])
@@ -391,10 +402,17 @@ function registerBatchQueryReadinessCheck (collection, query) {
391
402
  })
392
403
  }
393
404
 
394
- function isQueryReady (collection, idsSegments) {
405
+ function isQueryReady (collection, idsSegments, docsSegments, extraSegments, aggregationSegments, isAggregate) {
406
+ if (isAggregate) {
407
+ const docs = getRaw(docsSegments)
408
+ if (Array.isArray(docs)) return true
409
+ if (getRaw(extraSegments) !== undefined) return true
410
+ return getRaw(aggregationSegments) !== undefined
411
+ }
395
412
  const ids = getRaw(idsSegments)
396
413
  if (!Array.isArray(ids)) return false
397
414
  for (const id of ids) {
415
+ if (id == null) continue
398
416
  if (!isDocReady([collection, id])) return false
399
417
  }
400
418
  return true
@@ -416,3 +434,7 @@ function getShareDoc (collection, id) {
416
434
  return undefined
417
435
  }
418
436
  }
437
+
438
+ export const __COMPAT_BATCH_READY__ = {
439
+ isQueryReady
440
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teamplay",
3
- "version": "0.4.0-alpha.35",
3
+ "version": "0.4.0-alpha.36",
4
4
  "description": "Full-stack signals ORM with multiplayer",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -81,5 +81,5 @@
81
81
  ]
82
82
  },
83
83
  "license": "MIT",
84
- "gitHead": "92ba9ceb7dfb2ede1ccf1e7bb4d06cf71e2efafc"
84
+ "gitHead": "0f90958b39502634ec8fefc99d7e688f0ac4c4bc"
85
85
  }