Groups as permission scopes
Every CoValue has an owner, which can be a Group or an Account.
You can use a Group to grant access to a CoValue to multiple users. These users can
have different roles, such as "writer", "reader" or "admin".
CoValues owned by an Account can only be accessed by that Account. Additional collaborators cannot be added, and the ownership cannot be transferred to another Account. This makes account ownership very rigid.
Creating a Group for every new CoValue is a best practice, even if the Group only has a single user in it (this is the default behavior when creating a CoValue with no explicit owner).
While creating CoValues with Accounts as owners is still technically possible for backwards compatibility, it will be removed in a future release.
Role Matrix
| Role | admin | manager | writer | writeOnly | reader |
|---|---|---|---|---|---|
| Summary | Full control | Delegated management | Standard writer | Blind submissions | Viewer |
| Can add admins* | ✅ | ❌ | ❌ | ❌ | ❌ |
| Can add/remove managers | ✅ | ❌ | ❌ | ❌ | ❌ |
| Can add/remove readers and writers | ✅ | ✅ | ❌ | ❌ | ❌ |
| Can write | ✅ | ✅ | ✅ | ✅* | ❌ |
| Can read | ✅ | ✅ | ✅ | ❌*** | ✅ |
* admin users cannot be removed by anyone else, they must leave the group themselves.
** writeOnly users can only create and edit their own updates/submissions.
*** writeOnly cannot read updates from other users.
Creating a Group
Here's how you can create a Group.
import {class GroupGroup } from "jazz-tools"; constconst group: Groupgroup =class GroupGroup.create();Group.create<Group>(this: CoValueClass<Group>, options?: { owner: Account; } | Account): Group
The Group itself is a CoValue, and whoever owns it is the initial admin.
You typically add members using public sharing or invites. But if you already know their ID, you can add them directly (see below).
Adding group members by ID
You can add group members by ID by using Account.load and Group.addMember.
import {class GroupGroup,import coco } from "jazz-tools"; constconst group: Groupgroup =class GroupGroup.create(); constGroup.create<Group>(this: CoValueClass<Group>, options?: { owner: Account; } | Account): Groupbob = awaitconst bob: MaybeLoaded<{ readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & Account>import coco.account<BaseAccountShape>(shape?: BaseAccountShape | undefined): co.Account<BaseAccountShape, true> export accountDefines a collaborative account schema for Jazz applications. Creates an account schema that represents a user account with profile and root data. Accounts are the primary way to identify and manage users in Jazz applications.account().load(AccountSchema<BaseAccountShape, true>.load<true>(id: string, options?: { loadAs?: Account | AnonymousJazzAgent; resolve?: RefsToResolve<co.Account<BaseAccountShape, true>, 10, []> | undefined; } | undefined): Promise<...>const bobsID: "co_z123"bobsID); if (bob.const bob: MaybeLoaded<{ readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & Account>$isLoaded: booleanWhether the CoValue is loaded. Can be used to distinguish between loaded and {@link NotLoaded } CoValues. For more information about the CoValue's loading state, use {@link $jazz.loadingState } .$isLoaded) {const group: Groupgroup.Group.addMember(member: Account, role: AccountRole): void (+3 overloads)addMember(bob, "writer"); }const bob: { readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & Account
Note:
- Both
Account.load(id)andco.account().load(id)do the same thing — they load an account from its ID.
import {type ID<T> = stringIDs are unique identifiers for `CoValue`s. Can be used with a type argument to refer to a specific `CoValue` type.ID,class AccountAccount,import coco } from "jazz-tools"; constconst bob: MaybeLoaded<Account>bob = awaitclass AccountAccount.Account.load<Account, true>(this: CoValueClass<...>, id: ID<Account>, options?: { resolve?: RefsToResolve<Account, 10, []> | undefined; loadAs?: Account | AnonymousJazzAgent; } | undefined): Promise<...>Load an `Account`load(const bobsID: "co_z123"bobsID); // Or: const bob = await co.account().load(bobsID); if (const bob: MaybeLoaded<Account>bob.$isLoaded: booleanWhether the CoValue is loaded. Can be used to distinguish between loaded and {@link NotLoaded } CoValues. For more information about the CoValue's loading state, use {@link $jazz.loadingState } .$isLoaded) {const group: Groupgroup.Group.addMember(member: Account, role: AccountRole): void (+3 overloads)addMember(const bob: Accountbob, "writer"); }
Changing a member's role
To change a member's role, use the addMember method.
const group: Groupgroup.Group.addMember(member: Account, role: AccountRole): void (+3 overloads)addMember(bob, "reader");const bob: Account | ({ readonly [x: string]: any; } & Account)
Bob just went from a writer to a reader.
Note: only admins and managers can change a member's role.
Removing a member
To remove a member, use the removeMember method.
const group: Groupgroup.Group.removeMember(member: Everyone | Account): void (+1 overload)removeMember(bob);const bob: Account | ({ readonly [x: string]: any; } & Account)
Rules:
- All roles can remove themselves
- Admins can remove all roles (except other admins)
- Managers can remove users with less privileged roles (writer, writeOnly, reader)
Getting the Group of an existing CoValue
You can get the group of an existing CoValue by using coValue.$jazz.owner.
constconst group: undefinedgroup =existingCoValue.const existingCoValue: Account | ({ readonly [x: string]: any; } & Account)Account.$jazz: AccountJazzApi<Account> | AccountJazzApi<{ readonly [x: string]: any; } & Account>Jazz methods for Accounts are inside this property. This allows Accounts to be used as plain objects while still having access to Jazz methods.$jazz.AccountJazzApi<A extends Account>.owner: undefinedAccounts have no owner. They can be accessed by everyone.owner; constnewValue =const newValue: { readonly color: string; } & CoMapMyCoMap.const MyCoMap: co.Map<{ color: z.z.ZodString; }, unknown, Account | Group, true>create( {CoMapSchema<{ color: ZodString; }, unknown, Account | Group, true>.create(init: { color: string; }, options?: { owner?: Group; unique?: CoValueUniqueness["uniqueness"]; } | Group): { ...; } & CoMap (+1 overload)color: stringcolor: "red"}, {owner?: Group | undefinedowner:const group: undefinedgroup } );
Checking the permissions
You can check the permissions of an account on a CoValue by using the canRead, canWrite, canManage and canAdmin methods.
constvalue = awaitconst value: { readonly color: string; } & CoMapMyCoMap.const MyCoMap: co.Map<{ color: z.z.ZodString; }, unknown, Account | Group, true>create({CoMapSchema<{ color: ZodString; }, unknown, Account | Group, true>.create(init: { color: string; }, options?: { owner?: Group; unique?: CoValueUniqueness["uniqueness"]; } | Group): { ...; } & CoMap (+1 overload)color: stringcolor: "red"}) constme = awaitconst me: { readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & Accountimport coco.account<BaseAccountShape>(shape?: BaseAccountShape | undefined): co.Account<BaseAccountShape, true> export accountDefines a collaborative account schema for Jazz applications. Creates an account schema that represents a user account with profile and root data. Accounts are the primary way to identify and manage users in Jazz applications.account().getMe(); if (AccountSchema<BaseAccountShape, true>.getMe(): { readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & Accountme.const me: { readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & AccountAccount.canAdmin(value: CoValue): booleancanAdmin(value)) {const value: { readonly color: string; } & CoMapvar console: ConsoleThe `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log("I can add users of any role"); } else if (me.const me: { readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & AccountAccount.canManage(value: CoValue): booleancanManage(value)) {const value: { readonly color: string; } & CoMapvar console: ConsoleThe `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log("I can share value with others"); } else if (me.const me: { readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & AccountAccount.canWrite(value: CoValue): booleancanWrite(value)) {const value: { readonly color: string; } & CoMapvar console: ConsoleThe `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log("I can edit value"); } else if (me.const me: { readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & AccountAccount.canRead(value: CoValue): booleancanRead(value)) {const value: { readonly color: string; } & CoMapvar console: ConsoleThe `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log("I can view value"); } else {var console: ConsoleThe `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log("I cannot access value"); }
To check the permissions of another account, you need to load it first:
constvalue = awaitconst value: { readonly color: string; } & CoMapMyCoMap.const MyCoMap: co.Map<{ color: z.z.ZodString; }, unknown, Account | Group, true>create({CoMapSchema<{ color: ZodString; }, unknown, Account | Group, true>.create(init: { color: string; }, options?: { owner?: Group; unique?: CoValueUniqueness["uniqueness"]; } | Group): { ...; } & CoMap (+1 overload)color: stringcolor: "red"}) constbob = awaitconst bob: MaybeLoaded<{ readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & Account>import coco.account<BaseAccountShape>(shape?: BaseAccountShape | undefined): co.Account<BaseAccountShape, true> export accountDefines a collaborative account schema for Jazz applications. Creates an account schema that represents a user account with profile and root data. Accounts are the primary way to identify and manage users in Jazz applications.account().load(AccountSchema<BaseAccountShape, true>.load<true>(id: string, options?: { loadAs?: Account | AnonymousJazzAgent; resolve?: RefsToResolve<co.Account<BaseAccountShape, true>, 10, []> | undefined; } | undefined): Promise<...>const accountID: stringaccountID); if (bob.const bob: MaybeLoaded<{ readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & Account>$isLoaded: booleanWhether the CoValue is loaded. Can be used to distinguish between loaded and {@link NotLoaded } CoValues. For more information about the CoValue's loading state, use {@link $jazz.loadingState } .$isLoaded) { if (bob.const bob: { readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & AccountAccount.canAdmin(value: CoValue): booleancanAdmin(value)) {const value: { readonly color: string; } & CoMapvar console: ConsoleThe `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log("Bob can share value with others"); } else if (bob.const bob: { readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & AccountAccount.canWrite(value: CoValue): booleancanWrite(value)) {const value: { readonly color: string; } & CoMapvar console: ConsoleThe `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log("Bob can edit value"); } else if (bob.const bob: { readonly profile: MaybeLoaded<{ readonly name: string; readonly inbox?: string | undefined; readonly inboxInvite?: string | undefined; } & CoMap>; readonly root: MaybeLoaded<...>; } & AccountAccount.canRead(value: CoValue): booleancanRead(value)) {const value: { readonly color: string; } & CoMapvar console: ConsoleThe `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log("Bob can view value"); } else {var console: ConsoleThe `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log("Bob cannot access value"); } }