| 431 | } |
| 432 | |
| 433 | function buildOrder(opts: LoadSubsetOptions): undefined | Array<string> { |
| 434 | return opts.orderBy |
| 435 | ?.map((o: OrderByClause) => { |
| 436 | switch (o.expression.type) { |
| 437 | case 'ref': { |
| 438 | const field = o.expression.path[0] |
| 439 | if (o.compareOptions.direction == 'asc') { |
| 440 | return `+${field}` |
| 441 | } |
| 442 | return `-${field}` |
| 443 | } |
| 444 | default: { |
| 445 | console.warn( |
| 446 | 'Skipping unsupported order clause:', |
| 447 | JSON.stringify(o.expression), |
| 448 | ) |
| 449 | return undefined |
| 450 | } |
| 451 | } |
| 452 | }) |
| 453 | .filter((f: string | undefined) => f !== undefined) |
| 454 | } |
| 455 | |
| 456 | function buildCompareOp(name: string): CompareOp | undefined { |
| 457 | switch (name) { |