/** * Serialize / deserialize plugin for Kysely. * * Adapted from `kysely-plugin-serialize` (MIT, by subframe7536 — * https://github.com/subframe7536/kysely-plugin-serialize), which is * unmaintained and ships no `exports` map, so modern Node16/ESM resolution * falls back to its CommonJS build and cannot import ESM-only kysely (>= 0.29). * Maintained here directly as part of @pikku/kysely so we publish it ourselves. * * Serializes object/array/Date/boolean parameters to strings on the way into * SQLite-style dialects, and deserializes them back on the way out. */ import { type KyselyPlugin, type PluginTransformQueryArgs, type PluginTransformResultArgs, type QueryResult, type RootOperationNode, type UnknownRow } from 'kysely'; export type Serializer = (parameter: unknown) => unknown; export type Deserializer = (parameter: unknown) => unknown; export declare const defaultSerializer: Serializer; export declare const dateRegex: RegExp; export declare const defaultDeserializer: Deserializer; /** * Checks if a given string parameter is a JSON-like string. * * Determines whether the input starts and ends with curly braces `{}` or * square brackets `[]`, the typical indicators of JSON objects and arrays. */ export declare function maybeJson(parameter: string): boolean; /** * Determines whether a given parameter should be skipped during transformation. * * Skipped when it is `undefined`, `null`, a `bigint`, a `number`, or an object * that exposes a `buffer` property (e.g. a typed array / Buffer). */ export declare function skipTransform(parameter: unknown): boolean; export declare class BaseSerializePlugin implements KyselyPlugin { private readonly transformer; private readonly deserializer; private readonly skipNodeSet?; private readonly ctx?; /** * Base class for {@link SerializePlugin}, without default options. */ constructor(serializer: Serializer, deserializer: Deserializer, skipNodeKind: Array); transformQuery({ node, queryId, }: PluginTransformQueryArgs): RootOperationNode; transformResult({ result, queryId, }: PluginTransformResultArgs): Promise>; private parseRows; } export interface SerializePluginOptions { /** * serialize params */ serializer?: Serializer; /** * deserialize params */ deserializer?: Deserializer; /** * node kind to skip transform */ skipNodeKind?: Array; } export declare class SerializePlugin extends BaseSerializePlugin { /** * _**THIS PLUGIN SHOULD BE PLACED AT THE END OF PLUGINS ARRAY !!!**_ * * reference from https://github.com/koskimas/kysely/pull/138 * * Serializes object/array/Date/boolean column values to strings for * SQLite-style dialects and deserializes them on the way back out. Pass a * custom `serializer`/`deserializer` to override the default behaviour. */ constructor(options?: SerializePluginOptions); }