atom.io 0.21.1 → 0.22.0
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.
- package/data/dist/index.cjs +136 -63
- package/data/dist/index.d.ts +6 -0
- package/data/dist/index.js +3 -3
- package/data/src/join.ts +135 -51
- package/data/src/struct-family.ts +2 -2
- package/dist/{chunk-RT43TVKP.js → chunk-GVHKIJ3G.js} +1 -1
- package/dist/{chunk-HITX3MO4.js → chunk-JA4V7TJY.js} +135 -62
- package/dist/index.cjs +2 -7
- package/dist/index.d.ts +29 -14
- package/dist/index.js +4 -8
- package/ephemeral/dist/index.cjs +11 -0
- package/ephemeral/dist/index.js +9 -0
- package/ephemeral/package.json +16 -0
- package/ephemeral/src/index.ts +1 -0
- package/eslint-plugin/dist/index.cjs +156 -1
- package/eslint-plugin/dist/index.js +156 -1
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/eslint-plugin/src/rules/lifespan.ts +204 -0
- package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +1 -65
- package/eslint-plugin/src/walk.ts +73 -0
- package/immortal/dist/index.cjs +100 -0
- package/immortal/dist/index.js +97 -0
- package/immortal/package.json +16 -0
- package/immortal/src/index.ts +2 -0
- package/immortal/src/molecule.ts +134 -0
- package/immortal/src/seek-state.ts +60 -0
- package/internal/dist/index.cjs +186 -146
- package/internal/dist/index.d.ts +29 -13
- package/internal/dist/index.js +185 -146
- package/internal/src/atom/dispose-atom.ts +4 -1
- package/internal/src/families/create-readonly-selector-family.ts +9 -9
- package/internal/src/families/create-regular-atom-family.ts +15 -20
- package/internal/src/families/create-writable-selector-family.ts +6 -7
- package/internal/src/families/find-in-store.ts +11 -5
- package/internal/src/families/index.ts +2 -0
- package/internal/src/families/init-family-member.ts +91 -0
- package/internal/src/families/seek-in-store.ts +106 -0
- package/internal/src/get-state/get-from-store.ts +2 -2
- package/internal/src/mutable/create-mutable-atom-family.ts +17 -23
- package/internal/src/mutable/create-mutable-atom.ts +3 -1
- package/internal/src/mutable/get-json-family.ts +2 -2
- package/internal/src/mutable/get-json-token.ts +27 -12
- package/internal/src/mutable/tracker-family.ts +14 -12
- package/internal/src/not-found-error.ts +11 -3
- package/internal/src/selector/create-readonly-selector.ts +2 -2
- package/internal/src/selector/create-writable-selector.ts +2 -2
- package/internal/src/selector/dispose-selector.ts +40 -23
- package/internal/src/selector/register-selector.ts +8 -5
- package/internal/src/set-state/set-into-store.ts +2 -2
- package/internal/src/store/index.ts +0 -1
- package/internal/src/store/store.ts +18 -5
- package/internal/src/subscribe/subscribe-to-state.ts +2 -2
- package/internal/src/transaction/build-transaction.ts +7 -2
- package/introspection/dist/index.cjs +38 -52
- package/introspection/dist/index.js +38 -52
- package/introspection/src/attach-atom-index.ts +38 -48
- package/introspection/src/attach-selector-index.ts +45 -50
- package/json/dist/index.cjs +38 -4
- package/json/dist/index.js +40 -6
- package/json/src/select-json-family.ts +46 -7
- package/package.json +30 -10
- package/react/dist/index.cjs +1 -1
- package/react/dist/index.js +1 -1
- package/react/src/use-json.ts +1 -1
- package/react-devtools/dist/index.cjs +11 -10
- package/react-devtools/dist/index.js +2 -1
- package/react-devtools/src/StateIndex.tsx +2 -1
- package/react-devtools/src/TimelineIndex.tsx +2 -1
- package/react-devtools/src/TransactionIndex.tsx +7 -7
- package/realtime-client/dist/index.cjs +3 -3
- package/realtime-client/dist/index.js +3 -3
- package/realtime-client/src/pull-mutable-atom-family-member.ts +1 -1
- package/realtime-client/src/pull-mutable-atom.ts +1 -1
- package/realtime-client/src/sync-continuity.ts +1 -2
- package/realtime-react/dist/index.cjs +1 -1
- package/realtime-react/dist/index.js +1 -1
- package/realtime-server/dist/index.cjs +18 -17
- package/realtime-server/dist/index.js +7 -6
- package/realtime-server/src/realtime-continuity-synchronizer.ts +5 -3
- package/realtime-server/src/realtime-mutable-family-provider.ts +2 -1
- package/realtime-server/src/realtime-mutable-provider.ts +1 -1
- package/realtime-testing/dist/index.cjs +6 -2
- package/realtime-testing/dist/index.js +8 -5
- package/realtime-testing/src/setup-realtime-test.tsx +5 -2
- package/src/atom.ts +10 -4
- package/src/index.ts +1 -2
- package/src/selector.ts +10 -4
- package/src/silo.ts +3 -3
- package/src/transaction.ts +5 -2
- package/internal/src/store/withdraw-new-family-member.ts +0 -69
- /package/{src → ephemeral/src}/find-state.ts +0 -0
- /package/src/{dispose.ts → dispose-state.ts} +0 -0
package/data/src/join.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
2
|
import type {
|
|
3
|
-
findState,
|
|
4
3
|
MutableAtomFamily,
|
|
5
4
|
MutableAtomFamilyToken,
|
|
6
|
-
MutableAtomToken,
|
|
7
5
|
Read,
|
|
6
|
+
ReadableFamilyToken,
|
|
8
7
|
ReadonlySelectorFamily,
|
|
9
8
|
ReadonlySelectorToken,
|
|
10
9
|
RegularAtomFamily,
|
|
11
10
|
Transactors,
|
|
12
11
|
Write,
|
|
13
12
|
} from "atom.io"
|
|
14
|
-
import { disposeState
|
|
13
|
+
import { disposeState } from "atom.io"
|
|
14
|
+
import type { findState } from "atom.io/ephemeral"
|
|
15
|
+
import type { Molecule, seekState } from "atom.io/immortal"
|
|
15
16
|
import type { Store } from "atom.io/internal"
|
|
16
17
|
import {
|
|
17
18
|
createMutableAtomFamily,
|
|
@@ -21,11 +22,13 @@ import {
|
|
|
21
22
|
getFromStore,
|
|
22
23
|
getJsonFamily,
|
|
23
24
|
IMPLICIT,
|
|
25
|
+
initFamilyMember,
|
|
24
26
|
isChildStore,
|
|
25
27
|
newest,
|
|
28
|
+
seekInStore,
|
|
26
29
|
setIntoStore,
|
|
27
30
|
} from "atom.io/internal"
|
|
28
|
-
import type
|
|
31
|
+
import { type Json, stringifyJson } from "atom.io/json"
|
|
29
32
|
import type { SetRTXJson } from "atom.io/transceivers/set-rtx"
|
|
30
33
|
import { SetRTX } from "atom.io/transceivers/set-rtx"
|
|
31
34
|
|
|
@@ -130,6 +133,8 @@ export class Join<
|
|
|
130
133
|
private options: JoinOptions<ASide, BSide, Cardinality, Content>
|
|
131
134
|
private defaultContent: Content | undefined
|
|
132
135
|
private transactors: Transactors
|
|
136
|
+
public retrieve: typeof findState
|
|
137
|
+
public molecules: Map<string, Molecule<any>> = new Map()
|
|
133
138
|
public relations: Junction<ASide, BSide, Content>
|
|
134
139
|
public states: JoinStateFamilies<ASide, BSide, Cardinality, Content>
|
|
135
140
|
public core: {
|
|
@@ -149,7 +154,12 @@ export class Join<
|
|
|
149
154
|
this.transactors = originalTransactors
|
|
150
155
|
}
|
|
151
156
|
|
|
157
|
+
public store: Store
|
|
152
158
|
public alternates: Map<string, Join<ASide, BSide, Cardinality, Content>>
|
|
159
|
+
public [Symbol.dispose](): void {
|
|
160
|
+
this.alternates.delete(this.store.config.name)
|
|
161
|
+
}
|
|
162
|
+
|
|
153
163
|
public in(store: Store): Join<ASide, BSide, Cardinality, Content> {
|
|
154
164
|
const key = store.config.name
|
|
155
165
|
const alternate = this.alternates.get(key)
|
|
@@ -167,16 +177,38 @@ export class Join<
|
|
|
167
177
|
defaultContent: Content | undefined,
|
|
168
178
|
store: Store = IMPLICIT.STORE,
|
|
169
179
|
) {
|
|
180
|
+
this.store = store
|
|
170
181
|
this.options = options
|
|
171
182
|
this.defaultContent = defaultContent
|
|
172
183
|
this.alternates = new Map()
|
|
173
184
|
this.alternates.set(store.config.name, this)
|
|
185
|
+
|
|
186
|
+
this.store.miscResources.set(`join:${options.key}`, this)
|
|
187
|
+
|
|
174
188
|
this.transactors = {
|
|
175
189
|
get: (token) => getFromStore(token, store),
|
|
176
190
|
set: (token, value) => {
|
|
177
191
|
setIntoStore(token, value, store)
|
|
178
192
|
},
|
|
179
193
|
find: ((token, key) => findInStore(token, key, store)) as typeof findState,
|
|
194
|
+
seek: ((token, key) => seekInStore(token, key, store)) as typeof seekState,
|
|
195
|
+
}
|
|
196
|
+
this.retrieve = (
|
|
197
|
+
token: ReadableFamilyToken<any, any>,
|
|
198
|
+
key: Json.Serializable,
|
|
199
|
+
) => {
|
|
200
|
+
const maybeToken = this.transactors.seek(token, key)
|
|
201
|
+
if (maybeToken) {
|
|
202
|
+
return maybeToken
|
|
203
|
+
}
|
|
204
|
+
const molecule = this.molecules.get(stringifyJson(key))
|
|
205
|
+
if (!molecule) {
|
|
206
|
+
if (store.config.lifespan === `immortal`) {
|
|
207
|
+
throw new Error(`No molecule found for key "${stringifyJson(key)}"`)
|
|
208
|
+
}
|
|
209
|
+
return initFamilyMember(token, key, store)
|
|
210
|
+
}
|
|
211
|
+
return molecule.bond(token) as any
|
|
180
212
|
}
|
|
181
213
|
const aSide: ASide = options.between[0]
|
|
182
214
|
const bSide: BSide = options.between[1]
|
|
@@ -196,17 +228,17 @@ export class Join<
|
|
|
196
228
|
)
|
|
197
229
|
this.core = { findRelatedKeysState: relatedKeysAtoms }
|
|
198
230
|
const getRelatedKeys: Read<(key: string) => SetRTX<string>> = (
|
|
199
|
-
{
|
|
231
|
+
{ get },
|
|
200
232
|
key,
|
|
201
|
-
) => get(
|
|
233
|
+
) => get(this.retrieve(relatedKeysAtoms, key))
|
|
202
234
|
const addRelation: Write<(a: string, b: string) => void> = (
|
|
203
235
|
transactors,
|
|
204
236
|
a,
|
|
205
237
|
b,
|
|
206
238
|
) => {
|
|
207
|
-
const { set
|
|
208
|
-
const aKeysState =
|
|
209
|
-
const bKeysState =
|
|
239
|
+
const { set } = transactors
|
|
240
|
+
const aKeysState = this.retrieve(relatedKeysAtoms, a)
|
|
241
|
+
const bKeysState = this.retrieve(relatedKeysAtoms, b)
|
|
210
242
|
set(aKeysState, (aKeys) => aKeys.add(b))
|
|
211
243
|
set(bKeysState, (bKeys) => bKeys.add(a))
|
|
212
244
|
}
|
|
@@ -215,24 +247,50 @@ export class Join<
|
|
|
215
247
|
a,
|
|
216
248
|
b,
|
|
217
249
|
) => {
|
|
218
|
-
const {
|
|
219
|
-
const aKeysState =
|
|
220
|
-
const bKeysState =
|
|
221
|
-
|
|
222
|
-
|
|
250
|
+
const { set } = transactors
|
|
251
|
+
const aKeysState = this.retrieve(relatedKeysAtoms, a)
|
|
252
|
+
const bKeysState = this.retrieve(relatedKeysAtoms, b)
|
|
253
|
+
let stringA: string | undefined
|
|
254
|
+
let stringB: string | undefined
|
|
255
|
+
set(aKeysState, (aKeys) => {
|
|
256
|
+
aKeys.delete(b)
|
|
257
|
+
if (aKeys.size === 0) {
|
|
258
|
+
stringA = `"${a}"`
|
|
259
|
+
}
|
|
260
|
+
return aKeys
|
|
261
|
+
})
|
|
262
|
+
set(bKeysState, (bKeys) => {
|
|
263
|
+
bKeys.delete(a)
|
|
264
|
+
if (bKeys.size === 0) {
|
|
265
|
+
stringB = `"${b}"`
|
|
266
|
+
}
|
|
267
|
+
return bKeys
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
if (stringA && this.molecules.has(stringA)) {
|
|
271
|
+
this.molecules.get(stringA)?.clear()
|
|
272
|
+
this.molecules.delete(stringA)
|
|
273
|
+
}
|
|
274
|
+
if (stringB && this.molecules.has(stringB)) {
|
|
275
|
+
this.molecules.get(stringB)?.clear()
|
|
276
|
+
this.molecules.delete(stringB)
|
|
277
|
+
}
|
|
223
278
|
}
|
|
224
279
|
const replaceRelationsSafely: Write<
|
|
225
280
|
(a: string, newRelationsOfA: string[]) => void
|
|
226
281
|
> = (transactors, a, newRelationsOfA) => {
|
|
227
|
-
const {
|
|
228
|
-
const relationsOfAState =
|
|
282
|
+
const { get, set } = transactors
|
|
283
|
+
const relationsOfAState = this.retrieve(relatedKeysAtoms, a)
|
|
229
284
|
const currentRelationsOfA = get(relationsOfAState)
|
|
230
285
|
for (const currentRelationB of currentRelationsOfA) {
|
|
231
286
|
const remainsRelated = newRelationsOfA.includes(currentRelationB)
|
|
232
287
|
if (remainsRelated) {
|
|
233
288
|
continue
|
|
234
289
|
}
|
|
235
|
-
const relationsOfBState =
|
|
290
|
+
const relationsOfBState = this.retrieve(
|
|
291
|
+
relatedKeysAtoms,
|
|
292
|
+
currentRelationB,
|
|
293
|
+
)
|
|
236
294
|
set(relationsOfBState, (relationsOfB) => {
|
|
237
295
|
relationsOfB.delete(a)
|
|
238
296
|
return relationsOfB
|
|
@@ -245,6 +303,7 @@ export class Join<
|
|
|
245
303
|
const relationsOfB = getRelatedKeys(transactors, newRelationB)
|
|
246
304
|
const newRelationBIsAlreadyRelated = relationsOfB.has(a)
|
|
247
305
|
if (this.relations.cardinality === `1:n`) {
|
|
306
|
+
const previousOwnersToDispose: string[] = []
|
|
248
307
|
for (const previousOwner of relationsOfB) {
|
|
249
308
|
if (previousOwner === a) {
|
|
250
309
|
continue
|
|
@@ -254,10 +313,21 @@ export class Join<
|
|
|
254
313
|
previousOwner,
|
|
255
314
|
)
|
|
256
315
|
previousOwnerRelations.delete(newRelationB)
|
|
316
|
+
if (previousOwnerRelations.size === 0) {
|
|
317
|
+
previousOwnersToDispose.push(previousOwner)
|
|
318
|
+
}
|
|
257
319
|
}
|
|
258
320
|
if (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) {
|
|
259
321
|
relationsOfB.clear()
|
|
260
322
|
}
|
|
323
|
+
for (const previousOwner of previousOwnersToDispose) {
|
|
324
|
+
const molecule = this.molecules.get(previousOwner)
|
|
325
|
+
molecule?.clear()
|
|
326
|
+
this.molecules.delete(previousOwner)
|
|
327
|
+
const sorted = [newRelationB, previousOwner].sort()
|
|
328
|
+
const compositeKey = `"${sorted[0]}:${sorted[1]}"`
|
|
329
|
+
this.molecules.delete(compositeKey)
|
|
330
|
+
}
|
|
261
331
|
}
|
|
262
332
|
if (!newRelationBIsAlreadyRelated) {
|
|
263
333
|
relationsOfB.add(a)
|
|
@@ -272,8 +342,8 @@ export class Join<
|
|
|
272
342
|
const replaceRelationsUnsafely: Write<
|
|
273
343
|
(a: string, newRelationsOfA: string[]) => void
|
|
274
344
|
> = (transactors, a, newRelationsOfA) => {
|
|
275
|
-
const {
|
|
276
|
-
const relationsOfAState =
|
|
345
|
+
const { set } = transactors
|
|
346
|
+
const relationsOfAState = this.retrieve(relatedKeysAtoms, a)
|
|
277
347
|
set(relationsOfAState, (relationsOfA) => {
|
|
278
348
|
relationsOfA.transaction((nextRelationsOfA) => {
|
|
279
349
|
for (const newRelationB of newRelationsOfA) {
|
|
@@ -284,7 +354,7 @@ export class Join<
|
|
|
284
354
|
return relationsOfA
|
|
285
355
|
})
|
|
286
356
|
for (const newRelationB of newRelationsOfA) {
|
|
287
|
-
const newRelationsBState =
|
|
357
|
+
const newRelationsBState = this.retrieve(relatedKeysAtoms, newRelationB)
|
|
288
358
|
set(newRelationsBState, (newRelationsB) => {
|
|
289
359
|
newRelationsB.add(a)
|
|
290
360
|
return newRelationsB
|
|
@@ -326,19 +396,21 @@ export class Join<
|
|
|
326
396
|
},
|
|
327
397
|
store,
|
|
328
398
|
)
|
|
329
|
-
const getContent: Read<(key: string) => Content | null> = (
|
|
330
|
-
|
|
331
|
-
key,
|
|
332
|
-
) => get(find(contentAtoms, key))
|
|
399
|
+
const getContent: Read<(key: string) => Content | null> = ({ get }, key) =>
|
|
400
|
+
get(this.retrieve(contentAtoms, key))
|
|
333
401
|
const setContent: Write<(key: string, content: Content) => void> = (
|
|
334
|
-
{
|
|
402
|
+
{ set },
|
|
335
403
|
key,
|
|
336
404
|
content,
|
|
337
405
|
) => {
|
|
338
|
-
set(
|
|
406
|
+
set(this.retrieve(contentAtoms, key), content)
|
|
339
407
|
}
|
|
340
|
-
const deleteContent: Write<(
|
|
341
|
-
|
|
408
|
+
const deleteContent: Write<(compositeKey: string) => void> = (
|
|
409
|
+
_,
|
|
410
|
+
compositeKey,
|
|
411
|
+
) => {
|
|
412
|
+
disposeState(this.retrieve(contentAtoms, compositeKey))
|
|
413
|
+
this.molecules.delete(`"${compositeKey}"`)
|
|
342
414
|
}
|
|
343
415
|
const externalStoreWithContentConfiguration = {
|
|
344
416
|
getContent: (contentKey: string) => {
|
|
@@ -362,7 +434,18 @@ export class Join<
|
|
|
362
434
|
}
|
|
363
435
|
const relations = new Junction<ASide, BSide, Content>(options, {
|
|
364
436
|
externalStore,
|
|
365
|
-
makeContentKey: (...args) =>
|
|
437
|
+
makeContentKey: (...args) => {
|
|
438
|
+
const sorted = args.sort()
|
|
439
|
+
const compositeKey = `${sorted[0]}:${sorted[1]}`
|
|
440
|
+
const [m0, m1] = sorted.map((key) =>
|
|
441
|
+
this.molecules.get(stringifyJson(key)),
|
|
442
|
+
)
|
|
443
|
+
if (store.config.lifespan === `immortal` && m0 && m1) {
|
|
444
|
+
const composite = m0.with(m1)(compositeKey)
|
|
445
|
+
this.molecules.set(`"${compositeKey}"`, composite)
|
|
446
|
+
}
|
|
447
|
+
return compositeKey
|
|
448
|
+
},
|
|
366
449
|
})
|
|
367
450
|
|
|
368
451
|
const createSingleKeyStateFamily = () =>
|
|
@@ -371,8 +454,8 @@ export class Join<
|
|
|
371
454
|
key: `${options.key}/singleRelatedKey`,
|
|
372
455
|
get:
|
|
373
456
|
(key) =>
|
|
374
|
-
({
|
|
375
|
-
const relatedKeysState =
|
|
457
|
+
({ get }) => {
|
|
458
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, key)
|
|
376
459
|
const relatedKeys = get(relatedKeysState)
|
|
377
460
|
for (const relatedKey of relatedKeys) {
|
|
378
461
|
return relatedKey
|
|
@@ -388,9 +471,9 @@ export class Join<
|
|
|
388
471
|
key: `${options.key}/multipleRelatedKeys`,
|
|
389
472
|
get:
|
|
390
473
|
(key) =>
|
|
391
|
-
({
|
|
474
|
+
({ get }) => {
|
|
392
475
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store)
|
|
393
|
-
const jsonState =
|
|
476
|
+
const jsonState = this.retrieve(jsonFamily, key)
|
|
394
477
|
const json = get(jsonState)
|
|
395
478
|
return json.members
|
|
396
479
|
},
|
|
@@ -404,12 +487,12 @@ export class Join<
|
|
|
404
487
|
key: `${options.key}/singleRelatedEntry`,
|
|
405
488
|
get:
|
|
406
489
|
(key) =>
|
|
407
|
-
({
|
|
408
|
-
const relatedKeysState =
|
|
490
|
+
({ get }) => {
|
|
491
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, key)
|
|
409
492
|
const relatedKeys = get(relatedKeysState)
|
|
410
493
|
for (const relatedKey of relatedKeys) {
|
|
411
494
|
const contentKey = relations.makeContentKey(key, relatedKey)
|
|
412
|
-
const contentState =
|
|
495
|
+
const contentState = this.retrieve(contentAtoms, contentKey)
|
|
413
496
|
const content = get(contentState)
|
|
414
497
|
return [relatedKey, content]
|
|
415
498
|
}
|
|
@@ -424,12 +507,13 @@ export class Join<
|
|
|
424
507
|
key: `${options.key}/multipleRelatedEntries`,
|
|
425
508
|
get:
|
|
426
509
|
(key) =>
|
|
427
|
-
({
|
|
510
|
+
({ get }) => {
|
|
428
511
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store)
|
|
429
|
-
const
|
|
512
|
+
const jsonState = this.retrieve(jsonFamily, key)
|
|
513
|
+
const json = get(jsonState)
|
|
430
514
|
return json.members.map((relatedKey) => {
|
|
431
515
|
const contentKey = relations.makeContentKey(key, relatedKey)
|
|
432
|
-
const contentState =
|
|
516
|
+
const contentState = this.retrieve(contentAtoms, contentKey)
|
|
433
517
|
const content = get(contentState)
|
|
434
518
|
return [relatedKey, content]
|
|
435
519
|
})
|
|
@@ -688,12 +772,12 @@ export function findRelationsInStore<
|
|
|
688
772
|
relations = {
|
|
689
773
|
get [keyAB]() {
|
|
690
774
|
const familyAB = myJoin.states[keyAB as any]
|
|
691
|
-
const state =
|
|
775
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
692
776
|
return state
|
|
693
777
|
},
|
|
694
778
|
get [keyBA]() {
|
|
695
779
|
const familyBA = myJoin.states[keyBA as any]
|
|
696
|
-
const state =
|
|
780
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
697
781
|
return state
|
|
698
782
|
},
|
|
699
783
|
} as JoinStates<ASide, BSide, Cardinality, Content>
|
|
@@ -703,12 +787,12 @@ export function findRelationsInStore<
|
|
|
703
787
|
Object.assign(relations, {
|
|
704
788
|
get [entryAB]() {
|
|
705
789
|
const familyAB = myJoin.states[entryAB as any]
|
|
706
|
-
const state =
|
|
790
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
707
791
|
return state
|
|
708
792
|
},
|
|
709
793
|
get [entryBA]() {
|
|
710
794
|
const familyBA = myJoin.states[entryBA as any]
|
|
711
|
-
const state =
|
|
795
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
712
796
|
return state
|
|
713
797
|
},
|
|
714
798
|
})
|
|
@@ -721,12 +805,12 @@ export function findRelationsInStore<
|
|
|
721
805
|
relations = {
|
|
722
806
|
get [keyAB]() {
|
|
723
807
|
const familyAB = myJoin.states[keyAB as any]
|
|
724
|
-
const state =
|
|
808
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
725
809
|
return state
|
|
726
810
|
},
|
|
727
811
|
get [keysBA]() {
|
|
728
812
|
const familyBA = myJoin.states[keysBA as any]
|
|
729
|
-
const state =
|
|
813
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
730
814
|
return state
|
|
731
815
|
},
|
|
732
816
|
} as JoinStates<ASide, BSide, Cardinality, Content>
|
|
@@ -736,12 +820,12 @@ export function findRelationsInStore<
|
|
|
736
820
|
Object.assign(relations, {
|
|
737
821
|
get [entryAB]() {
|
|
738
822
|
const familyAB = myJoin.states[entryAB as any]
|
|
739
|
-
const state =
|
|
823
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
740
824
|
return state
|
|
741
825
|
},
|
|
742
826
|
get [entriesBA]() {
|
|
743
827
|
const familyBA = myJoin.states[entriesBA as any]
|
|
744
|
-
const state =
|
|
828
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
745
829
|
return state
|
|
746
830
|
},
|
|
747
831
|
})
|
|
@@ -754,12 +838,12 @@ export function findRelationsInStore<
|
|
|
754
838
|
relations = {
|
|
755
839
|
get [keysAB]() {
|
|
756
840
|
const familyAB = myJoin.states[keysAB as any]
|
|
757
|
-
const state =
|
|
841
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
758
842
|
return state
|
|
759
843
|
},
|
|
760
844
|
get [keysBA]() {
|
|
761
845
|
const familyBA = myJoin.states[keysBA as any]
|
|
762
|
-
const state =
|
|
846
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
763
847
|
return state
|
|
764
848
|
},
|
|
765
849
|
} as JoinStates<ASide, BSide, Cardinality, Content>
|
|
@@ -769,12 +853,12 @@ export function findRelationsInStore<
|
|
|
769
853
|
Object.assign(relations, {
|
|
770
854
|
get [entriesAB]() {
|
|
771
855
|
const familyAB = myJoin.states[entriesAB as any]
|
|
772
|
-
const state =
|
|
856
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
773
857
|
return state
|
|
774
858
|
},
|
|
775
859
|
get [entriesBA]() {
|
|
776
860
|
const familyBA = myJoin.states[entriesBA as any]
|
|
777
|
-
const state =
|
|
861
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
778
862
|
return state
|
|
779
863
|
},
|
|
780
864
|
})
|
|
@@ -44,10 +44,10 @@ export function structFamily<
|
|
|
44
44
|
key: options.key,
|
|
45
45
|
get:
|
|
46
46
|
(id) =>
|
|
47
|
-
({ get }) => {
|
|
47
|
+
({ find, get }) => {
|
|
48
48
|
return Object.keys(options.default).reduce((acc, subKey) => {
|
|
49
49
|
acc[subKey] = get(
|
|
50
|
-
(atoms as any)[nameFamily(options.key, subKey)]
|
|
50
|
+
find((atoms as any)[nameFamily(options.key, subKey)], id),
|
|
51
51
|
)
|
|
52
52
|
return acc
|
|
53
53
|
}, {} as any)
|