repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
jazz
github_2023
garden-co
typescript
TodoAccount.migrate
migrate() { if (!this._refs.root) { this.root = TodoAccountRoot.create( { projects: ListOfProjects.create([], { owner: this }), }, { owner: this }, ); } }
/** The account migration is run on account creation and on every log-in. * You can use it to set up the account root and any other initial CoValues you need. */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/examples/todo/src/1_schema.ts#L42-L51
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
SyncPromise.then
public then<U>(onSuccess: HandlerOnSuccess<T, U>, onFail?: HandlerOnFail<U>) { return new SyncPromise<U>((resolve, reject) => { return this.attachHandler({ onSuccess: (result) => { try { return resolve(onSuccess(result)); } catch (e) { return reject(e); ...
// biome-ignore lint/suspicious/noThenProperty: TODO(JAZZ-561): Review
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson-storage-indexeddb/src/syncPromises.ts#L106-L129
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
SyncPromise.toString
public toString() { return "[object SyncPromise]"; }
// methods
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson-storage-indexeddb/src/syncPromises.ts#L137-L139
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
SyncPromise.resolve
public static resolve<U = any>(value?: U | Thenable<U>) { return new SyncPromise<U>((resolve) => { return resolve(value); }); }
// static
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson-storage-indexeddb/src/syncPromises.ts#L179-L183
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
WebSocketPeerWithReconnection.onNetworkChange
onNetworkChange(callback: (connected: boolean) => void): () => void { callback; return () => {}; }
// Needs to be extended to handle platform specific APIs
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson-transport-ws/src/WebSocketPeerWithReconnection.ts#L28-L31
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawUnknownCoValue.group
get group(): RawGroup { return this.core.getGroup(); }
/** @category 6. Meta */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValue.ts#L56-L58
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoValueCore.knownStateUncached
knownStateUncached(): CoValueKnownState { const sessions: CoValueKnownState["sessions"] = {}; for (const [sessionID, sessionLog] of this.sessionLogs.entries()) { sessions[sessionID] = sessionLog.transactions.length; } return { id: this.id, header: true, sessions, }; }
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValueCore.ts#L162-L174
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoValueCore.getDependedOnCoValuesUncached
getDependedOnCoValuesUncached(): RawCoID[] { return this.header.ruleset.type === "group" ? getGroupDependentKeyList(expectGroup(this.getCurrentContent()).keys()) : this.header.ruleset.type === "ownedByGroup" ? [ this.header.ruleset.group, ...new Set( [...thi...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValueCore.ts#L916-L934
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoValueLoadingState.waitForPeer
waitForPeer(peerId: PeerID) { const entry = this.peers.get(peerId); if (!entry) { return Promise.resolve(); } return entry.promise; }
// Wait for a specific peer to have a known state
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValueState.ts#L65-L73
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.constructor
constructor( account: ControlledAccountOrAgent, currentSessionID: SessionID, crypto: CryptoProvider, ) { this.account = account; this.currentSessionID = currentSessionID; this.crypto = crypto; }
/** @category 3. Low-level */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L60-L68
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.withNewlyCreatedAccount
static async withNewlyCreatedAccount<Meta extends AccountMeta = AccountMeta>({ creationProps, peersToLoadFrom, migration, crypto, initialAgentSecret = crypto.newRandomAgentSecret(), }: { creationProps: { name: string }; peersToLoadFrom?: Peer[]; migration?: RawAccountMigration<Meta>; ...
/** @category 2. Node Creation */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L71-L160
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
syncAllCoValuesAfterCreateAccount
function syncAllCoValuesAfterCreateAccount() { for (const coValueEntry of nodeWithAccount.coValuesStore.getValues()) { if (coValueEntry.state.type === "available") { void nodeWithAccount.syncManager.syncCoValue( coValueEntry.state.coValue, ); } } }
// we shouldn't need this, but it fixes account data not syncing for new accounts
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L140-L148
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.withLoadedAccount
static async withLoadedAccount<Meta extends AccountMeta = AccountMeta>({ accountID, accountSecret, sessionID, peersToLoadFrom, crypto, migration, }: { accountID: RawAccountID; accountSecret: AgentSecret; sessionID: SessionID | undefined; peersToLoadFrom: Peer[]; crypto: Cry...
/** @category 2. Node Creation */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L163-L237
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.createCoValue
createCoValue(header: CoValueHeader): CoValueCore { if (this.crashed) { throw new Error("Trying to create CoValue after node has crashed", { cause: this.crashed, }); } const coValue = new CoValueCore(header, this); this.coValuesStore.setAsAvailable(coValue.id, coValue); void th...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L240-L253
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.loadCoValueCore
async loadCoValueCore( id: RawCoID, skipLoadingFromPeer?: PeerID, ): Promise<CoValueCore | "unavailable"> { if (this.crashed) { throw new Error("Trying to load CoValue after node has crashed", { cause: this.crashed, }); } const entry = this.coValuesStore.get(id); if (entr...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L256-L280
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.load
async load<T extends RawCoValue>(id: CoID<T>): Promise<T | "unavailable"> { const core = await this.loadCoValueCore(id); if (core === "unavailable") { return "unavailable"; } return core.getCurrentContent() as T; }
/** * Loads a CoValue's content, syncing from peers as necessary and resolving the returned * promise once a first version has been loaded. See `coValue.subscribe()` and `node.useTelepathicData()` * for listening to subsequent updates to the CoValue. * * @category 3. Low-level */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L289-L297
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.subscribe
subscribe<T extends RawCoValue>( id: CoID<T>, callback: (update: T | "unavailable") => void, ): () => void { let stopped = false; let unsubscribe!: () => void; this.load(id) .then((coValue) => { if (stopped) { return; } if (coValue === "unavailable") { ...
/** @category 3. Low-level */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L310-L338
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.acceptInvite
async acceptInvite<T extends RawCoValue>( groupOrOwnedValueID: CoID<T>, inviteSecret: InviteSecret, ): Promise<void> { const groupOrOwnedValue = await this.load(groupOrOwnedValueID); if (groupOrOwnedValue === "unavailable") { throw new Error( "Trying to accept invite: Group/owned value ...
/** @deprecated Use Account.acceptInvite instead */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L341-L425
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.expectCoValueLoaded
expectCoValueLoaded(id: RawCoID, expectation?: string): CoValueCore { const entry = this.coValuesStore.get(id); if (entry.state.type !== "available") { throw new Error( `${expectation ? expectation + ": " : ""}CoValue ${id} not yet loaded. Current state: ${entry.state.type}`, ); } r...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L428-L437
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.expectProfileLoaded
expectProfileLoaded(id: RawAccountID, expectation?: string): RawProfile { const account = this.expectCoValueLoaded(id, expectation); const profileID = expectGroup(account.getCurrentContent()).get("profile"); if (!profileID) { throw new Error( `${expectation ? expectation + ": " : ""}Account ${...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L440-L452
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.createAccount
createAccount( agentSecret = this.crypto.newRandomAgentSecret(), ): RawControlledAccount { const accountAgentID = this.crypto.getAgentID(agentSecret); const account = expectGroup( this.createCoValue( accountHeaderForInitialAgentSecret(agentSecret, this.crypto), ) .testWithDiffe...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L455-L495
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.resolveAccountAgent
resolveAccountAgent( id: RawAccountID | AgentID, expectation?: string, ): Result<AgentID, ResolveAccountAgentError> { if (isAgentID(id)) { return ok(id); } let coValue: CoValueCore; try { coValue = this.expectCoValueLoaded(id, expectation); } catch (e) { return err({ ...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L498-L534
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.createGroup
createGroup( uniqueness: CoValueUniqueness = this.crypto.createdNowUnique(), ): RawGroup { const groupCoValue = this.createCoValue({ type: "comap", ruleset: { type: "group", initialAdmin: this.account.id }, meta: null, ...uniqueness, }); const group = expectGroup(groupCoValue....
/** * @deprecated use Account.createGroup() instead */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L583-L618
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
LocalNode.testWithDifferentAccount
testWithDifferentAccount( account: ControlledAccountOrAgent, currentSessionID: SessionID, ): LocalNode { const newNode = new LocalNode(account, currentSessionID, this.crypto); const coValuesToCopy = Array.from(this.coValuesStore.getEntries()); while (coValuesToCopy.length > 0) { const [coV...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/localNode.ts#L621-L673
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawControlledAccount.createGroup
createGroup( uniqueness: CoValueUniqueness = this.core.crypto.createdNowUnique(), ) { return this.core.node.createGroup(uniqueness); }
/** * Creates a new group (with the current account as the group's first admin). * @category 1. High-level */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/account.ts#L106-L110
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.constructor
constructor(core: CoValueCore) { this.id = core.id as CoID<this>; this.core = core; this.afterStart = []; this.beforeEnd = []; this.insertions = {}; this.deletionsByInsertion = {}; this.insertions = {}; this.deletionsByInsertion = {}; this.afterStart = []; this.beforeEnd = []; ...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L86-L196
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.headerMeta
get headerMeta(): Meta { return this.core.header.meta as Meta; }
/** @category 6. Meta */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L199-L201
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.group
get group(): RawGroup { return this.core.getGroup(); }
/** @category 6. Meta */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L204-L206
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.atTime
atTime(_time: number): this { throw new Error("Not yet implemented"); }
/** * Not yet implemented * * @category 4. Time travel */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L213-L215
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.get
get(idx: number): Item | undefined { const entry = this.entries()[idx]; if (!entry) { return undefined; } return entry.value; }
/** * Get the item currently at `idx`. * * @category 1. Reading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L222-L228
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.asArray
asArray(): Item[] { return this.entries().map((entry) => entry.value); }
/** * Returns the current items in the CoList as an array. * * @category 1. Reading **/
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L235-L237
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.entries
entries(): { value: Item; madeAt: number; opID: OpID; }[] { if (this._cachedEntries) { return this._cachedEntries; } const arr = this.entriesUncached(); this._cachedEntries = arr; return arr; }
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L240-L251
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.entriesUncached
entriesUncached(): { value: Item; madeAt: number; opID: OpID; }[] { const arr: { value: Item; madeAt: number; opID: OpID; }[] = []; for (const opID of this.afterStart) { this.fillArrayFromOpID(opID, arr); } for (const opID of this.beforeEnd) { this.fillArr...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L254-L271
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.fillArrayFromOpID
private fillArrayFromOpID( opID: OpID, arr: { value: Item; madeAt: number; opID: OpID; }[], ) { const entry = this.insertions[opID.sessionID]?.[opID.txIndex]?.[opID.changeIdx]; if (!entry) { throw new Error("Missing op " + opID); } for (const predecessor of e...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L274-L307
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.toJSON
toJSON(): Item[] { return this.asArray(); }
/** * Returns the current items in the CoList as an array. (alias of `asArray`) * * @category 1. Reading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L314-L316
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.editAt
editAt(idx: number): | { by: RawAccountID | AgentID; tx: TransactionID; at: Date; value: Item; } | undefined { const entry = this.entries()[idx]; if (!entry) { return undefined; } const madeAt = new Date(entry.madeAt); const by = accountOrAgentIDfr...
/** @category 5. Edit history */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L319-L343
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.deletionEdits
deletionEdits(): { by: RawAccountID | AgentID; tx: TransactionID; at: Date; // TODO: add indices that are now before and after the deleted item }[] { const edits: { by: RawAccountID | AgentID; tx: TransactionID; at: Date; }[] = []; for (const sessionID in this.deletionsB...
/** @category 5. Edit history */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L346-L380
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoListView.subscribe
subscribe(listener: (coList: this) => void): () => void { return this.core.subscribe((content) => { listener(content as this); }); }
/** @category 3. Subscription */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L383-L387
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoList.append
append( item: Item, after?: number, privacy: "private" | "trusting" = "private", ) { this.appendItems([item], after, privacy); }
/** Appends `item` after the item currently at index `after`. * * If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext. * * If `privacy` is `"trusting"`,...
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L405-L411
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoList.prepend
prepend( item: Item, before?: number, privacy: "private" | "trusting" = "private", ) { const entries = this.entries(); before = before === undefined ? 0 : before; let opIDAfter; if (entries.length > 0) { const entryAfter = entries[before]; if (entryAfter) { opIDAfter = ...
/** * Prepends `item` before the item currently at index `before`. * * If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext. * * If `privacy` is `"tru...
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L465-L501
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoList.delete
delete(at: number, privacy: "private" | "trusting" = "private") { const entries = this.entries(); const entry = entries[at]; if (!entry) { throw new Error("Invalid index " + at); } this.core.makeTransaction( [ { op: "del", insertion: entry.opID, }, ...
/** Deletes the item at index `at`. * * If `privacy` is `"private"` **(default)**, the fact of this deletion is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext. * * If `privacy` is `"trusting"`, the fa...
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L511-L528
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoList.rebuildFromCore
rebuildFromCore() { const listAfter = new RawCoList(this.core) as this; this.afterStart = listAfter.afterStart; this.beforeEnd = listAfter.beforeEnd; this.insertions = listAfter.insertions; this.deletionsByInsertion = listAfter.deletionsByInsertion; this._cachedEntries = undefined; }
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coList.ts#L559-L567
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.constructor
constructor( core: CoValueCore, options?: { ignorePrivateTransactions: boolean; }, ) { this.id = core.id as CoID<this>; this.core = core; this.latestTxMadeAt = 0; this.ignorePrivateTransactions = options?.ignorePrivateTransactions ?? false; this.ops = {}; this.latest = ...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L64-L80
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.headerMeta
get headerMeta(): Meta { return this.core.header.meta as Meta; }
/** @category 6. Meta */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L146-L148
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.group
get group(): RawGroup { return this.core.getGroup(); }
/** @category 6. Meta */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L151-L153
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.atTime
atTime(time: number): this { if (time >= this.latestTxMadeAt) { return this; } else { const clone = Object.create(this) as RawCoMapView<Shape, Meta>; clone.atTimeFilter = time; clone.latest = {}; return clone as this; } }
/** @category 4. Time travel */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L156-L167
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.timeFilteredOps
timeFilteredOps<K extends keyof Shape & string>( key: K, ): MapOp<K, Shape[K]>[] | undefined { if (key === "constructor") { return undefined; } const atTimeFilter = this.atTimeFilter; if (atTimeFilter) { return this.ops[key]?.filter((op) => op.madeAt <= atTimeFilter); } else { ...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L170-L184
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.keys
keys<K extends keyof Shape & string = keyof Shape & string>(): K[] { return (Object.keys(this.ops) as K[]).filter((key) => { const entry = this.getRaw(key); if (entry === undefined) { return false; } if (entry.change.op === "del") { return false; } return true;...
/** * Get all keys currently in the map. * * @category 1. Reading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L190-L204
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.get
get<K extends keyof Shape & string>(key: K): Shape[K] | undefined { const entry = this.getRaw(key); if (entry === undefined) { return undefined; } if (entry.change.op === "del") { return undefined; } else { return entry.change.value as Shape[K]; } }
/** * Returns the current value for the given key. * * @category 1. Reading **/
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L238-L250
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.asObject
asObject(): { [K in keyof Shape & string]: Shape[K]; } { const object: Partial<{ [K in keyof Shape & string]: Shape[K]; }> = {}; for (const key of Object.keys(this.ops) as (keyof Shape & string)[]) { const value = this.get(key); if (value !== undefined) { object[key] = value...
/** @category 1. Reading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L253-L270
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.toJSON
toJSON(): { [K in keyof Shape & string]: Shape[K]; } { return this.asObject(); }
/** @category 1. Reading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L273-L277
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.nthEditAt
nthEditAt<K extends keyof Shape & string>(key: K, n: number) { const ops = this.ops[key]; const atTimeFilter = this.atTimeFilter; const entry = ops?.[n]; if (!entry) { return undefined; } if (atTimeFilter && entry.madeAt > atTimeFilter) { return undefined; } return operat...
/** @category 5. Edit history */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L280-L295
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.lastEditAt
lastEditAt<K extends keyof Shape & string>( key: K, ): | { by: RawAccountID | AgentID; tx: TransactionID; at: Date; value?: Shape[K]; } | undefined { const entry = this.getRaw(key); if (!entry) { return undefined; } return operationToEditEntry(...
/** @category 5. Edit history */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L298-L315
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.editsAt
*editsAt<K extends keyof Shape & string>(key: K) { const entries = this.ops[key]; if (!entries) { return; } const atTimeFilter = this.atTimeFilter; for (const entry of entries) { // Entries are sorted by madeAt if (atTimeFilter && entry.madeAt > atTimeFilter) { return; ...
/** @category 5. Edit history */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L318-L335
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMapView.subscribe
subscribe(listener: (coMap: this) => void): () => void { return this.core.subscribe((content) => { listener(content as this); }); }
/** @category 3. Subscription */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L338-L342
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMap.set
set<K extends keyof Shape & string>( key: K, value: Shape[K], privacy: "private" | "trusting" = "private", ): void { if (this.isTimeTravelEntity()) { throw new Error("Cannot set value on a time travel entity"); } this.core.makeTransaction( [ { op: "set", ...
/** Set a new value for the given key. * * If `privacy` is `"private"` **(default)**, both `key` and `value` are encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext. * * If `privacy` is `"trusting"`, both `...
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L363-L384
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoMap.delete
delete( key: keyof Shape & string, privacy: "private" | "trusting" = "private", ) { if (this.isTimeTravelEntity()) { throw new Error("Cannot delete value on a time travel entity"); } this.core.makeTransaction( [ { op: "del", key, }, ], p...
/** Delete the given key (setting it to undefined). * * If `privacy` is `"private"` **(default)**, `key` is encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext. * * If `privacy` is `"trusting"`, `key` is st...
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coMap.ts#L414-L433
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoStreamView.atTime
atTime(_time: number): this { throw new Error("Not yet implemented"); }
/** Not yet implemented */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coStream.ts#L78-L80
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawCoStreamView.processNewTransactions
protected processNewTransactions() { const changeEntries = new Set<CoStreamItem<Item>[]>(); for (const { txID, madeAt, changes } of this.core.getValidTransactions({ ignorePrivateTransactions: false, knownTransactions: this.knownTransactions, })) { for (const changeUntyped of changes) { ...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coStream.ts#L83-L114
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawBinaryCoStream.push
push( item: BinaryStreamItem, privacy: "private" | "trusting" = "private", updateView: boolean = true, ): void { this.core.makeTransaction([item], privacy); if (updateView) { this.processNewTransactions(); } }
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/coStream.ts#L357-L366
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.roleOf
roleOf(accountID: RawAccountID): Role | undefined { return this.roleOfInternal(accountID)?.role; }
/** * Returns the current role of a given account. * * @category 1. Role reading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L80-L82
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.roleOfInternal
roleOfInternal( accountID: RawAccountID | AgentID | typeof EVERYONE, ): { role: Role; via: CoID<RawGroup> | undefined } | undefined { const roleHere = this.get(accountID); if (roleHere === "revoked") { return undefined; } let roleInfo: | { role: Exclude<Role, "revoked">; ...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L85-L118
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.myRole
myRole(): Role | undefined { return this.roleOfInternal(this.core.node.account.id)?.role; }
/** * Returns the role of the current account in the group. * * @category 1. Role reading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L202-L204
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.addMember
addMember( account: RawAccount | ControlledAccountOrAgent | Everyone, role: Role, ) { this.addMemberInternal(account, role); }
/** * Directly grants a new member a role in the group. The current account must be an * admin to be able to do so. Throws otherwise. * * @category 2. Role changing */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L212-L217
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.addMemberInternal
addMemberInternal( account: RawAccount | ControlledAccountOrAgent | AgentID | Everyone, role: Role, ) { if (account === EVERYONE) { if (!(role === "reader" || role === "writer")) { throw new Error( "Can't make everyone something other than reader or writer", ); } ...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L220-L337
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.rotateReadKey
rotateReadKey(removedMemberKey?: RawAccountID | AgentID | "everyone") { const memberKeys = this.getMemberKeys().filter( (key) => key !== removedMemberKey, ); const currentlyPermittedReaders = memberKeys.filter((key) => { const role = this.get(key); return ( role === "admin" || ...
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L391-L534
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.isSelfExtension
isSelfExtension(parent: RawGroup) { if (parent.id === this.id) { return true; } const childGroups = this.getChildGroups(); for (const child of childGroups) { if (child.isSelfExtension(parent)) { return true; } } return false; }
/** Detect circular references in group inheritance */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L537-L551
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.removeMember
async removeMember( account: RawAccount | ControlledAccountOrAgent | Everyone, ) { // Ensure all child groups are loaded before removing a member await this.loadAllChildGroups(); this.removeMemberInternal(account); }
/** * Strips the specified member of all roles (preventing future writes in * the group and owned values) and rotates the read encryption key for that group * (preventing reads of new content in the group and owned values) * * @category 2. Role changing */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L618-L625
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.removeMemberInternal
removeMemberInternal( account: RawAccount | ControlledAccountOrAgent | AgentID | Everyone, ) { const memberKey = typeof account === "string" ? account : account.id; this.rotateReadKey(memberKey); this.set(memberKey, "revoked", "trusting"); }
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L628-L635
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.createInvite
createInvite(role: AccountRole): InviteSecret { const secretSeed = this.core.crypto.newRandomSecretSeed(); const inviteSecret = this.core.crypto.agentSecretFromSecretSeed(secretSeed); const inviteID = this.core.crypto.getAgentID(inviteSecret); this.addMemberInternal(inviteID, `${role}Invite` as Role);...
/** * Creates an invite for new members to indirectly join the group, * allowing them to grant themselves the specified role with the InviteSecret * (a string starting with "inviteSecret_") - use `LocalNode.acceptInvite()` for this purpose. * * @category 2. Role changing */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L644-L653
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.createMap
createMap<M extends RawCoMap>( init?: M["_shape"], meta?: M["headerMeta"], initPrivacy: "trusting" | "private" = "private", uniqueness: CoValueUniqueness = this.core.crypto.createdNowUnique(), ): M { const map = this.core.node .createCoValue({ type: "comap", ruleset: { ...
/** * Creates a new `CoMap` within this group, with the specified specialized * `CoMap` type `M` and optional static metadata. * * @category 3. Value creation */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L661-L684
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.createList
createList<L extends RawCoList>( init?: L["_item"][], meta?: L["headerMeta"], initPrivacy: "trusting" | "private" = "private", uniqueness: CoValueUniqueness = this.core.crypto.createdNowUnique(), ): L { const list = this.core.node .createCoValue({ type: "colist", ruleset: { ...
/** * Creates a new `CoList` within this group, with the specified specialized * `CoList` type `L` and optional static metadata. * * @category 3. Value creation */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L692-L715
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.createPlainText
createPlainText<T extends RawCoPlainText>( init?: string, meta?: T["headerMeta"], initPrivacy: "trusting" | "private" = "private", ): T { const text = this.core.node .createCoValue({ type: "coplaintext", ruleset: { type: "ownedByGroup", group: this.id, ...
/** * Creates a new `CoPlainText` within this group, with the specified specialized * `CoPlainText` type `T` and optional static metadata. * * @category 3. Value creation */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L723-L745
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.createStream
createStream<C extends RawCoStream>( meta?: C["headerMeta"], uniqueness: CoValueUniqueness = this.core.crypto.createdNowUnique(), ): C { return this.core.node .createCoValue({ type: "costream", ruleset: { type: "ownedByGroup", group: this.id, }, me...
/** @category 3. Value creation */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L748-L763
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
RawGroup.createBinaryStream
createBinaryStream<C extends RawBinaryCoStream>( meta: C["headerMeta"] = { type: "binary" }, uniqueness: CoValueUniqueness = this.core.crypto.createdNowUnique(), ): C { return this.core.node .createCoValue({ type: "costream", ruleset: { type: "ownedByGroup", group...
/** @category 3. Value creation */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/coValues/group.ts#L766-L781
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
PureJSCrypto.cloneBlake3State
cloneBlake3State(state: any): Blake3State { return state.clone(); }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/cojson/src/crypto/PureJSCrypto.ts#L41-L43
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
migrateExistingUsers
async function migrateExistingUsers(kvStore: KvStore) { if ((await getStorageVersion(kvStore)) < 2) { const existingUsers = await getExistingUsersList(kvStore); for (const username of existingUsers) { const legacyKey = `demo-auth-existing-users-${username}`; const storageData = await kvStore.get(...
/** * Migrates existing users keys to work with any storage. */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/auth/DemoAuth.ts#L146-L188
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
Account.isMe
get isMe() { return activeAccountContext.get().id === this.id; }
/** * Whether this account is the currently active account. */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/account.ts#L131-L133
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
Account.create
static async create<A extends Account>( this: CoValueClass<A> & typeof Account, options: { creationProps: { name: string }; initialAgentSecret?: AgentSecret; peersToLoadFrom?: Peer[]; crypto: CryptoProvider; }, ): Promise<A> { const { node } = await LocalNode.withNewlyCreatedAc...
/** @private */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/account.ts#L190-L211
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
Account.toJSON
toJSON(): object | any[] { return { id: this.id, _type: this._type, }; }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/account.ts#L250-L255
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
Account.migrate
migrate(creationProps?: AccountCreationProps) { creationProps; // To avoid unused parameter warning }
// Placeholder method for subclasses to override
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/account.ts#L286-L288
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
Account.ensureLoaded
ensureLoaded<A extends Account, Depth>( this: A, depth: Depth & DepthsIn<A>, ): Promise<DeeplyLoaded<A, Depth>> { return ensureCoValueLoaded(this, depth); }
/** @category Subscription & Loading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/account.ts#L344-L349
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
Account.subscribe
subscribe<A extends Account, Depth>( this: A, depth: Depth & DepthsIn<A>, listener: (value: DeeplyLoaded<A, Depth>) => void, ): () => void { return subscribeToExistingCoValue(this, depth, listener); }
/** @category Subscription & Loading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/account.ts#L352-L358
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
Account.waitForSync
waitForSync(options?: { timeout?: number; }) { return this._raw.core.waitForSync(options); }
/** * Wait for the `Account` to be uploaded to the other peers. * * @category Subscription & Loading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/account.ts#L365-L369
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
Account.waitForAllCoValuesSync
waitForAllCoValuesSync(options?: { timeout?: number; }) { return this._raw.core.node.syncManager.waitForAllCoValuesSync( options?.timeout, ); }
/** * Wait for all the available `CoValues` to be uploaded to the other peers. * * @category Subscription & Loading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/account.ts#L376-L382
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed.Of
static Of<Item>(item: IfCo<Item, Item>): typeof CoFeed<Item> { return class CoFeedOf extends CoFeed<Item> { [co.items] = item; }; }
/** * Declare a `CoFeed` by subclassing `CoFeed.Of(...)` and passing the item schema using a `co` primitive or a `co.ref`. * * @example * ```ts * class ColorFeed extends CoFeed.Of(co.string) {} * class AnimalFeed extends CoFeed.Of(co.ref(Animal)) {} * ``` * * @category Declaration */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L95-L99
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed._schema
get _schema(): { [ItemsSym]: SchemaFor<Item>; } { return (this.constructor as typeof CoFeed)._schema; }
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L119-L123
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed.byMe
get byMe(): CoFeedEntry<Item> | undefined { if (this._loadedAs._type === "Account") { return this[this._loadedAs.id]; } else { return undefined; } }
/** * The current account's view of this `CoFeed` * @category Content */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L153-L159
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed.inCurrentSession
get inCurrentSession(): CoFeedEntry<Item> | undefined { if (this._loadedAs._type === "Account") { return this.perSession[this._loadedAs.sessionID!]; } else { return 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. * * @category Content */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L176-L182
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed.create
static create<S extends CoFeed>( this: CoValueClass<S>, init: S extends CoFeed<infer Item> ? UnCo<Item>[] : never, options?: { owner: Account | Group } | Account | Group, ) { const { owner } = parseCoValueCreateOptions(options); const instance = new this({ init, owner }); const raw = owner._ra...
/** * Create a new `CoFeed` * @category Creation */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L208-L229
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed.push
push(...items: Item[]) { for (const item of items) { this.pushItem(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 * ```ts * // Adds items to current session's log * feed.push("i...
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L251-L255
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed.toJSON
toJSON(): { id: string; _type: "CoStream"; [key: string]: unknown; in: { [key: string]: unknown }; } { const itemDescriptor = this._schema[ItemsSym] as Schema; const mapper = itemDescriptor === "json" ? (v: unknown) => v : "encoded" in itemDescriptor ? itemDescr...
/** * Get a JSON representation of the `CoFeed` * @category */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L273-L303
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed.schema
static schema<V extends CoFeed>( // eslint-disable-next-line @typescript-eslint/no-explicit-any this: { new (...args: any): V } & typeof CoFeed, def: { [ItemsSym]: V["_schema"][ItemsSym] }, ) { this._schema ||= {}; Object.assign(this._schema, def); }
/** @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L316-L323
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed.ensureLoaded
ensureLoaded<S extends CoFeed, Depth>( this: S, depth: Depth & DepthsIn<S>, ): Promise<DeeplyLoaded<S, Depth>> { return ensureCoValueLoaded(this, depth); }
/** * Ensure a `CoFeed` is loaded to the specified depth * * @returns A new instance of the same CoFeed that's loaded to the specified depth, * or undefined if it cannot be loaded that deeply * @category Subscription & Loading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L391-L396
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed.subscribe
subscribe<S extends CoFeed, Depth>( this: S, depth: Depth & DepthsIn<S>, listener: (value: DeeplyLoaded<S, Depth>) => void, ): () => void { return subscribeToExistingCoValue(this, depth, listener); }
/** * 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. * @category Subscription & Loading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L404-L410
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoFeed.waitForSync
waitForSync(options?: { timeout?: number; }) { return this._raw.core.waitForSync(options); }
/** * Wait for the `CoFeed` to be uploaded to the other peers. * * @category Subscription & Loading */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L417-L421
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
entryFromRawEntry
function entryFromRawEntry<Item>( accessFrom: CoValue, rawEntry: { by: RawAccountID | AgentID; tx: CojsonInternalTypes.TransactionID; at: Date; value: JsonValue; }, loadedAs: Account | AnonymousJazzAgent, accountID: ID<Account> | undefined, itemField: Schema, ): Omit<CoFeedEntry<Item>, "all"...
/** * Converts a raw stream entry into a formatted CoFeed entry with proper typing and accessors. * @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L428-L488
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
CoStreamPerSessionProxyHandler
const CoStreamPerSessionProxyHandler = ( innerTarget: CoFeed, accessFrom: CoFeed, ): ProxyHandler<Record<string, never>> => ({ get(_target, key, receiver) { if (typeof key === "string" && key.includes("session")) { const sessionID = key as SessionID; const rawEntry = innerTarget._raw.lastItemIn(se...
/** * The proxy handler for the per-session view of a `CoFeed` * @internal */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L586-L649
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
FileStream.create
static create<S extends FileStream>( this: CoValueClass<S>, options?: { owner?: Account | Group } | Account | Group, ) { return new this(parseCoValueCreateOptions(options)); }
/** * Create a new empty `FileStream` instance. * * @param options - Configuration options for the new FileStream * @param options.owner - The Account or Group that will own this FileStream and control access rights * * @example * ```typescript * // Create owned by an account * const stream =...
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L734-L739
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
FileStream.createFromBlob
static async createFromBlob( blob: Blob | File, options?: | { owner?: Group | Account; onProgress?: (progress: number) => void; } | Account | Group, ): Promise<FileStream> { const stream = this.create(options); const onProgress = options && "onProgre...
/** * Create a `FileStream` from a `Blob` or `File` * * @example * ```ts * import { co, FileStream } from "jazz-tools"; * * const fileStream = await FileStream.createFromBlob(file, {owner: group}) * ``` * @category Content */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/packages/jazz-tools/src/coValues/coFeed.ts#L847-L895
617ea91a130d64560624421d5e02af198b2d2086