init commit for iPAL-kit plugin

This commit is contained in:
2026-07-18 20:30:23 +02:00
parent 10638127a9
commit 5733a9c8bf
119 changed files with 6892 additions and 411 deletions
+29
View File
@@ -0,0 +1,29 @@
import type { Config } from 'payload'
import type { AccessOption } from './types.js'
import { buildRolesField } from './rolesField.js'
/**
* Injects the fixed `roles` field into the client's auth collection.
*
* The plugin owns the role definition; the client owns the collection. This
* finds the collection by slug and appends the field. We control the whole
* stack, so no conflict handling is needed — the field is simply added.
*/
export function injectRoles(config: Config, access: AccessOption): Config {
const rolesField = buildRolesField(access.defaultRole)
return {
...config,
collections: (config.collections ?? []).map((collection) => {
if (collection.slug !== access.authCollection) {
return collection
}
return {
...collection,
fields: [...collection.fields, rolesField],
}
}),
}
}