Skip to content

API reference

Functions

createCMSClient

Source
createCMSClient<TPayloadConfig extends PayloadTypesShape = UntypedPayloadTypes, const TOperations extends CMSOperationsTree = CMSOperationsTree>(options: CMSClientOptions<TOperations>) => CMSClient<TPayloadConfig, TOperations>

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/client

Public function exported by @nexload-sdk/payload-operations.

createPayloadEndpoints

Source
createPayloadEndpoints<const TOperations extends CMSOperationsTree>(options: CreatePayloadEndpointsOptions<TOperations>) => Endpoint[]

Exported from: @nexload-sdk/payload-operations/server

Public function exported by @nexload-sdk/payload-operations.

defineCMSOperations

Source
defineCMSOperations<const TOperations extends CMSOperationsTree>(operations: TOperations) => TOperations

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/contract

Public function exported by @nexload-sdk/payload-operations.

defineClientPlugin

Source
defineClientPlugin<const TPlugin extends CMSClientPlugin>(plugin: TPlugin) => TPlugin

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/client

Public function exported by @nexload-sdk/payload-operations.

isCMSOperationError

Source
isCMSOperationError(error: unknown) => error is CMSOperationError

Exported from: @nexload-sdk/payload-operations/errors

Public function exported by @nexload-sdk/payload-operations.

isDefinedError

Source
isDefinedError<TError extends CMSOperationError<string, unknown, true>>(error: TError) => error is TError
isDefinedError<TError extends CMSOperationError<string, unknown, true>, TCode extends TError["code"]>(error: TError, code: TCode) => error is Extract<TError, { code: TCode; }>
isDefinedError(error: unknown, code?: string) => error is CMSOperationError<string, unknown, true>

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/errors

Public function exported by @nexload-sdk/payload-operations.

isTimeoutError

Source
isTimeoutError(error: unknown) => boolean

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/plugins/timeout

Public function exported by @nexload-sdk/payload-operations.

operation

Source
operation<const TInput extends z.ZodType, const TOutput extends z.ZodType, const TErrors extends CMSOperationErrorDefinitions = Readonly<Record<string, never>>>(definition: { errors?: TErrors; input: TInput; output: TOutput; }) => CMSOperation<TInput, TOutput, TErrors>

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/contract

Public function exported by @nexload-sdk/payload-operations.

safe

Source
safe<const TPromise extends PromiseLike<unknown>>(promise: TPromise) => Promise<CMSSafeResult<AwaitedData<TPromise>, DefinedError<TPromise>>>

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/errors

Public function exported by @nexload-sdk/payload-operations.

timeoutPlugin

Source
timeoutPlugin(options: TimeoutPluginOptions) => { readonly name: "timeout"; readonly wrapTransport: (next: CMSClientTransport) => (request: CMSClientTransportRequest) => Promise<Response>; }

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/plugins/timeout

Public function exported by @nexload-sdk/payload-operations.

Classes

CMSOperationError

Source
class CMSOperationError

Exported from: @nexload-sdk/payload-operations/errors, @nexload-sdk/payload-operations/server

Public classe exported by @nexload-sdk/payload-operations.

Interfaces

CMSClient

Source
interface CMSClient<
  TPayloadConfig extends PayloadTypesShape = PayloadTypes,
  TOperations extends CMSOperationsTree = CMSOperationsTree
> {
  readonly operations: InferOperationsClient<TOperations>
  readonly payload: PayloadSDK<TPayloadConfig>
}

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/client

Public interface exported by @nexload-sdk/payload-operations.

CMSClientOptions

Source
interface CMSClientOptions<
  TOperations extends CMSOperationsTree
> {
  basePath?: string
  operations: TOperations
  payload: CMSPayloadClientOptions
  plugins?: readonly CMSClientPlugin[]
}

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/client

Public interface exported by @nexload-sdk/payload-operations.

CMSClientPlugin

Source
interface CMSClientPlugin {
  readonly name: string
  wrapTransport(next: CMSClientTransport): CMSClientTransport
}

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/client

Public interface exported by @nexload-sdk/payload-operations.

CMSClientTransportRequest

Source
interface CMSClientTransportRequest {
  readonly init: RequestInit
  readonly operation?: {
    readonly name: string
    readonly path: string
  }
  readonly source: "operation" | "payload"
  readonly url: string
}

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/client

Public interface exported by @nexload-sdk/payload-operations.

CMSOperation

Source
interface CMSOperation<
  TInputSchema extends z.ZodType = z.ZodType,
  TOutputSchema extends z.ZodType = z.ZodType,
  TErrors extends CMSOperationErrorDefinitions = CMSOperationErrorDefinitions
> {
  readonly [CMS_OPERATION_SYMBOL]: true
  readonly errors: TErrors
  readonly input: TInputSchema
  readonly output: TOutputSchema
}

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/contract

Public interface exported by @nexload-sdk/payload-operations.

CMSOperationAccessContext

Source
interface CMSOperationAccessContext<
  TOperation extends CMSOperationContract = CMSOperationContract
> {
  readonly operation: CMSOperationMetadata<TOperation>
  readonly req: PayloadRequest
}

Exported from: @nexload-sdk/payload-operations/server

Public interface exported by @nexload-sdk/payload-operations.

CMSOperationErrorJSON

Source
interface CMSOperationErrorJSON {
  code: string
  data?: unknown
  defined: boolean
  message: string
  status: number
}

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/errors

Public interface exported by @nexload-sdk/payload-operations.

CMSOperationHandlerContext

Source
interface CMSOperationHandlerContext<
  TOperation extends CMSOperationContract
> {
  readonly errors: CMSDefinedErrorFactories<TOperation>
  readonly input: InferParsedOperationInput<TOperation>
  readonly operation: CMSOperationMetadata<TOperation>
  readonly req: PayloadRequest
}

Exported from: @nexload-sdk/payload-operations/server

Public interface exported by @nexload-sdk/payload-operations.

CMSOperationMetadata

Source
interface CMSOperationMetadata<
  TOperation extends CMSOperationContract = CMSOperationContract
> {
  readonly definition: TOperation
  readonly name: string
  readonly path: string
}

Exported from: @nexload-sdk/payload-operations/server

Public interface exported by @nexload-sdk/payload-operations.

CMSPayloadClientOptions

Source
interface CMSPayloadClientOptions {
  baseInit?: RequestInit
  baseURL: string
  fetch?: typeof fetch
}

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/client

Public interface exported by @nexload-sdk/payload-operations.

CMSValidationErrorData

Source
interface CMSValidationErrorData {
  issues: Array<{
    code?: string
    message: string
    path: Array<number | string>
  }>
}

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/errors

Public interface exported by @nexload-sdk/payload-operations.

CreatePayloadEndpointsOptions

Source
interface CreatePayloadEndpointsOptions<
  TOperations extends CMSOperationsTree
> {
  access?: {
    default?: CMSOperationAccess
    overrides?: CMSOperationAccessOverrides<TOperations>
  }
  basePath?: string
  handlers: CMSOperationHandlers<TOperations>
  operations: TOperations
}

Exported from: @nexload-sdk/payload-operations/server

Public interface exported by @nexload-sdk/payload-operations.

TimeoutPluginOptions

Source
interface TimeoutPluginOptions { timeout: number }

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/plugins/timeout

Public interface exported by @nexload-sdk/payload-operations.

Types

CMSClientTransport

Source
type CMSClientTransport = (
  request: CMSClientTransportRequest
) => Promise<Response>;

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/client

Public type exported by @nexload-sdk/payload-operations.

CMSDefinedErrorFactories

Source
type CMSDefinedErrorFactories<
  TOperation extends CMSOperationContract
> = {
  readonly [TCode in keyof TOperation["errors"] & string]:
  ErrorFactoryFromDefinition<TCode, TOperation["errors"][TCode]>;
};

Exported from: @nexload-sdk/payload-operations/errors

Public type exported by @nexload-sdk/payload-operations.

CMSDefinedOperationError

Source
type CMSDefinedOperationError<
  TOperation extends CMSOperationContract = CMSOperationContract
> = {
  [TCode in keyof TOperation["errors"] & string]: DefinedErrorFromDefinition<
    TCode,
    TOperation["errors"][TCode]
  >;
}[keyof TOperation["errors"] & string];

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/errors

Public type exported by @nexload-sdk/payload-operations.

CMSOperationAccess

Source
type CMSOperationAccess<
  TOperation extends CMSOperationContract = CMSOperationContract
> = (
  context: CMSOperationAccessContext<TOperation>
) => boolean | Promise<boolean>;

Exported from: @nexload-sdk/payload-operations/server

Public type exported by @nexload-sdk/payload-operations.

CMSOperationAccessOverrides

Source
type CMSOperationAccessOverrides<
  TOperations extends CMSOperationsTree
> = {
  readonly [TKey in keyof TOperations]?:
  TOperations[TKey] extends CMSOperationContract
    ? CMSOperationAccess<TOperations[TKey]>
    : TOperations[TKey] extends CMSOperationsTree
      ? CMSOperationAccessOverrides<TOperations[TKey]>
      : never;
};

Exported from: @nexload-sdk/payload-operations/server

Public type exported by @nexload-sdk/payload-operations.

CMSOperationCallOptions

Source
type CMSOperationCallOptions = Omit<RequestInit, "body" | "method">;

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/contract

Public type exported by @nexload-sdk/payload-operations.

CMSOperationContract

Source
type CMSOperationContract = CMSOperation;

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/contract

Public type exported by @nexload-sdk/payload-operations.

CMSOperationErrorDefinition

Source
type CMSOperationErrorDefinition<
  TDataSchema extends z.ZodType | undefined = z.ZodType | undefined
> = Readonly<{
  data?: TDataSchema
  message: string
  status: number
}>;

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/contract

Public type exported by @nexload-sdk/payload-operations.

CMSOperationErrorDefinitions

Source
type CMSOperationErrorDefinitions = Readonly<
  Record<string, CMSOperationErrorDefinition<z.ZodType | undefined>>
>;

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/contract

Public type exported by @nexload-sdk/payload-operations.

CMSOperationHandler

Source
type CMSOperationHandler<
  TOperation extends CMSOperationContract
> = (
  context: CMSOperationHandlerContext<TOperation>
) => Promise<InferHandlerOutput<TOperation>>;

Exported from: @nexload-sdk/payload-operations/server

Public type exported by @nexload-sdk/payload-operations.

CMSOperationHandlers

Source
type CMSOperationHandlers<TOperations extends CMSOperationsTree> = {
  readonly [TKey in keyof TOperations]:
  TOperations[TKey] extends CMSOperationContract
    ? CMSOperationHandler<TOperations[TKey]>
    : TOperations[TKey] extends CMSOperationsTree
      ? CMSOperationHandlers<TOperations[TKey]>
      : never;
};

Exported from: @nexload-sdk/payload-operations/server

Public type exported by @nexload-sdk/payload-operations.

CMSOperationsTree

Source
type CMSOperationsTree = Readonly<{ [key: string]: CMSOperationContract | CMSOperationsTree }>;

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/contract

Public type exported by @nexload-sdk/payload-operations.

CMSSafeResult

Source
type CMSSafeResult<TData, TDefinedError>
  = | readonly [error: null, data: TData, isDefined: false]
    | readonly [
      error: TDefinedError,
      data: undefined,
      isDefined: true
    ]
    | readonly [error: unknown, data: undefined, isDefined: false];

Exported from: @nexload-sdk/payload-operations/errors

Public type exported by @nexload-sdk/payload-operations.

InferHandlerOutput

Source
type InferHandlerOutput<TOperation extends CMSOperationContract>
  = z.input<TOperation["output"]>;

Exported from: @nexload-sdk/payload-operations/contract

Public type exported by @nexload-sdk/payload-operations.

InferOperationInput

Source
type InferOperationInput<TOperation extends CMSOperationContract>
  = z.input<TOperation["input"]>;

Exported from: @nexload-sdk/payload-operations/contract

Public type exported by @nexload-sdk/payload-operations.

InferOperationOutput

Source
type InferOperationOutput<TOperation extends CMSOperationContract>
  = z.output<TOperation["output"]>;

Exported from: @nexload-sdk/payload-operations/contract

Public type exported by @nexload-sdk/payload-operations.

InferOperationsClient

Source
type InferOperationsClient<TOperations extends CMSOperationsTree> = {
  readonly [TKey in keyof TOperations]:
  TOperations[TKey] extends CMSOperationContract
    ? CMSOperationMethod<TOperations[TKey]>
    : TOperations[TKey] extends CMSOperationsTree
      ? InferOperationsClient<TOperations[TKey]>
      : never;
};

Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/client

Public type exported by @nexload-sdk/payload-operations.

InferParsedOperationInput

Source
type InferParsedOperationInput<
  TOperation extends CMSOperationContract
> = z.output<TOperation["input"]>;

Exported from: @nexload-sdk/payload-operations/contract

Public type exported by @nexload-sdk/payload-operations.

PayloadOperationEndpoints

Source
type PayloadOperationEndpoints = readonly Endpoint[];

Exported from: @nexload-sdk/payload-operations/server

Public type exported by @nexload-sdk/payload-operations.

SubpathPurpose
package rootUniversal contract, client, error, and timeout helpers
/contractoperation, defineCMSOperations, and contract types
/clientcreateCMSClient, defineClientPlugin, and client/transport types
/errorsCMSOperationError, guards, safe, and error types
/plugins/timeouttimeoutPlugin, isTimeoutError, and timeout options
/servercreatePayloadEndpoints, CMSOperationError, and server types

operation({ input, output, errors? }) brands one immutable operation definition while preserving schema identity. Error codes must be uppercase snake case, status must be 400–599, and messages must be non-empty.

defineCMSOperations(tree) validates and snapshots a direct recursive namespace. It accepts no query or command wrapper.

createCMSClient(options) returns { payload, operations }. payload is the actual PayloadSDK<Config> instance. operations mirrors the supplied contract.

CMSClientOptions accepts operations, payload, optional plugins, and optional operation basePath. payload.baseInit is merged before per-call options. Operation calls accept Omit<RequestInit, "body" | "method">; the package always supplies POST and the serialized body.

defineClientPlugin(plugin) validates and freezes a named transport wrapper. Plugin names must be unique; the first plugin is outermost.

safe(promise) resolves to [null, data, false], [definedError, undefined, true], or [unknownError, undefined, false].

isDefinedError(error, code?) validates the shared error brand and optionally narrows the declared code. isTimeoutError(error) recognizes operation timeout errors.

createPayloadEndpoints(options) returns Payload Endpoint[] containing a POST endpoint and matching OPTIONS preflight endpoint for each contract leaf. Options include exact handlers, partial access overrides, an optional default access policy, and basePath.

See the package source for the live export surface.