@temboplus/afloat 0.1.73 → 0.1.75-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.
@@ -0,0 +1,49 @@
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 +1,2 @@
1
- export * from "./common-responses.js";
1
+ export * from "./common-schemas.js";
2
2
  export * from "./base-repository.js";
@@ -0,0 +1,2 @@
1
+ export * from "./query.builder.js";
2
+ export * from "./query.types.js";
@@ -0,0 +1,71 @@
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
+ }
@@ -0,0 +1,36 @@
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temboplus/afloat",
3
- "version": "0.1.73",
3
+ "version": "0.1.75-0",
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,12 +0,0 @@
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 {};