jazz-tools

CoValues

type ID

type ID<T> = CojsonInternalTypes.RawCoID & IDMarker<T>

IDs are unique identifiers for CoValues.
Can be used with a type argument to refer to a specific
CoValue type.
FileStreams are CoFeeds that contain binary data, collaborative versions of Blobs.
Content
BinaryCoStream.loadAsBlob(id, options): Promise<Blob | undefined>
function fn(...args: [
id: ID<FileStream>,
options: { allowUnfinished: boolean, loadAs: AnonymousJazzAgent | Account }
]) {}
Load a FileStream as a Blob
BinaryCoStream.createFromBlob(blob, options): Promise<FileStream>
function fn(...args: [
blob: File | Blob,
options: { owner: Group | Account, onProgress: (progress: number) => void } | Group | Account
]) {}
Create a FileStream from a Blob or File
Example
import { co, FileStream } from "jazz-tools";

const fileStream = await FileStream.createFromBlob(file, {owner: group})
.id: class X {
prop:
ID<FileStream>
The ID of this FileStream
.toJSON(): { id: string, _type: "BinaryCoStream", mimeType: string, totalSizeBytes: number, fileName: string, chunks: Uint8Array<ArrayBufferLike>[], finished: boolean }
Get a JSON representation of the FileStream
Creation
BinaryCoStream.create<S>(options): S
class Thing<
S extends FileStream
]> {}
function fn(...args: [
this: CoValueClass<S>,
options: { owner: Group | Account } | Group | Account
]) {}
Create a new empty FileStream instance.
Example
// Create owned by an account
const stream = FileStream.create({ owner: myAccount });

// Create owned by a group
const stream = FileStream.create({ owner: teamGroup });

// Create with implicit owner
const stream = FileStream.create(myAccount);
Subscription & Loading
BinaryCoStream.load<C>(id, options): Promise<C | null>
class Thing<
C extends FileStream
]> {}
function fn(...args: [
this: CoValueClass<C>,
id: ID<C>,
options: { loadAs: AnonymousJazzAgent | Account }
]) {}
Load a FileStream
BinaryCoStream.subscribe<C>(id, options, listener): () => void
class Thing<
C extends FileStream
]> {}
function fn(...args: [
this: CoValueClass<C>,
id: ID<C>,
options: { loadAs: AnonymousJazzAgent | Account },
listener: (value: C) => void
]) {}
Subscribe to a FileStream, when you have an ID but don't have a FileStream instance yet
.subscribe<B>(listener): () => void
class Thing<
B extends FileStream
]> {}
function fn(...args: [
this: B,
listener: (value: B) => void
]) {}
An instance method to subscribe to an existing FileStream
.waitForSync(options): Promise<unknown[]>
function fn(...args: [
options: { timeout: number }
]) {}
Wait for the FileStream to be uploaded to the other peers.
Collaboration
._owner: class X {
prop:
Group | Account
Internals
BinaryCoStream.fromRaw<V>(raw): V
class Thing<
V extends CoValue
]> {}
function fn(...args: [
this: CoValueClass<V>,
raw: RawCoValue
]) {}
._instanceID: class X {
prop:
string
Type Helpers
._type: class X {
prop:
"BinaryCoStream"
.castAs<Cl>(cl): InstanceType<Cl>
class Thing<
Cl extends CoValueClass<CoValue> & CoValueFromRaw<CoValue>
]> {}
function fn(...args: [
cl: Cl
]) {}
Other
.constructor: class X {
prop:
NO TYPE
⚠️ undocumented
.getChunks(options): BinaryStreamInfo & { chunks: Uint8Array<ArrayBufferLike>[], finished: boolean } | undefined
function fn(...args: [
options: { allowUnfinished: boolean }
]) {}
⚠️ undocumented
.isBinaryStreamEnded(): boolean
⚠️ undocumented
.start(options): void
function fn(...args: [
options: BinaryStreamInfo
]) {}
⚠️ undocumented
.push(data): void
function fn(...args: [
data: Uint8Array
]) {}
⚠️ undocumented
.end(): void
⚠️ undocumented
.toBlob(options): Blob | undefined
function fn(...args: [
options: { allowUnfinished: boolean }
]) {}
⚠️ undocumented
CoFeeds are collaborative logs of data.
Declaration
CoFeed.Of<Item>(item): CoFeed
function fn(...args: [
item: IfCo<Item, Item>
]) {}
Declare a CoFeed by subclassing CoFeed.Of(...) and passing the item schema using a co primitive or a co.ref.
Example
class ColorFeed extends CoFeed.Of(co.string) {}
class AnimalFeed extends CoFeed.Of(co.ref(Animal)) {}
Content
They are similar to CoLists, but with a few key differences:
- They are append-only
- They consist of several internal append-only logs, one per account session (tab, device, app instance, etc.)
- They expose those as a per-account aggregated view (default) or a precise per-session view

Example
favDog.push("Poodle");
favDog.push("Schnowzer");
.id: class X {
prop:
ID<CoFeed<Item>>
The ID of this CoFeed
.byMe: class X {
prop:
CoFeedEntry<Item> | undefined
The current account's view of this CoFeed
.perSession: class X {
prop:
{ undefined }
The per-session view of this CoFeed
.inCurrentSession: class X {
prop:
CoFeedEntry<Item> | undefined
The current session's view of this CoFeed

This is a shortcut for
this.perSession where the session ID is the current session ID.
.push(items): void
function fn(...args: [
items: Item[]
]) {}
Push items to this CoFeed

Items are appended to the current session's log. Each session (tab, device, app instance)
maintains its own append-only log, which is then aggregated into the per-account view.
Example
// Adds items to current session's log
feed.push("item1", "item2");

// View items from current session
console.log(feed.inCurrentSession);

// View aggregated items from all sessions for current account
console.log(feed.byMe);
Creation
CoFeed.create<S>(init, options): S
class Thing<
S extends CoFeed<any>
]> {}
function fn(...args: [
this: CoValueClass<S>,
init: TODO type conditional,
options: { owner: Group | Account } | Group | Account
]) {}
Create a new CoFeed
Subscription & Loading
CoFeed.load<F, R>(id, options): Promise<Resolved<F, R> | null>
class Thing<
F extends CoFeed<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<F>,
id: ID<F>,
options: { resolve: RefsToResolveStrict<F, R>, loadAs: AnonymousJazzAgent | Account }
]) {}
Load a CoFeed
CoFeed.subscribe<F, R>(id, listener): () => void
class Thing<
F extends CoFeed<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<F>,
id: ID<F>,
listener: (value: Resolved<F, R>, unsubscribe: () => void) => void
]) {}
Subscribe to a CoFeed, when you have an ID but don't have a CoFeed instance yet
CoFeed.subscribe<F, R>(id, options, listener): () => void
class Thing<
F extends CoFeed<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<F>,
id: ID<F>,
options: SubscribeListenerOptions<F, R>,
listener: (value: Resolved<F, R>, unsubscribe: () => void) => void
]) {}
Subscribe to a CoFeed, when you have an ID but don't have a CoFeed instance yet
.ensureLoaded<F, R>(options): Promise<Resolved<F, R>>
class Thing<
F extends CoFeed<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: F,
options: { resolve: RefsToResolveStrict<F, R> }
]) {}
Ensure a CoFeed is loaded to the specified depth
.subscribe<F, R>(listener): () => void
class Thing<
F extends CoFeed<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: F,
listener: (value: Resolved<F, R>, unsubscribe: () => void) => void
]) {}
An instance method to subscribe to an existing CoFeed

No need to provide an ID or Account since they're already part of the instance.
.subscribe<F, R>(options, listener): () => void
class Thing<
F extends CoFeed<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: F,
options: { resolve: RefsToResolveStrict<F, R> },
listener: (value: Resolved<F, R>, unsubscribe: () => void) => void
]) {}
An instance method to subscribe to an existing CoFeed

No need to provide an ID or Account since they're already part of the instance.
.waitForSync(options): Promise<unknown[]>
function fn(...args: [
options: { timeout: number }
]) {}
Wait for the CoFeed to be uploaded to the other peers.
Collaboration
._owner: class X {
prop:
Group | Account
Internals
CoFeed.fromRaw<V>(raw): V
class Thing<
V extends CoValue
]> {}
function fn(...args: [
this: CoValueClass<V>,
raw: RawCoValue
]) {}
._raw: class X {
prop:
RawCoStream
._instanceID: class X {
prop:
string
Type Helpers
._type: class X {
prop:
"CoStream"
.castAs<Cl>(cl): InstanceType<Cl>
class Thing<
Cl extends CoValueClass<CoValue> & CoValueFromRaw<CoValue>
]> {}
function fn(...args: [
cl: Cl
]) {}
Other
.constructor: class X {
prop:
NO TYPE
⚠️ undocumented
.toJSON(): { id: string, _type: "CoStream", in: { undefined } }
Get a JSON representation of the CoFeed
CoLists are collaborative versions of plain arrays.
Declaration
CoList.Of<Item>(item): CoList
function fn(...args: [
item: Item
]) {}
Declare a CoList by subclassing CoList.Of(...) and passing the item schema using co.
Example
class ColorList extends CoList.Of(
co.string
) {}
class AnimalList extends CoList.Of(
co.ref(Animal)
) {}
Content
You can access items on a CoList as if they were normal items on a plain array, using [] notation, etc.

Since
CoList is a subclass of Array, you can use all the normal array methods like push, pop, splice, etc.

Example
colorList[0];
colorList[3] = "yellow";
colorList.push("Kawazaki Green");
colorList.splice(1, 1);
.id: class X {
prop:
ID<CoList<Item>>
The ID of this CoList
._refs: class X {
prop:
{ undefined } & { length: number, [iterator]: NO TYPE }
If a CoList's items are a co.ref(...), you can use coList._refs[i] to access
the
Ref instead of the potentially loaded/null value.

This allows you to always get the ID or load the value manually.
Example
animals._refs[0].id; // => ID<Animal>
animals._refs[0].value;
// => Animal | null
const animal = await animals._refs[0].load();
Creation
CoList.create<L>(items, options): L
class Thing<
L extends CoList<any>
]> {}
function fn(...args: [
this: CoValueClass<L>,
items: UnCo<L[number]>[],
options: { owner: Group | Account } | Group | Account
]) {}
Create a new CoList with the given initial values and owner.

The owner (a Group or Account) determines access rights to the CoMap.

The CoList will immediately be persisted and synced to connected peers.
Example
const colours = ColorList.create(
["red", "green", "blue"],
{ owner: me }
);
const animals = AnimalList.create(
[cat, dog, fish],
{ owner: me }
);
Subscription & Loading
CoList.load<L, R>(id, options): Promise<Resolved<L, R> | null>
class Thing<
L extends CoList<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<L>,
id: ID<L>,
options: { resolve: RefsToResolveStrict<L, R>, loadAs: AnonymousJazzAgent | Account }
]) {}
Load a CoList with a given ID, as a given account.

depth specifies if item CoValue references should be loaded as well before resolving.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or for shallowly loading only this CoList, or [itemDepth] for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.
Example
const animalsWithVets =
await ListOfAnimals.load(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
me,
[{ vet: {} }]
);
CoList.subscribe<L, R>(id, listener): () => void
class Thing<
L extends CoList<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<L>,
id: ID<L>,
listener: (value: Resolved<L, R>, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoList with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

depth specifies if item CoValue references should be loaded as well before calling listener for the first time.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or for shallowly loading only this CoList, or [itemDepth] for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
Example
const unsub = ListOfAnimals.subscribe(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
me,
{ vet: {} },
(animalsWithVets) => console.log(animalsWithVets)
);
CoList.subscribe<L, R>(id, options, listener): () => void
class Thing<
L extends CoList<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<L>,
id: ID<L>,
options: SubscribeListenerOptions<L, R>,
listener: (value: Resolved<L, R>, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoList with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

depth specifies if item CoValue references should be loaded as well before calling listener for the first time.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or for shallowly loading only this CoList, or [itemDepth] for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
Example
const unsub = ListOfAnimals.subscribe(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
me,
{ vet: {} },
(animalsWithVets) => console.log(animalsWithVets)
);
.ensureLoaded<L, R>(options): Promise<Resolved<L, R>>
class Thing<
L extends CoList<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: L,
options: { resolve: RefsToResolveStrict<L, R> }
]) {}
Given an already loaded CoList, ensure that items are loaded to the specified depth.

Works like
CoList.load(), but you don't need to pass the ID or the account to load as again.
.subscribe<L, R>(listener): () => void
class Thing<
L extends CoList<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: L,
listener: (value: Resolved<L, R>, unsubscribe: () => void) => void
]) {}
Given an already loaded CoList, subscribe to updates to the CoList and ensure that items are loaded to the specified depth.

Works like
CoList.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
.subscribe<L, R>(options, listener): () => void
class Thing<
L extends CoList<any>,
R extends { $each: RefsToResolve<any, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: L,
options: { resolve: RefsToResolveStrict<L, R> },
listener: (value: Resolved<L, R>, unsubscribe: () => void) => void
]) {}
Given an already loaded CoList, subscribe to updates to the CoList and ensure that items are loaded to the specified depth.

Works like
CoList.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
.waitForSync(options): Promise<unknown[]>
function fn(...args: [
options: { timeout: number }
]) {}
Wait for the CoList to be uploaded to the other peers.
Collaboration
._owner: class X {
prop:
Group | Account
Stringifying & Inspection
.toJSON(_key, seenAbove): any[]
function fn(...args: [
_key: string,
seenAbove: ID<CoValue>[]
]) {}
.[inspect](): any[]
Internals
CoList.fromRaw<V>(raw): V & CoList<any>
class Thing<
V extends CoList<any>
]> {}
function fn(...args: [
this: CoValueClass<V> & CoList,
raw: RawCoList
]) {}
._raw: class X {
prop:
RawCoList
._instanceID: class X {
prop:
string
Type Helpers
._type: class X {
prop:
"CoList"
.castAs<Cl>(cl): InstanceType<Cl>
class Thing<
Cl extends CoValueClass<CoValue> & CoValueFromRaw<CoValue>
]> {}
function fn(...args: [
cl: Cl
]) {}
Other
CoList[species]: class X {
prop:
ArrayConstructor
⚠️ undocumented
CoList.isArray(arg): arg is any[]
function fn(...args: [
arg: any
]) {}
⚠️ undocumented
CoList.from<T>(arrayLike): T[]
function fn(...args: [
arrayLike: ArrayLike<T>
]) {}
Creates an array from an array-like object.
CoList.from<T, U>(arrayLike, mapfn, thisArg): U[]
function fn(...args: [
arrayLike: ArrayLike<T>,
mapfn: (v: T, k: number) => U,
thisArg: any
]) {}
Creates an array from an iterable object.
CoList.from<T>(iterable): T[]
function fn(...args: [
iterable: ArrayLike<T> | Iterable<T, any, any>
]) {}
Creates an array from an iterable object.
CoList.from<T, U>(iterable, mapfn, thisArg): U[]
function fn(...args: [
iterable: ArrayLike<T> | Iterable<T, any, any>,
mapfn: (v: T, k: number) => U,
thisArg: any
]) {}
Creates an array from an iterable object.
CoList.fromAsync<T>(iterableOrArrayLike): Promise<T[]>
function fn(...args: [
iterableOrArrayLike: ArrayLike<PromiseLike<T> | T> | Iterable<PromiseLike<T> | T, any, any> | AsyncIterable<T, any, any>
]) {}
Creates an array from an async iterator or iterable object.
CoList.fromAsync<T, U>(iterableOrArrayLike, mapFn, thisArg): Promise<Awaited<U>[]>
function fn(...args: [
iterableOrArrayLike: ArrayLike<T> | Iterable<T, any, any> | AsyncIterable<T, any, any>,
mapFn: (value: Awaited<T>, index: number) => U,
thisArg: any
]) {}
Creates an array from an async iterator or iterable object.
.constructor: class X {
prop:
NO TYPE
⚠️ undocumented
._edits: class X {
prop:
{ undefined }
⚠️ undocumented
.push(items): number
function fn(...args: [
items: Item[]
]) {}
Appends new elements to the end of an array, and returns the new length of the array.
.unshift(items): number
function fn(...args: [
items: Item[]
]) {}
Inserts new elements at the start of an array, and returns the new length of the array.
.pop(): Item | undefined
Removes the last element from an array and returns it.
If the array is empty, undefined is returned and the array is not modified.
.shift(): Item | undefined
Removes the first element from an array and returns it.
If the array is empty, undefined is returned and the array is not modified.
.splice(start, deleteCount, items): Item[]
function fn(...args: [
start: number,
deleteCount: number,
items: Item[]
]) {}
Splice the CoList at a given index.
.applyDiff(result): void
function fn(...args: [
result: Item[]
]) {}
Modify the CoList to match another list, where the changes are managed internally.
.length: class X {
prop:
number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.
.toString(): string
Returns a string representation of an array.
.toLocaleString(): string
Returns a string representation of an array. The elements are converted to string using their toLocaleString methods.
.toLocaleString(locales, options): string
function fn(...args: [
locales: string[] | string,
options: NumberFormatOptions & DateTimeFormatOptions
]) {}
⚠️ undocumented
.concat(items): Item[]
function fn(...args: [
items: ConcatArray<Item>[]
]) {}
Combines two or more arrays.
This method returns a new array without modifying any existing arrays.
.concat(items): Item[]
function fn(...args: [
items: ConcatArray<Item> | Item[]
]) {}
Combines two or more arrays.
This method returns a new array without modifying any existing arrays.
.join(separator): string
function fn(...args: [
separator: string
]) {}
Adds all the elements of an array into a string, separated by the specified separator string.
.reverse(): Item[]
Reverses the elements in an array in place.
This method mutates the array and returns a reference to the same array.
.slice(start, end): Item[]
function fn(...args: [
start: number,
end: number
]) {}
Returns a copy of a section of an array.
For both start and end, a negative index can be used to indicate an offset from the end of the array.
For example, -2 refers to the second to last element of the array.
.sort(compareFn): this
function fn(...args: [
compareFn: (a: Item, b: Item) => number
]) {}
Sorts an array in place.
This method mutates the array and returns a reference to the same array.
.indexOf(searchElement, fromIndex): number
function fn(...args: [
searchElement: Item,
fromIndex: number
]) {}
Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
.lastIndexOf(searchElement, fromIndex): number
function fn(...args: [
searchElement: Item,
fromIndex: number
]) {}
Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present.
.every<S>(predicate, thisArg): this is S[]
function fn(...args: [
predicate: (value: Item, index: number, array: Item[]) => value is S,
thisArg: any
]) {}
Determines whether all the members of an array satisfy the specified test.
.every(predicate, thisArg): boolean
function fn(...args: [
predicate: (value: Item, index: number, array: Item[]) => unknown,
thisArg: any
]) {}
Determines whether all the members of an array satisfy the specified test.
.some(predicate, thisArg): boolean
function fn(...args: [
predicate: (value: Item, index: number, array: Item[]) => unknown,
thisArg: any
]) {}
Determines whether the specified callback function returns true for any element of an array.
.forEach(callbackfn, thisArg): void
function fn(...args: [
callbackfn: (value: Item, index: number, array: Item[]) => void,
thisArg: any
]) {}
Performs the specified action for each element in an array.
.map<U>(callbackfn, thisArg): U[]
function fn(...args: [
callbackfn: (value: Item, index: number, array: Item[]) => U,
thisArg: any
]) {}
Calls a defined callback function on each element of an array, and returns an array that contains the results.
.filter<S>(predicate, thisArg): S[]
function fn(...args: [
predicate: (value: Item, index: number, array: Item[]) => value is S,
thisArg: any
]) {}
Returns the elements of an array that meet the condition specified in a callback function.
.filter(predicate, thisArg): Item[]
function fn(...args: [
predicate: (value: Item, index: number, array: Item[]) => unknown,
thisArg: any
]) {}
Returns the elements of an array that meet the condition specified in a callback function.
.reduce(callbackfn): Item
function fn(...args: [
callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item
]) {}
Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
.reduce(callbackfn, initialValue): Item
function fn(...args: [
callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item,
initialValue: Item
]) {}
⚠️ undocumented
.reduce<U>(callbackfn, initialValue): U
function fn(...args: [
callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U,
initialValue: U
]) {}
Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
.reduceRight(callbackfn): Item
function fn(...args: [
callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item
]) {}
Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
.reduceRight(callbackfn, initialValue): Item
function fn(...args: [
callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item,
initialValue: Item
]) {}
⚠️ undocumented
.reduceRight<U>(callbackfn, initialValue): U
function fn(...args: [
callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U,
initialValue: U
]) {}
Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
.find<S>(predicate, thisArg): S | undefined
function fn(...args: [
predicate: (value: Item, index: number, obj: Item[]) => value is S,
thisArg: any
]) {}
Returns the value of the first element in the array where predicate is true, and undefined
otherwise.
.find(predicate, thisArg): Item | undefined
function fn(...args: [
predicate: (value: Item, index: number, obj: Item[]) => unknown,
thisArg: any
]) {}
⚠️ undocumented
.findIndex(predicate, thisArg): number
function fn(...args: [
predicate: (value: Item, index: number, obj: Item[]) => unknown,
thisArg: any
]) {}
Returns the index of the first element in the array where predicate is true, and -1
otherwise.
.fill(value, start, end): this
function fn(...args: [
value: Item,
start: number,
end: number
]) {}
Changes all array elements from start to end index to a static value and returns the modified array
.copyWithin(target, start, end): this
function fn(...args: [
target: number,
start: number,
end: number
]) {}
Returns the this object after copying a section of the array identified by start and end
to the same array starting at position target
.entries(): ArrayIterator<[number, Item]>
Returns an iterable of key, value pairs for every entry in the array
.keys(): ArrayIterator<number>
Returns an iterable of keys in the array
.values(): ArrayIterator<Item>
Returns an iterable of values in the array
.includes(searchElement, fromIndex): boolean
function fn(...args: [
searchElement: Item,
fromIndex: number
]) {}
Determines whether an array includes a certain element, returning true or false as appropriate.
.flatMap<U, This>(callback, thisArg): U[]
function fn(...args: [
callback: (this: This, value: Item, index: number, array: Item[]) => TODO type typeOperator | U,
thisArg: This
]) {}
Calls a defined callback function on each element of an array. Then, flattens the result into
a new array.
This is identical to a map followed by flat with depth 1.
.flat<A, D>(depth): FlatArray<A, D>[]
class Thing<
D extends number
]> {}
function fn(...args: [
this: A,
depth: D
]) {}
Returns a new array with all sub-array elements concatenated into it recursively up to the
specified depth.
.at(index): Item | undefined
function fn(...args: [
index: number
]) {}
Returns the item located at the specified index.
.findLast<S>(predicate, thisArg): S | undefined
function fn(...args: [
predicate: (value: Item, index: number, array: Item[]) => value is S,
thisArg: any
]) {}
Returns the value of the last element in the array where predicate is true, and undefined
otherwise.
.findLast(predicate, thisArg): Item | undefined
function fn(...args: [
predicate: (value: Item, index: number, array: Item[]) => unknown,
thisArg: any
]) {}
⚠️ undocumented
.findLastIndex(predicate, thisArg): number
function fn(...args: [
predicate: (value: Item, index: number, array: Item[]) => unknown,
thisArg: any
]) {}
Returns the index of the last element in the array where predicate is true, and -1
otherwise.
.toReversed(): Item[]
Returns a copy of an array with its elements reversed.
.toSorted(compareFn): Item[]
function fn(...args: [
compareFn: (a: Item, b: Item) => number
]) {}
Returns a copy of an array with its elements sorted.
.toSpliced(start, deleteCount, items): Item[]
function fn(...args: [
start: number,
deleteCount: number,
items: Item[]
]) {}
Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array.
.toSpliced(start, deleteCount): Item[]
function fn(...args: [
start: number,
deleteCount: number
]) {}
Copies an array and removes elements while returning the remaining elements.
.with(index, value): Item[]
function fn(...args: [
index: number,
value: Item
]) {}
Copies an array, then overwrites the value at the provided index with the
given value. If the index is negative, then it replaces from the end
of the array.
.[iterator](): ArrayIterator<Item>
Iterator
[unscopables]: class X {
prop:
{ length: boolean, toString: boolean, toLocaleString: boolean, pop: boolean, push: boolean, concat: boolean, join: boolean, reverse: boolean, shift: boolean, slice: boolean, sort: boolean, splice: boolean, unshift: boolean, indexOf: boolean, lastIndexOf: boolean, every: boolean, some: boolean, forEach: boolean, map: boolean, filter: boolean, reduce: boolean, reduceRight: boolean, find: boolean, findIndex: boolean, fill: boolean, copyWithin: boolean, entries: boolean, keys: boolean, values: boolean, includes: boolean, flatMap: boolean, flat: boolean, at: boolean, findLast: boolean, findLastIndex: boolean, toReversed: boolean, toSorted: boolean, toSpliced: boolean, with: boolean, [iterator]: boolean, [unscopables]: boolean }
Is an object whose properties have the value 'true'
when they will be absent when used in a 'with' statement.
CoMaps are collaborative versions of plain objects, mapping string-like keys to values.
Declaration
Declare your own CoMap schemas by subclassing CoMap and assigning field schemas with co.

Optional
co.ref(...) fields must be marked with { optional: true }.

Example
import { co, CoMap } from "jazz-tools";

class Person extends CoMap {
name = co.string;
age = co.number;
pet = co.ref(Animal);
car = co.ref(Car, { optional: true });
}
CoMap.Record<Value>(value): RecordLikeCoMap
function fn(...args: [
value: IfCo<Value, Value>
]) {}
Declare a Record-like CoMap schema, by extending CoMap.Record(...) and passing the value schema using co. Keys are always string.
Example
import { co, CoMap } from "jazz-tools";

class ColorToFruitMap extends CoMap.Record(
co.ref(Fruit)
) {}

// assume we have map: ColorToFruitMap
// and strawberry: Fruit
map["red"] = strawberry;
Content
You can access properties you declare on a CoMap (using co) as if they were normal properties on a plain object, using dot notation, Object.keys(), etc.

Example
person.name;
person["age"];
person.age = 42;
person.pet?.name;
Object.keys(person);
// => ["name", "age", "pet"]
.id: class X {
prop:
ID<CoMap>
The ID of this CoMap
._refs: class X {
prop:
{[Key in string]: IfCo<this[Key], RefIfCoValue<this[Key]>>}
If property prop is a co.ref(...), you can use coMaps._refs.prop to access
the
Ref instead of the potentially loaded/null value.

This allows you to always get the ID or load the value manually.
Example
person._refs.pet.id; // => ID<Animal>
person._refs.pet.value;
// => Animal | null
const pet = await person._refs.pet.load();
.toJSON(_key, seenAbove): any[]
function fn(...args: [
_key: string,
seenAbove: ID<CoValue>[]
]) {}
Return a JSON representation of the CoMap
Creation
CoMap.create<M>(init, options): M
class Thing<
M extends CoMap
]> {}
function fn(...args: [
this: CoValueClass<M>,
init: Simplify<CoMapInit<M>>,
options: { owner: Group | Account, unique: JsonValue } | Group | Account
]) {}
Create a new CoMap with the given initial values and owner.

The owner (a Group or Account) determines access rights to the CoMap.

The CoMap will immediately be persisted and synced to connected peers.
Example
const person = Person.create({
name: "Alice",
age: 42,
pet: cat,
}, { owner: friendGroup });
Subscription & Loading
CoMap.load<M, R>(id, options): Promise<Resolved<M, R> | null>
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
options: { resolve: RefsToResolveStrict<M, R>, loadAs: AnonymousJazzAgent | Account }
]) {}
Load a CoMap with a given ID, as a given account.

depth specifies which (if any) fields that reference other CoValues to load as well before resolving.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.
Example
const person = await Person.load(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} }
);
CoMap.subscribe<M, R>(id, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoMap with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

depth specifies which (if any) fields that reference other CoValues to load as well before calling listener for the first time.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
Example
const unsub = Person.subscribe(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} },
(person) => console.log(person)
);
CoMap.subscribe<M, R>(id, options, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
options: SubscribeListenerOptions<M, R>,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoMap with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

depth specifies which (if any) fields that reference other CoValues to load as well before calling listener for the first time.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
Example
const unsub = Person.subscribe(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} },
(person) => console.log(person)
);
.ensureLoaded<M, R>(options): Promise<Resolved<M, R>>
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
options: { resolve: RefsToResolveStrict<M, R> }
]) {}
Given an already loaded CoMap, ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.load(), but you don't need to pass the ID or the account to load as again.
.subscribe<M, R>(listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Given an already loaded CoMap, subscribe to updates to the CoMap and ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
.subscribe<M, R>(options, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
options: { resolve: RefsToResolveStrict<M, R> },
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Given an already loaded CoMap, subscribe to updates to the CoMap and ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
.waitForSync(options): Promise<unknown[]>
function fn(...args: [
options: { timeout: number }
]) {}
Wait for the CoMap to be uploaded to the other peers.
Collaboration
._edits: class X {
prop:
{[Key in string]: IfCo<this[Key], LastAndAllCoMapEdits<this[Key]>>}
._owner: class X {
prop:
Group | Account
Stringifying & Inspection
.[inspect](): any[]
Internals
CoMap.fromRaw<V>(raw): V
class Thing<
V extends CoValue
]> {}
function fn(...args: [
this: CoValueClass<V>,
raw: RawCoValue
]) {}
._raw: class X {
prop:
RawCoMap
._instanceID: class X {
prop:
string
Type Helpers
._type: class X {
prop:
"CoMap"
.castAs<Cl>(cl): InstanceType<Cl>
class Thing<
Cl extends CoValueClass<CoValue> & CoValueFromRaw<CoValue>
]> {}
function fn(...args: [
cl: Cl
]) {}
Other
CoMap.findUnique<M>(unique, ownerID, as): ID<M>
class Thing<
M extends CoMap
]> {}
function fn(...args: [
this: CoValueClass<M>,
unique: JsonValue,
ownerID: ID<Group> | ID<Account>,
as: Group | AnonymousJazzAgent | Account
]) {}
⚠️ undocumented
.applyDiff<N>(newValues): CoMap
class Thing<
N extends Partial<CoMapInit<CoMap>>
]> {}
function fn(...args: [
newValues: N
]) {}
⚠️ undocumented
SchemaUnion allows you to create union types of CoValues that can be discriminated at runtime.
Declaration
Declare your union types by extending SchemaUnion.Of(...) and passing a discriminator function that determines which concrete type to use based on the raw data.

Example
import { SchemaUnion, CoMap } from "jazz-tools";

class BaseWidget extends CoMap {
type = co.string;
}

class ButtonWidget extends BaseWidget {
type = co.literal("button");
label = co.string;
}

class SliderWidget extends BaseWidget {
type = co.literal("slider");
min = co.number;
max = co.number;
}

const WidgetUnion = SchemaUnion.Of<BaseWidget>((raw) => {
switch (raw.get("type")) {
case "button": return ButtonWidget;
case "slider": return SliderWidget;
default: throw new Error("Unknown widget type");
}
});
SchemaUnion.Of<V>(discriminator): CoValueClass<V> & SchemaUnion
class Thing<
V extends CoValue
]> {}
function fn(...args: [
discriminator: (raw: V["_raw"]) => CoValueClass<V> & CoValueFromRaw<V>
]) {}
Create a new union type from a discriminator function.

The discriminator function receives the raw data and should return the appropriate concrete class to use for that data.

When loading a SchemaUnion, the correct subclass will be instantiated based on the discriminator.
Example
const WidgetUnion = SchemaUnion.Of<BaseWidget>((raw) => {
switch (raw.get("type")) {
case "button": return ButtonWidget;
case "slider": return SliderWidget;
default: throw new Error("Unknown widget type");
}
});

const widget = await loadCoValue(WidgetUnion, id, me, {});

// You can narrow the returned instance to a subclass by using `instanceof`
if (widget instanceof ButtonWidget) {
console.log(widget.label);
} else if (widget instanceof SliderWidget) {
console.log(widget.min, widget.max);
}
Content
.id: class X {
prop:
ID<SchemaUnion>
Collaboration
._owner: class X {
prop:
Group | Account
Stringifying & Inspection
.toJSON(): any[] | string | object
.[inspect](): any[] | string | object
Internals
._raw: class X {
prop:
RawCoValue
._instanceID: class X {
prop:
string
Type Helpers
._type: class X {
prop:
string
.castAs<Cl>(cl): InstanceType<Cl>
class Thing<
Cl extends CoValueClass<CoValue> & CoValueFromRaw<CoValue>
]> {}
function fn(...args: [
cl: Cl
]) {}
Other
.constructor: class X {
prop:
NO TYPE
⚠️ undocumented

Context Creation

type JazzAuthContext

type JazzAuthContext<Acc extends Account> = { me: Acc, node: LocalNode, authenticate: AuthenticateAccountFunction, register: RegisterAccountFunction, logOut: () => Promise<void>, done: () => void, isAuthenticated: boolean }

Identity & Permissions

Content
.id: class X {
prop:
ID<Account>
Subscription & Loading
Account.load<A, R>(id, options): Promise<Resolved<A, R> | null>
class Thing<
A extends Account,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<A>,
id: ID<A>,
options: { resolve: RefsToResolveStrict<A, R>, loadAs: AnonymousJazzAgent | Account }
]) {}
Account.subscribe<A, R>(id, listener): () => void
class Thing<
A extends Account,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<A>,
id: ID<A>,
listener: (value: Resolved<A, R>, unsubscribe: () => void) => void
]) {}
Account.subscribe<A, R>(id, options, listener): () => void
class Thing<
A extends Account,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<A>,
id: ID<A>,
options: SubscribeListenerOptions<A, R>,
listener: (value: Resolved<A, R>, unsubscribe: () => void) => void
]) {}
.ensureLoaded<A, R>(options): Promise<Resolved<A, R>>
class Thing<
A extends Account,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: A,
options: { resolve: RefsToResolveStrict<A, R> }
]) {}
.subscribe<A, R>(listener): () => void
class Thing<
A extends Account,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: A,
listener: (value: Resolved<A, R>, unsubscribe: () => void) => void
]) {}
.subscribe<A, R>(options, listener): () => void
class Thing<
A extends Account,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: A,
options: { resolve: RefsToResolveStrict<A, R> },
listener: (value: Resolved<A, R>, unsubscribe: () => void) => void
]) {}
.waitForSync(options): Promise<unknown[]>
function fn(...args: [
options: { timeout: number }
]) {}
Wait for the Account to be uploaded to the other peers.
.waitForAllCoValuesSync(options): Promise<unknown[][]>
function fn(...args: [
options: { timeout: number }
]) {}
Wait for all the available CoValues to be uploaded to the other peers.
Collaboration
._owner: class X {
prop:
Account
Stringifying & Inspection
.toJSON(): any[] | object
.[inspect](): any[] | object
Internals
Account.fromRaw<V>(raw): V
class Thing<
V extends CoValue
]> {}
function fn(...args: [
this: CoValueClass<V>,
raw: RawCoValue
]) {}
._raw: class X {
prop:
RawAccount<AccountMeta> | RawControlledAccount<AccountMeta>
._instanceID: class X {
prop:
string
Type Helpers
._type: class X {
prop:
"Account"
.castAs<Cl>(cl): InstanceType<Cl>
class Thing<
Cl extends CoValueClass<CoValue> & CoValueFromRaw<CoValue>
]> {}
function fn(...args: [
cl: Cl
]) {}
Other
Account._schema: class X {
prop:
any
⚠️ undocumented
Account.getMe<A>(): A
class Thing<
A extends Account
]> {}
function fn(...args: [
this: CoValueClass<A> & Account
]) {}
⚠️ undocumented
Account.createAs<A>(as, options): Promise<A>
class Thing<
A extends Account
]> {}
function fn(...args: [
this: CoValueClass<A> & Account,
as: Account,
options: { creationProps: { name: string } }
]) {}
⚠️ undocumented
Account.fromNode<A>(node): A
class Thing<
A extends Account
]> {}
function fn(...args: [
this: CoValueClass<A>,
node: LocalNode
]) {}
⚠️ undocumented
.constructor: class X {
prop:
NO TYPE
⚠️ undocumented
._schema: class X {
prop:
{ profile: Schema, root: Schema }
⚠️ undocumented
.profile: class X {
prop:
Profile | null
⚠️ undocumented
.root: class X {
prop:
CoMap | null
⚠️ undocumented
._refs: class X {
prop:
{ profile: Ref<Profile> | undefined, root: Ref<CoMap> | undefined }
⚠️ undocumented
.isMe: class X {
prop:
boolean
Whether this account is the currently active account.
.isLocalNodeOwner: class X {
prop:
boolean
Whether this account is the owner of the local node.
.sessionID: class X {
prop:
TODO type templateLiteral | TODO type templateLiteral | undefined
⚠️ undocumented
.myRole(): "admin" | undefined
⚠️ undocumented
.getRoleOf(member): "admin" | undefined
function fn(...args: [
member: "me" | "everyone" | ID<Account>
]) {}
⚠️ undocumented
.getParentGroups(): Group[]
⚠️ undocumented
.members: class X {
prop:
{ id: "everyone" | ID<Account>, role: Role, ref: Ref<Account> | undefined, account: Account | null | undefined }[]
⚠️ undocumented
.canRead(value): boolean
function fn(...args: [
value: CoValue
]) {}
⚠️ undocumented
.canWrite(value): boolean
function fn(...args: [
value: CoValue
]) {}
⚠️ undocumented
.canAdmin(value): boolean
function fn(...args: [
value: CoValue
]) {}
⚠️ undocumented
.acceptInvite<V>(valueID, inviteSecret, coValueClass): Promise<V | null>
class Thing<
V extends CoValue
]> {}
function fn(...args: [
valueID: ID<V>,
inviteSecret: TODO type templateLiteral,
coValueClass: CoValueClass<V>
]) {}
⚠️ undocumented
.applyMigration(creationProps): Promise<void>
function fn(...args: [
creationProps: AccountCreationProps
]) {}
⚠️ undocumented
.migrate(creationProps): void
function fn(...args: [
creationProps: AccountCreationProps
]) {}
⚠️ undocumented
function
isControlledAccount(account):
{}
account is Account & { isLocalNodeOwner: true, sessionID: TODO type templateLiteral | TODO type templateLiteral, _raw: RawControlledAccount }
function fn(...args: [
account: Account
]) {}
Content
.id: class X {
prop:
ID<Group>
Subscription & Loading
Group.load<G, R>(id, options): Promise<Resolved<G, R> | null>
class Thing<
G extends Group,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<G>,
id: ID<G>,
options: { resolve: RefsToResolveStrict<G, R>, loadAs: Account }
]) {}
Group.subscribe<G, R>(id, listener): () => void
class Thing<
G extends Group,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<G>,
id: ID<G>,
listener: (value: Resolved<G, R>, unsubscribe: () => void) => void
]) {}
Group.subscribe<G, R>(id, options, listener): () => void
class Thing<
G extends Group,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: CoValueClass<G>,
id: ID<G>,
options: SubscribeListenerOptions<G, R>,
listener: (value: Resolved<G, R>, unsubscribe: () => void) => void
]) {}
.ensureLoaded<G, R>(options): Promise<Resolved<G, R>>
class Thing<
G extends Group,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: G,
options: { resolve: RefsToResolveStrict<G, R> }
]) {}
.subscribe<G, R>(listener): () => void
class Thing<
G extends Group,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: G,
listener: (value: Resolved<G, R>, unsubscribe: () => void) => void
]) {}
.subscribe<G, R>(options, listener): () => void
class Thing<
G extends Group,
R extends { profile: RefsToResolve<Profile, 10, [0]>, root: RefsToResolve<CoMap, 10, [0]> } | boolean
]> {}
function fn(...args: [
this: G,
options: { resolve: RefsToResolveStrict<G, R> },
listener: (value: Resolved<G, R>, unsubscribe: () => void) => void
]) {}
.waitForSync(options): Promise<unknown[]>
function fn(...args: [
options: { timeout: number }
]) {}
Wait for the Group to be uploaded to the other peers.
Collaboration
._owner: class X {
prop:
Group | Account
Stringifying & Inspection
.toJSON(): any[] | string | object
.[inspect](): any[] | string | object
Internals
Group.fromRaw<V>(raw): V
class Thing<
V extends CoValue
]> {}
function fn(...args: [
this: CoValueClass<V>,
raw: RawCoValue
]) {}
._raw: class X {
prop:
RawGroup
._instanceID: class X {
prop:
string
Type Helpers
._type: class X {
prop:
"Group"
.castAs<Cl>(cl): InstanceType<Cl>
class Thing<
Cl extends CoValueClass<CoValue> & CoValueFromRaw<CoValue>
]> {}
function fn(...args: [
cl: Cl
]) {}
Other
Group._schema: class X {
prop:
any
⚠️ undocumented
Group.create<G>(options): G
class Thing<
G extends Group
]> {}
function fn(...args: [
this: CoValueClass<G>,
options: { owner: Account } | Account
]) {}
⚠️ undocumented
.constructor: class X {
prop:
NO TYPE
⚠️ undocumented
._schema: class X {
prop:
{ profile: Schema, root: Schema }
⚠️ undocumented
.profile: class X {
prop:
Profile | null
⚠️ undocumented
.root: class X {
prop:
CoMap | null
⚠️ undocumented
._refs: class X {
prop:
{ profile: Ref<Profile> | undefined, root: Ref<CoMap> | undefined }
⚠️ undocumented
.myRole(): Role | undefined
⚠️ undocumented
.addMember(member, role): void
function fn(...args: [
member: "everyone",
role: "writer" | "reader"
]) {}
⚠️ undocumented
.addMember(member, role): void
function fn(...args: [
member: Account,
role: AccountRole
]) {}
⚠️ undocumented
.removeMember(member): Promise<void>
function fn(...args: [
member: "everyone" | Account
]) {}
⚠️ undocumented
.members: class X {
prop:
{ id: ID<Account>, role: AccountRole, ref: Ref<Account>, account: Account }[]
⚠️ undocumented
.getRoleOf(member): Role | undefined
function fn(...args: [
member: "me" | "everyone" | ID<Account>
]) {}
⚠️ undocumented
.getParentGroups(): Group[]
⚠️ undocumented
.extend(parent, roleMapping): Group
function fn(...args: [
parent: Group,
roleMapping: "inherit" | "admin" | "writer" | "reader"
]) {}
⚠️ undocumented
.revokeExtend(parent): Promise<Group>
function fn(...args: [
parent: Group
]) {}
⚠️ undocumented
Declaration
Profile.Record<Value>(value): RecordLikeCoMap
function fn(...args: [
value: IfCo<Value, Value>
]) {}
Declare a Record-like CoMap schema, by extending CoMap.Record(...) and passing the value schema using co. Keys are always string.
Example
import { co, CoMap } from "jazz-tools";

class ColorToFruitMap extends CoMap.Record(
co.ref(Fruit)
) {}

// assume we have map: ColorToFruitMap
// and strawberry: Fruit
map["red"] = strawberry;
Content
.id: class X {
prop:
ID<Profile>
The ID of this CoMap
._refs: class X {
prop:
{[Key in string]: IfCo<this[Key], RefIfCoValue<this[Key]>>}
If property prop is a co.ref(...), you can use coMaps._refs.prop to access
the
Ref instead of the potentially loaded/null value.

This allows you to always get the ID or load the value manually.
Example
person._refs.pet.id; // => ID<Animal>
person._refs.pet.value;
// => Animal | null
const pet = await person._refs.pet.load();
.toJSON(_key, seenAbove): any[]
function fn(...args: [
_key: string,
seenAbove: ID<CoValue>[]
]) {}
Return a JSON representation of the CoMap
Creation
Profile.create<M>(init, options): M
class Thing<
M extends CoMap
]> {}
function fn(...args: [
this: CoValueClass<M>,
init: Simplify<CoMapInit<M>>,
options: { owner: Group } | Group
]) {}
Creates a new profile with the given initial values and owner.

The owner (a Group) determines access rights to the Profile.
Subscription & Loading
Profile.load<M, R>(id, options): Promise<Resolved<M, R> | null>
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
options: { resolve: RefsToResolveStrict<M, R>, loadAs: AnonymousJazzAgent | Account }
]) {}
Load a CoMap with a given ID, as a given account.

depth specifies which (if any) fields that reference other CoValues to load as well before resolving.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.
Example
const person = await Person.load(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} }
);
Profile.subscribe<M, R>(id, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoMap with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

depth specifies which (if any) fields that reference other CoValues to load as well before calling listener for the first time.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
Example
const unsub = Person.subscribe(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} },
(person) => console.log(person)
);
Profile.subscribe<M, R>(id, options, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
options: SubscribeListenerOptions<M, R>,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoMap with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

depth specifies which (if any) fields that reference other CoValues to load as well before calling listener for the first time.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
Example
const unsub = Person.subscribe(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} },
(person) => console.log(person)
);
.ensureLoaded<M, R>(options): Promise<Resolved<M, R>>
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
options: { resolve: RefsToResolveStrict<M, R> }
]) {}
Given an already loaded CoMap, ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.load(), but you don't need to pass the ID or the account to load as again.
.subscribe<M, R>(listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Given an already loaded CoMap, subscribe to updates to the CoMap and ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
.subscribe<M, R>(options, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
options: { resolve: RefsToResolveStrict<M, R> },
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Given an already loaded CoMap, subscribe to updates to the CoMap and ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
.waitForSync(options): Promise<unknown[]>
function fn(...args: [
options: { timeout: number }
]) {}
Wait for the CoMap to be uploaded to the other peers.
Collaboration
._owner: class X {
prop:
Group
._edits: class X {
prop:
{[Key in string]: IfCo<this[Key], LastAndAllCoMapEdits<this[Key]>>}
Stringifying & Inspection
.[inspect](): any[]
Internals
Profile.fromRaw<V>(raw): V
class Thing<
V extends CoValue
]> {}
function fn(...args: [
this: CoValueClass<V>,
raw: RawCoValue
]) {}
._raw: class X {
prop:
RawCoMap
._instanceID: class X {
prop:
string
Type Helpers
._type: class X {
prop:
"CoMap"
.castAs<Cl>(cl): InstanceType<Cl>
class Thing<
Cl extends CoValueClass<CoValue> & CoValueFromRaw<CoValue>
]> {}
function fn(...args: [
cl: Cl
]) {}
Other
Profile.findUnique<M>(unique, ownerID, as): ID<M>
class Thing<
M extends CoMap
]> {}
function fn(...args: [
this: CoValueClass<M>,
unique: JsonValue,
ownerID: ID<Group> | ID<Account>,
as: Group | AnonymousJazzAgent | Account
]) {}
⚠️ undocumented
.name: class X {
prop:
co<string>
⚠️ undocumented
.inbox: class X {
prop:
co<CoID<InboxRoot> | undefined>
⚠️ undocumented
.inboxInvite: class X {
prop:
co<TODO type templateLiteral | undefined>
⚠️ undocumented
.applyDiff<N>(newValues): Profile
class Thing<
N extends Partial<CoMapInit<Profile>>
]> {}
function fn(...args: [
newValues: N
]) {}
⚠️ undocumented

Schema definition

Encoders reflection

co reflection

type co

type co<T> = T & CoMarker | T

Abstract interfaces

Content
.id: class X {
prop:
ID<CoValue>
Collaboration
._owner: class X {
prop:
Group | Account
Stringifying & Inspection
.toJSON(key, seenAbove): any[] | string | object
function fn(...args: [
key: string,
seenAbove: ID<CoValue>[]
]) {}
.[inspect](): any
Internals
._raw: class X {
prop:
RawCoValue
Type Helpers
._type: class X {
prop:
string
Content
.id: class X {
prop:
ID<CoPlainText>
Subscription & Loading
CoPlainText.load<T>(id, options): Promise<T | null>
class Thing<
T extends CoPlainText
]> {}
function fn(...args: [
this: CoValueClass<T>,
id: ID<T>,
options: { loadAs: AnonymousJazzAgent | Account }
]) {}
Load a CoPlainText with a given ID, as a given account.
CoPlainText.subscribe<T>(id, listener): () => void
class Thing<
T extends CoPlainText
]> {}
function fn(...args: [
this: CoValueClass<T>,
id: ID<T>,
listener: (value: T, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoPlainText with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

Check out the
load methods on CoMap/CoList/CoStream/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
CoPlainText.subscribe<T>(id, options, listener): () => void
class Thing<
T extends CoPlainText
]> {}
function fn(...args: [
this: CoValueClass<T>,
id: ID<T>,
options: Omit<SubscribeListenerOptions<T, true>, "resolve">,
listener: (value: T, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoPlainText with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

Check out the
load methods on CoMap/CoList/CoStream/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
.subscribe<T>(listener): () => void
class Thing<
T extends CoPlainText
]> {}
function fn(...args: [
this: T,
listener: (value: T, unsubscribe: () => void) => void
]) {}
Given an already loaded CoPlainText, subscribe to updates to the CoPlainText and ensure that the specified fields are loaded to the specified depth.

Works like
CoPlainText.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
Collaboration
._owner: class X {
prop:
Group | Account
Stringifying & Inspection
.toJSON(): string
.[inspect](): string
Internals
._raw: class X {
prop:
RawCoPlainText
Type Helpers
._type: class X {
prop:
"CoPlainText"
Other
CoPlainText.create<T>(text, options): T
class Thing<
T extends CoPlainText
]> {}
function fn(...args: [
this: CoValueClass<T>,
text: string,
options: { owner: Group | Account }
]) {}
⚠️ undocumented
CoPlainText.fromRaw<V>(raw): V & CoPlainText
class Thing<
V extends CoPlainText
]> {}
function fn(...args: [
this: CoValueClass<V> & CoPlainText,
raw: RawCoPlainText
]) {}
⚠️ undocumented
CoPlainText.fromCharCode(codes): string
function fn(...args: [
codes: number[]
]) {}
⚠️ undocumented
CoPlainText.fromCodePoint(codePoints): string
function fn(...args: [
codePoints: number[]
]) {}
Return the String value whose elements are, in order, the elements in the List elements.
If length is 0, the empty string is returned.
CoPlainText.raw(template, substitutions): string
function fn(...args: [
template: { raw: ArrayLike<string> | TODO type typeOperator },
substitutions: any[]
]) {}
String.raw is usually used as a tag function of a Tagged Template String. When called as
such, the first argument will be a well formed template call site object and the rest
parameter will contain the substitution values. It can also be called directly, for example,
to interleave strings and values from your own tag function, and in this case the only thing
it needs from the first argument is the raw property.
.constructor: class X {
prop:
NO TYPE
⚠️ undocumented
.length: class X {
prop:
number
Returns the length of a String object.
.toString(): string
Returns a string representation of a string.
.valueOf(): string
Returns the primitive value of the specified object.
.insertAfter(idx, text): void
function fn(...args: [
idx: number,
text: string
]) {}
⚠️ undocumented
.deleteRange(range): void
function fn(...args: [
range: { from: number, to: number }
]) {}
⚠️ undocumented
.posBefore(idx): OpID | undefined
function fn(...args: [
idx: number
]) {}
⚠️ undocumented
.posAfter(idx): OpID | undefined
function fn(...args: [
idx: number
]) {}
⚠️ undocumented
.idxBefore(pos): undefined | number
function fn(...args: [
pos: OpID
]) {}
⚠️ undocumented
.idxAfter(pos): undefined | number
function fn(...args: [
pos: OpID
]) {}
⚠️ undocumented
.charAt(pos): string
function fn(...args: [
pos: number
]) {}
Returns the character at the specified index.
.charCodeAt(index): number
function fn(...args: [
index: number
]) {}
Returns the Unicode value of the character at the specified location.
.concat(strings): string
function fn(...args: [
strings: string[]
]) {}
Returns a string that contains the concatenation of two or more strings.
.indexOf(searchString, position): number
function fn(...args: [
searchString: string,
position: number
]) {}
Returns the position of the first occurrence of a substring.
.lastIndexOf(searchString, position): number
function fn(...args: [
searchString: string,
position: number
]) {}
Returns the last occurrence of a substring in the string.
.localeCompare(that): number
function fn(...args: [
that: string
]) {}
Determines whether two strings are equivalent in the current locale.
.localeCompare(that, locales, options): number
function fn(...args: [
that: string,
locales: string[] | string,
options: CollatorOptions
]) {}
Determines whether two strings are equivalent in the current or specified locale.
.localeCompare(that, locales, options): number
function fn(...args: [
that: string,
locales: LocalesArgument,
options: CollatorOptions
]) {}
Determines whether two strings are equivalent in the current or specified locale.
.match(regexp): RegExpMatchArray | null
function fn(...args: [
regexp: RegExp | string
]) {}
Matches a string with a regular expression, and returns an array containing the results of that search.
.match(matcher): RegExpMatchArray | null
function fn(...args: [
matcher: { [match]: NO TYPE }
]) {}
Matches a string or an object that supports being matched against, and returns an array
containing the results of that search, or null if no matches are found.
.replace(searchValue, replaceValue): string
function fn(...args: [
searchValue: RegExp | string,
replaceValue: string
]) {}
Replaces text in a string, using a regular expression or search string.
.replace(searchValue, replacer): string
function fn(...args: [
searchValue: RegExp | string,
replacer: (substring: string, args: any[]) => string
]) {}
Replaces text in a string, using a regular expression or search string.
.replace(searchValue, replaceValue): string
function fn(...args: [
searchValue: { [replace]: NO TYPE },
replaceValue: string
]) {}
Passes a string and @linkcode replaceValue to the [Symbol.replace] method on @linkcode searchValue. This method is expected to implement its own replacement algorithm.
.replace(searchValue, replacer): string
function fn(...args: [
searchValue: { [replace]: NO TYPE },
replacer: (substring: string, args: any[]) => string
]) {}
Replaces text in a string, using an object that supports replacement within a string.
.search(regexp): number
function fn(...args: [
regexp: RegExp | string
]) {}
Finds the first substring match in a regular expression search.
.search(searcher): number
function fn(...args: [
searcher: { [search]: NO TYPE }
]) {}
Finds the first substring match in a regular expression search.
.slice(start, end): string
function fn(...args: [
start: number,
end: number
]) {}
Returns a section of a string.
.split(separator, limit): string[]
function fn(...args: [
separator: RegExp | string,
limit: number
]) {}
Split a string into substrings using the specified separator and return them as an array.
.split(splitter, limit): string[]
function fn(...args: [
splitter: { [split]: NO TYPE },
limit: number
]) {}
Split a string into substrings using the specified separator and return them as an array.
.substring(start, end): string
function fn(...args: [
start: number,
end: number
]) {}
Returns the substring at the specified location within a String object.
.toLowerCase(): string
Converts all the alphabetic characters in a string to lowercase.
.toLocaleLowerCase(locales): string
function fn(...args: [
locales: string[] | string
]) {}
Converts all alphabetic characters to lowercase, taking into account the host environment's current locale.
.toLocaleLowerCase(locales): string
function fn(...args: [
locales: LocalesArgument
]) {}
Converts all alphabetic characters to lowercase, taking into account the host environment's current locale.
.toUpperCase(): string
Converts all the alphabetic characters in a string to uppercase.
.toLocaleUpperCase(locales): string
function fn(...args: [
locales: string[] | string
]) {}
Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale.
.toLocaleUpperCase(locales): string
function fn(...args: [
locales: LocalesArgument
]) {}
Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale.
.trim(): string
Removes the leading and trailing white space and line terminator characters from a string.
.substr(from, length): string
function fn(...args: [
from: number,
length: number
]) {}
Gets a substring beginning at the specified location and having the specified length.
.codePointAt(pos): undefined | number
function fn(...args: [
pos: number
]) {}
Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
value of the UTF-16 encoded code point starting at the string element at position pos in
the String resulting from converting this object to a String.
If there is no element at that position, the result is undefined.
If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
.includes(searchString, position): boolean
function fn(...args: [
searchString: string,
position: number
]) {}
Returns true if searchString appears as a substring of the result of converting this
object to a String, at one or more positions that are
greater than or equal to position; otherwise, returns false.
.endsWith(searchString, endPosition): boolean
function fn(...args: [
searchString: string,
endPosition: number
]) {}
Returns true if the sequence of elements of searchString converted to a String is the
same as the corresponding elements of this object (converted to a String) starting at
endPosition – length(this). Otherwise returns false.
.normalize(form): string
function fn(...args: [
form: "NFKD" | "NFKC" | "NFD" | "NFC"
]) {}
Returns the String value result of normalizing the string into the normalization form
named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
.normalize(form): string
function fn(...args: [
form: string
]) {}
Returns the String value result of normalizing the string into the normalization form
named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
.repeat(count): string
function fn(...args: [
count: number
]) {}
Returns a String value that is made from count copies appended together. If count is 0,
the empty string is returned.
.startsWith(searchString, position): boolean
function fn(...args: [
searchString: string,
position: number
]) {}
Returns true if the sequence of elements of searchString converted to a String is the
same as the corresponding elements of this object (converted to a String) starting at
position. Otherwise returns false.
.anchor(name): string
function fn(...args: [
name: string
]) {}
Returns an <a> HTML anchor element and sets the name attribute to the text value
.big(): string
Returns a <big> HTML element
.bold(): string
Returns a <b> HTML element
.fixed(): string
Returns a <tt> HTML element
.fontcolor(color): string
function fn(...args: [
color: string
]) {}
Returns a <font> HTML element and sets the color attribute value
.fontsize(size): string
function fn(...args: [
size: number
]) {}
Returns a <font> HTML element and sets the size attribute value
.fontsize(size): string
function fn(...args: [
size: string
]) {}
Returns a <font> HTML element and sets the size attribute value
.italics(): string
Returns an <i> HTML element
.small(): string
Returns a <small> HTML element
.strike(): string
Returns a <strike> HTML element
.sub(): string
Returns a <sub> HTML element
.sup(): string
Returns a <sup> HTML element
.padStart(maxLength, fillString): string
function fn(...args: [
maxLength: number,
fillString: string
]) {}
Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
The padding is applied from the start (left) of the current string.
.padEnd(maxLength, fillString): string
function fn(...args: [
maxLength: number,
fillString: string
]) {}
Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
The padding is applied from the end (right) of the current string.
.trimEnd(): string
Removes the trailing white space and line terminator characters from a string.
.trimStart(): string
Removes the leading white space and line terminator characters from a string.
.trimLeft(): string
Removes the leading white space and line terminator characters from a string.
.trimRight(): string
Removes the trailing white space and line terminator characters from a string.
.matchAll(regexp): RegExpStringIterator<RegExpExecArray>
function fn(...args: [
regexp: RegExp
]) {}
Matches a string with a regular expression, and returns an iterable of matches
containing the results of that search.
.replaceAll(searchValue, replaceValue): string
function fn(...args: [
searchValue: RegExp | string,
replaceValue: string
]) {}
Replace all instances of a substring in a string, using a regular expression or search string.
.replaceAll(searchValue, replacer): string
function fn(...args: [
searchValue: RegExp | string,
replacer: (substring: string, args: any[]) => string
]) {}
Replace all instances of a substring in a string, using a regular expression or search string.
.at(index): undefined | string
function fn(...args: [
index: number
]) {}
Returns a new String consisting of the single UTF-16 code unit located at the specified index.
.isWellFormed(): boolean
Returns true if all leading surrogates and trailing surrogates appear paired and in order.
.toWellFormed(): string
Returns a string where all lone or out-of-order surrogates have been replaced by the Unicode replacement character (U+FFFD).
.[iterator](): StringIterator<string>
Iterator
class Thing<
Value extends CoValue
]> {}

Media

Declaration
ImageDefinition.Record<Value>(value): RecordLikeCoMap
function fn(...args: [
value: IfCo<Value, Value>
]) {}
Declare a Record-like CoMap schema, by extending CoMap.Record(...) and passing the value schema using co. Keys are always string.
Example
import { co, CoMap } from "jazz-tools";

class ColorToFruitMap extends CoMap.Record(
co.ref(Fruit)
) {}

// assume we have map: ColorToFruitMap
// and strawberry: Fruit
map["red"] = strawberry;
Content
.id: class X {
prop:
ID<ImageDefinition>
The ID of this CoMap
._refs: class X {
prop:
{[Key in string]: IfCo<this[Key], RefIfCoValue<this[Key]>>}
If property prop is a co.ref(...), you can use coMaps._refs.prop to access
the
Ref instead of the potentially loaded/null value.

This allows you to always get the ID or load the value manually.
Example
person._refs.pet.id; // => ID<Animal>
person._refs.pet.value;
// => Animal | null
const pet = await person._refs.pet.load();
.toJSON(_key, seenAbove): any[]
function fn(...args: [
_key: string,
seenAbove: ID<CoValue>[]
]) {}
Return a JSON representation of the CoMap
Creation
ImageDefinition.create<M>(init, options): M
class Thing<
M extends CoMap
]> {}
function fn(...args: [
this: CoValueClass<M>,
init: Simplify<CoMapInit<M>>,
options: { owner: Group | Account, unique: JsonValue } | Group | Account
]) {}
Create a new CoMap with the given initial values and owner.

The owner (a Group or Account) determines access rights to the CoMap.

The CoMap will immediately be persisted and synced to connected peers.
Example
const person = Person.create({
name: "Alice",
age: 42,
pet: cat,
}, { owner: friendGroup });
Subscription & Loading
ImageDefinition.load<M, R>(id, options): Promise<Resolved<M, R> | null>
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
options: { resolve: RefsToResolveStrict<M, R>, loadAs: AnonymousJazzAgent | Account }
]) {}
Load a CoMap with a given ID, as a given account.

depth specifies which (if any) fields that reference other CoValues to load as well before resolving.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.
Example
const person = await Person.load(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} }
);
ImageDefinition.subscribe<M, R>(id, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoMap with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

depth specifies which (if any) fields that reference other CoValues to load as well before calling listener for the first time.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
Example
const unsub = Person.subscribe(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} },
(person) => console.log(person)
);
ImageDefinition.subscribe<M, R>(id, options, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
options: SubscribeListenerOptions<M, R>,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoMap with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

depth specifies which (if any) fields that reference other CoValues to load as well before calling listener for the first time.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
Example
const unsub = Person.subscribe(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} },
(person) => console.log(person)
);
.ensureLoaded<M, R>(options): Promise<Resolved<M, R>>
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
options: { resolve: RefsToResolveStrict<M, R> }
]) {}
Given an already loaded CoMap, ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.load(), but you don't need to pass the ID or the account to load as again.
.subscribe<M, R>(listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Given an already loaded CoMap, subscribe to updates to the CoMap and ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
.subscribe<M, R>(options, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
options: { resolve: RefsToResolveStrict<M, R> },
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Given an already loaded CoMap, subscribe to updates to the CoMap and ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
.waitForSync(options): Promise<unknown[]>
function fn(...args: [
options: { timeout: number }
]) {}
Wait for the CoMap to be uploaded to the other peers.
Collaboration
._edits: class X {
prop:
{[Key in string]: IfCo<this[Key], LastAndAllCoMapEdits<this[Key]>>}
._owner: class X {
prop:
Group | Account
Stringifying & Inspection
.[inspect](): any[]
Internals
ImageDefinition.fromRaw<V>(raw): V
class Thing<
V extends CoValue
]> {}
function fn(...args: [
this: CoValueClass<V>,
raw: RawCoValue
]) {}
._raw: class X {
prop:
RawCoMap
._instanceID: class X {
prop:
string
Type Helpers
._type: class X {
prop:
"CoMap"
.castAs<Cl>(cl): InstanceType<Cl>
class Thing<
Cl extends CoValueClass<CoValue> & CoValueFromRaw<CoValue>
]> {}
function fn(...args: [
cl: Cl
]) {}
Other
ImageDefinition.findUnique<M>(unique, ownerID, as): ID<M>
class Thing<
M extends CoMap
]> {}
function fn(...args: [
this: CoValueClass<M>,
unique: JsonValue,
ownerID: ID<Group> | ID<Account>,
as: Group | AnonymousJazzAgent | Account
]) {}
⚠️ undocumented
.originalSize: class X {
prop:
co<[number, number]>
⚠️ undocumented
.highestResAvailable(options): { res: TODO type templateLiteral, stream: FileStream } | undefined
function fn(...args: [
options: { maxWidth: number, targetWidth: number }
]) {}
⚠️ undocumented
.$items$: class X {
prop:
co<FileStream | null>
⚠️ undocumented
.applyDiff<N>(newValues): ImageDefinition
class Thing<
N extends Partial<CoMapInit<ImageDefinition>>
]> {}
function fn(...args: [
newValues: N
]) {}
⚠️ undocumented
.placeholderDataURL: class X {
prop:
co<string>
⚠️ undocumented

Auth Providers

DemoAuth provides a JazzAuth object for demo authentication.

Demo authentication is useful for quickly testing your app, as it allows you to create new accounts and log in as existing ones.

import { DemoAuth } from "jazz-tools";

const auth = new DemoAuth(jazzContext.authenticate, new AuthSecretStorage());
PassphraseAuth provides a JazzAuth object for passphrase authentication.

import { PassphraseAuth } from "jazz-tools";

const auth = new PassphraseAuth(crypto, jazzContext.authenticate, new AuthSecretStorage(), wordlist);

Invite Links

Other

type AgentID

type AgentIDundefined = TODO type templateLiteral

⚠️ undocumented

type CoValueUniqueness

type CoValueUniquenessundefined = { uniqueness: JsonValue, createdAt: null | TODO type templateLiteral }

⚠️ undocumented

type InviteSecret

type InviteSecretundefined = TODO type templateLiteral

⚠️ undocumented

type SessionID

type SessionIDundefined = TODO type templateLiteral

⚠️ undocumented

type SyncMessage

type SyncMessageundefined = DoneMessage | NewContentMessage | KnownStateMessage | LoadMessage

⚠️ undocumented
class Thing<
I extends CoValue,
O extends CoValue | undefined
]> {}

type AccountClass

type AccountClass<Acc extends Account> = CoValueClass<Acc> & { fromNode: Account["fromNode"] }

⚠️ undocumented

type AccountCreationProps

type AccountCreationPropsundefined = { name: string, onboarding: boolean }

⚠️ undocumented

CoStream

type CoFeedEntry

type CoFeedEntry<Item> = SingleCoFeedEntry<Item> & { all: IterableIterator<SingleCoFeedEntry<Item>> }

⚠️ undocumented

FileStream

type CoMapInit

type CoMapInit<Map extends object> = {[Key in CoKeys<Map>]: ForceRequiredRef<Map[Key]>} & {[Key in CoKeys<Map>]: ForceRequiredRef<Map[Key]>}

⚠️ undocumented

type TextPos

type TextPosundefined = OpID

⚠️ undocumented
Main class for handling rich text content with marks.
Combines plain text with a list of marks for formatting and annotations.
Provides methods for text manipulation, mark insertion, and tree conversion.
Declaration
CoRichText.Record<Value>(value): RecordLikeCoMap
function fn(...args: [
value: IfCo<Value, Value>
]) {}
Declare a Record-like CoMap schema, by extending CoMap.Record(...) and passing the value schema using co. Keys are always string.
Example
import { co, CoMap } from "jazz-tools";

class ColorToFruitMap extends CoMap.Record(
co.ref(Fruit)
) {}

// assume we have map: ColorToFruitMap
// and strawberry: Fruit
map["red"] = strawberry;
Content
.id: class X {
prop:
ID<CoRichText>
The ID of this CoMap
._refs: class X {
prop:
{[Key in string]: IfCo<this[Key], RefIfCoValue<this[Key]>>}
If property prop is a co.ref(...), you can use coMaps._refs.prop to access
the
Ref instead of the potentially loaded/null value.

This allows you to always get the ID or load the value manually.
Example
person._refs.pet.id; // => ID<Animal>
person._refs.pet.value;
// => Animal | null
const pet = await person._refs.pet.load();
.toJSON(_key, seenAbove): any[]
function fn(...args: [
_key: string,
seenAbove: ID<CoValue>[]
]) {}
Return a JSON representation of the CoMap
Creation
CoRichText.create<M>(init, options): M
class Thing<
M extends CoMap
]> {}
function fn(...args: [
this: CoValueClass<M>,
init: Simplify<CoMapInit<M>>,
options: { owner: Group | Account, unique: JsonValue } | Group | Account
]) {}
Create a new CoMap with the given initial values and owner.

The owner (a Group or Account) determines access rights to the CoMap.

The CoMap will immediately be persisted and synced to connected peers.
Example
const person = Person.create({
name: "Alice",
age: 42,
pet: cat,
}, { owner: friendGroup });
Subscription & Loading
CoRichText.load<M, R>(id, options): Promise<Resolved<M, R> | null>
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
options: { resolve: RefsToResolveStrict<M, R>, loadAs: AnonymousJazzAgent | Account }
]) {}
Load a CoMap with a given ID, as a given account.

depth specifies which (if any) fields that reference other CoValues to load as well before resolving.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.
Example
const person = await Person.load(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} }
);
CoRichText.subscribe<M, R>(id, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoMap with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

depth specifies which (if any) fields that reference other CoValues to load as well before calling listener for the first time.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
Example
const unsub = Person.subscribe(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} },
(person) => console.log(person)
);
CoRichText.subscribe<M, R>(id, options, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: CoValueClass<M>,
id: ID<M>,
options: SubscribeListenerOptions<M, R>,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Load and subscribe to a CoMap with a given ID, as a given account.

Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.

depth specifies which (if any) fields that reference other CoValues to load as well before calling listener for the first time.
The
DeeplyLoaded return type guarantees that corresponding referenced CoValues are loaded to the specified depth.

You can pass
[] or {} for shallowly loading only this CoMap, or { fieldA: depthA, fieldB: depthB } for recursively loading referenced CoValues.

Check out the
load methods on CoMap/CoList/CoFeed/Group/Account to see which depth structures are valid to nest.

Returns an unsubscribe function that you should call when you no longer need updates.

Also see the
useCoState hook to reactively subscribe to a CoValue in a React component.
Example
const unsub = Person.subscribe(
"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
{ pet: {} },
(person) => console.log(person)
);
.ensureLoaded<M, R>(options): Promise<Resolved<M, R>>
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
options: { resolve: RefsToResolveStrict<M, R> }
]) {}
Given an already loaded CoMap, ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.load(), but you don't need to pass the ID or the account to load as again.
.subscribe<M, R>(listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Given an already loaded CoMap, subscribe to updates to the CoMap and ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
.subscribe<M, R>(options, listener): () => void
class Thing<
M extends CoMap,
R extends { undefined } | boolean
]> {}
function fn(...args: [
this: M,
options: { resolve: RefsToResolveStrict<M, R> },
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void
]) {}
Given an already loaded CoMap, subscribe to updates to the CoMap and ensure that the specified fields are loaded to the specified depth.

Works like
CoMap.subscribe(), but you don't need to pass the ID or the account to load as again.

Returns an unsubscribe function that you should call when you no longer need updates.
.waitForSync(options): Promise<unknown[]>
function fn(...args: [
options: { timeout: number }
]) {}
Wait for the CoMap to be uploaded to the other peers.
Collaboration
._edits: class X {
prop:
{[Key in string]: IfCo<this[Key], LastAndAllCoMapEdits<this[Key]>>}
._owner: class X {
prop:
Group | Account
Stringifying & Inspection
.[inspect](): any[]
Internals
CoRichText.fromRaw<V>(raw): V
class Thing<
V extends CoValue
]> {}
function fn(...args: [
this: CoValueClass<V>,
raw: RawCoValue
]) {}
._raw: class X {
prop:
RawCoMap
._instanceID: class X {
prop:
string
Type Helpers
._type: class X {
prop:
"CoMap"
.castAs<Cl>(cl): InstanceType<Cl>
class Thing<
Cl extends CoValueClass<CoValue> & CoValueFromRaw<CoValue>
]> {}
function fn(...args: [
cl: Cl
]) {}
Other
CoRichText.createFromPlainText(text, options): CoRichText
function fn(...args: [
text: string,
options: { owner: Group | Account }
]) {}
Create a CoRichText from plain text.
CoRichText.createFromPlainTextAndMark<MarkClass>(text, WrapIn, extraArgs, options): CoRichText
class Thing<
MarkClass extends (args: any[]) => Mark
]> {}
function fn(...args: [
text: string,
WrapIn: MarkClass,
extraArgs: Omit<CoMapInit<InstanceType<MarkClass>>, "endBefore" | "endAfter" | "startBefore" | "startAfter">,
options: { owner: Group | Account }
]) {}
Create a CoRichText from plain text and a mark.
CoRichText.findUnique<M>(unique, ownerID, as): ID<M>
class Thing<
M extends CoMap
]> {}
function fn(...args: [
this: CoValueClass<M>,
unique: JsonValue,
ownerID: ID<Group> | ID<Account>,
as: Group | AnonymousJazzAgent | Account
]) {}
⚠️ undocumented
.text: class X {
prop:
co<CoPlainText | null>
⚠️ undocumented
.marks: class X {
prop:
co<CoList<co<Mark | null>> | null>
⚠️ undocumented
.insertAfter(idx, text): void
function fn(...args: [
idx: number,
text: string
]) {}
Insert text at a specific index.
.deleteRange(range): void
function fn(...args: [
range: { from: number, to: number }
]) {}
Delete a range of text.
.posBefore(idx): OpID | undefined
function fn(...args: [
idx: number
]) {}
Get the position of a specific index.
.posAfter(idx): OpID | undefined
function fn(...args: [
idx: number
]) {}
Get the position of a specific index.
.idxBefore(pos): undefined | number
function fn(...args: [
pos: OpID
]) {}
Get the index of a specific position.
.idxAfter(pos): undefined | number
function fn(...args: [
pos: OpID
]) {}
Get the index of a specific position.
.insertMark<MarkClass>(start, end, RangeClass, extraArgs, options): void
class Thing<
MarkClass extends (args: any[]) => Mark
]> {}
function fn(...args: [
start: number,
end: number,
RangeClass: MarkClass,
extraArgs: Omit<CoMapInit<InstanceType<MarkClass>>, "endBefore" | "endAfter" | "startBefore" | "startAfter">,
options: { markOwner: Group | Account }
]) {}
Insert a mark at a specific range.
.removeMark<MarkClass>(start, end, RangeClass, options): void
class Thing<
MarkClass extends (args: any[]) => Mark
]> {}
function fn(...args: [
start: number,
end: number,
RangeClass: MarkClass,
options: { tag: string }
]) {}
Remove a mark at a specific range.
.resolveMarks(): ResolvedMark<Mark>[]
Resolve the positions of all marks.
.resolveAndDiffuseMarks(): ResolvedAndDiffusedMark<Mark>[]
Resolve and diffuse the positions of all marks.
.resolveAndDiffuseAndFocusMarks(): ResolvedAndFocusedMark<Mark>[]
Resolve, diffuse, and focus the positions of all marks.
.toTree(tagPrecedence): TreeNode
function fn(...args: [
tagPrecedence: string[]
]) {}
Convert a CoRichText to a tree structure useful for client libraries.
.length: class X {
prop:
number
⚠️ undocumented
.toString(): string
Convert a CoRichText to plain text.
.applyDiff<N>(newValues): CoRichText
class Thing<
N extends Partial<CoMapInit<CoRichText>>
]> {}
function fn(...args: [
newValues: N
]) {}
⚠️ undocumented

Marks reflection

type TreeLeaf

type TreeLeafundefined = { type: "leaf", start: number, end: number }

Represents a leaf node in the rich text tree structure.
Contains plain text without any marks.

type TreeNode

type TreeNodeundefined = { type: "node", tag: string, start: number, end: number, children: TreeLeaf | TreeNode[], range: ResolvedAndFocusedMark }

Represents a node in the rich text tree structure.
Can contain other nodes or leaves, and includes formatting information.

type ResolvedMark

type ResolvedMark<R extends Mark> = { startAfter: number, startBefore: number, endAfter: number, endBefore: number, sourceMark: R }

A mark with resolved numeric positions in text.
Contains both position information and reference to the source mark.

type DeeplyLoaded

type DeeplyLoaded<V, Depth, DepthLimit extends number, CurrentDepth extends number[]> = TODO type conditional

⚠️ undocumented

type Resolved

type Resolved<T, R extends RefsToResolve<T> | undefined> = DeeplyLoaded<T, R, 10, []>

⚠️ undocumented

type RefsToResolve

type RefsToResolve<V, DepthLimit extends number, CurrentDepth extends number[]> = (TODO type conditional) | boolean

⚠️ undocumented

type RefsToResolveStrict

type RefsToResolveStrict<T, V> = TODO type conditional

⚠️ undocumented
function
createCoValueObservable<V, R>():
{}
{ getCurrentValue: () => Resolved<V, R> | null | undefined, subscribe: (cls: CoValueClass<V>, id: ID<CoValue>, options: { loadAs: AnonymousJazzAgent | Account, resolve: RefsToResolveStrict<V, R>, onUnavailable: () => void, onUnauthorized: () => void, syncResolution: boolean }, listener: () => void) => () => void }
function
loadCoValue<V, R>(cls, id, options):
{}
Promise<Resolved<V, R> | null>
function fn(...args: [
cls: CoValueClass<V>,
id: ID<CoValue>,
options: { loadAs: AnonymousJazzAgent | Account, resolve: RefsToResolveStrict<V, R> }
]) {}
function
subscribeToCoValue<V, R>(cls, id, options, listener):
{}
() => void
function fn(...args: [
cls: CoValueClass<V>,
id: ID<CoValue>,
options: { loadAs: AnonymousJazzAgent | Account, resolve: RefsToResolveStrict<V, R>, onUnavailable: () => void, onUnauthorized: () => void, syncResolution: boolean },
listener: SubscribeListener<V, R>
]) {}
class Thing<
Acc extends Account,
P extends JazzContextManagerBaseProps<Acc>
]> {}

type JazzContextManagerAuthProps

type JazzContextManagerAuthPropsundefined = { credentials: AuthCredentials, newAccountProps: { secret: AgentSecret, creationProps: { name: string } } }

⚠️ undocumented
function
createAnonymousJazzContext({ peersToLoadFrom, crypto }):
{}
Promise<JazzContextWithAgent>
function fn(...args: [
{ peersToLoadFrom: Peer[], crypto: CryptoProvider }
]) {}
function
createJazzContextFromExistingCredentials<Acc>({ credentials, peersToLoadFrom, crypto, sessionProvider, AccountSchema?, onLogOut? }):
{}
Promise<JazzContextWithAccount<Acc>>
function fn(...args: [
{ credentials: Credentials, peersToLoadFrom: Peer[], crypto: CryptoProvider, sessionProvider: SessionProvider, AccountSchema: AccountClass<Acc>, onLogOut: () => void }
]) {}
function
createJazzContextForNewAccount<Acc>({ creationProps, peersToLoadFrom, crypto, initialAgentSecret?, AccountSchema?, onLogOut? }):
{}
Promise<JazzContextWithAccount<Acc>>
function fn(...args: [
{ creationProps: { name: string }, peersToLoadFrom: Peer[], crypto: CryptoProvider, initialAgentSecret: TODO type templateLiteral, AccountSchema: AccountClass<Acc>, onLogOut: () => Promise<void> }
]) {}
function
createJazzContext<Acc>(options):
{}
Promise<{ authSecretStorage: AuthSecretStorage, node: LocalNode, account: Acc, done: () => void, logOut: () => Promise<void> }>
function fn(...args: [
options: { peersToLoadFrom: Peer[], crypto: CryptoProvider, sessionProvider: SessionProvider, authSecretStorage: AuthSecretStorage, credentials: AuthCredentials, newAccountProps: NewAccountProps, defaultProfileName: string, AccountSchema: AccountClass<Acc> }
]) {}
function
randomSessionProvider(accountID, crypto):
{}
Promise<{ sessionID: TODO type templateLiteral | TODO type templateLiteral, sessionDone: () => void }>
function fn(...args: [
accountID: ID<Account>,
crypto: CryptoProvider
]) {}

type AuthResult

type AuthResultundefined = { type: "new", creationProps: { name: string, anonymous: boolean, other: Record<string, unknown> }, saveCredentials: (credentials: Credentials) => Promise<void>, onSuccess: () => void, onError: (error: Error | string) => void, logOut: () => Promise<void>, initialSecret: AgentSecret } | { type: "existing", credentials: Credentials, onSuccess: () => void, onError: (error: Error | string) => void, logOut: () => Promise<void>, username: string, saveCredentials: (credentials: Credentials) => Promise<void> }

⚠️ undocumented

type Credentials

type Credentialsundefined = { accountID: ID<Account>, secret: AgentSecret }

⚠️ undocumented

type JazzContextWithAccount

type JazzContextWithAccount<Acc extends Account> = { node: LocalNode, account: Acc, done: () => void, logOut: () => Promise<void> }

⚠️ undocumented

type AuthCredentials

type AuthCredentialsundefined = { accountID: ID<Account>, accountSecret: AgentSecret, secretSeed: Uint8Array, provider: "passphrase" | "passkey" | "demo" | "clerk" | "anonymous" | string }

⚠️ undocumented

type AuthenticateAccountFunction

type AuthenticateAccountFunctionundefined = (credentials: AuthCredentials) => Promise<void>

⚠️ undocumented

type RegisterAccountFunction

type RegisterAccountFunctionundefined = (accountSecret: AgentSecret, creationProps: { name: string }) => Promise<ID<Account>>

⚠️ undocumented

type JazzGuestContext

type JazzGuestContextundefined = { guest: AnonymousJazzAgent, node: LocalNode, authenticate: AuthenticateAccountFunction, register: RegisterAccountFunction, logOut: () => void, done: () => void, isAuthenticated: boolean }

⚠️ undocumented

type JazzContextType

type JazzContextType<Acc extends Account> = JazzGuestContext | JazzAuthContext<Acc>

⚠️ undocumented

type NewAccountProps

type NewAccountPropsundefined = { secret: AgentSecret, creationProps: { name: string } }

⚠️ undocumented

type SyncConfig

type SyncConfigundefined = { when: "never", peer: TODO type templateLiteral | TODO type templateLiteral } | { peer: TODO type templateLiteral | TODO type templateLiteral, when: "signedUp" | "always" }

⚠️ undocumented

type RegisteredAccount

type RegisteredAccountundefined = TODO type conditional

⚠️ undocumented