# payload-preset — Agent usage Configure a coding agent for @nexload-sdk/payload-preset. **Topic:** agents **Package:** `@nexload-sdk/payload-preset` v1.1.0 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/payload-preset/agents/ ## Install matching skills Install the skills whose triggers match the task. ### payload-preset [Trigger](https://github.com/gecut/nexload-sdk/blob/main/skills/payload-preset/SKILL.md) ```text Use when configuring or reviewing Payload CMS configuration with @nexload-sdk/payload-preset, composing Persian admin defaults, logger bridge, after-commit callbacks (afterCommit option), field hooks, or collection audit logging with auditPlugin. Decides between preset and standalone plugins, validates options and defaults, verifies plugin order and non-interference with collection fields, or migrates from deprecated logOperation. Do not use for field schema definitions (use payload-schema) or single field customizations (use payload-fields). ``` ```bash npx skills add gecut/nexload-sdk --skill payload-preset ``` ## Project AGENTS.md ```markdown For @nexload-sdk/payload-preset, load payload-preset when its trigger matches. Read the package bundle and check public exports against the installed version before editing. ``` ## Package context [Scoped Markdown bundle](/nexload-sdk/packages/payload-preset/llms.txt). ## Prompts ```text Configure a Persian Payload admin. Use @nexload-sdk/payload-preset and payload-preset. Inspect the installed version and show a minimal typed example for my project. ``` ```text Review my @nexload-sdk/payload-preset integration against the optimization page. Identify the relevant source for each finding and one test for the highest-risk behavior. ``` --- # API Reference & Compatibility Public preset exports and runtime constraints. **Topic:** api **Package:** `@nexload-sdk/payload-preset` v1.1.0 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/payload-preset/api/ The inventory is generated from the package source exports. ## Functions ### `nexloadPreset` ```ts nexloadPreset(options?: NexloadPresetOptions) => Plugin[] ``` **Exported from:** `@nexload-sdk/payload-preset` Public function exported by @nexload-sdk/payload-preset. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/payload-preset/src/index.ts#L29) ### `payloadLoggerPlugin` ```ts payloadLoggerPlugin() => Plugin ``` **Exported from:** `@nexload-sdk/payload-preset` Public function exported by @nexload-sdk/payload-preset. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/payload-preset/src/logger.ts#L5) ### `persianPlugin` ```ts persianPlugin() => Plugin ``` **Exported from:** `@nexload-sdk/payload-preset` Public function exported by @nexload-sdk/payload-preset. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/payload-preset/src/persian.ts#L91) ## Types ### `AuditOperation` ```ts type AuditOperation = "create" | "update" | "delete" | "read" | "auth"; ``` **Exported from:** `@nexload-sdk/payload-preset` Public type exported by @nexload-sdk/payload-preset. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/payload-hooks/src/audit-plugin.ts#L16) ### `AuditPluginOptions` ```ts type AuditPluginOptions = { collections?: "all" | string[]; exclude?: string[]; operations?: AuditOperation[]; logger?: Pick; }; ``` **Exported from:** `@nexload-sdk/payload-preset` Public type exported by @nexload-sdk/payload-preset. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/payload-hooks/src/audit-plugin.ts#L18) ### `NexloadPresetOptions` ```ts type NexloadPresetOptions = { persian?: boolean fields?: false | PayloadFieldsPluginOptions audit?: false | AuditPluginOptions logger?: boolean /** * Installs `afterCommitPlugin()` from `@nexload-sdk/payload-hooks` (default `true`). * It enables `runAfterCommit`, commit-exact revalidation batches and audit entries * written after commit. Set to `false` to leave it out. */ afterCommit?: boolean }; ``` **Exported from:** `@nexload-sdk/payload-preset` Public type exported by @nexload-sdk/payload-preset. [Source](https://github.com/gecut/nexload-sdk/blob/main/packages/payload-preset/src/index.ts#L16) ## Exported Factories Summary `nexloadPreset(options?: NexloadPresetOptions): Plugin[]` returns the enabled plugins. Options: `persian`, `logger`, `afterCommit`, `fields`, `audit`; each accepts `false` to leave that plugin out. `persianPlugin()` and `payloadLoggerPlugin()` are also available separately. The package re-exports `AuditOperation` and `AuditPluginOptions`, and exports `NexloadPresetOptions`. Import `payloadFieldsPlugin` from `@nexload-sdk/payload-fields`, and `auditPlugin` and `afterCommitPlugin` from `@nexload-sdk/payload-hooks`. This package is ESM only and intended for Node.js Payload configuration. --- # Production Guides & Recipes Options, merge rules, ordering, and logging for the Payload preset. **Topic:** guides **Package:** `@nexload-sdk/payload-preset` v1.1.0 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/payload-preset/guides/ ## Options | Option | Default | Behavior | | --- | --- | --- | | `persian` | `true` | Persian admin defaults; set `false` to disable. | | `logger` | `true` | Bridge SDK options when `config.logger` is unset; set `false` to disable. | | `afterCommit` | `true` | Installs `afterCommitPlugin()` from `@nexload-sdk/payload-hooks`; set `false` to disable. | | `fields` | `{}` | Options for `payloadFieldsPlugin`; set `false` to disable. | | `audit` | `{}` | Options for `auditPlugin`; set `false` to disable. | The preset returns its plugins in this order: Persian, logger bridge, after-commit, fields, audit. `payloadFieldsPlugin` runs at order 900 and `auditPlugin` at 1000. Ordinary host plugins run first, so their collections are available to both. The preset does not add, remove, or change collection fields. Define them with [Payload Schema](/nexload-sdk/packages/payload-schema/) and [Payload Fields](/nexload-sdk/packages/payload-fields/). ## Persian merge rules The Persian plugin preserves host languages, fallback language, and default timezone. It adds Persian translations if absent, defaults the fallback to `fa`, and adds `Asia/Tehran` to supported timezones. It sets RTL only on existing `fa` locale objects without an explicit RTL value. It never creates localization or adds locales. ## Logger bridge Call `configureLogger()` before `buildConfig()`. When `config.logger` is unset, the plugin uses the options form from `getPayloadLoggerConfig()`; Payload creates its own Pino logger from those options. Payload writes JSON in development unless `configureLogger({ destination })` supplies a stream. Rebuild the Payload config after forced SDK reconfiguration. See the [logger API](/nexload-sdk/packages/logger/api/). ## After-commit behaviour With `afterCommit` enabled (the default), three things work on the exact commit of each database transaction: * `auditPlugin` writes `payload.document.created`, `payload.document.updated` and `payload.document.deleted` after the commit. A write that rolls back produces no entry. * [`@nexload-sdk/payload-revalidate`](/nexload-sdk/packages/payload-revalidate/) sends each batch on commit, with no polling and no 5-second cap. * Your own hooks can call `runAfterCommit(req, key, fn)` from `@nexload-sdk/payload-hooks`. Set `afterCommit: false` to go back to immediate audit entries and the revalidate polling fallback. Callbacks live in process memory: an entry or a callback is lost if the process stops between the commit and the callback. ## Audit boundaries Audit reads are off by default; auth is on. The implicit default users collection is created after plugins run and is not audited: declare it explicitly. Read and auth entries are always written immediately. Write entries are written after commit unless `afterCommit` is `false`, in which case they are emitted before the commit and may describe rolled-back changes. See [Payload Hooks](/nexload-sdk/packages/payload-hooks/) for options and events. The `getPayloadLoggerConfig()` bridge maps the SDK `success` threshold to Payload `warn`. Payload’s logger has no `success()` method. --- # Overview & Quick Start Compose Payload configuration with Nexload defaults. **Topic:** overview **Package:** `@nexload-sdk/payload-preset` v1.1.0 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/payload-preset/ **Package:** `@nexload-sdk/payload-preset` **Workspace version:** `1.1.0` [npm](https://www.npmjs.com/package/@nexload-sdk/payload-preset) · [Source](https://github.com/gecut/nexload-sdk/tree/main/packages/payload-preset) `nexloadPreset()` composes Persian admin defaults, the SDK logger bridge, after-commit callbacks, field hooks, and collection audit logging. It is ESM only and runs in Node.js Payload configuration. ## Installation ```bash pnpm add @nexload-sdk/payload-preset @nexload-sdk/logger payload @payloadcms/translations @payloadcms/ui react react-dom ``` `@payloadcms/ui`, `react` and `react-dom` are peer dependencies, because the fields plugin registers admin components. ## Quick Start ```ts import { configureLogger } from "@nexload-sdk/logger"; import { nexloadPreset } from "@nexload-sdk/payload-preset"; import { buildConfig } from "payload"; configureLogger({ service: "shop-cms" }); export default buildConfig({ // Add db, secret, and collections here. plugins: [...nexloadPreset()], }); ``` Configure the logger before `buildConfig()`. Define collections explicitly, including the auth collection. See [guides](./guides/) and the [API reference](./api/). ## Next steps [Optimization](./optimization/) [Agent usage](./agents/) --- # payload-preset — Optimization Production choices for @nexload-sdk/payload-preset. **Topic:** optimization **Package:** `@nexload-sdk/payload-preset` v1.1.0 **Canonical page:** https://gecut.github.io/nexload-sdk/packages/payload-preset/optimization/ ## Initialize logging first Call configureLogger() before buildConfig(). Supply a destination when Payload should use the configured output stream. ## Choose plugin ownership Disable a preset option when the project registers the corresponding plugin itself. ## Keep read auditing deliberate Audit read logging is off by default. The preset changes top-level configuration and does not mutate collection field definitions. ## Run in Payload configuration This ESM-only package targets Node.js and Payload configuration. After forced logger reconfiguration, rebuild the Payload configuration. ## Sources [Package guidance](https://github.com/gecut/nexload-sdk/blob/main/packages/payload-preset/README.md) · [Implementation](https://github.com/gecut/nexload-sdk/blob/main/packages/payload-preset/src/index.ts). · [Matching skill](https://github.com/gecut/nexload-sdk/blob/main/skills/payload-preset/SKILL.md).