Functions
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<const TOperations extends CMSOperationsTree>(options: CreatePayloadEndpointsOptions<TOperations>) => Endpoint[]
Exported from: @nexload-sdk/payload-operations/server
Public function exported by @nexload-sdk/payload-operations.
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<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(error: unknown) => error is CMSOperationError
Exported from: @nexload-sdk/payload-operations/errors
Public function exported by @nexload-sdk/payload-operations.
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(error: unknown) => boolean
Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/plugins/timeout
Public function exported by @nexload-sdk/payload-operations.
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<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(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.
Interfaces
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.
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.
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
Sourceinterface 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.
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
Sourceinterface 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.
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
Sourceinterface 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.
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.
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.
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
Sourceinterface 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.
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
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
Sourcetype 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
Sourcetype 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.
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
Sourcetype 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.
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.
type CMSOperationContract = CMSOperation;
Exported from: @nexload-sdk/payload-operations, @nexload-sdk/payload-operations/contract
Public type exported by @nexload-sdk/payload-operations.
CMSOperationErrorDefinition
Sourcetype 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
Sourcetype 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.
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.
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.
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.
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.
type InferHandlerOutput<TOperation extends CMSOperationContract>
= z.input<TOperation["output"]>;
Exported from: @nexload-sdk/payload-operations/contract
Public type exported by @nexload-sdk/payload-operations.
type InferOperationInput<TOperation extends CMSOperationContract>
= z.input<TOperation["input"]>;
Exported from: @nexload-sdk/payload-operations/contract
Public type exported by @nexload-sdk/payload-operations.
type InferOperationOutput<TOperation extends CMSOperationContract>
= z.output<TOperation["output"]>;
Exported from: @nexload-sdk/payload-operations/contract
Public type exported by @nexload-sdk/payload-operations.
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
Sourcetype InferParsedOperationInput<
TOperation extends CMSOperationContract
> = z.output<TOperation["input"]>;
Exported from: @nexload-sdk/payload-operations/contract
Public type exported by @nexload-sdk/payload-operations.
PayloadOperationEndpoints
Sourcetype PayloadOperationEndpoints = readonly Endpoint[];
Exported from: @nexload-sdk/payload-operations/server
Public type exported by @nexload-sdk/payload-operations.