Adds a grants collection where a user holds a position type on a scope such as a project, organization or site, with start and end dates and a status. Position types, scope kinds and who may grant are passed in through plugin options. Every change writes a history row in the same database transaction, so the database must support transactions. Holders must accept a grant before it takes effect, and a host veto can refuse acceptance.
Positions for Payload: scoped, dated grants people hold on a site, an organization or a project, with host-defined types, grant rules and an audit trail.
Installation
npm i @extantape/payload-plugin-positions0
Stars
0
Forks
0
Open Issues
1 weeks ago
Last Updated
382
Weekly Downloads
v0.2.2
npm Version
73.4 KB
Unpacked Size
0
Dependencies
00 since Nov 22
| Date | Stars |
|---|---|
| Dec 6, 2026 | 0 |
| Dec 5, 2026 | 0 |
| Dec 4, 2026 | 0 |
| Dec 3, 2026 | 0 |
| Dec 2, 2026 | 0 |
| Dec 1, 2026 | 0 |
| Nov 30, 2026 | 0 |
| Nov 29, 2026 | 0 |
| Nov 28, 2026 | 0 |
| Nov 27, 2026 | 0 |
| Nov 26, 2026 | 0 |
| Nov 25, 2026 | 0 |
| Nov 24, 2026 | 0 |
| Nov 23, 2026 | 0 |
| Nov 22, 2026 | 0 |
418+418 since Nov 25
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 418 |
| Dec 5, 2026 | 635 |
| Dec 4, 2026 | 832 |
| Dec 3, 2026 | 820 |
| Dec 2, 2026 | 929 |
| Dec 1, 2026 | 866 |
| Nov 30, 2026 | 686 |
| Nov 29, 2026 | 625 |
| Nov 28, 2026 | 388 |
| Nov 27, 2026 | 177 |
| Nov 26, 2026 | 137 |
| Nov 25, 2026 | 0 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1468359119-root)<a href="https://payloaddirectory.dev/plugins/1468359119-root"><img src="https://payloaddirectory.dev/badge/1468359119-root.svg" alt="Payload Directory"></a>README
Positions for Payload: scoped, dated grants people hold on a site, an organization or a project, with host-defined types, grant rules and an audit trail.
Status: early, 0.x. 0.2.2 is the latest release. Releases go to npm as @extantape/payload-plugin-positions. The 131 tests run against a real Payload with an in-memory MongoDB. It hasn't been tried in a real app, and the admin screens haven't been looked at in a browser.
The scope agreed with Captive Origins:
project and p-1), a start and end date (ISO dates only. 0, 1, words and dates that don't exist, such as 2026-02-30, are refused. A time needs a zone, Z or an offset like +02:00, because a time with none would be read in the server's zone. A plain date is read as midnight UTC), who granted it, a status and notes. A position with no scope, such as one for a whole site, is a type marked unscoped.where (bulk) is refused.position-grant-history: what changed, who did it (as collection:id), and a copy of the grant (without its notes). Only the plugin can add rows, and rows can't be changed or deleted through Payload. Someone with direct database access can still change anything.canRead and canReadPrivate: a non-empty object that canRead returns, or that canReadPrivate returns for the history, counts as a Payload where. {}, [] and anything else that isn't true or a non-empty object is a no, the same as false. For notes, canReadPrivate must answer exactly true; an object there is a no. For the history canReadPrivate is called with grant: undefined, so a rule like "true unless the scope is X" is also true for the history. Check for the grant before you say yes. A where on notes is always refused, because which rows match would tell the asker what the notes say.canReadPrivate, not canGrant, so a granter limited to one scope doesn't read everything. Without it, nobody reads them through the API. For notes it is asked per grant and must answer exactly true. For the history it may also answer with a Payload where on the rows, such as { 'snapshot.scopeId': { equals: 'p-1' } }. Holders can't read their own notes, and someone who can't read a grant's notes can't overwrite them either. Notes are capped at 2000 characters and scope ids at 200.transactionOptions: false, for one), startup fails, because a history failure couldn't undo its change. Set allowWithoutTransactions to accept that. The probe only asks the adapter: a standalone Mongo with default options passes it and then fails closed on each write, because every change also checks that its own request has a transaction. That per-request check is what stands behind the startup one. The startup check can be skipped, because Payload 3.92 doesn't run onInit on getPayload({ disableOnInit: true }), and after a failed start the next getPayload call with the same key gets the cached instance without running it. Don't rely on startup alone.canGrant that answers exactly true, nobody can grant. A throw or any other answer is a no. canRevoke (default: the same as canGrant) covers revoking, pausing and shortening an end date. Resuming a paused grant, or moving an end date later or to none, is a grant, so it needs canGrant and can't be done for your own account. Anyone refused gets the standard Forbidden answer. A self-grant, self-resume or self-extension gets "You can’t do that for your own account." (unless allowSelfGrant is on). Two changes to one grant at the same moment (two accepts, or an accept and a revoke) let one through; the other gets "This grant was just changed. Check it and try again." with a 403. canRead and canReadPrivate must answer true, false or a real where with at least one condition; {}, [] and anything else is no.disableDuplicate: true, so the admin has no Duplicate action and Payload offers no REST duplicate route or GraphQL mutation for grants. The plugin also refuses any create that carries duplicateFromID, before the source is looked up, so the setting being changed by other config doesn't turn duplication on while the plugin's hooks are in place and start-up runs. At start-up it puts the setting back and runs the refusal again after any beforeOperation hook added later. With start-up skipped (see Transactions), duplication can come back if other config turns disableDuplicate off and also adds duplicateFromID in a later hook or replaces the grants' beforeOperation hooks. Fields or hooks of yours that fill in data after create access has run are yours to check. Payload 3.92 ignores duplicateFromID in the query of a REST create, so that is an ordinary create from the body.allowSelfGrant: true.pending, the same for every holder, and gives nothing until the holder accepts it. The holder (or server code with no user) sets the status to active; nobody else can. The holder can also set a pending grant to revoked to decline it, and can change nothing else. A resume of a paused grant, or an extension of an active one, puts the grant back to pending in the same way, so the holder accepts again. Extending an active grant puts it back to pending, so the holder loses the position until they accept again. A granter who can't revoke can suspend someone this way. Hosts should tell the holder when a grant they hold goes back to pending. Nobody can set a grant to pending themselves, over any API: only the plugin does, on create, resume and extension. Server code is held to the same rule: passing status: 'pending' throws, and any status passed on create is replaced with pending. A status that is not one of the five values (null and empty included) is refused on update.refuseGrant is required: pass a function, or exactly false for no veto (null, 0, '' and anything else is refused at setup). It runs when the holder accepts, never when someone grants, resumes or extends, so a granter can't use it to learn that someone is, say, a minor. It sees the grant as it stands, with endsAt as null for no end, and action is always grant. A holder who is vetoed gets the standard Forbidden answer and the grant stays pending. The granter sees the same pending grant whether the holder has not answered or was refused, and no audit event or history row is written for a refused accept. Server code with no signed-in user sees the host's reason, so it can log it. A granter can still see that a grant stays pending for a long time. Don't relay the veto's reason to the granter, and never accept on the holder's behalf (for example from a granter's session, or with a service account that acts for them). Either one gives the granter back the answer the plugin keeps from them. Changed in 0.2.0: before, the veto ran when the grant was made and its refusal told the granter who was barred.before hook stops the change. A failing after hook is logged.hasPosition and positionsOf.liveKey field, so two requests at once can't both get in. The index has to exist. On Mongo, set ensureIndexes: true on mongooseAdapter (it is off by default). On SQL adapters, run a migration that adds a unique index on position_grants.live_key.db.create for the grants collection. Two identical grants at once both pass the check for a live one, and the unique liveKey index stops the second. Payload's afterError hook never sees the Local API, and a check beforehand can't close the race, so the wrapper turns exactly three errors into the same 403 the check gives: a duplicate key on liveKey, a validation error on liveKey, and a write conflict (code 112). Any other error, including a duplicate on another index, passes through unchanged. It is tested on Mongo only. SQL adapters are untested, so check how yours reports a unique violation before relying on it.where from canRead may dot into the accounts collection (holder.email, or a field inside a row, group or array). Paths are read from the accounts collection's own field list. A path that names no field gives no rows, not an error.transactionOptions: false) the plugin refuses every change. Set allowWithoutTransactions: true only if you accept a grant that can be saved without its history row.On its own: Positions needs only Payload and a database with transactions. Position types, scope kinds, who may grant and the veto all come from your config. It doesn't depend on any other plugin.
Needs: Payload ^3.80.0 as a peer dependency. No other EXTANT APE plugin is required.
Works with:
organization can be a scope kind whose ids are that plugin's organizations. Your site makes the connection.recordEvent. That's your own code, and neither plugin imports the other.Color Theory: none needed. It has no screens of its own, and its collections use Payload's standard admin, which takes Color Theory's admin colors when its applyToAdmin option is on.
Releases go to npm as @extantape/payload-plugin-positions.
npm install @extantape/payload-plugin-positions
To work on it:
npm install
npm test
npm run build
import { positions, hasPosition, expireGrants } from '@extantape/payload-plugin-positions'
positions({
users: 'users', // default
positionTypes: [
{ value: 'editor', label: 'Editor' },
{ value: 'steward', unscoped: true },
],
scopeKinds: [{ value: 'project' }, { value: 'group' }],
canGrant: ({ user }) => user.role === 'staff',
refuseGrant: ({ holder }) => (holder.restricted ? 'Not available for this account.' : null), // or false
audit: { afterGrant: (e) => console.log(e.event, e.grant.id) },
})
await hasPosition(payload, user, 'editor', { kind: 'project', id: 'p-1' }) // true or false
await positionsOf(payload, user) // [{ id, position, scope, startsAt, endsAt }]
await expireGrants(payload) // run from a job: marks ended grants expired and runs the expiry hooks
Pass req.user or a user id. A user document is only accepted when its collection is the plugin's users collection, so an id from another collection can't match. hasPosition answers for exactly the scope you give. Leave the scope out to ask about an unscoped position. No user, a paused, revoked or expired grant, a date outside the window, or an error reading grants all give false. positionsOf throws if grants can't be read. Pass { at } to check another moment and { req } to stay in a transaction.
By default staff who pass canGrant read every grant and everyone else reads their own. canRevoke and canRead can change who revokes and who reads. A person can only change a grant they can also read: canRevoke and the read rule (canRead, or the host's own read access on the collection) must both allow it.
Invites, codes, contact addresses, a verification step, expiry reminders and syncing a user's role list are not built. Expiry runs when the host calls expireGrants; until then the helpers already refuse an ended grant.
MIT. Copyright (c) 2026 EXTANT APE. See LICENSE.
Contributions arrive as pull requests from co/ branches in this repo. Only the owner merges.
payload plugin organizations
Organizations with member levels, approval of pending organizations, email-domain matching and an organization picker…
67596/wk0v3
payload plugin sharing
Share records with users and organizations through groups with Owner, Manager and Viewer levels
76425/wk0v3
payload plugin guardians
Link minors to guardians, turn guardian edits into suggestions the minor decides, and route requests for approval
76366/wk0v3
payload plugin masq
Read-only masquerade for Payload admins to sign in as another user with a banner, time-limited session and audit hooks
691.3k/wk0v3
rbac
Role and capability engine with inheritance, wildcards and access guards for collections and fields
67737/wk0v3
payload plugin rbac ui
Permissions matrix UI for a Payload Roles collection with auto-discovered, validated permission strings
38172/wk1v3