atom.io 0.21.1 → 0.23.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 +152 -63
- package/data/dist/index.d.ts +6 -0
- package/data/dist/index.js +3 -3
- package/data/src/join.ts +164 -51
- package/data/src/struct-family.ts +2 -2
- package/dist/chunk-6MLFYN32.js +18 -0
- package/dist/{chunk-HITX3MO4.js → chunk-7DT3PVS3.js} +151 -62
- package/dist/{chunk-RT43TVKP.js → chunk-GVHKIJ3G.js} +1 -1
- package/dist/chunk-OAYGID5B.js +27 -0
- package/dist/index.cjs +4 -18
- package/dist/index.d.ts +71 -28
- package/dist/index.js +6 -19
- 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 +155 -1
- package/eslint-plugin/dist/index.js +155 -1
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/eslint-plugin/src/rules/lifespan.ts +203 -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 +260 -0
- package/immortal/dist/index.js +212 -0
- package/immortal/package.json +16 -0
- package/immortal/src/index.ts +3 -0
- package/immortal/src/make-molecule.ts +222 -0
- package/immortal/src/molecule.ts +167 -0
- package/immortal/src/seek-state.ts +73 -0
- package/internal/dist/index.cjs +1242 -837
- package/internal/dist/index.d.ts +135 -22
- package/internal/dist/index.js +1215 -838
- package/internal/src/atom/create-regular-atom.ts +0 -2
- package/internal/src/atom/create-standalone-atom.ts +6 -2
- package/internal/src/atom/dispose-atom.ts +26 -3
- package/internal/src/families/create-readonly-selector-family.ts +15 -10
- package/internal/src/families/create-regular-atom-family.ts +20 -21
- package/internal/src/families/create-writable-selector-family.ts +13 -9
- package/{src/dispose.ts → internal/src/families/dispose-from-store.ts} +7 -4
- package/internal/src/families/find-in-store.ts +11 -6
- package/internal/src/families/index.ts +3 -0
- package/internal/src/families/init-family-member.ts +112 -0
- package/internal/src/families/seek-in-store.ts +123 -0
- package/internal/src/get-state/get-from-store.ts +2 -2
- package/internal/src/ingest-updates/index.ts +1 -0
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +104 -0
- package/internal/src/ingest-updates/ingest-transaction-update.ts +26 -4
- package/internal/src/mutable/create-mutable-atom-family.ts +22 -24
- package/internal/src/mutable/create-mutable-atom.ts +3 -3
- package/internal/src/mutable/get-json-family.ts +2 -2
- package/internal/src/mutable/get-json-token.ts +26 -12
- package/internal/src/mutable/tracker-family.ts +21 -19
- package/internal/src/not-found-error.ts +16 -3
- package/internal/src/selector/create-readonly-selector.ts +2 -3
- package/internal/src/selector/create-standalone-selector.ts +6 -2
- package/internal/src/selector/create-writable-selector.ts +2 -3
- package/internal/src/selector/dispose-selector.ts +68 -24
- package/internal/src/selector/register-selector.ts +10 -5
- package/internal/src/set-state/set-into-store.ts +2 -2
- package/internal/src/set-state/stow-update.ts +5 -1
- package/internal/src/store/deposit.ts +41 -7
- package/internal/src/store/index.ts +0 -1
- package/internal/src/store/store.ts +29 -5
- package/internal/src/store/withdraw.ts +28 -1
- package/internal/src/subscribe/subscribe-to-state.ts +2 -2
- package/internal/src/timeline/add-atom-to-timeline.ts +206 -182
- package/internal/src/timeline/create-timeline.ts +181 -60
- package/internal/src/timeline/time-travel.ts +20 -0
- package/internal/src/transaction/apply-transaction.ts +2 -12
- package/internal/src/transaction/build-transaction.ts +16 -2
- package/introspection/dist/index.cjs +40 -53
- package/introspection/dist/index.js +40 -53
- package/introspection/src/attach-atom-index.ts +38 -48
- package/introspection/src/attach-selector-index.ts +45 -50
- package/introspection/src/attach-timeline-family.ts +1 -0
- package/json/dist/index.cjs +40 -6
- package/json/dist/index.js +44 -9
- package/json/src/select-json-family.ts +47 -9
- 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 +69 -57
- package/react-devtools/dist/index.js +62 -49
- package/react-devtools/src/StateIndex.tsx +2 -1
- package/react-devtools/src/TimelineIndex.tsx +17 -14
- package/react-devtools/src/TransactionIndex.tsx +7 -7
- package/react-devtools/src/Updates.tsx +41 -32
- 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 +39 -27
- package/realtime-server/dist/index.d.ts +1 -1
- package/realtime-server/dist/index.js +27 -16
- 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-server/src/realtime-server-stores/server-sync-store.ts +21 -11
- package/realtime-testing/dist/index.cjs +7 -2
- package/realtime-testing/dist/index.js +8 -5
- package/realtime-testing/src/setup-realtime-test.tsx +5 -2
- package/src/atom.ts +19 -7
- package/src/dispose-state.ts +10 -0
- package/src/index.ts +5 -2
- package/src/selector.ts +13 -7
- package/src/silo.ts +3 -3
- package/src/subscribe.ts +8 -4
- package/src/timeline.ts +18 -1
- package/src/transaction.ts +59 -4
- package/dist/chunk-BF4MVQF6.js +0 -44
- package/internal/src/store/withdraw-new-family-member.ts +0 -69
- /package/{src → ephemeral/src}/find-state.ts +0 -0
package/data/src/join.ts
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
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 {
|
|
16
|
+
MoleculeFamilyToken,
|
|
17
|
+
MoleculeToken,
|
|
18
|
+
seekState,
|
|
19
|
+
} from "atom.io/immortal"
|
|
20
|
+
import {
|
|
21
|
+
createMoleculeFamily,
|
|
22
|
+
makeMoleculeInStore,
|
|
23
|
+
Molecule,
|
|
24
|
+
} from "atom.io/immortal"
|
|
15
25
|
import type { Store } from "atom.io/internal"
|
|
16
26
|
import {
|
|
17
27
|
createMutableAtomFamily,
|
|
@@ -20,12 +30,15 @@ import {
|
|
|
20
30
|
findInStore,
|
|
21
31
|
getFromStore,
|
|
22
32
|
getJsonFamily,
|
|
33
|
+
getJsonToken,
|
|
23
34
|
IMPLICIT,
|
|
35
|
+
initFamilyMember,
|
|
24
36
|
isChildStore,
|
|
25
37
|
newest,
|
|
38
|
+
seekInStore,
|
|
26
39
|
setIntoStore,
|
|
27
40
|
} from "atom.io/internal"
|
|
28
|
-
import type
|
|
41
|
+
import { type Json, stringifyJson } from "atom.io/json"
|
|
29
42
|
import type { SetRTXJson } from "atom.io/transceivers/set-rtx"
|
|
30
43
|
import { SetRTX } from "atom.io/transceivers/set-rtx"
|
|
31
44
|
|
|
@@ -130,6 +143,8 @@ export class Join<
|
|
|
130
143
|
private options: JoinOptions<ASide, BSide, Cardinality, Content>
|
|
131
144
|
private defaultContent: Content | undefined
|
|
132
145
|
private transactors: Transactors
|
|
146
|
+
public retrieve: typeof findState
|
|
147
|
+
public molecules: Map<string, Molecule<any>> = new Map()
|
|
133
148
|
public relations: Junction<ASide, BSide, Content>
|
|
134
149
|
public states: JoinStateFamilies<ASide, BSide, Cardinality, Content>
|
|
135
150
|
public core: {
|
|
@@ -149,7 +164,12 @@ export class Join<
|
|
|
149
164
|
this.transactors = originalTransactors
|
|
150
165
|
}
|
|
151
166
|
|
|
167
|
+
public store: Store
|
|
152
168
|
public alternates: Map<string, Join<ASide, BSide, Cardinality, Content>>
|
|
169
|
+
public [Symbol.dispose](): void {
|
|
170
|
+
this.alternates.delete(this.store.config.name)
|
|
171
|
+
}
|
|
172
|
+
|
|
153
173
|
public in(store: Store): Join<ASide, BSide, Cardinality, Content> {
|
|
154
174
|
const key = store.config.name
|
|
155
175
|
const alternate = this.alternates.get(key)
|
|
@@ -167,16 +187,39 @@ export class Join<
|
|
|
167
187
|
defaultContent: Content | undefined,
|
|
168
188
|
store: Store = IMPLICIT.STORE,
|
|
169
189
|
) {
|
|
190
|
+
this.store = store
|
|
170
191
|
this.options = options
|
|
171
192
|
this.defaultContent = defaultContent
|
|
172
193
|
this.alternates = new Map()
|
|
173
194
|
this.alternates.set(store.config.name, this)
|
|
195
|
+
|
|
196
|
+
this.store.miscResources.set(`join:${options.key}`, this)
|
|
197
|
+
|
|
174
198
|
this.transactors = {
|
|
175
199
|
get: (token) => getFromStore(token, store),
|
|
176
200
|
set: (token, value) => {
|
|
177
201
|
setIntoStore(token, value, store)
|
|
178
202
|
},
|
|
179
203
|
find: ((token, key) => findInStore(token, key, store)) as typeof findState,
|
|
204
|
+
seek: ((token, key) => seekInStore(token, key, store)) as typeof seekState,
|
|
205
|
+
json: (token) => getJsonToken(token, store),
|
|
206
|
+
}
|
|
207
|
+
this.retrieve = (
|
|
208
|
+
token: ReadableFamilyToken<any, any>,
|
|
209
|
+
key: Json.Serializable,
|
|
210
|
+
) => {
|
|
211
|
+
const maybeToken = this.transactors.seek(token, key)
|
|
212
|
+
if (maybeToken) {
|
|
213
|
+
return maybeToken
|
|
214
|
+
}
|
|
215
|
+
const molecule = this.molecules.get(stringifyJson(key))
|
|
216
|
+
if (!molecule) {
|
|
217
|
+
if (store.config.lifespan === `immortal`) {
|
|
218
|
+
throw new Error(`No molecule found for key "${stringifyJson(key)}"`)
|
|
219
|
+
}
|
|
220
|
+
return initFamilyMember(token, key, store)
|
|
221
|
+
}
|
|
222
|
+
return molecule.bond(token) as any
|
|
180
223
|
}
|
|
181
224
|
const aSide: ASide = options.between[0]
|
|
182
225
|
const bSide: BSide = options.between[1]
|
|
@@ -196,17 +239,17 @@ export class Join<
|
|
|
196
239
|
)
|
|
197
240
|
this.core = { findRelatedKeysState: relatedKeysAtoms }
|
|
198
241
|
const getRelatedKeys: Read<(key: string) => SetRTX<string>> = (
|
|
199
|
-
{
|
|
242
|
+
{ get },
|
|
200
243
|
key,
|
|
201
|
-
) => get(
|
|
244
|
+
) => get(this.retrieve(relatedKeysAtoms, key))
|
|
202
245
|
const addRelation: Write<(a: string, b: string) => void> = (
|
|
203
246
|
transactors,
|
|
204
247
|
a,
|
|
205
248
|
b,
|
|
206
249
|
) => {
|
|
207
|
-
const { set
|
|
208
|
-
const aKeysState =
|
|
209
|
-
const bKeysState =
|
|
250
|
+
const { set } = transactors
|
|
251
|
+
const aKeysState = this.retrieve(relatedKeysAtoms, a)
|
|
252
|
+
const bKeysState = this.retrieve(relatedKeysAtoms, b)
|
|
210
253
|
set(aKeysState, (aKeys) => aKeys.add(b))
|
|
211
254
|
set(bKeysState, (bKeys) => bKeys.add(a))
|
|
212
255
|
}
|
|
@@ -215,24 +258,50 @@ export class Join<
|
|
|
215
258
|
a,
|
|
216
259
|
b,
|
|
217
260
|
) => {
|
|
218
|
-
const {
|
|
219
|
-
const aKeysState =
|
|
220
|
-
const bKeysState =
|
|
221
|
-
|
|
222
|
-
|
|
261
|
+
const { set } = transactors
|
|
262
|
+
const aKeysState = this.retrieve(relatedKeysAtoms, a)
|
|
263
|
+
const bKeysState = this.retrieve(relatedKeysAtoms, b)
|
|
264
|
+
let stringA: string | undefined
|
|
265
|
+
let stringB: string | undefined
|
|
266
|
+
set(aKeysState, (aKeys) => {
|
|
267
|
+
aKeys.delete(b)
|
|
268
|
+
if (aKeys.size === 0) {
|
|
269
|
+
stringA = `"${a}"`
|
|
270
|
+
}
|
|
271
|
+
return aKeys
|
|
272
|
+
})
|
|
273
|
+
set(bKeysState, (bKeys) => {
|
|
274
|
+
bKeys.delete(a)
|
|
275
|
+
if (bKeys.size === 0) {
|
|
276
|
+
stringB = `"${b}"`
|
|
277
|
+
}
|
|
278
|
+
return bKeys
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
if (stringA && this.molecules.has(stringA)) {
|
|
282
|
+
this.molecules.get(stringA)?.clear()
|
|
283
|
+
this.molecules.delete(stringA)
|
|
284
|
+
}
|
|
285
|
+
if (stringB && this.molecules.has(stringB)) {
|
|
286
|
+
this.molecules.get(stringB)?.clear()
|
|
287
|
+
this.molecules.delete(stringB)
|
|
288
|
+
}
|
|
223
289
|
}
|
|
224
290
|
const replaceRelationsSafely: Write<
|
|
225
291
|
(a: string, newRelationsOfA: string[]) => void
|
|
226
292
|
> = (transactors, a, newRelationsOfA) => {
|
|
227
|
-
const {
|
|
228
|
-
const relationsOfAState =
|
|
293
|
+
const { get, set } = transactors
|
|
294
|
+
const relationsOfAState = this.retrieve(relatedKeysAtoms, a)
|
|
229
295
|
const currentRelationsOfA = get(relationsOfAState)
|
|
230
296
|
for (const currentRelationB of currentRelationsOfA) {
|
|
231
297
|
const remainsRelated = newRelationsOfA.includes(currentRelationB)
|
|
232
298
|
if (remainsRelated) {
|
|
233
299
|
continue
|
|
234
300
|
}
|
|
235
|
-
const relationsOfBState =
|
|
301
|
+
const relationsOfBState = this.retrieve(
|
|
302
|
+
relatedKeysAtoms,
|
|
303
|
+
currentRelationB,
|
|
304
|
+
)
|
|
236
305
|
set(relationsOfBState, (relationsOfB) => {
|
|
237
306
|
relationsOfB.delete(a)
|
|
238
307
|
return relationsOfB
|
|
@@ -245,6 +314,7 @@ export class Join<
|
|
|
245
314
|
const relationsOfB = getRelatedKeys(transactors, newRelationB)
|
|
246
315
|
const newRelationBIsAlreadyRelated = relationsOfB.has(a)
|
|
247
316
|
if (this.relations.cardinality === `1:n`) {
|
|
317
|
+
const previousOwnersToDispose: string[] = []
|
|
248
318
|
for (const previousOwner of relationsOfB) {
|
|
249
319
|
if (previousOwner === a) {
|
|
250
320
|
continue
|
|
@@ -254,10 +324,21 @@ export class Join<
|
|
|
254
324
|
previousOwner,
|
|
255
325
|
)
|
|
256
326
|
previousOwnerRelations.delete(newRelationB)
|
|
327
|
+
if (previousOwnerRelations.size === 0) {
|
|
328
|
+
previousOwnersToDispose.push(previousOwner)
|
|
329
|
+
}
|
|
257
330
|
}
|
|
258
331
|
if (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) {
|
|
259
332
|
relationsOfB.clear()
|
|
260
333
|
}
|
|
334
|
+
for (const previousOwner of previousOwnersToDispose) {
|
|
335
|
+
const molecule = this.molecules.get(previousOwner)
|
|
336
|
+
molecule?.clear()
|
|
337
|
+
this.molecules.delete(previousOwner)
|
|
338
|
+
const sorted = [newRelationB, previousOwner].sort()
|
|
339
|
+
const compositeKey = `"${sorted[0]}:${sorted[1]}"`
|
|
340
|
+
this.molecules.delete(compositeKey)
|
|
341
|
+
}
|
|
261
342
|
}
|
|
262
343
|
if (!newRelationBIsAlreadyRelated) {
|
|
263
344
|
relationsOfB.add(a)
|
|
@@ -272,8 +353,8 @@ export class Join<
|
|
|
272
353
|
const replaceRelationsUnsafely: Write<
|
|
273
354
|
(a: string, newRelationsOfA: string[]) => void
|
|
274
355
|
> = (transactors, a, newRelationsOfA) => {
|
|
275
|
-
const {
|
|
276
|
-
const relationsOfAState =
|
|
356
|
+
const { set } = transactors
|
|
357
|
+
const relationsOfAState = this.retrieve(relatedKeysAtoms, a)
|
|
277
358
|
set(relationsOfAState, (relationsOfA) => {
|
|
278
359
|
relationsOfA.transaction((nextRelationsOfA) => {
|
|
279
360
|
for (const newRelationB of newRelationsOfA) {
|
|
@@ -284,7 +365,7 @@ export class Join<
|
|
|
284
365
|
return relationsOfA
|
|
285
366
|
})
|
|
286
367
|
for (const newRelationB of newRelationsOfA) {
|
|
287
|
-
const newRelationsBState =
|
|
368
|
+
const newRelationsBState = this.retrieve(relatedKeysAtoms, newRelationB)
|
|
288
369
|
set(newRelationsBState, (newRelationsB) => {
|
|
289
370
|
newRelationsB.add(a)
|
|
290
371
|
return newRelationsB
|
|
@@ -318,6 +399,7 @@ export class Join<
|
|
|
318
399
|
}
|
|
319
400
|
let externalStore: ExternalStoreConfiguration<Content>
|
|
320
401
|
let contentAtoms: RegularAtomFamily<Content, string>
|
|
402
|
+
let contentMolecules: MoleculeFamilyToken<string, any, any>
|
|
321
403
|
if (defaultContent) {
|
|
322
404
|
contentAtoms = createRegularAtomFamily<Content, string>(
|
|
323
405
|
{
|
|
@@ -326,19 +408,36 @@ export class Join<
|
|
|
326
408
|
},
|
|
327
409
|
store,
|
|
328
410
|
)
|
|
329
|
-
|
|
330
|
-
{
|
|
331
|
-
|
|
332
|
-
|
|
411
|
+
contentMolecules = createMoleculeFamily(
|
|
412
|
+
{
|
|
413
|
+
key: `${options.key}/content-molecules`,
|
|
414
|
+
new: (s) =>
|
|
415
|
+
class ContentMolecule extends Molecule<string> {
|
|
416
|
+
public constructor(
|
|
417
|
+
context: Molecule<any>[],
|
|
418
|
+
token: MoleculeToken<string, any, any>,
|
|
419
|
+
) {
|
|
420
|
+
super(s, context, token)
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
store,
|
|
425
|
+
)
|
|
426
|
+
const getContent: Read<(key: string) => Content | null> = ({ get }, key) =>
|
|
427
|
+
get(this.retrieve(contentAtoms, key))
|
|
333
428
|
const setContent: Write<(key: string, content: Content) => void> = (
|
|
334
|
-
{
|
|
429
|
+
{ set },
|
|
335
430
|
key,
|
|
336
431
|
content,
|
|
337
432
|
) => {
|
|
338
|
-
set(
|
|
433
|
+
set(this.retrieve(contentAtoms, key), content)
|
|
339
434
|
}
|
|
340
|
-
const deleteContent: Write<(
|
|
341
|
-
|
|
435
|
+
const deleteContent: Write<(compositeKey: string) => void> = (
|
|
436
|
+
_,
|
|
437
|
+
compositeKey,
|
|
438
|
+
) => {
|
|
439
|
+
disposeState(this.retrieve(contentAtoms, compositeKey))
|
|
440
|
+
this.molecules.delete(`"${compositeKey}"`)
|
|
342
441
|
}
|
|
343
442
|
const externalStoreWithContentConfiguration = {
|
|
344
443
|
getContent: (contentKey: string) => {
|
|
@@ -362,7 +461,20 @@ export class Join<
|
|
|
362
461
|
}
|
|
363
462
|
const relations = new Junction<ASide, BSide, Content>(options, {
|
|
364
463
|
externalStore,
|
|
365
|
-
makeContentKey: (...args) =>
|
|
464
|
+
makeContentKey: (...args) => {
|
|
465
|
+
const sorted = args.sort()
|
|
466
|
+
const compositeKey = `${sorted[0]}:${sorted[1]}`
|
|
467
|
+
const [m0, m1] = sorted.map((key) =>
|
|
468
|
+
this.molecules.get(stringifyJson(key)),
|
|
469
|
+
)
|
|
470
|
+
if (store.config.lifespan === `immortal` && m0 && m1) {
|
|
471
|
+
const composite = m0.with(m1)(compositeKey)
|
|
472
|
+
this.molecules.set(`"${compositeKey}"`, composite)
|
|
473
|
+
const target = newest(store)
|
|
474
|
+
makeMoleculeInStore(target, [m0, m1], contentMolecules, compositeKey)
|
|
475
|
+
}
|
|
476
|
+
return compositeKey
|
|
477
|
+
},
|
|
366
478
|
})
|
|
367
479
|
|
|
368
480
|
const createSingleKeyStateFamily = () =>
|
|
@@ -371,8 +483,8 @@ export class Join<
|
|
|
371
483
|
key: `${options.key}/singleRelatedKey`,
|
|
372
484
|
get:
|
|
373
485
|
(key) =>
|
|
374
|
-
({
|
|
375
|
-
const relatedKeysState =
|
|
486
|
+
({ get }) => {
|
|
487
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, key)
|
|
376
488
|
const relatedKeys = get(relatedKeysState)
|
|
377
489
|
for (const relatedKey of relatedKeys) {
|
|
378
490
|
return relatedKey
|
|
@@ -388,9 +500,9 @@ export class Join<
|
|
|
388
500
|
key: `${options.key}/multipleRelatedKeys`,
|
|
389
501
|
get:
|
|
390
502
|
(key) =>
|
|
391
|
-
({
|
|
503
|
+
({ get }) => {
|
|
392
504
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store)
|
|
393
|
-
const jsonState =
|
|
505
|
+
const jsonState = this.retrieve(jsonFamily, key)
|
|
394
506
|
const json = get(jsonState)
|
|
395
507
|
return json.members
|
|
396
508
|
},
|
|
@@ -404,12 +516,12 @@ export class Join<
|
|
|
404
516
|
key: `${options.key}/singleRelatedEntry`,
|
|
405
517
|
get:
|
|
406
518
|
(key) =>
|
|
407
|
-
({
|
|
408
|
-
const relatedKeysState =
|
|
519
|
+
({ get }) => {
|
|
520
|
+
const relatedKeysState = this.retrieve(relatedKeysAtoms, key)
|
|
409
521
|
const relatedKeys = get(relatedKeysState)
|
|
410
522
|
for (const relatedKey of relatedKeys) {
|
|
411
523
|
const contentKey = relations.makeContentKey(key, relatedKey)
|
|
412
|
-
const contentState =
|
|
524
|
+
const contentState = this.retrieve(contentAtoms, contentKey)
|
|
413
525
|
const content = get(contentState)
|
|
414
526
|
return [relatedKey, content]
|
|
415
527
|
}
|
|
@@ -424,12 +536,13 @@ export class Join<
|
|
|
424
536
|
key: `${options.key}/multipleRelatedEntries`,
|
|
425
537
|
get:
|
|
426
538
|
(key) =>
|
|
427
|
-
({
|
|
539
|
+
({ get }) => {
|
|
428
540
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store)
|
|
429
|
-
const
|
|
541
|
+
const jsonState = this.retrieve(jsonFamily, key)
|
|
542
|
+
const json = get(jsonState)
|
|
430
543
|
return json.members.map((relatedKey) => {
|
|
431
544
|
const contentKey = relations.makeContentKey(key, relatedKey)
|
|
432
|
-
const contentState =
|
|
545
|
+
const contentState = this.retrieve(contentAtoms, contentKey)
|
|
433
546
|
const content = get(contentState)
|
|
434
547
|
return [relatedKey, content]
|
|
435
548
|
})
|
|
@@ -688,12 +801,12 @@ export function findRelationsInStore<
|
|
|
688
801
|
relations = {
|
|
689
802
|
get [keyAB]() {
|
|
690
803
|
const familyAB = myJoin.states[keyAB as any]
|
|
691
|
-
const state =
|
|
804
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
692
805
|
return state
|
|
693
806
|
},
|
|
694
807
|
get [keyBA]() {
|
|
695
808
|
const familyBA = myJoin.states[keyBA as any]
|
|
696
|
-
const state =
|
|
809
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
697
810
|
return state
|
|
698
811
|
},
|
|
699
812
|
} as JoinStates<ASide, BSide, Cardinality, Content>
|
|
@@ -703,12 +816,12 @@ export function findRelationsInStore<
|
|
|
703
816
|
Object.assign(relations, {
|
|
704
817
|
get [entryAB]() {
|
|
705
818
|
const familyAB = myJoin.states[entryAB as any]
|
|
706
|
-
const state =
|
|
819
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
707
820
|
return state
|
|
708
821
|
},
|
|
709
822
|
get [entryBA]() {
|
|
710
823
|
const familyBA = myJoin.states[entryBA as any]
|
|
711
|
-
const state =
|
|
824
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
712
825
|
return state
|
|
713
826
|
},
|
|
714
827
|
})
|
|
@@ -721,12 +834,12 @@ export function findRelationsInStore<
|
|
|
721
834
|
relations = {
|
|
722
835
|
get [keyAB]() {
|
|
723
836
|
const familyAB = myJoin.states[keyAB as any]
|
|
724
|
-
const state =
|
|
837
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
725
838
|
return state
|
|
726
839
|
},
|
|
727
840
|
get [keysBA]() {
|
|
728
841
|
const familyBA = myJoin.states[keysBA as any]
|
|
729
|
-
const state =
|
|
842
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
730
843
|
return state
|
|
731
844
|
},
|
|
732
845
|
} as JoinStates<ASide, BSide, Cardinality, Content>
|
|
@@ -736,12 +849,12 @@ export function findRelationsInStore<
|
|
|
736
849
|
Object.assign(relations, {
|
|
737
850
|
get [entryAB]() {
|
|
738
851
|
const familyAB = myJoin.states[entryAB as any]
|
|
739
|
-
const state =
|
|
852
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
740
853
|
return state
|
|
741
854
|
},
|
|
742
855
|
get [entriesBA]() {
|
|
743
856
|
const familyBA = myJoin.states[entriesBA as any]
|
|
744
|
-
const state =
|
|
857
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
745
858
|
return state
|
|
746
859
|
},
|
|
747
860
|
})
|
|
@@ -754,12 +867,12 @@ export function findRelationsInStore<
|
|
|
754
867
|
relations = {
|
|
755
868
|
get [keysAB]() {
|
|
756
869
|
const familyAB = myJoin.states[keysAB as any]
|
|
757
|
-
const state =
|
|
870
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
758
871
|
return state
|
|
759
872
|
},
|
|
760
873
|
get [keysBA]() {
|
|
761
874
|
const familyBA = myJoin.states[keysBA as any]
|
|
762
|
-
const state =
|
|
875
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
763
876
|
return state
|
|
764
877
|
},
|
|
765
878
|
} as JoinStates<ASide, BSide, Cardinality, Content>
|
|
@@ -769,12 +882,12 @@ export function findRelationsInStore<
|
|
|
769
882
|
Object.assign(relations, {
|
|
770
883
|
get [entriesAB]() {
|
|
771
884
|
const familyAB = myJoin.states[entriesAB as any]
|
|
772
|
-
const state =
|
|
885
|
+
const state = myJoin.retrieve(familyAB, key)
|
|
773
886
|
return state
|
|
774
887
|
},
|
|
775
888
|
get [entriesBA]() {
|
|
776
889
|
const familyBA = myJoin.states[entriesBA as any]
|
|
777
|
-
const state =
|
|
890
|
+
const state = myJoin.retrieve(familyBA, key)
|
|
778
891
|
return state
|
|
779
892
|
},
|
|
780
893
|
})
|
|
@@ -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)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// ../anvl/src/primitive/index.ts
|
|
2
|
+
var isString = (input) => {
|
|
3
|
+
return typeof input === `string`;
|
|
4
|
+
};
|
|
5
|
+
var isNumber = (input) => {
|
|
6
|
+
return typeof input === `number`;
|
|
7
|
+
};
|
|
8
|
+
var isBoolean = (input) => {
|
|
9
|
+
return typeof input === `boolean`;
|
|
10
|
+
};
|
|
11
|
+
var isNull = (input) => {
|
|
12
|
+
return input === null;
|
|
13
|
+
};
|
|
14
|
+
var isPrimitive = (input) => {
|
|
15
|
+
return isString(input) || isNumber(input) || isBoolean(input) || isNull(input);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { isBoolean, isNull, isNumber, isPrimitive, isString };
|