|
| 1 | +// ─── CRUD types mirroring the Dynamia Platform Java model ─────────────────── |
| 2 | + |
| 3 | +/** |
| 4 | + * Maps to Java `DataPaginator` — serialized as the `pageable` field inside `ListResult`. |
| 5 | + * |
| 6 | + * Java source: `tools.dynamia.domain.query.DataPaginator` |
| 7 | + * |
| 8 | + * | Java field | Java type | JSON key | |
| 9 | + * |-----------------|-----------|----------------| |
| 10 | + * | `totalSize` | `long` | `totalSize` | |
| 11 | + * | `pageSize` | `int` | `pageSize` | |
| 12 | + * | `firstResult` | `int` | `firstResult` | |
| 13 | + * | `page` | `int` | `page` | |
| 14 | + * | `pagesNumber` | `int` | `pagesNumber` | |
| 15 | + */ |
| 16 | +export interface CrudPageable { |
| 17 | + /** Total number of records across all pages (`DataPaginator.totalSize` — Java `long`) */ |
| 18 | + totalSize: number; |
| 19 | + /** Number of records per page (`DataPaginator.pageSize` — default 30) */ |
| 20 | + pageSize: number; |
| 21 | + /** Zero-based offset of the first record on this page (`DataPaginator.firstResult`) */ |
| 22 | + firstResult: number; |
| 23 | + /** Current 1-based page number (`DataPaginator.page`) */ |
| 24 | + page: number; |
| 25 | + /** Total number of pages (`DataPaginator.pagesNumber`) */ |
| 26 | + pagesNumber: number; |
| 27 | +} |
| 28 | + |
| 29 | +/** |
| 30 | + * Raw envelope returned by `RestNavigationContext.ListResult`. |
| 31 | + * |
| 32 | + * Java source: `tools.dynamia.web.navigation.RestNavigationContext.ListResult` |
| 33 | + * |
| 34 | + * | Java field | Annotation | JSON key | |
| 35 | + * |-------------|------------------------------------|------------| |
| 36 | + * | `data` | — | `data` | |
| 37 | + * | `pageable` | `@JsonInclude(NON_NULL)` — nullable | `pageable` | |
| 38 | + * | `response` | — | `response` | |
| 39 | + * |
| 40 | + * `pageable` is `null` when the result is not paginated (e.g. a flat list endpoint). |
| 41 | + */ |
| 42 | +export interface CrudRawResponse<T = unknown> { |
| 43 | + /** The page records */ |
| 44 | + data: T[]; |
| 45 | + /** |
| 46 | + * Pagination metadata. `null` when the response is not paginated |
| 47 | + * (`@JsonInclude(JsonInclude.Include.NON_NULL)` in Java — field may be absent from JSON). |
| 48 | + */ |
| 49 | + pageable: CrudPageable | null; |
| 50 | + /** Status string, typically `"OK"` */ |
| 51 | + response: string; |
| 52 | +} |
| 53 | + |
| 54 | +/** |
| 55 | + * Normalised result returned by all SDK `CrudResourceApi.findAll()` calls. |
| 56 | + * The SDK maps `CrudRawResponse` → `CrudListResult` so consumers never deal with the raw envelope. |
| 57 | + */ |
| 58 | +export interface CrudListResult<T = unknown> { |
| 59 | + /** The records for this page */ |
| 60 | + content: T[]; |
| 61 | + /** Total number of records across all pages (`DataPaginator.totalSize`) */ |
| 62 | + total: number; |
| 63 | + /** Current 1-based page number (`DataPaginator.page`) */ |
| 64 | + page: number; |
| 65 | + /** Number of records per page (`DataPaginator.pageSize`) */ |
| 66 | + pageSize: number; |
| 67 | + /** Total number of pages (`DataPaginator.pagesNumber`) */ |
| 68 | + totalPages: number; |
| 69 | +} |
| 70 | + |
| 71 | +export type CrudQueryParams = Record<string, string | number | boolean | undefined | null>; |
0 commit comments