@greatapps/common 1.1.378 → 1.1.379
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.
package/dist/infra/api/types.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/infra/api/types.ts"],"sourcesContent":["import z from 'zod';\r\n\r\nexport const PaginationParamsSchema = z.object({\
|
|
1
|
+
{"version":3,"sources":["../../../src/infra/api/types.ts"],"sourcesContent":["import z from 'zod';\r\n\r\nexport const PaginationParamsSchema = z.object({\n page: z.number().min(1).optional().default(1),\n limit: z.number().optional().default(20),\n});\n\r\nexport interface PaginationParams extends z.infer<typeof PaginationParamsSchema> {}\r\n\r\nexport const SearchParamsSchema = z.object({\r\n search: z.string().optional(),\r\n});\r\n\r\nexport interface SearchParams extends z.infer<typeof SearchParamsSchema> {}\r\n\r\nexport const SortParamsSchema = z.object({\r\n sort: z.string().optional(),\r\n});\r\n\r\nexport interface SortParams extends z.infer<typeof SortParamsSchema> {}\r\n\r\nexport interface ApiSuccessResult<T> {\r\n status: 1;\r\n data?: T;\r\n}\r\n\r\nexport interface ApiPaginatedSuccessResult<T> extends Omit<ApiSuccessResult<T>, 'data'> {\r\n data: T[];\r\n total: number;\r\n}\r\n\r\nexport interface ApiErrorResult {\r\n status: 0;\r\n message: string;\r\n}\r\n\r\nexport type ApiActionResult<T> = ApiSuccessResult<T> | ApiErrorResult;\r\nexport type ApiPaginatedActionResult<T> = ApiPaginatedSuccessResult<T> | ApiErrorResult;\r\n\r\nexport interface SuccessResult<T> {\r\n success: true;\r\n data?: T;\r\n total?: number;\r\n}\r\n\r\nexport interface PaginatedSuccessResult<T> extends Omit<SuccessResult<T>, 'data'> {\r\n data: T[];\r\n total: number;\r\n}\r\n\r\nexport interface ErrorResult {\r\n success: false;\r\n error?: string;\r\n}\r\n\r\nexport type ActionResult<T> = SuccessResult<T> | ErrorResult;\r\nexport type PaginatedActionResult<T> = PaginatedSuccessResult<T> | ErrorResult;\r\n\r\nexport class ApiError extends Error {\r\n public readonly code: string;\r\n public readonly statusCode: number;\r\n\r\n constructor(message: string, code: string = 'UNKNOWN_ERROR', statusCode: number = 500) {\r\n super(message);\r\n this.name = 'ApiError';\r\n this.code = code;\r\n this.statusCode = statusCode;\r\n }\r\n\r\n static isApiError(error: unknown): error is ApiError {\r\n return error instanceof ApiError;\r\n }\r\n}\r\n\r\nexport interface ApiResponse<T = unknown> {\r\n status: 0 | 1;\r\n message?: string;\r\n data?: T;\r\n}\r\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC5C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE;AACzC,CAAC;AAIM,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,QAAQ,EAAE,OAAO,EAAE,SAAS;AAC9B,CAAC;AAIM,MAAM,mBAAmB,EAAE,OAAO;AAAA,EACvC,MAAM,EAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;AAyCM,MAAM,iBAAiB,MAAM;AAAA,EAClB;AAAA,EACA;AAAA,EAEhB,YAAY,SAAiB,OAAe,iBAAiB,aAAqB,KAAK;AACrF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,OAAO,WAAW,OAAmC;AACnD,WAAO,iBAAiB;AAAA,EAC1B;AACF;","names":[]}
|
package/package.json
CHANGED
package/src/infra/api/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
|
|
3
|
-
export const PaginationParamsSchema = z.object({
|
|
4
|
-
page: z.number().min(1).optional().default(
|
|
5
|
-
limit: z.number().optional().default(20),
|
|
6
|
-
});
|
|
3
|
+
export const PaginationParamsSchema = z.object({
|
|
4
|
+
page: z.number().min(1).optional().default(1),
|
|
5
|
+
limit: z.number().optional().default(20),
|
|
6
|
+
});
|
|
7
7
|
|
|
8
8
|
export interface PaginationParams extends z.infer<typeof PaginationParamsSchema> {}
|
|
9
9
|
|