Public sharing and invites
Public sharing
You can share CoValues publicly by setting the owner to a Group, and granting access to "everyone".
constconst group: Groupgroup =class GroupGroup.create();Group.create<Group>(this: CoValueClass<Group>, options?: { owner: Account; } | Account): Groupconst group: Groupgroup.Group.addMember(member: Everyone, role: "writer" | "reader" | "writeOnly"): void (+2 overloads)addMember("everyone", "writer");
You can also use makePublic(role) alias to grant access to everyone with a specific role (defaults to reader).
constconst group: Groupgroup =class GroupGroup.create();Group.create<Group>(this: CoValueClass<Group>, options?: { owner: Account; } | Account): Groupconst group: Groupgroup.Group.addMember(member: Everyone, role: "writer" | "reader" | "writeOnly"): void (+2 overloads)addMember("everyone", "writer");const group: Groupgroup.Group.makePublic(role?: "reader" | "writer"): GroupMake the group public, so that everyone can read it. Alias for `addMember("everyone", role)`.makePublic("writer"); // group.makePublic(); // Defaults to "reader" access
This is done in the chat example where anyone can join the chat, and send messages.
You can also add members by Account ID.
Invites
You can grant users access to a CoValue by sending them an invite link.
This is used in the todo example.
import {createInviteLink } from "jazz-tools/react";function createInviteLink<C extends CoValue>(value: C, role: "reader" | "writer" | "admin" | "writeOnly", { baseURL, valueHint, }?: { baseURL?: string; valueHint?: string; }): stringcreateInviteLink(createInviteLink<{ name: string; } & CoMap>(value: { name: string; } & CoMap, role: "reader" | "writer" | "admin" | "writeOnly", { baseURL, valueHint, }?: { baseURL?: string; valueHint?: string; }): stringorganization, "writer"); // or reader, admin, writeOnlyconst organization: { name: string; } & CoMap
It generates a URL that looks like .../invite/[CoValue ID]/[inviteSecret]
In your app, you need to handle this route, and let the user accept the invitation, as done here.
import {useAcceptInviteNative } from "jazz-tools/expo";function useAcceptInviteNative<S extends CoValueOrZodSchema>({ invitedObjectSchema, onAccept, forValueHint, }: { invitedObjectSchema: S; onAccept: (projectID: string) => void; forValueHint?: string; }): voiduseAcceptInviteNative({useAcceptInviteNative<CoMapSchema<{ name: z.z.ZodString; }>>({ invitedObjectSchema, onAccept, forValueHint, }: { invitedObjectSchema: CoMapSchema<{ name: z.z.ZodString; }>; onAccept: (projectID: string) => void; forValueHint?: string; }): voidinvitedObjectSchema:invitedObjectSchema: CoMapSchema<{ name: z.z.ZodString; }>Organization,const Organization: CoMapSchema<{ name: z.z.ZodString; }>onAccept: (projectID: string) => voidonAccept: (organizationID: stringorganizationID) => {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("Accepted invite!") // navigate to the organization page }, });
You can accept an invitation programmatically by using the acceptInvite method on an account.
Pass the ID of the CoValue you're being invited to, the secret from the invite link, and the schema of the CoValue.
awaitconst account: Accountaccount.acceptInvite(Account.acceptInvite<CoMapSchema<{ name: z.z.ZodString; }>>(valueID: string, inviteSecret: InviteSecret, coValueClass: CoMapSchema<{ name: z.z.ZodString; }>): Promise<...>const organizationId: ""organizationId,const inviteSecret: "inviteSecret_z"inviteSecret,Organization );const Organization: CoMapSchema<{ name: z.z.ZodString; }>
Requesting Invites
To allow a non-group member to request an invitation to a group you can use the writeOnly role.
This means that users only have write access to a specific requests list (they can't read other requests).
However, Administrators can review and approve these requests.
Create the data models.
constJoinRequest =const JoinRequest: CoMapSchema<{ account: <Shape extends { profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>(shape?: Shape) => AccountSchema<Shape>; status: z.z.ZodLiteral<...>; }>import coco.map({map<{ account: <Shape extends { profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>(shape?: Shape) => AccountSchema<Shape>; status: z.z.ZodLiteral<...>; }>(shape: { account: <Shape extends { profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>(shape?: Shape) => AccountSchema<Shape>; status: z.z.ZodLiteral<...>; }): CoMapSchema<...> export mapaccount:account: <Shape extends { profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>(shape?: Shape) => AccountSchema<Shape>import coco.account,const account: <Shape extends { profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>(shape?: Shape) => AccountSchema<Shape> export accountstatus: z.z.ZodLiteral<"pending" | "approved" | "rejected">status:import zz.literal(["pending", "approved", "rejected"]), }); constliteral<["pending", "approved", "rejected"]>(value: ["pending", "approved", "rejected"], params?: string | z.z.core.$ZodLiteralParams): z.z.ZodLiteral<"pending" | "approved" | "rejected"> (+1 overload) export literalRequestsList =const RequestsList: CoListSchema<CoMapSchema<{ account: <Shape extends { profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>(shape?: Shape) => AccountSchema<Shape>; status: z.z.ZodLiteral<...>; }>>import coco.list(list<CoMapSchema<{ account: <Shape extends { profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>(shape?: Shape) => AccountSchema<Shape>; status: z.z.ZodLiteral<...>; }>>(element: CoMapSchema<...>): CoListSchema<...> export listJoinRequest);const JoinRequest: CoMapSchema<{ account: <Shape extends { profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>(shape?: Shape) => AccountSchema<Shape>; status: z.z.ZodLiteral<...>; }>
Set up the request system with appropriate access controls.
functioncreateRequestsToJoin() { constfunction createRequestsToJoin(): CoList<{ account: { profile: { name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap; root: { [x: string]: any; } & CoMap; } & { profile: Profile; } & Account; status: "pending" | ... 1 more ... | "rejected"; } & CoMap>const requestsGroup: GrouprequestsGroup =class GroupGroup.create();Group.create<Group>(this: CoValueClass<Group>, options?: { owner: Account; } | Account): Groupconst requestsGroup: GrouprequestsGroup.Group.addMember(member: Everyone, role: "writer" | "reader" | "writeOnly"): void (+2 overloads)addMember("everyone", "writeOnly"); returnRequestsList.const RequestsList: CoListSchema<CoMapSchema<{ account: AccountSchema<{ profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>; status: z.z.ZodLiteral<...>; }>>create([],create: (items: CoListInit<CoMapSchema<{ account: AccountSchema<{ profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>; status: z.z.ZodLiteral<...>; }>>, options?: { owner: Account | Group; } | Account | Group) => CoList<...>const requestsGroup: GrouprequestsGroup); } async functionsendJoinRequest(function sendJoinRequest(requestsList: co.loaded<typeof RequestsList>, account: Account): Promise<{ account: { profile: { name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap; root: { ...; } & CoMap; } & { ...; } & Account; status: "pending" | ... 1 more ... | "rejected"; } & CoMap>requestsList:requestsList: CoList<({ account: ({ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account) | null; status: "pending" | ... 1 more ... | "rejected"; } & CoMap) | null>import coco.loaded<typeoftype loaded<T extends CoValueClass | AnyCoSchema, R extends ResolveQuery<T> = true> = R extends boolean | undefined ? NonNullable<InstanceOfSchemaCoValuesNullable<T>> : [NonNullable<InstanceOfSchemaCoValuesNullable<T>>] extends [...] ? Exclude<...> extends CoValue ? R extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<... export loadedRequestsList>,const RequestsList: CoListSchema<CoMapSchema<{ account: AccountSchema<{ profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>; status: z.z.ZodLiteral<...>; }>>account:account: { profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & AccountAccount, ) { consttype Account = { profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & Accountrequest =const request: { account: { profile: { name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap; root: { [x: string]: any; } & CoMap; } & { profile: Profile; } & Account; status: "pending" | ... 1 more ... | "rejected"; } & CoMapJoinRequest.const JoinRequest: CoMapSchema<{ account: AccountSchema<{ profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>; status: z.z.ZodLiteral<...>; }>create( {create: (init: { account: { profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account; status: NonNullable<...>; }, options?: Account | ... 2 more ... | undefined) => { ...; } & CoMapaccount,account: { profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { profile: Profile | null; } & Accountstatus: NonNullable<"pending" | "approved" | "rejected">status: "pending", },requestsList.requestsList: CoList<({ account: ({ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account) | null; status: "pending" | ... 1 more ... | "rejected"; } & CoMap) | null>CoList<({ account: ({ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account) | null; status: "pending" | ... 1 more ... | "rejected"; } & CoMap) | null>._owner: Account | Group_owner // Inherit the access controls of the requestsList );requestsList.requestsList: CoList<({ account: ({ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account) | null; status: "pending" | ... 1 more ... | "rejected"; } & CoMap) | null>CoList<({ account: ({ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account) | null; status: "pending" | ... 1 more ... | "rejected"; } & CoMap) | null>.push(...items: (({ account: ({ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account) | null; status: "pending" | ... 1 more ... | "rejected"; } & CoMap) | null)[]): numberAppends new elements to the end of an array, and returns the new length of the array.push(request); returnconst request: { account: { profile: { name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap; root: { [x: string]: any; } & CoMap; } & { profile: Profile; } & Account; status: "pending" | ... 1 more ... | "rejected"; } & CoMaprequest; }const request: { account: { profile: { name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap; root: { [x: string]: any; } & CoMap; } & { profile: Profile; } & Account; status: "pending" | ... 1 more ... | "rejected"; } & CoMap
Using the write-only access users can submit requests that only administrators can review and approve.
async functionapproveJoinRequest(function approveJoinRequest(joinRequest: co.loaded<typeof JoinRequest, { account: true; }>, targetGroup: Group): Promise<boolean>joinRequest:joinRequest: { account: { profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account; } & { ...; } & CoMapimport coco.loaded<typeoftype loaded<T extends CoValueClass | AnyCoSchema, R extends ResolveQuery<T> = true> = R extends boolean | undefined ? NonNullable<InstanceOfSchemaCoValuesNullable<T>> : [NonNullable<InstanceOfSchemaCoValuesNullable<T>>] extends [...] ? Exclude<...> extends CoValue ? R extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<...> extends CoValue ? ItemDepth extends { ...; } ? ((CoValue & ... 1 more ... & (ItemDepth extends boolean | undefined ? CoValue & Exclude<...> : [...] extends [...] ? Exclude<... export loadedJoinRequest, {const JoinRequest: CoMapSchema<{ account: AccountSchema<{ profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>; status: z.z.ZodLiteral<...>; }>account: trueaccount: true }>,targetGroup: GrouptargetGroup:class GroupGroup, ) { constaccount = awaitconst account: ({ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & Account) | ({ ...; } & ... 1 more ... & Account) | nullAccount.const Account: AccountSchema<{ profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>load(load: <ResolveQuery<AccountSchema<{ profile: AnyCoMapSchema<{ name: z.z.core.$ZodString<string>; inbox?: z.z.core.$ZodOptional<z.z.core.$ZodString>; inboxInvite?: z.z.core.$ZodOptional<z.z.core.$ZodString>; }>; root: AnyCoMapSchema; }>>>(id: string, options?: { ...; } | undefined) => Promise<...>joinRequest.joinRequest: { account: { profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account; } & { ...; } & CoMapCoMap._refs: { account: Ref<NonNullable<{ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account>>; }If property `prop` is a `coField.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._refs.account.account: Ref<NonNullable<{ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { profile: Profile | null; } & Account>>Ref<NonNullable<{ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { profile: Profile | null; } & Account>>.id: stringid); if (account) {const account: ({ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & Account) | ({ ...; } & ... 1 more ... & Account) | nulltargetGroup: GrouptargetGroup.Group.addMember(member: Account, role: AccountRole): void (+2 overloads)addMember(account, "reader");const account: ({ profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & Account) | ({ ...; } & ... 1 more ... & Account)joinRequest.joinRequest: { account: { profile: ({ name: string; inbox?: string | undefined; inboxInvite?: string | undefined; } & CoMap) | null; root: ({ [x: string]: any; } & CoMap) | null; } & { ...; } & Account; } & { ...; } & CoMapstatus: "pending" | "approved" | "rejected"status = "approved"; return true; } else { return false; } }