@temboplus/tembo-dashboard 0.0.8 → 0.0.10

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.
@@ -1,12 +1,12 @@
1
1
  import { BaseRepository, PaginationDTO, WalletSummaryDTO } from "@/lib/api";
2
2
  import { collectionContract } from "./collection.api-contract";
3
- import { type CollectionQueryParamsDTO } from "./collection.dtos";
4
3
  import { Collection } from "./collection.model";
5
4
  import { CollectionQueryBuilder } from "./collection.query-builder";
5
+ import { CollectionQueryParams } from "./collection.query-params.model";
6
6
  /**
7
- * Flexible query input type - supports both string-based URL params and typed DTO
7
+ * Flexible query input type - supports the class, DTO, URL params, etc.
8
8
  */
9
- export type CollectionQueryInput = CollectionQueryParamsDTO | Record<string, string> | URLSearchParams | null | undefined;
9
+ export type CollectionQueryInput = CollectionQueryParams | Parameters<typeof CollectionQueryParams.from>[0];
10
10
  /**
11
11
  * Repository class for managing collections through API interactions.
12
12
  * Handles collection operations, filtering, and summary data retrieval.
@@ -18,36 +18,12 @@ export declare class CollectionRepository extends BaseRepository<typeof collecti
18
18
  root?: string;
19
19
  });
20
20
  /**
21
- * Converts various query input types to a standardized CollectionQueryParamsDTO.
22
- * This method handles the heavy lifting of parameter conversion and validation.
23
- *
24
- * @param query - Query parameters in various formats (DTO, URLSearchParams, string record, etc.)
25
- * @returns Validated and typed CollectionQueryParamsDTO
26
- *
27
- * @example
28
- * ```typescript
29
- * // Works with URL search params
30
- * const urlParams = new URLSearchParams("page=1&limit=20&status=PAYMENT_ACCEPTED");
31
- * const dto = repository.normalizeQueryParams(urlParams);
32
- *
33
- * // Works with string record
34
- * const stringParams = { page: "1", limit: "20", status: "PAYMENT_ACCEPTED" };
35
- * const dto2 = repository.normalizeQueryParams(stringParams);
36
- *
37
- * // Works with typed DTO
38
- * const typedParams: CollectionQueryParamsDTO = { page: 1, limit: 20 };
39
- * const dto3 = repository.normalizeQueryParams(typedParams);
40
- * ```
21
+ * Normalize query input to CollectionQueryParams class instance
22
+ * @param query - Any supported query input type
23
+ * @returns CollectionQueryParams instance
24
+ * @throws Error if validation fails
41
25
  */
42
26
  private normalizeQueryParams;
43
- /**
44
- * Type guard to check if input is a string-based record (from URL params)
45
- */
46
- private isStringRecord;
47
- /**
48
- * Type guard to check if input is a typed DTO
49
- */
50
- private isTypedDTO;
51
27
  /**
52
28
  * Get all collections with filtering and pagination.
53
29
  * Supports flexible input types: typed DTO, URL search params, or string records.
@@ -4,3 +4,4 @@ export * from "./collection.model";
4
4
  export * from "./collection.query-builder";
5
5
  export * from "./collection.repository";
6
6
  export * from "./collection.utils";
7
+ export * from "./collection.query-params.model";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temboplus/tembo-dashboard",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "A foundational library for Temboplus-Dashboard projects providing type-safe data layer abstraction with API contracts, domain models, and repositories.",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",