import { type AppDefinition, type ResourceDefinition } from '@appsemble/lang-sdk'; import { type Resource as ResourceType } from '@appsemble/types'; import { type PreValidatePropertyFunction } from 'jsonschema'; import { type Context, type DefaultContext, type DefaultState, type ParameterizedContext } from 'koa'; import { type JsonValue } from 'type-fest'; import { type PreparedAsset, TempFile } from './index.js'; export declare function stripResource({ $author, $created, $editor, $ephemeral, $group, $seed, $updated, ...data }: ResourceType): Record; /** * Works on a resource, which has been processed on the server by the streamParser * * @param data The resource to be serialized, optionally containing parsed TempFile instance assets * @returns An object containing the resource and an array of the assets referenced * from the resource */ export declare function serializeServerResource(data: any): JsonValue | { resource: JsonValue; assets: TempFile[]; }; export type SerializedServerResourceBody = ReturnType; /** * Get the resource definition of an app by name. * * If there is no match, a 404 HTTP error is thrown. * * @param appDefinition The app definition to get the resource definition of * @param resourceType The name of the resource definition to get. * @param ctx Context used to throw back the errors. * @param view The view that’s being used. * @returns The matching resource definition. */ export declare function getResourceDefinition(appDefinition: AppDefinition, resourceType: string, ctx?: Context, view?: string): ResourceDefinition; /** * Extracts the IDs of resource request body. * * @param ctx The Koa context to extract the body from. * @param suppliedBody A resource body to use directly without reading from context. * Supports multipart-style `{ resource, assets }` input. * @returns A tuple which consists of: * * 1. One or more resources processed from the request body. * 2. A list of newly uploaded assets which should be linked to the resources. * 3. preValidateProperty function used for reconstructing resources from a CSV file. */ export declare function extractResourceBody(ctx: Context | ParameterizedContext | undefined, suppliedBody?: SerializedServerResourceBody): [ Record | Record[], TempFile[], PreValidatePropertyFunction | undefined ]; /** * Process an incoming resource request body. * * This handles JSON schema validation, resource expiration, and asset linking and validation. * * @param ctx The Koa context to process. * @param definition The resource definition to use for processing the request body. * @param knownAssetIds A list of asset IDs that are already known to be linked to the resource. * @param knownExpires A previously known expires value. * @param knownAssetNameIds A list of asset ids with asset names that already exist. * @param [isPatch] if the "PATCH" HTTP method is being used. * @param resourceBody Used to process resources from non-request contexts. * @returns A tuple which consists of: * * 1. One or more resources processed from the request body. * 2. A list of newly uploaded assets which should be linked to the resources. * 3. Asset IDs from the `knownAssetIds` array which are no longer used. */ export declare function processResourceBody(ctx: Context | ParameterizedContext, definition: ResourceDefinition, knownAssetIds?: string[], knownExpires?: Date, knownAssetNameIds?: { id: string; name?: string; }[], isPatch?: boolean, resourceBody?: SerializedServerResourceBody): Promise<[Record | Record[], PreparedAsset[], string[]]>;