atom.io 0.30.0 → 0.30.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.
@@ -22,20 +22,24 @@ declare function counterfeit<T, K extends Canonical, Key extends K>(token: Writa
22
22
  declare function counterfeit<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): ReadableToken<T>;
23
23
  declare function counterfeit<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key: MoleculeKey<M>): MoleculeKey<M>;
24
24
 
25
- interface JunctionEntries<Content extends Json.Object | null> extends Json.Object {
26
- readonly relations: [string, string[]][];
25
+ type JunctionEntriesBase<AType extends string, BType extends string, Content extends Json.Object | null> = {
26
+ readonly relations: ([AType, BType[]] | [BType, AType[]])[];
27
27
  readonly contents: [string, Content][];
28
+ };
29
+ interface JunctionEntries<AType extends string, BType extends string, Content extends Json.Object | null> extends Json.Object, JunctionEntriesBase<AType, BType, Content> {
28
30
  }
29
- interface JunctionSchema<ASide extends string, BSide extends string> extends Json.Object {
31
+ type JunctionSchemaBase<ASide extends string, BSide extends string> = {
30
32
  readonly between: [a: ASide, b: BSide];
31
33
  readonly cardinality: `1:1` | `1:n` | `n:n`;
34
+ };
35
+ interface JunctionSchema<ASide extends string, BSide extends string> extends Json.Object, JunctionSchemaBase<ASide, BSide> {
32
36
  }
33
37
  type BaseExternalStoreConfiguration = {
34
38
  addRelation: (a: string, b: string) => void;
35
39
  deleteRelation: (a: string, b: string) => void;
36
40
  replaceRelationsSafely: (a: string, bs: string[]) => void;
37
41
  replaceRelationsUnsafely: (a: string, bs: string[]) => void;
38
- getRelatedKeys: (key: string) => Set<string> | undefined;
42
+ getRelatedKeys(key: string): Set<string> | undefined;
39
43
  has: (a: string, b?: string) => boolean;
40
44
  };
41
45
  type ExternalStoreWithContentConfiguration<Content extends Json.Object> = {
@@ -47,45 +51,70 @@ type Empty<Obj extends object> = {
47
51
  [Key in keyof Obj]?: undefined;
48
52
  };
49
53
  type ExternalStoreConfiguration<Content extends Json.Object | null> = Content extends Json.Object ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Json.Object>>;
50
- type JunctionAdvancedConfiguration<Content extends Json.Object | null> = {
54
+ type JunctionAdvancedConfiguration<AType extends string, BType extends string, Content extends Json.Object | null> = {
51
55
  warn?: (...args: any[]) => void;
52
56
  externalStore?: ExternalStoreConfiguration<Content>;
57
+ isAType?: Refinement<string, AType>;
58
+ isBType?: Refinement<string, BType>;
53
59
  isContent?: Refinement<unknown, Content>;
54
- makeContentKey?: (a: string, b: string) => string;
60
+ makeContentKey?: (a: AType, b: BType) => string;
55
61
  };
56
- type JunctionJSON<ASide extends string, BSide extends string, Content extends Json.Object | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
57
- declare class Junction<const ASide extends string, const BSide extends string, const Content extends Json.Object | null = null> {
62
+ type JunctionJSON<ASide extends string, AType extends string, BSide extends string, BType extends string, Content extends Json.Object | null> = JunctionEntries<AType, BType, Content> & JunctionSchema<ASide, BSide>;
63
+ declare class Junction<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Content extends Json.Object | null = null> {
58
64
  readonly a: ASide;
59
65
  readonly b: BSide;
60
66
  readonly cardinality: `1:1` | `1:n` | `n:n`;
61
- readonly relations: Map<string, Set<string>>;
67
+ readonly relations: Map<AType | BType, Set<AType> | Set<BType>>;
62
68
  readonly contents: Map<string, Content>;
69
+ isAType?: Refinement<string, AType> | null;
70
+ isBType?: Refinement<string, BType> | null;
63
71
  isContent: Refinement<unknown, Content> | null;
64
- makeContentKey: (a: string, b: string) => string;
72
+ makeContentKey: (a: AType, b: BType) => string;
65
73
  warn?: (...args: any[]) => void;
66
- getRelatedKeys(key: string): Set<string> | undefined;
67
- protected addRelation(a: string, b: string): void;
68
- protected deleteRelation(a: string, b: string): void;
69
- protected replaceRelationsUnsafely(a: string, bs: string[]): void;
70
- protected replaceRelationsSafely(a: string, bs: string[]): void;
74
+ getRelatedKeys(key: AType): Set<BType> | undefined;
75
+ getRelatedKeys(key: BType): Set<AType> | undefined;
76
+ getRelatedKeys(key: AType | BType): Set<AType> | Set<BType> | undefined;
77
+ protected addRelation(a: AType, b: BType): void;
78
+ protected deleteRelation(a: AType, b: BType): void;
79
+ protected replaceRelationsUnsafely(a: AType, bs: BType[]): void;
80
+ protected replaceRelationsUnsafely(b: BType, as: AType[]): void;
81
+ protected replaceRelationsSafely(a: AType, bs: BType[]): void;
82
+ protected replaceRelationsSafely(b: BType, as: AType[]): void;
71
83
  protected getContentInternal(contentKey: string): Content | undefined;
72
84
  protected setContent(contentKey: string, content: Content): void;
73
85
  protected deleteContent(contentKey: string): void;
74
- constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
75
- toJSON(): JunctionJSON<ASide, BSide, Content>;
76
- set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
86
+ constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<NoInfer<AType>, NoInfer<BType>, Content>>, config?: JunctionAdvancedConfiguration<AType, BType, Content>);
87
+ toJSON(): JunctionJSON<ASide, AType, BSide, BType, Content>;
88
+ set(a: AType, ...rest: Content extends null ? [b: BType] : [b: BType, content: Content]): this;
77
89
  set(relation: {
78
- [Key in ASide | BSide]: string;
79
- }, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
80
- delete(a: string, b?: string): this;
81
- delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
82
- getRelatedKey(key: string): string | undefined;
83
- replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
90
+ [Key in ASide]: AType;
91
+ } & {
92
+ [Key in BSide]: BType;
93
+ }, ...rest: Content extends null ? [] | [void?: undefined] : [content: Content]): this;
94
+ delete(a: AType, b?: BType): this;
95
+ delete(b: BType, a?: AType): this;
96
+ delete(relation: {
97
+ [Key in ASide]: AType;
98
+ } | {
99
+ [Key in BSide]: BType;
100
+ } | ({
101
+ [Key in ASide]: AType;
102
+ } & {
103
+ [Key in BSide]: BType;
104
+ }), b?: undefined): this;
105
+ getRelatedKey(key: AType): BType | undefined;
106
+ getRelatedKey(key: BType): AType | undefined;
107
+ replaceRelations(a: AType, relations: Content extends null ? BType[] : Record<BType, Content>, config?: {
108
+ reckless: boolean;
109
+ }): this;
110
+ replaceRelations(b: BType, relations: Content extends null ? AType[] : Record<AType, Content>, config?: {
84
111
  reckless: boolean;
85
112
  }): this;
86
- getContent(a: string, b: string): Content | undefined;
87
- getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
88
- has(a: string, b?: string): boolean;
113
+ getContent(a: AType, b: BType): Content | undefined;
114
+ getRelationEntries(input: Record<ASide, AType>): [BType, Content][];
115
+ getRelationEntries(input: Record<BSide, BType>): [AType, Content][];
116
+ has(a: AType, b?: BType): boolean;
117
+ has(b: BType, a?: AType): boolean;
89
118
  }
90
119
 
91
120
  type Func = (...parameters: any[]) => any;
@@ -163,7 +192,7 @@ type TransactionProgress<F extends Func> = {
163
192
  };
164
193
  type TransactionEpoch = {
165
194
  epoch: Map<string, number>;
166
- actionContinuities: Junction<`continuity`, `action`>;
195
+ actionContinuities: Junction<`continuity`, string, `action`, string>;
167
196
  };
168
197
 
169
198
  declare function deposit<T>(state: RegularAtom<T>): RegularAtomToken<T>;
@@ -210,7 +239,7 @@ declare class Molecule<M extends MoleculeConstructor> implements MoleculeToken<M
210
239
  tokens: Map<string, ReadableToken<any>>;
211
240
  above: Map<string, Molecule<any>>;
212
241
  below: Map<string, Molecule<any>>;
213
- joins: Map<string, Join<any, any, any, any>>;
242
+ joins: Map<string, Join<any, any, any, any, any, any>>;
214
243
  instance: InstanceType<M>;
215
244
  constructor(ctx: Molecule<any>[] | undefined, key: MoleculeKey<M>, family?: MoleculeFamilyToken<M>);
216
245
  }
@@ -306,8 +335,8 @@ declare class Store implements Lineage {
306
335
  selectors: Map<string, WritableSelector<any>>;
307
336
  readonlySelectors: Map<string, ReadonlySelector<any>>;
308
337
  atomsThatAreDefault: Set<string>;
309
- selectorAtoms: Junction<"selectorKey", "atomKey", null>;
310
- selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
338
+ selectorAtoms: Junction<"selectorKey", string, "atomKey", string, null>;
339
+ selectorGraph: Junction<"upstreamSelectorKey", string, "downstreamSelectorKey", string, {
311
340
  source: string;
312
341
  }>;
313
342
  trackers: Map<string, Tracker<Transceiver<any>>>;
@@ -315,7 +344,7 @@ declare class Store implements Lineage {
315
344
  transactions: Map<string, Transaction<Func>>;
316
345
  transactionMeta: TransactionEpoch | TransactionProgress<Func>;
317
346
  timelines: Map<string, Timeline<any>>;
318
- timelineTopics: Junction<"timelineKey", "topicKey", {
347
+ timelineTopics: Junction<"timelineKey", string, "topicKey", string, {
319
348
  topicType: `atom_family` | `atom` | `molecule_family` | `molecule`;
320
349
  }>;
321
350
  disposalTraces: CircularBuffer<{
@@ -393,9 +422,9 @@ type Signal<TVR extends Transceiver<any>> = TVR extends Transceiver<infer S> ? S
393
422
 
394
423
  declare function createMutableAtom<T extends Transceiver<any>, J extends Json.Serializable>(store: Store, options: MutableAtomOptions<T, J>, family: FamilyMetadata | undefined): MutableAtomToken<T, J>;
395
424
 
396
- declare function createMutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends string>(store: Store, options: MutableAtomFamilyOptions<T, J, K>, internalRoles?: string[]): MutableAtomFamilyToken<T, J, K>;
425
+ declare function createMutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(store: Store, options: MutableAtomFamilyOptions<T, J, K>, internalRoles?: string[]): MutableAtomFamilyToken<T, J, K>;
397
426
 
398
- declare const getJsonFamily: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable, Key extends string>(mutableAtomFamily: MutableAtomFamilyToken<Core, SerializableCore, Key>, store: Store) => WritableSelectorFamily<SerializableCore, Key>;
427
+ declare const getJsonFamily: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable, Key extends Canonical>(mutableAtomFamily: MutableAtomFamilyToken<Core, SerializableCore, Key>, store: Store) => WritableSelectorFamily<SerializableCore, Key>;
399
428
 
400
429
  declare const getJsonToken: <Core extends Transceiver<any>, SerializableCore extends Json.Serializable>(store: Store, mutableAtomToken: MutableAtomToken<Core, SerializableCore>) => WritableSelectorToken<SerializableCore>;
401
430
 
@@ -672,4 +701,4 @@ type SelectorFamily<T, K extends Canonical> = ReadonlySelectorFamily<T, K> | Wri
672
701
  type WritableFamily<T, K extends Canonical> = AtomFamily<T, K> | WritableSelectorFamily<T, K>;
673
702
  type ReadableFamily<T, K extends Canonical> = AtomFamily<T, K> | SelectorFamily<T, K>;
674
703
 
675
- export { type Atom, type AtomFamily, type AtomIOState, type AtomIOToken, type AtomKey, type BaseExternalStoreConfiguration, type ChildStore, type Count, type Each, type Empty, type EnvironmentData, type ExternalStoreConfiguration, type ExternalStoreWithContentConfiguration, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, type Flat, type Func, Future, IMPLICIT, Junction, type JunctionAdvancedConfiguration, type JunctionEntries, type JunctionJSON, type JunctionSchema, LazyMap, type Lineage, type Modify, Molecule, type MutableAtom, type MutableAtomFamily, NotFoundError, type OperationProgress, type ReadableFamily, type ReadableState, type ReadonlySelector, type ReadonlySelectorFamily, type ReadonlySelectorKey, type RegularAtom, type RegularAtomFamily, type RootStore, type Selector, type SelectorFamily, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineMoleculeCreation, type TimelineMoleculeDisposal, type TimelineSelectorUpdate, type TimelineStateCreation, type TimelineStateDisposal, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type Withdrawable, type WritableFamily, type WritableSelector, type WritableSelectorFamily, type WritableState, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
704
+ export { type Atom, type AtomFamily, type AtomIOState, type AtomIOToken, type AtomKey, type BaseExternalStoreConfiguration, type ChildStore, type Count, type Each, type Empty, type EnvironmentData, type ExternalStoreConfiguration, type ExternalStoreWithContentConfiguration, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, type Flat, type Func, Future, IMPLICIT, Junction, type JunctionAdvancedConfiguration, type JunctionEntries, type JunctionEntriesBase, type JunctionJSON, type JunctionSchema, type JunctionSchemaBase, LazyMap, type Lineage, type Modify, Molecule, type MutableAtom, type MutableAtomFamily, NotFoundError, type OperationProgress, type ReadableFamily, type ReadableState, type ReadonlySelector, type ReadonlySelectorFamily, type ReadonlySelectorKey, type RegularAtom, type RegularAtomFamily, type RootStore, type Selector, type SelectorFamily, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineMoleculeCreation, type TimelineMoleculeDisposal, type TimelineSelectorUpdate, type TimelineStateCreation, type TimelineStateDisposal, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type Withdrawable, type WritableFamily, type WritableSelector, type WritableSelectorFamily, type WritableState, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
@@ -1,3 +1,3 @@
1
- export { FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, Junction, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw } from '../../dist/chunk-7PUUHSXC.js';
2
- import '../../dist/chunk-ZKG6ZA4I.js';
1
+ export { FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, Junction, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw } from '../../dist/chunk-LSCRHXLI.js';
2
+ import '../../dist/chunk-ADMEAXYU.js';
3
3
  import '../../dist/chunk-XWL6SNVU.js';