# autoinvite This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`. ## `autoinvite.add` *Source: `src/store/autoinvite/add.js`* Registers an email for automatic company membership. When that email is registered (`google_auth.add`) the invitation is consumed: it is removed from the list and the new user is added to the company with the given role. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the acting Google auth user (must be admin of the selected company). | | `input` | `{email: string, role?: 'admin'|'user'}` | The email to invite and the role (default 'user'). | | `[tx]` | `object` | Optional transaction to run within. | **Returns** `Promise<{id: number, email: string, role: 'admin'|'user'}>` — The created invitation. **Throws** `Error` — 'Not authorized', 'Invalid email', 'Invalid role', 'User already registered', 'Invitation already exists' **Example** ```js await store.autoinvite.add(42, { email: 'new@example.com', role: 'user' }); ``` ## `autoinvite.list` *Source: `src/store/autoinvite/list.js`* Lists the pending auto-invitations of the admin's selected company. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user (must be admin of the selected company). | | `[tx]` | `object` | Optional transaction to run within. | **Returns** `Promise>` — The invitations ordered by email. **Throws** `Error` — 'Not authorized' / 'No company selected' **Example** ```js const invites = await store.autoinvite.list(42); ``` ## `autoinvite.remove` *Source: `src/store/autoinvite/remove.js`* Deletes a pending auto-invitation of the admin's selected company. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the acting Google auth user (must be admin of the selected company). | | `id` | `number` | The invitation id. | | `[tx]` | `object` | Optional transaction to run within. | **Returns** `Promise` **Throws** `Error` — 'Not authorized', 'Invitation not found' **Example** ```js await store.autoinvite.remove(42, 3); ```