( options: LoadSubsetOptions | undefined, )
| 7 | * @internal |
| 8 | */ |
| 9 | export function serializeLoadSubsetOptions( |
| 10 | options: LoadSubsetOptions | undefined, |
| 11 | ): string | undefined { |
| 12 | if (!options) { |
| 13 | return undefined |
| 14 | } |
| 15 | |
| 16 | const result: Record<string, unknown> = {} |
| 17 | |
| 18 | if (options.where) { |
| 19 | result.where = serializeExpression(options.where) |
| 20 | } |
| 21 | |
| 22 | if (options.orderBy?.length) { |
| 23 | result.orderBy = options.orderBy.map((clause) => { |
| 24 | const baseOrderBy = { |
| 25 | expression: serializeExpression(clause.expression), |
| 26 | direction: clause.compareOptions.direction, |
| 27 | nulls: clause.compareOptions.nulls, |
| 28 | stringSort: clause.compareOptions.stringSort, |
| 29 | } |
| 30 | |
| 31 | // Handle locale-specific options when stringSort is 'locale' |
| 32 | if (clause.compareOptions.stringSort === `locale`) { |
| 33 | return { |
| 34 | ...baseOrderBy, |
| 35 | locale: clause.compareOptions.locale, |
| 36 | localeOptions: clause.compareOptions.localeOptions, |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | return baseOrderBy |
| 41 | }) |
| 42 | } |
| 43 | |
| 44 | if (options.limit !== undefined) { |
| 45 | result.limit = options.limit |
| 46 | } |
| 47 | |
| 48 | // Include offset for pagination support |
| 49 | if (options.offset !== undefined) { |
| 50 | result.offset = options.offset |
| 51 | } |
| 52 | |
| 53 | return Object.keys(result).length === 0 ? undefined : JSON.stringify(result) |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Recursively serializes an IR expression for stable hashing |
no test coverage detected