@dashai/sdk 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -416,21 +416,83 @@ interface Client {
416
416
  }
417
417
  /** Custom Modules Platform v1 (P1b) — Data Hub access surface. */
418
418
  interface DatahubClient {
419
- /** Bind a Data Hub table by its numeric id. */
420
- table(tableId: number): DatahubTableClient;
419
+ /**
420
+ * Bind a Data Hub table by its numeric id. Pass a hand-written row
421
+ * interface as the type argument for typed `filter` / `sort` keys on
422
+ * `list()`; defaults to an untyped `Record` (Data Hub rows have no
423
+ * compile-time schema).
424
+ */
425
+ table<Row = Record<string, unknown>>(tableId: number): DatahubTableClient<Row>;
421
426
  }
422
427
  /** Result envelope of a Data Hub list (mirrors the backend RowQueryService). */
423
428
  interface DatahubListResult {
424
429
  results: Array<Record<string, unknown>>;
425
430
  count: number;
431
+ /**
432
+ * 1-based index of the next page, or `null` when on the last page.
433
+ * Mirrors the backend envelope (`RowQueryService.list` →
434
+ * `offset + size < count ? page + 1 : null`).
435
+ */
436
+ next: number | null;
437
+ /**
438
+ * 1-based index of the previous page, or `null` when on the first page.
439
+ * Mirrors the backend envelope (`page > 1 ? page - 1 : null`).
440
+ */
441
+ previous: number | null;
442
+ }
443
+ /**
444
+ * Typed options for {@link DatahubTableClient.list}. A higher-level
445
+ * mirror of {@link ListOpts} that the runtime compiles to the Data Hub
446
+ * bridge's flat query protocol (`filter__<field>__<op>` /
447
+ * `filters=<json>` / `order_by` / `search` / `size` / `page`).
448
+ *
449
+ * Unlike module tables, Data Hub rows have no compile-time row type, so
450
+ * `Row` defaults to a bare `Record` — pass a hand-written interface as
451
+ * the type argument for editor help on `filter` / `sort` keys.
452
+ *
453
+ * The raw `Record<string, string>` passthrough on `list()` stays
454
+ * supported for back-compat; reach for it when you need a flat param
455
+ * the typed shape doesn't model yet.
456
+ */
457
+ interface DatahubListOpts<Row = Record<string, unknown>> {
458
+ /**
459
+ * Recursive filter clause, same shape as {@link ListOpts.filter}. Top
460
+ * level keys are AND'd; bare primitives are shorthand for
461
+ * `{ equal: ... }`. Simple (non-grouped) filters compile to repeated
462
+ * `filter__<field>__<op>=<value>` params; any clause using `AND` / `OR`
463
+ * grouping compiles to a single `filters=<json>` tree param (the
464
+ * backend's Phase 9b syntax).
465
+ */
466
+ filter?: Where<Row>;
467
+ /**
468
+ * Sort order, same shape as {@link ListOpts.sort}. Compiles to the
469
+ * Data Hub `order_by` param (`-` prefix for descending), joined with
470
+ * commas for multi-field sorts.
471
+ */
472
+ sort?: SortClause<Row>[];
473
+ /** Full-text / substring search across searchable fields → `search`. */
474
+ search?: string;
475
+ /** Page size → `size`. */
476
+ limit?: number;
477
+ /** 1-based page index → `page`. */
478
+ page?: number;
426
479
  }
427
480
  /** Row CRUD against a single Data Hub table, gated by the key's grants. */
428
- interface DatahubTableClient {
481
+ interface DatahubTableClient<Row = Record<string, unknown>> {
429
482
  /**
430
- * List rows. `query` is the Baserow flat shape (e.g.
431
- * `{ size: '50', order_by: '-created_on' }`); values are strings.
483
+ * List rows. Accepts either:
484
+ * - a typed {@link DatahubListOpts} object (`{ filter, sort, search,
485
+ * limit, page }`), which the client compiles to the Data Hub
486
+ * bridge's flat query protocol; or
487
+ * - the raw Baserow flat shape (`Record<string, string>`, e.g.
488
+ * `{ size: '50', order_by: '-created_on' }`) for back-compat and
489
+ * for params the typed shape doesn't model yet.
490
+ *
491
+ * The two are distinguished structurally: an options object carrying
492
+ * any of the known `DatahubListOpts` keys is compiled; anything else
493
+ * is passed through verbatim as raw query params.
432
494
  */
433
- list(query?: Record<string, string>): Promise<DatahubListResult>;
495
+ list(opts?: DatahubListOpts<Row> | Record<string, string>): Promise<DatahubListResult>;
434
496
  get(rowId: number): Promise<Record<string, unknown>>;
435
497
  create(body: Record<string, unknown>): Promise<Record<string, unknown>>;
436
498
  update(rowId: number, body: Record<string, unknown>): Promise<Record<string, unknown>>;
@@ -439,4 +501,4 @@ interface DatahubTableClient {
439
501
  }>;
440
502
  }
441
503
 
442
- export type { BaseInsert as B, ClientConfig as C, Deps as D, FetchImpl as F, ListOpts as L, Page as P, ReadOnlyTableClient as R, SlowQueryInfo as S, TokenResolver as T, Where as W, Client as a, BaseRow as b, BaseUpdate as c, DatahubClient as d, DatahubListResult as e, DatahubTableClient as f, FileRef as g, FilterOps as h, FilterValue as i, SortClause as j, SortDir as k, TableClient as l };
504
+ export type { BaseInsert as B, ClientConfig as C, Deps as D, FetchImpl as F, ListOpts as L, Page as P, ReadOnlyTableClient as R, SlowQueryInfo as S, TokenResolver as T, Where as W, Client as a, BaseRow as b, BaseUpdate as c, DatahubClient as d, DatahubListOpts as e, DatahubListResult as f, DatahubTableClient as g, FileRef as h, FilterOps as i, FilterValue as j, SortClause as k, SortDir as l, TableClient as m };
@@ -416,21 +416,83 @@ interface Client {
416
416
  }
417
417
  /** Custom Modules Platform v1 (P1b) — Data Hub access surface. */
418
418
  interface DatahubClient {
419
- /** Bind a Data Hub table by its numeric id. */
420
- table(tableId: number): DatahubTableClient;
419
+ /**
420
+ * Bind a Data Hub table by its numeric id. Pass a hand-written row
421
+ * interface as the type argument for typed `filter` / `sort` keys on
422
+ * `list()`; defaults to an untyped `Record` (Data Hub rows have no
423
+ * compile-time schema).
424
+ */
425
+ table<Row = Record<string, unknown>>(tableId: number): DatahubTableClient<Row>;
421
426
  }
422
427
  /** Result envelope of a Data Hub list (mirrors the backend RowQueryService). */
423
428
  interface DatahubListResult {
424
429
  results: Array<Record<string, unknown>>;
425
430
  count: number;
431
+ /**
432
+ * 1-based index of the next page, or `null` when on the last page.
433
+ * Mirrors the backend envelope (`RowQueryService.list` →
434
+ * `offset + size < count ? page + 1 : null`).
435
+ */
436
+ next: number | null;
437
+ /**
438
+ * 1-based index of the previous page, or `null` when on the first page.
439
+ * Mirrors the backend envelope (`page > 1 ? page - 1 : null`).
440
+ */
441
+ previous: number | null;
442
+ }
443
+ /**
444
+ * Typed options for {@link DatahubTableClient.list}. A higher-level
445
+ * mirror of {@link ListOpts} that the runtime compiles to the Data Hub
446
+ * bridge's flat query protocol (`filter__<field>__<op>` /
447
+ * `filters=<json>` / `order_by` / `search` / `size` / `page`).
448
+ *
449
+ * Unlike module tables, Data Hub rows have no compile-time row type, so
450
+ * `Row` defaults to a bare `Record` — pass a hand-written interface as
451
+ * the type argument for editor help on `filter` / `sort` keys.
452
+ *
453
+ * The raw `Record<string, string>` passthrough on `list()` stays
454
+ * supported for back-compat; reach for it when you need a flat param
455
+ * the typed shape doesn't model yet.
456
+ */
457
+ interface DatahubListOpts<Row = Record<string, unknown>> {
458
+ /**
459
+ * Recursive filter clause, same shape as {@link ListOpts.filter}. Top
460
+ * level keys are AND'd; bare primitives are shorthand for
461
+ * `{ equal: ... }`. Simple (non-grouped) filters compile to repeated
462
+ * `filter__<field>__<op>=<value>` params; any clause using `AND` / `OR`
463
+ * grouping compiles to a single `filters=<json>` tree param (the
464
+ * backend's Phase 9b syntax).
465
+ */
466
+ filter?: Where<Row>;
467
+ /**
468
+ * Sort order, same shape as {@link ListOpts.sort}. Compiles to the
469
+ * Data Hub `order_by` param (`-` prefix for descending), joined with
470
+ * commas for multi-field sorts.
471
+ */
472
+ sort?: SortClause<Row>[];
473
+ /** Full-text / substring search across searchable fields → `search`. */
474
+ search?: string;
475
+ /** Page size → `size`. */
476
+ limit?: number;
477
+ /** 1-based page index → `page`. */
478
+ page?: number;
426
479
  }
427
480
  /** Row CRUD against a single Data Hub table, gated by the key's grants. */
428
- interface DatahubTableClient {
481
+ interface DatahubTableClient<Row = Record<string, unknown>> {
429
482
  /**
430
- * List rows. `query` is the Baserow flat shape (e.g.
431
- * `{ size: '50', order_by: '-created_on' }`); values are strings.
483
+ * List rows. Accepts either:
484
+ * - a typed {@link DatahubListOpts} object (`{ filter, sort, search,
485
+ * limit, page }`), which the client compiles to the Data Hub
486
+ * bridge's flat query protocol; or
487
+ * - the raw Baserow flat shape (`Record<string, string>`, e.g.
488
+ * `{ size: '50', order_by: '-created_on' }`) for back-compat and
489
+ * for params the typed shape doesn't model yet.
490
+ *
491
+ * The two are distinguished structurally: an options object carrying
492
+ * any of the known `DatahubListOpts` keys is compiled; anything else
493
+ * is passed through verbatim as raw query params.
432
494
  */
433
- list(query?: Record<string, string>): Promise<DatahubListResult>;
495
+ list(opts?: DatahubListOpts<Row> | Record<string, string>): Promise<DatahubListResult>;
434
496
  get(rowId: number): Promise<Record<string, unknown>>;
435
497
  create(body: Record<string, unknown>): Promise<Record<string, unknown>>;
436
498
  update(rowId: number, body: Record<string, unknown>): Promise<Record<string, unknown>>;
@@ -439,4 +501,4 @@ interface DatahubTableClient {
439
501
  }>;
440
502
  }
441
503
 
442
- export type { BaseInsert as B, ClientConfig as C, Deps as D, FetchImpl as F, ListOpts as L, Page as P, ReadOnlyTableClient as R, SlowQueryInfo as S, TokenResolver as T, Where as W, Client as a, BaseRow as b, BaseUpdate as c, DatahubClient as d, DatahubListResult as e, DatahubTableClient as f, FileRef as g, FilterOps as h, FilterValue as i, SortClause as j, SortDir as k, TableClient as l };
504
+ export type { BaseInsert as B, ClientConfig as C, Deps as D, FetchImpl as F, ListOpts as L, Page as P, ReadOnlyTableClient as R, SlowQueryInfo as S, TokenResolver as T, Where as W, Client as a, BaseRow as b, BaseUpdate as c, DatahubClient as d, DatahubListOpts as e, DatahubListResult as f, DatahubTableClient as g, FileRef as h, FilterOps as i, FilterValue as j, SortClause as k, SortDir as l, TableClient as m };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashai/sdk",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Runtime client for DashWise: typed data access + auth helpers for modules.",
5
5
  "license": "MIT",
6
6
  "type": "module",