@temboplus/afloat 0.1.74-0 → 0.1.74

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.
@@ -0,0 +1,12 @@
1
+ import type { AppRouteResponse } from "@ts-rest/core";
2
+ import { z } from "zod";
3
+ type ApiErrorResponseSchemaType = z.ZodObject<{
4
+ statusCode: z.ZodNumber;
5
+ message: z.ZodString;
6
+ error: z.ZodString;
7
+ details: z.ZodOptional<z.ZodRecord>;
8
+ }>;
9
+ export declare const common400ResponseSchema: ApiErrorResponseSchemaType;
10
+ export type Common400APIResponse = z.infer<typeof common400ResponseSchema>;
11
+ export declare const commonAPIResponses: Record<number, AppRouteResponse>;
12
+ export {};
@@ -1,2 +1,2 @@
1
- export * from "./common-schemas.js";
1
+ export * from "./common-responses.js";
2
2
  export * from "./base-repository.js";
@@ -1,5 +1,5 @@
1
1
  import { WalletStatementEntryDTO } from "@/features/wallet/wallet.dtos.js";
2
- import { Amount, AmountJson } from "@temboplus/frontend-core";
2
+ import { Amount, AmountJSON, AmountJson } from "@temboplus/frontend-core";
3
3
  import { NarrationJson, Narration } from "./narration.model.js";
4
4
  /**
5
5
  * Interface for the JSON representation of WalletStatementEntry
@@ -11,9 +11,9 @@ export interface WalletStatementEntryJson {
11
11
  narration: NarrationJson;
12
12
  txnDate: string;
13
13
  valueDate: string;
14
- amountCredited: AmountJson;
15
- amountDebited: AmountJson;
16
- balance: AmountJson;
14
+ amountCredited: AmountJSON;
15
+ amountDebited: AmountJSON;
16
+ balance: AmountJSON;
17
17
  currencyCode: string;
18
18
  version?: string;
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temboplus/afloat",
3
- "version": "0.1.74-0",
3
+ "version": "0.1.74",
4
4
  "description": "A foundational library for Temboplus-Afloat projects.",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -1,126 +0,0 @@
1
- import { QueryBuilder } from "@/lib/query/index.js";
2
- import { PayoutStatus, PayoutApprovalStatus, PayoutFilters } from "./payout.dtos.js";
3
- /**
4
- * Payout-specific query builder that extends the base QueryBuilder
5
- * and handles all possible input conversions (DTOs, URL params, etc.)
6
- */
7
- export declare class PayoutQuery extends QueryBuilder {
8
- /**
9
- * Create empty payout query with defaults
10
- */
11
- static create(): PayoutQuery;
12
- /**
13
- * Create from typed DTO/filters object
14
- */
15
- static fromFilters(filters: PayoutFilters): PayoutQuery;
16
- /**
17
- * Create from URL search parameters (strings)
18
- */
19
- static fromUrlParams(params: Record<string, string>): PayoutQuery;
20
- /**
21
- * Create from URLSearchParams object
22
- */
23
- static fromSearchParams(searchParams: URLSearchParams): PayoutQuery;
24
- /**
25
- * Create from Next.js Request object
26
- */
27
- static fromRequest(request: Request): PayoutQuery;
28
- /**
29
- * Create from any supported input type
30
- */
31
- static from(input: QueryBuilder | PayoutFilters | Record<string, string> | URLSearchParams | null | undefined): PayoutQuery;
32
- /**
33
- * Type guard for string records
34
- */
35
- private static isStringRecord;
36
- whereStatus(status: PayoutStatus): this;
37
- whereApprovalStatus(approvalStatus: PayoutApprovalStatus): this;
38
- whereChannel(channel: string): this;
39
- wherePending(): this;
40
- whereApproved(): this;
41
- whereRejected(): this;
42
- wherePaid(): this;
43
- whereFailed(): this;
44
- whereAmountBetween(min: number, max: number): this;
45
- wherePayee(payeeName: string): this;
46
- whereMsisdn(msisdn: string): this;
47
- whereProfileId(profileId: string): this;
48
- wherePartnerReference(partnerReference: string): this;
49
- whereSearch(searchTerm: string): this;
50
- /**
51
- * Apply all filters from PayoutFilters object
52
- */
53
- private applyFilters;
54
- /**
55
- * Convert to PayoutFilters DTO
56
- */
57
- toFilters(): PayoutFilters;
58
- /**
59
- * Convert to URL-safe string parameters
60
- */
61
- toUrlParams(): Record<string, string>;
62
- /**
63
- * Convert to URLSearchParams
64
- */
65
- toSearchParams(): URLSearchParams;
66
- /**
67
- * Convert to query string
68
- */
69
- toQueryString(): string;
70
- /**
71
- * Create new instance with updated pagination
72
- */
73
- withPagination(page: number, limit?: number): PayoutQuery;
74
- /**
75
- * Create new instance with updated sorting
76
- */
77
- withSorting(sortBy: string, sortOrder?: "asc" | "desc"): PayoutQuery;
78
- /**
79
- * Create new instance with date range
80
- */
81
- withDateRange(startDate?: string, endDate?: string): PayoutQuery;
82
- /**
83
- * Create new instance with status filter
84
- */
85
- withStatus(status?: PayoutStatus): PayoutQuery;
86
- /**
87
- * Create new instance with approval status filter
88
- */
89
- withApprovalStatus(approvalStatus?: PayoutApprovalStatus): PayoutQuery;
90
- /**
91
- * Create new instance with channel filter
92
- */
93
- withChannel(channel?: string): PayoutQuery;
94
- /**
95
- * Reset to first page
96
- */
97
- resetPage(): PayoutQuery;
98
- /**
99
- * Check if any filters are applied
100
- */
101
- hasFilters(): boolean;
102
- /**
103
- * Get human-readable filter descriptions
104
- */
105
- getActiveFilters(): string[];
106
- /**
107
- * Extract filter values from QueryBuilder options
108
- */
109
- private extractFilterValues;
110
- /**
111
- * Extract primary sort field
112
- */
113
- private extractSortField;
114
- /**
115
- * Extract primary sort order
116
- */
117
- private extractSortOrder;
118
- /**
119
- * Type guard for valid statuses
120
- */
121
- private isValidStatus;
122
- /**
123
- * Type guard for valid approval statuses
124
- */
125
- private isValidApprovalStatus;
126
- }
@@ -1,49 +0,0 @@
1
- import z from "zod";
2
- declare const paginationSchema: z.ZodObject<{
3
- page: z.ZodNumber;
4
- limit: z.ZodNumber;
5
- total: z.ZodNumber;
6
- totalPages: z.ZodNumber;
7
- hasNext: z.ZodBoolean;
8
- hasPrev: z.ZodBoolean;
9
- }, "strip", z.ZodTypeAny, {
10
- page: number;
11
- limit: number;
12
- total: number;
13
- totalPages: number;
14
- hasNext: boolean;
15
- hasPrev: boolean;
16
- }, {
17
- page: number;
18
- limit: number;
19
- total: number;
20
- totalPages: number;
21
- hasNext: boolean;
22
- hasPrev: boolean;
23
- }>;
24
- export declare const CommonSchemas: {
25
- pagination: z.ZodObject<{
26
- page: z.ZodNumber;
27
- limit: z.ZodNumber;
28
- total: z.ZodNumber;
29
- totalPages: z.ZodNumber;
30
- hasNext: z.ZodBoolean;
31
- hasPrev: z.ZodBoolean;
32
- }, "strip", z.ZodTypeAny, {
33
- page: number;
34
- limit: number;
35
- total: number;
36
- totalPages: number;
37
- hasNext: boolean;
38
- hasPrev: boolean;
39
- }, {
40
- page: number;
41
- limit: number;
42
- total: number;
43
- totalPages: number;
44
- hasNext: boolean;
45
- hasPrev: boolean;
46
- }>;
47
- };
48
- export type PaginationDTO = z.infer<typeof paginationSchema>;
49
- export {};
@@ -1,2 +0,0 @@
1
- export * from "./query.builder.js";
2
- export * from "./query.types.js";
@@ -1,71 +0,0 @@
1
- import { FilterCriteria, QueryOptions, SortCriteria, SortDirection } from "./query.types.js";
2
- export declare const QUERY_BUILDER_TYPE: unique symbol;
3
- export declare class QueryBuilder {
4
- readonly options: QueryOptions;
5
- constructor(options?: QueryOptions);
6
- /**
7
- * Type tag to identify QueryBuilder instances
8
- */
9
- [QUERY_BUILDER_TYPE]: string;
10
- /**
11
- * Safely check if an object is a QueryBuilder instance
12
- */
13
- static is(obj: any): obj is QueryBuilder;
14
- addFilter(criteria: FilterCriteria): this;
15
- where(field: string, value: any): this;
16
- whereNot(field: string, value: any): this;
17
- whereLike(field: string, value: string): this;
18
- whereLikeLower(field: string, value: string): this;
19
- whereContains(field: string, value: string): this;
20
- whereStartsWith(field: string, value: string): this;
21
- whereEndsWith(field: string, value: string): this;
22
- whereIn(field: string, values: any[]): this;
23
- whereNull(field: string): this;
24
- whereNotNull(field: string): this;
25
- whereGreaterThan(field: string, value: any): this;
26
- whereGreaterThanOrEqual(field: string, value: any): this;
27
- whereLessThan(field: string, value: any): this;
28
- whereLessThanOrEqual(field: string, value: any): this;
29
- whereBetween(field: string, min: any, max: any): this;
30
- whereDateBetween(startDate?: string | null, endDate?: string | null): this;
31
- addSort(criteria: SortCriteria): this;
32
- orderBy(field: string, direction?: SortDirection): this;
33
- orderByAsc(field: string): this;
34
- orderByDesc(field: string): this;
35
- paginate(page: number, limit: number): this;
36
- /**
37
- * Add eager loading for related models
38
- * @param relations Relation name or array of relation names
39
- */
40
- with(relations: string | string[]): this;
41
- /**
42
- * Add a JOIN to the query to fetch related models
43
- * @param relations Relation name or array of relation names to join
44
- */
45
- join(relations: string | string[]): this;
46
- /**
47
- * Add GROUP BY clause to the query
48
- * @param fields Field or fields to group by
49
- */
50
- groupBy(fields: string | string[]): this;
51
- /**
52
- * Enable count mode for the query
53
- * @param expression Optional count expression (defaults to '*')
54
- */
55
- count(expression?: string): this;
56
- /**
57
- * Count specific expression with alias
58
- * @param expression Expression to count
59
- * @param alias Alias for the count result
60
- */
61
- countAs(expression: string, alias: string): this;
62
- /**
63
- * @returns an objection-find query
64
- */
65
- build(): Record<string, any>;
66
- /**
67
- * Create a clone of this query builder
68
- */
69
- clone(): this;
70
- static create<T extends QueryOptions>(options?: T): QueryBuilder;
71
- }
@@ -1,36 +0,0 @@
1
- export declare enum FilterOperator {
2
- EQUALS = "eq",
3
- NOT_EQUALS = "neq",
4
- LESS_THAN = "lt",
5
- LESS_THAN_OR_EQUAL = "lte",
6
- GREATER_THAN = "gt",
7
- GREATER_THAN_OR_EQUAL = "gte",
8
- LIKE = "like",
9
- LIKE_LOWER = "likeLower",
10
- IS_NULL = "isNull",
11
- IS_NOT_NULL = "isNotNull",
12
- IN = "in"
13
- }
14
- export declare enum SortDirection {
15
- ASC = "asc",
16
- DESC = "desc"
17
- }
18
- export interface FilterCriteria {
19
- field: string;
20
- operator: FilterOperator;
21
- value?: any;
22
- }
23
- export interface SortCriteria {
24
- field: string;
25
- direction: SortDirection;
26
- }
27
- export interface QueryOptions {
28
- page?: number;
29
- limit?: number;
30
- filters?: FilterCriteria[];
31
- sort?: SortCriteria[];
32
- includes?: string[];
33
- join?: string[];
34
- groupBy?: string[];
35
- count?: string;
36
- }