@angelps/prisma-query-builder 0.1.1
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/README.md +709 -0
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/valibot.adapter.d.ts +14 -0
- package/dist/adapters/valibot.adapter.d.ts.map +1 -0
- package/dist/adapters/valibot.adapter.js +21 -0
- package/dist/adapters/valibot.adapter.js.map +1 -0
- package/dist/adapters/zod.adapter.d.ts +29 -0
- package/dist/adapters/zod.adapter.d.ts.map +1 -0
- package/dist/adapters/zod.adapter.js +42 -0
- package/dist/adapters/zod.adapter.js.map +1 -0
- package/dist/controllers/generic.controller.d.ts +79 -0
- package/dist/controllers/generic.controller.d.ts.map +1 -0
- package/dist/controllers/generic.controller.js +279 -0
- package/dist/controllers/generic.controller.js.map +1 -0
- package/dist/controllers/index.d.ts +2 -0
- package/dist/controllers/index.d.ts.map +1 -0
- package/dist/controllers/index.js +2 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/errors/app-errors.d.ts +17 -0
- package/dist/errors/app-errors.d.ts.map +1 -0
- package/dist/errors/app-errors.js +28 -0
- package/dist/errors/app-errors.js.map +1 -0
- package/dist/errors/error-messages.d.ts +80 -0
- package/dist/errors/error-messages.d.ts.map +1 -0
- package/dist/errors/error-messages.js +75 -0
- package/dist/errors/error-messages.js.map +1 -0
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +3 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/query-builder/helpers/order-by.helper.d.ts +4 -0
- package/dist/query-builder/helpers/order-by.helper.d.ts.map +1 -0
- package/dist/query-builder/helpers/order-by.helper.js +24 -0
- package/dist/query-builder/helpers/order-by.helper.js.map +1 -0
- package/dist/query-builder/helpers/pagination.helper.d.ts +6 -0
- package/dist/query-builder/helpers/pagination.helper.d.ts.map +1 -0
- package/dist/query-builder/helpers/pagination.helper.js +9 -0
- package/dist/query-builder/helpers/pagination.helper.js.map +1 -0
- package/dist/query-builder/helpers/where.helper.d.ts +5 -0
- package/dist/query-builder/helpers/where.helper.d.ts.map +1 -0
- package/dist/query-builder/helpers/where.helper.js +356 -0
- package/dist/query-builder/helpers/where.helper.js.map +1 -0
- package/dist/query-builder/index.d.ts +3 -0
- package/dist/query-builder/index.d.ts.map +1 -0
- package/dist/query-builder/index.js +3 -0
- package/dist/query-builder/index.js.map +1 -0
- package/dist/query-builder/query-builder.d.ts +56 -0
- package/dist/query-builder/query-builder.d.ts.map +1 -0
- package/dist/query-builder/query-builder.js +149 -0
- package/dist/query-builder/query-builder.js.map +1 -0
- package/dist/query-builder/query-builder.types.d.ts +83 -0
- package/dist/query-builder/query-builder.types.d.ts.map +1 -0
- package/dist/query-builder/query-builder.types.js +2 -0
- package/dist/query-builder/query-builder.types.js.map +1 -0
- package/dist/repositories/crud.repository.prisma.d.ts +44 -0
- package/dist/repositories/crud.repository.prisma.d.ts.map +1 -0
- package/dist/repositories/crud.repository.prisma.js +246 -0
- package/dist/repositories/crud.repository.prisma.js.map +1 -0
- package/dist/repositories/index.d.ts +2 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +2 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/services/audit.service.d.ts +32 -0
- package/dist/services/audit.service.d.ts.map +1 -0
- package/dist/services/audit.service.js +57 -0
- package/dist/services/audit.service.js.map +1 -0
- package/dist/services/error-handler.service.d.ts +34 -0
- package/dist/services/error-handler.service.d.ts.map +1 -0
- package/dist/services/error-handler.service.js +159 -0
- package/dist/services/error-handler.service.js.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +3 -0
- package/dist/services/index.js.map +1 -0
- package/dist/types/crud-config.d.ts +20 -0
- package/dist/types/crud-config.d.ts.map +1 -0
- package/dist/types/crud-config.js +2 -0
- package/dist/types/crud-config.js.map +1 -0
- package/dist/types/generic-repository.d.ts +36 -0
- package/dist/types/generic-repository.d.ts.map +1 -0
- package/dist/types/generic-repository.js +2 -0
- package/dist/types/generic-repository.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/logger.d.ts +17 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/logger.js +8 -0
- package/dist/types/logger.js.map +1 -0
- package/dist/types/pagination.d.ts +11 -0
- package/dist/types/pagination.d.ts.map +1 -0
- package/dist/types/pagination.js +2 -0
- package/dist/types/pagination.js.map +1 -0
- package/dist/types/prisma-delegate.types.d.ts +36 -0
- package/dist/types/prisma-delegate.types.d.ts.map +1 -0
- package/dist/types/prisma-delegate.types.js +15 -0
- package/dist/types/prisma-delegate.types.js.map +1 -0
- package/dist/types/query-params.d.ts +40 -0
- package/dist/types/query-params.d.ts.map +1 -0
- package/dist/types/query-params.js +2 -0
- package/dist/types/query-params.js.map +1 -0
- package/dist/types/schema-adapter.d.ts +19 -0
- package/dist/types/schema-adapter.d.ts.map +1 -0
- package/dist/types/schema-adapter.js +2 -0
- package/dist/types/schema-adapter.js.map +1 -0
- package/dist/utils/date.utils.d.ts +13 -0
- package/dist/utils/date.utils.d.ts.map +1 -0
- package/dist/utils/date.utils.js +75 -0
- package/dist/utils/date.utils.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/phone.utils.d.ts +7 -0
- package/dist/utils/phone.utils.d.ts.map +1 -0
- package/dist/utils/phone.utils.js +15 -0
- package/dist/utils/phone.utils.js.map +1 -0
- package/dist/utils/response.utils.d.ts +5 -0
- package/dist/utils/response.utils.d.ts.map +1 -0
- package/dist/utils/response.utils.js +13 -0
- package/dist/utils/response.utils.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PaginationModel } from './pagination.js';
|
|
2
|
+
import { QueryParams } from './query-params.js';
|
|
3
|
+
export type RepositoryOptions = {
|
|
4
|
+
userId?: number;
|
|
5
|
+
companyId?: number;
|
|
6
|
+
requestId?: string;
|
|
7
|
+
ip?: string;
|
|
8
|
+
userAgent?: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
method?: string;
|
|
11
|
+
};
|
|
12
|
+
/** Extra options for findById — allows dynamic include/select. */
|
|
13
|
+
export type FindByIdOptions = RepositoryOptions & {
|
|
14
|
+
include?: Record<string, boolean | object>;
|
|
15
|
+
select?: Record<string, boolean>;
|
|
16
|
+
};
|
|
17
|
+
export interface IGenericRepository<T> {
|
|
18
|
+
findAll(queryParams?: QueryParams, options?: RepositoryOptions): Promise<PaginationModel<T>>;
|
|
19
|
+
findById(id: number, options?: FindByIdOptions): Promise<T | null>;
|
|
20
|
+
create(data: unknown, options?: RepositoryOptions): Promise<T>;
|
|
21
|
+
update(id: number, data: unknown, options?: RepositoryOptions): Promise<void>;
|
|
22
|
+
delete(id: number, options?: RepositoryOptions): Promise<void>;
|
|
23
|
+
createMany(data: unknown[], options?: RepositoryOptions): Promise<{
|
|
24
|
+
count: number;
|
|
25
|
+
}>;
|
|
26
|
+
updateMany(ids: number[], data: unknown, options?: RepositoryOptions): Promise<{
|
|
27
|
+
count: number;
|
|
28
|
+
}>;
|
|
29
|
+
deleteMany(ids: number[], options?: RepositoryOptions): Promise<{
|
|
30
|
+
count: number;
|
|
31
|
+
}>;
|
|
32
|
+
findOne(where: Partial<T>, options?: RepositoryOptions): Promise<T | null>;
|
|
33
|
+
upsert(data: unknown, options?: RepositoryOptions): Promise<T>;
|
|
34
|
+
[x: string]: any;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=generic-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic-repository.d.ts","sourceRoot":"","sources":["../../src/types/generic-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,OAAO,CACL,WAAW,CAAC,EAAE,WAAW,EACzB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACnE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC/D,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAG/D,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrF,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnF,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3E,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE/D,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic-repository.js","sourceRoot":"","sources":["../../src/types/generic-repository.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './query-params.js';
|
|
2
|
+
export * from './pagination.js';
|
|
3
|
+
export * from './crud-config.js';
|
|
4
|
+
export * from './generic-repository.js';
|
|
5
|
+
export * from './prisma-delegate.types.js';
|
|
6
|
+
export * from './logger.js';
|
|
7
|
+
export * from './schema-adapter.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './query-params.js';
|
|
2
|
+
export * from './pagination.js';
|
|
3
|
+
export * from './crud-config.js';
|
|
4
|
+
export * from './generic-repository.js';
|
|
5
|
+
export * from './prisma-delegate.types.js';
|
|
6
|
+
export * from './logger.js';
|
|
7
|
+
export * from './schema-adapter.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injectable logger interface.
|
|
3
|
+
*
|
|
4
|
+
* Replace `console.*` calls with an injectable logger so consumers can
|
|
5
|
+
* plug in winston, pino, or any other logging library.
|
|
6
|
+
*
|
|
7
|
+
* By default the library uses `console.*` — no external dependency required.
|
|
8
|
+
*/
|
|
9
|
+
export interface Logger {
|
|
10
|
+
warn(message: string, ...args: unknown[]): void;
|
|
11
|
+
error(message: string, ...args: unknown[]): void;
|
|
12
|
+
info(message: string, ...args: unknown[]): void;
|
|
13
|
+
debug(message: string, ...args: unknown[]): void;
|
|
14
|
+
}
|
|
15
|
+
/** Default logger that delegates to the global console. */
|
|
16
|
+
export declare const defaultLogger: Logger;
|
|
17
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAClD;AAED,2DAA2D;AAC3D,eAAO,MAAM,aAAa,EAAE,MAK3B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Default logger that delegates to the global console. */
|
|
2
|
+
export const defaultLogger = {
|
|
3
|
+
warn: (...args) => console.warn(...args),
|
|
4
|
+
error: (...args) => console.error(...args),
|
|
5
|
+
info: (...args) => console.info(...args),
|
|
6
|
+
debug: (...args) => console.debug(...args),
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":"AAeA,2DAA2D;AAC3D,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACxC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAC1C,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACxC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;CAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/types/pagination.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC/B,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/types/pagination.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility types to infer Prisma model types from a delegate.
|
|
3
|
+
*
|
|
4
|
+
* This allows users to pass `typeof prisma.user` and automatically
|
|
5
|
+
* have TResult, TWhere, TOrderBy, and TFindManyArgs inferred.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* type Result = InferResult<typeof prisma.user>; // User
|
|
10
|
+
* type Where = InferWhere<typeof prisma.user>; // Prisma.UserWhereInput
|
|
11
|
+
* type OrderBy = InferOrderBy<typeof prisma.user>; // Prisma.UserOrderByWithRelationInput
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
type AnyFn = (...args: any[]) => any;
|
|
15
|
+
/** Infers the model result type from a Prisma delegate's `findMany` return. */
|
|
16
|
+
export type InferResult<D> = D extends {
|
|
17
|
+
findMany: AnyFn;
|
|
18
|
+
} ? Awaited<ReturnType<D['findMany']>> extends (infer T)[] ? T : never : never;
|
|
19
|
+
/** Infers the WhereInput type from a Prisma delegate's `findMany` args. */
|
|
20
|
+
export type InferWhere<D> = D extends {
|
|
21
|
+
findMany(args?: infer A): any;
|
|
22
|
+
} ? A extends {
|
|
23
|
+
where?: infer W | undefined;
|
|
24
|
+
} ? NonNullable<W> : never : never;
|
|
25
|
+
/** Infers the OrderByInput type from a Prisma delegate's `findMany` args. */
|
|
26
|
+
export type InferOrderBy<D> = D extends {
|
|
27
|
+
findMany(args?: infer A): any;
|
|
28
|
+
} ? A extends {
|
|
29
|
+
orderBy?: infer O | undefined;
|
|
30
|
+
} ? NonNullable<O> : never : never;
|
|
31
|
+
/** Infers the full FindManyArgs type from a Prisma delegate. */
|
|
32
|
+
export type InferFindManyArgs<D> = D extends {
|
|
33
|
+
findMany(args?: infer A): any;
|
|
34
|
+
} ? NonNullable<A> : never;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=prisma-delegate.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-delegate.types.d.ts","sourceRoot":"","sources":["../../src/types/prisma-delegate.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,KAAK,KAAK,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAErC,+EAA+E;AAC/E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,QAAQ,EAAE,KAAK,CAAA;CAAE,GACtD,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACpD,CAAC,GACD,KAAK,GACP,KAAK,CAAC;AAEV,2EAA2E;AAC3E,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC;CAC/B,GACG,CAAC,SAAS;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;CAAE,GACvC,WAAW,CAAC,CAAC,CAAC,GACd,KAAK,GACP,KAAK,CAAC;AAEV,6EAA6E;AAC7E,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC;CAC/B,GACG,CAAC,SAAS;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;CAAE,GACzC,WAAW,CAAC,CAAC,CAAC,GACd,KAAK,GACP,KAAK,CAAC;AAEV,gEAAgE;AAChE,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC;CAC/B,GACG,WAAW,CAAC,CAAC,CAAC,GACd,KAAK,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility types to infer Prisma model types from a delegate.
|
|
3
|
+
*
|
|
4
|
+
* This allows users to pass `typeof prisma.user` and automatically
|
|
5
|
+
* have TResult, TWhere, TOrderBy, and TFindManyArgs inferred.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* type Result = InferResult<typeof prisma.user>; // User
|
|
10
|
+
* type Where = InferWhere<typeof prisma.user>; // Prisma.UserWhereInput
|
|
11
|
+
* type OrderBy = InferOrderBy<typeof prisma.user>; // Prisma.UserOrderByWithRelationInput
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=prisma-delegate.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-delegate.types.js","sourceRoot":"","sources":["../../src/types/prisma-delegate.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base query parameters shared by all paginated endpoints.
|
|
3
|
+
*/
|
|
4
|
+
export type BaseQueryParams = {
|
|
5
|
+
page?: number | string;
|
|
6
|
+
size?: number | string;
|
|
7
|
+
sort?: string;
|
|
8
|
+
search?: string;
|
|
9
|
+
from?: string;
|
|
10
|
+
to?: string;
|
|
11
|
+
notLike?: string;
|
|
12
|
+
greaterThan?: number | string;
|
|
13
|
+
lessThan?: number | string;
|
|
14
|
+
/** Cursor for cursor-based pagination (last seen ID). */
|
|
15
|
+
cursor?: string | number;
|
|
16
|
+
/**
|
|
17
|
+
* Comma-separated list of fields to return (Prisma `select`).
|
|
18
|
+
* Ignored when `extraArgs` already contains `select` or `include`.
|
|
19
|
+
* @example `fields=id,name,email`
|
|
20
|
+
*/
|
|
21
|
+
fields?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Full query parameters type.
|
|
25
|
+
*
|
|
26
|
+
* When `T` is provided, the filterable model fields get proper type-checking.
|
|
27
|
+
* The index signature is kept for backwards compatibility and for dynamic
|
|
28
|
+
* params like nested filters (`orders.status`) or operator suffixes (`price_gte`).
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* type UserQuery = QueryParams<User>; // page, size, ... + User fields
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export type QueryParams<T = Record<string, unknown>> = BaseQueryParams & {
|
|
36
|
+
[K in keyof T]?: T[K] | string;
|
|
37
|
+
} & {
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=query-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../src/types/query-params.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,eAAe,GACpE;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM;CAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-params.js","sourceRoot":"","sources":["../../src/types/query-params.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema adapter interface — decouples validation from a specific library.
|
|
3
|
+
*
|
|
4
|
+
* The default implementation uses Valibot, but consumers can provide
|
|
5
|
+
* their own adapter for Zod, Yup, or any other validation library.
|
|
6
|
+
*/
|
|
7
|
+
export interface SchemaAdapter {
|
|
8
|
+
/**
|
|
9
|
+
* Parse and validate `data` against `schema`.
|
|
10
|
+
* Must throw on validation failure (the error will be caught by ErrorHandlerService).
|
|
11
|
+
*/
|
|
12
|
+
parse<T = unknown>(schema: unknown, data: unknown): T;
|
|
13
|
+
/**
|
|
14
|
+
* Returns `true` if `schema` looks like a valid schema object for this adapter.
|
|
15
|
+
* Used to guard against missing / empty schema definitions.
|
|
16
|
+
*/
|
|
17
|
+
isValidSchema(schema: unknown): boolean;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=schema-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-adapter.d.ts","sourceRoot":"","sources":["../../src/types/schema-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC,CAAC;IAEtD;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-adapter.js","sourceRoot":"","sources":["../../src/types/schema-adapter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function startDateOfDay(date?: string): string;
|
|
2
|
+
export declare function endDateOfDay(date?: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Formatea una fecha a "DD-MM-YYYY" o "YYYY-MM-DD", opcionalmente incluye la hora "HH:MM"
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatDate(timeInput: string | Date, format?: 'DD-MM-YYYY' | 'YYYY-MM-DD', showTime?: boolean): string;
|
|
7
|
+
export declare function getTimeFromDateString(date: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Formatea una fecha o cadena de fecha a una hora específica ("HH:MM") según la zona horaria indicada.
|
|
10
|
+
* Por defecto usa "America/Santo_Domingo".
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatTimeWithTimezone(dateInput: string | Date, timeZone?: string): string;
|
|
13
|
+
//# sourceMappingURL=date.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.utils.d.ts","sourceRoot":"","sources":["../../src/utils/date.utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAQlD;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,MAAM,GAAE,YAAY,GAAG,YAA2B,EAClD,QAAQ,UAAQ,GACf,MAAM,CAmBR;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS1D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,QAAQ,GAAE,MAAgC,GACzC,MAAM,CAcR"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ErrorMessages } from '../errors/error-messages.js';
|
|
2
|
+
export function startDateOfDay(date) {
|
|
3
|
+
try {
|
|
4
|
+
const startDate = new Date(date ?? '');
|
|
5
|
+
const formattedDate = startDate.toISOString().split('T')[0];
|
|
6
|
+
return formattedDate + 'T00:00:00.000Z';
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
throw new Error(ErrorMessages.INVALID_DATE.message);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function endDateOfDay(date) {
|
|
13
|
+
try {
|
|
14
|
+
const endDate = new Date(date ?? '');
|
|
15
|
+
const formattedDate = endDate.toISOString().split('T')[0];
|
|
16
|
+
return formattedDate + 'T23:59:59.999Z';
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
throw new Error(ErrorMessages.INVALID_DATE.message);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Formatea una fecha a "DD-MM-YYYY" o "YYYY-MM-DD", opcionalmente incluye la hora "HH:MM"
|
|
24
|
+
*/
|
|
25
|
+
export function formatDate(timeInput, format = 'DD-MM-YYYY', showTime = false) {
|
|
26
|
+
if (!timeInput)
|
|
27
|
+
return '';
|
|
28
|
+
const date = new Date(timeInput);
|
|
29
|
+
const day = String(date.getUTCDate()).padStart(2, '0');
|
|
30
|
+
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
|
31
|
+
const year = date.getUTCFullYear();
|
|
32
|
+
let formattedDate = format === 'YYYY-MM-DD'
|
|
33
|
+
? `${year}-${month}-${day}`
|
|
34
|
+
: `${day}-${month}-${year}`;
|
|
35
|
+
if (showTime) {
|
|
36
|
+
const hours = String(date.getUTCHours()).padStart(2, '0');
|
|
37
|
+
const minutes = String(date.getUTCMinutes()).padStart(2, '0');
|
|
38
|
+
formattedDate += ` ${hours}:${minutes}`;
|
|
39
|
+
}
|
|
40
|
+
return formattedDate;
|
|
41
|
+
}
|
|
42
|
+
export function getTimeFromDateString(date) {
|
|
43
|
+
try {
|
|
44
|
+
const time = date.split('T')[1];
|
|
45
|
+
const [hours, minutes] = time.split(':');
|
|
46
|
+
return `${hours}:${minutes}`;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
console.error('Invalid date format');
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Formatea una fecha o cadena de fecha a una hora específica ("HH:MM") según la zona horaria indicada.
|
|
55
|
+
* Por defecto usa "America/Santo_Domingo".
|
|
56
|
+
*/
|
|
57
|
+
export function formatTimeWithTimezone(dateInput, timeZone = 'America/Santo_Domingo') {
|
|
58
|
+
try {
|
|
59
|
+
if (!dateInput)
|
|
60
|
+
return '';
|
|
61
|
+
const date = new Date(dateInput);
|
|
62
|
+
if (isNaN(date.getTime()))
|
|
63
|
+
return '';
|
|
64
|
+
return new Intl.DateTimeFormat('en-US', {
|
|
65
|
+
hour: '2-digit',
|
|
66
|
+
minute: '2-digit',
|
|
67
|
+
hour12: false,
|
|
68
|
+
timeZone,
|
|
69
|
+
}).format(date);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=date.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.utils.js","sourceRoot":"","sources":["../../src/utils/date.utils.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type CountryCode } from 'libphonenumber-js';
|
|
2
|
+
export declare function extractCountryCodeAndNumber(phone: string, defaultCountry?: CountryCode): {
|
|
3
|
+
prefix: string | null;
|
|
4
|
+
number: string;
|
|
5
|
+
country: CountryCode;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=phone.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone.utils.d.ts","sourceRoot":"","sources":["../../src/utils/phone.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAA6B,MAAM,mBAAmB,CAAC;AAEhF,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,cAAc,GAAE,WAAkB,GACjC;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAWjE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { parsePhoneNumberWithError } from 'libphonenumber-js';
|
|
2
|
+
export function extractCountryCodeAndNumber(phone, defaultCountry = 'DO') {
|
|
3
|
+
try {
|
|
4
|
+
const phoneNumber = parsePhoneNumberWithError(phone, defaultCountry);
|
|
5
|
+
return {
|
|
6
|
+
prefix: `+${phoneNumber.countryCallingCode}`,
|
|
7
|
+
number: phoneNumber.nationalNumber,
|
|
8
|
+
country: (phoneNumber.country ?? defaultCountry),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return { prefix: null, number: phone, country: defaultCountry };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=phone.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone.utils.js","sourceRoot":"","sources":["../../src/utils/phone.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEhF,MAAM,UAAU,2BAA2B,CACzC,KAAa,EACb,iBAA8B,IAAI;IAElC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,yBAAyB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QACrE,OAAO;YACL,MAAM,EAAE,IAAI,WAAW,CAAC,kBAAkB,EAAE;YAC5C,MAAM,EAAE,WAAW,CAAC,cAAc;YAClC,OAAO,EAAE,CAAC,WAAW,CAAC,OAAO,IAAI,cAAc,CAAgB;SAChE,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IAClE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Response } from 'express';
|
|
2
|
+
import type { PaginationModel } from '../types/pagination.js';
|
|
3
|
+
export declare function apiPaginationResponse<T>(res: Response, data: PaginationModel<T>, message?: string, status?: number): void;
|
|
4
|
+
export declare function apiResponse<T>(res: Response, data: T, message?: string, status?: number): void;
|
|
5
|
+
//# sourceMappingURL=response.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.utils.d.ts","sourceRoot":"","sources":["../../src/utils/response.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EACxB,OAAO,SAAK,EACZ,MAAM,SAAM,GACX,IAAI,CAQN;AAED,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,SAAM,GACX,IAAI,CAEN"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function apiPaginationResponse(res, data, message = '', status = 200) {
|
|
2
|
+
res.status(status).json({
|
|
3
|
+
data: data.items,
|
|
4
|
+
total: data.total ?? undefined,
|
|
5
|
+
metadata: { pagination: data.pagination },
|
|
6
|
+
message,
|
|
7
|
+
status,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export function apiResponse(res, data, message, status = 200) {
|
|
11
|
+
res.status(status).json({ data, message, status });
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=response.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.utils.js","sourceRoot":"","sources":["../../src/utils/response.utils.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,qBAAqB,CACnC,GAAa,EACb,IAAwB,EACxB,OAAO,GAAG,EAAE,EACZ,MAAM,GAAG,GAAG;IAEZ,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;QACtB,IAAI,EAAE,IAAI,CAAC,KAAK;QAChB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS;QAC9B,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE;QACzC,OAAO;QACP,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,GAAa,EACb,IAAO,EACP,OAAgB,EAChB,MAAM,GAAG,GAAG;IAEZ,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AACrD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@angelps/prisma-query-builder",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Library to build Prisma queries from HTTP parameters (pagination, filters, sorting)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.build.json",
|
|
19
|
+
"build:watch": "tsc -p tsconfig.build.json --watch",
|
|
20
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
21
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
22
|
+
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
23
|
+
"prepublishOnly": "npm run build",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"test:watch": "vitest"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@prisma/client": ">=5.0.0",
|
|
29
|
+
"express": ">=4.0.0",
|
|
30
|
+
"valibot": ">=0.31.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@prisma/adapter-pg": "^7.2.0",
|
|
34
|
+
"@prisma/client": "^7.4.0",
|
|
35
|
+
"@types/express": "^5.0.6",
|
|
36
|
+
"@types/node": "^20.11.30",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
38
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
39
|
+
"eslint": "^8.57.1",
|
|
40
|
+
"prisma": "^7.4.0",
|
|
41
|
+
"tsx": "^4.7.0",
|
|
42
|
+
"typescript": "^5.5.4",
|
|
43
|
+
"valibot": "^1.0.0",
|
|
44
|
+
"vitest": "^4.1.2"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"libphonenumber-js": "^1.12.41"
|
|
48
|
+
}
|
|
49
|
+
}
|