@forinda/kickjs-prisma 2.0.1 → 2.2.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,172 @@
1
+
2
+ import { AdapterContext, AppAdapter, ParsedQuery, QueryBuilderAdapter } from "@forinda/kickjs";
3
+
4
+ //#region src/types.d.ts
5
+ interface PrismaAdapterOptions {
6
+ /**
7
+ * PrismaClient instance — typed as `any` to avoid version coupling.
8
+ *
9
+ * Prisma 5/6: `new PrismaClient()` from `@prisma/client`
10
+ * Prisma 7+: `new PrismaClient({ adapter })` from your generated output path
11
+ */
12
+ client: any;
13
+ /**
14
+ * Enable query logging (default: false).
15
+ * Uses `$on('query', ...)` for Prisma 5/6 and `$extends` for Prisma 7+.
16
+ */
17
+ logging?: boolean;
18
+ }
19
+ /** DI token for resolving the PrismaClient from the container */
20
+ declare const PRISMA_CLIENT: unique symbol;
21
+ /**
22
+ * Common Prisma model delegate operations.
23
+ * Use this to type-narrow the injected PrismaClient to a specific model
24
+ * without needing `as any` casts in repositories.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * @Repository()
29
+ * export class PrismaUserRepository {
30
+ * @Inject(PRISMA_CLIENT) private prisma!: { user: PrismaModelDelegate }
31
+ *
32
+ * async findById(id: string) {
33
+ * return this.prisma.user.findUnique({ where: { id } })
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ interface PrismaModelDelegate {
39
+ findUnique(args: {
40
+ where: Record<string, unknown>;
41
+ include?: Record<string, unknown>;
42
+ }): Promise<unknown>;
43
+ findFirst?(args?: Record<string, unknown>): Promise<unknown>;
44
+ findMany(args?: Record<string, unknown>): Promise<unknown[]>;
45
+ create(args: {
46
+ data: Record<string, unknown>;
47
+ }): Promise<unknown>;
48
+ update(args: {
49
+ where: Record<string, unknown>;
50
+ data: Record<string, unknown>;
51
+ }): Promise<unknown>;
52
+ delete(args: {
53
+ where: Record<string, unknown>;
54
+ }): Promise<unknown>;
55
+ deleteMany(args?: {
56
+ where?: Record<string, unknown>;
57
+ }): Promise<{
58
+ count: number;
59
+ }>;
60
+ count(args?: {
61
+ where?: Record<string, unknown>;
62
+ }): Promise<number>;
63
+ }
64
+ //#endregion
65
+ //#region src/prisma.adapter.d.ts
66
+ /**
67
+ * Prisma adapter — registers a PrismaClient in the DI container and manages
68
+ * its lifecycle (connection setup and teardown).
69
+ *
70
+ * Works with Prisma 5, 6, and 7+.
71
+ *
72
+ * @example Prisma 5/6
73
+ * ```ts
74
+ * import { PrismaClient } from '@prisma/client'
75
+ *
76
+ * new PrismaAdapter({ client: new PrismaClient(), logging: true })
77
+ * ```
78
+ *
79
+ * @example Prisma 7+ (driver adapters)
80
+ * ```ts
81
+ * import { PrismaClient } from './generated/prisma'
82
+ * import { PrismaPg } from '@prisma/adapter-pg'
83
+ * import pg from 'pg'
84
+ *
85
+ * const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
86
+ * const client = new PrismaClient({ adapter: new PrismaPg(pool) })
87
+ * new PrismaAdapter({ client, logging: true })
88
+ * ```
89
+ *
90
+ * Inject the client in services:
91
+ * ```ts
92
+ * @Service()
93
+ * class UserService {
94
+ * @Inject(PRISMA_CLIENT) private prisma!: PrismaClient
95
+ * }
96
+ * ```
97
+ */
98
+ declare class PrismaAdapter implements AppAdapter {
99
+ private options;
100
+ name: string;
101
+ private client;
102
+ constructor(options: PrismaAdapterOptions);
103
+ /** Register the PrismaClient in the DI container */
104
+ beforeStart({
105
+ container
106
+ }: AdapterContext): void;
107
+ /** Disconnect the PrismaClient on shutdown */
108
+ shutdown(): Promise<void>;
109
+ }
110
+ //#endregion
111
+ //#region src/query-adapter.d.ts
112
+ /**
113
+ * Configuration for the Prisma query builder adapter.
114
+ *
115
+ * Use the generic parameter to constrain `searchColumns` to actual model field names:
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * import type { User } from '@prisma/client'
120
+ *
121
+ * // Type-safe — only User field names are accepted
122
+ * const config: PrismaQueryConfig<User> = {
123
+ * searchColumns: ['name', 'email'], // ✓ valid User fields
124
+ * }
125
+ *
126
+ * // Without generic — accepts any string (backward compatible)
127
+ * const config: PrismaQueryConfig = {
128
+ * searchColumns: ['name', 'email'],
129
+ * }
130
+ * ```
131
+ */
132
+ interface PrismaQueryConfig<TModel = Record<string, any>> {
133
+ /** Columns to search across when a search string is provided */
134
+ searchColumns?: (keyof TModel & string)[];
135
+ }
136
+ /** Result shape matching Prisma's findMany arguments */
137
+ interface PrismaQueryResult {
138
+ where?: Record<string, any>;
139
+ orderBy?: Record<string, 'asc' | 'desc'>[];
140
+ skip?: number;
141
+ take?: number;
142
+ }
143
+ /**
144
+ * Translates a ParsedQuery into Prisma-compatible `findMany` arguments.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * import type { User } from '@prisma/client'
149
+ *
150
+ * const adapter = new PrismaQueryAdapter()
151
+ * const parsed = parseQuery(req.query)
152
+ *
153
+ * // Type-safe — only User fields allowed in searchColumns
154
+ * const args = adapter.build(parsed, { searchColumns: ['name', 'email'] } satisfies PrismaQueryConfig<User>)
155
+ * const users = await prisma.user.findMany(args)
156
+ * ```
157
+ */
158
+ declare class PrismaQueryAdapter implements QueryBuilderAdapter<PrismaQueryResult, PrismaQueryConfig<any>> {
159
+ readonly name = "PrismaQueryAdapter";
160
+ build<TModel = Record<string, any>>(parsed: ParsedQuery, config?: PrismaQueryConfig<TModel>): PrismaQueryResult;
161
+ /** Map FilterItem[] to Prisma where conditions */
162
+ private buildFilters;
163
+ /** Build Prisma orderBy from SortItem[] */
164
+ private buildSort;
165
+ /** Build a search condition using OR + contains across multiple columns */
166
+ private buildSearch;
167
+ /** Attempt to coerce a string value to a number or boolean if appropriate */
168
+ private coerce;
169
+ }
170
+ //#endregion
171
+ export { PRISMA_CLIENT, PrismaAdapter, type PrismaAdapterOptions, type PrismaModelDelegate, PrismaQueryAdapter, type PrismaQueryConfig, type PrismaQueryResult };
172
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 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A,IAAA;AAAA;;;;;;;;;;;;;;;;cAkBW,kBAAA,YAA8B,mBAAA,CACzC,iBAAA,EACA,iBAAA;EAAA,SAES,IAAA;EAET,KAAA,UAAe,MAAA,cAAA,CACb,MAAA,EAAQ,WAAA,EACR,MAAA,GAAQ,iBAAA,CAAkB,MAAA,IACzB,iBAAA;EFlBuC;EAAA,QEoDlC,YAAA;EFnDO;EAAA,QEyFP,SAAA;EFzFD;EAAA,QE8FC,WAAA;EF7FR;EAAA,QE0GQ,MAAA;AAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @forinda/kickjs-prisma v2.2.0
3
+ *
4
+ * Copyright (c) Felix Orinda
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import { Logger, Scope } from "@forinda/kickjs";
12
+ //#region src/types.ts
13
+ /** DI token for resolving the PrismaClient from the container */
14
+ const PRISMA_CLIENT = Symbol("PrismaClient");
15
+ //#endregion
16
+ //#region src/prisma.adapter.ts
17
+ const log = Logger.for("PrismaAdapter");
18
+ /**
19
+ * Prisma adapter — registers a PrismaClient in the DI container and manages
20
+ * its lifecycle (connection setup and teardown).
21
+ *
22
+ * Works with Prisma 5, 6, and 7+.
23
+ *
24
+ * @example Prisma 5/6
25
+ * ```ts
26
+ * import { PrismaClient } from '@prisma/client'
27
+ *
28
+ * new PrismaAdapter({ client: new PrismaClient(), logging: true })
29
+ * ```
30
+ *
31
+ * @example Prisma 7+ (driver adapters)
32
+ * ```ts
33
+ * import { PrismaClient } from './generated/prisma'
34
+ * import { PrismaPg } from '@prisma/adapter-pg'
35
+ * import pg from 'pg'
36
+ *
37
+ * const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
38
+ * const client = new PrismaClient({ adapter: new PrismaPg(pool) })
39
+ * new PrismaAdapter({ client, logging: true })
40
+ * ```
41
+ *
42
+ * Inject the client in services:
43
+ * ```ts
44
+ * @Service()
45
+ * class UserService {
46
+ * @Inject(PRISMA_CLIENT) private prisma!: PrismaClient
47
+ * }
48
+ * ```
49
+ */
50
+ var PrismaAdapter = class {
51
+ name = "PrismaAdapter";
52
+ client;
53
+ constructor(options) {
54
+ this.options = options;
55
+ this.client = options.client;
56
+ }
57
+ /** Register the PrismaClient in the DI container */
58
+ beforeStart({ container }) {
59
+ if (this.options.logging) {
60
+ if (typeof this.client.$on === "function") this.client.$on("query", (event) => {
61
+ log.debug(`Query: ${event.query}`);
62
+ log.debug(`Params: ${event.params}`);
63
+ log.debug(`Duration: ${event.duration}ms`);
64
+ });
65
+ else if (typeof this.client.$extends === "function") this.client = this.client.$extends({ query: { $allOperations({ operation, model, args, query }) {
66
+ const start = performance.now();
67
+ return query(args).then((result) => {
68
+ const duration = Math.round(performance.now() - start);
69
+ log.debug(`${model}.${operation} — ${duration}ms`);
70
+ return result;
71
+ });
72
+ } } });
73
+ }
74
+ container.registerFactory(PRISMA_CLIENT, () => this.client, Scope.SINGLETON);
75
+ log.info("PrismaClient registered in DI container");
76
+ }
77
+ /** Disconnect the PrismaClient on shutdown */
78
+ async shutdown() {
79
+ if (typeof this.client.$disconnect === "function") {
80
+ await this.client.$disconnect();
81
+ log.info("PrismaClient disconnected");
82
+ }
83
+ }
84
+ };
85
+ //#endregion
86
+ //#region src/query-adapter.ts
87
+ /**
88
+ * Translates a ParsedQuery into Prisma-compatible `findMany` arguments.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * import type { User } from '@prisma/client'
93
+ *
94
+ * const adapter = new PrismaQueryAdapter()
95
+ * const parsed = parseQuery(req.query)
96
+ *
97
+ * // Type-safe — only User fields allowed in searchColumns
98
+ * const args = adapter.build(parsed, { searchColumns: ['name', 'email'] } satisfies PrismaQueryConfig<User>)
99
+ * const users = await prisma.user.findMany(args)
100
+ * ```
101
+ */
102
+ var PrismaQueryAdapter = class {
103
+ name = "PrismaQueryAdapter";
104
+ build(parsed, config = {}) {
105
+ const result = {};
106
+ const whereConditions = this.buildFilters(parsed.filters);
107
+ const searchCondition = this.buildSearch(parsed.search, config.searchColumns);
108
+ if (whereConditions.length > 0 || searchCondition) {
109
+ const andClauses = [];
110
+ if (whereConditions.length > 0) andClauses.push(...whereConditions);
111
+ if (searchCondition) andClauses.push(searchCondition);
112
+ result.where = andClauses.length === 1 ? andClauses[0] : { AND: andClauses };
113
+ }
114
+ const orderBy = this.buildSort(parsed.sort);
115
+ if (orderBy.length > 0) result.orderBy = orderBy;
116
+ result.skip = parsed.pagination.offset;
117
+ result.take = parsed.pagination.limit;
118
+ return result;
119
+ }
120
+ /** Map FilterItem[] to Prisma where conditions */
121
+ buildFilters(filters) {
122
+ return filters.map((filter) => {
123
+ const { field, operator, value } = filter;
124
+ switch (operator) {
125
+ case "eq": return { [field]: { equals: this.coerce(value) } };
126
+ case "neq": return { [field]: { not: this.coerce(value) } };
127
+ case "gt": return { [field]: { gt: this.coerce(value) } };
128
+ case "gte": return { [field]: { gte: this.coerce(value) } };
129
+ case "lt": return { [field]: { lt: this.coerce(value) } };
130
+ case "lte": return { [field]: { lte: this.coerce(value) } };
131
+ case "contains": return { [field]: {
132
+ contains: value,
133
+ mode: "insensitive"
134
+ } };
135
+ case "starts": return { [field]: {
136
+ startsWith: value,
137
+ mode: "insensitive"
138
+ } };
139
+ case "ends": return { [field]: {
140
+ endsWith: value,
141
+ mode: "insensitive"
142
+ } };
143
+ case "in": {
144
+ const values = value.split(",").map((v) => this.coerce(v.trim()));
145
+ return { [field]: { in: values } };
146
+ }
147
+ case "between": {
148
+ const [min, max] = value.split(",").map((v) => this.coerce(v.trim()));
149
+ return { [field]: {
150
+ gte: min,
151
+ lte: max
152
+ } };
153
+ }
154
+ default: return { [field]: { equals: this.coerce(value) } };
155
+ }
156
+ });
157
+ }
158
+ /** Build Prisma orderBy from SortItem[] */
159
+ buildSort(sort) {
160
+ return sort.map((item) => ({ [item.field]: item.direction }));
161
+ }
162
+ /** Build a search condition using OR + contains across multiple columns */
163
+ buildSearch(search, searchColumns) {
164
+ if (!search || !searchColumns || searchColumns.length === 0) return null;
165
+ return { OR: searchColumns.map((column) => ({ [column]: {
166
+ contains: search,
167
+ mode: "insensitive"
168
+ } })) };
169
+ }
170
+ /** Attempt to coerce a string value to a number or boolean if appropriate */
171
+ coerce(value) {
172
+ if (value === "true") return true;
173
+ if (value === "false") return false;
174
+ const num = Number(value);
175
+ if (!Number.isNaN(num) && value.trim() !== "") return num;
176
+ return value;
177
+ }
178
+ };
179
+ //#endregion
180
+ export { PRISMA_CLIENT, PrismaAdapter, PrismaQueryAdapter };
181
+
182
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/types.ts","../src/prisma.adapter.ts","../src/query-adapter.ts"],"sourcesContent":["export interface PrismaAdapterOptions {\n /**\n * PrismaClient instance — typed as `any` to avoid version coupling.\n *\n * Prisma 5/6: `new PrismaClient()` from `@prisma/client`\n * Prisma 7+: `new PrismaClient({ adapter })` from your generated output path\n */\n client: any\n /**\n * Enable query logging (default: false).\n * Uses `$on('query', ...)` for Prisma 5/6 and `$extends` for Prisma 7+.\n */\n logging?: boolean\n}\n\n/** DI token for resolving the PrismaClient from the container */\nexport const PRISMA_CLIENT = Symbol('PrismaClient')\n\n/**\n * Common Prisma model delegate operations.\n * Use this to type-narrow the injected PrismaClient to a specific model\n * without needing `as any` casts in repositories.\n *\n * @example\n * ```ts\n * @Repository()\n * export class PrismaUserRepository {\n * @Inject(PRISMA_CLIENT) private prisma!: { user: PrismaModelDelegate }\n *\n * async findById(id: string) {\n * return this.prisma.user.findUnique({ where: { id } })\n * }\n * }\n * ```\n */\nexport interface PrismaModelDelegate {\n findUnique(args: {\n where: Record<string, unknown>\n include?: Record<string, unknown>\n }): Promise<unknown>\n findFirst?(args?: Record<string, unknown>): Promise<unknown>\n findMany(args?: Record<string, unknown>): Promise<unknown[]>\n create(args: { data: Record<string, unknown> }): Promise<unknown>\n update(args: { where: Record<string, unknown>; data: Record<string, unknown> }): Promise<unknown>\n delete(args: { where: Record<string, unknown> }): Promise<unknown>\n deleteMany(args?: { where?: Record<string, unknown> }): Promise<{ count: number }>\n count(args?: { where?: Record<string, unknown> }): Promise<number>\n}\n","import { Logger, type AppAdapter, type AdapterContext, Scope } from '@forinda/kickjs'\nimport { PRISMA_CLIENT, type PrismaAdapterOptions } from './types'\n\nconst log = Logger.for('PrismaAdapter')\n\n/**\n * Prisma adapter — registers a PrismaClient in the DI container and manages\n * its lifecycle (connection setup and teardown).\n *\n * Works with Prisma 5, 6, and 7+.\n *\n * @example Prisma 5/6\n * ```ts\n * import { PrismaClient } from '@prisma/client'\n *\n * new PrismaAdapter({ client: new PrismaClient(), logging: true })\n * ```\n *\n * @example Prisma 7+ (driver adapters)\n * ```ts\n * import { PrismaClient } from './generated/prisma'\n * import { PrismaPg } from '@prisma/adapter-pg'\n * import pg from 'pg'\n *\n * const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })\n * const client = new PrismaClient({ adapter: new PrismaPg(pool) })\n * new PrismaAdapter({ client, logging: true })\n * ```\n *\n * Inject the client in services:\n * ```ts\n * @Service()\n * class UserService {\n * @Inject(PRISMA_CLIENT) private prisma!: PrismaClient\n * }\n * ```\n */\nexport class PrismaAdapter implements AppAdapter {\n name = 'PrismaAdapter'\n private client: any\n\n constructor(private options: PrismaAdapterOptions) {\n this.client = options.client\n }\n\n /** Register the PrismaClient in the DI container */\n beforeStart({ container }: AdapterContext): void {\n // Set up query logging if requested\n if (this.options.logging) {\n if (typeof this.client.$on === 'function') {\n // Prisma 5/6: event-based logging\n this.client.$on('query', (event: any) => {\n log.debug(`Query: ${event.query}`)\n log.debug(`Params: ${event.params}`)\n log.debug(`Duration: ${event.duration}ms`)\n })\n } else if (typeof this.client.$extends === 'function') {\n // Prisma 7+: Client Extensions for logging ($on removed)\n this.client = this.client.$extends({\n query: {\n $allOperations({ operation, model, args, query }: any) {\n const start = performance.now()\n return query(args).then((result: any) => {\n const duration = Math.round(performance.now() - start)\n log.debug(`${model}.${operation} — ${duration}ms`)\n return result\n })\n },\n },\n })\n }\n }\n\n // Register the client instance as a singleton factory in the container\n container.registerFactory(PRISMA_CLIENT, () => this.client, Scope.SINGLETON)\n\n log.info('PrismaClient registered in DI container')\n }\n\n /** Disconnect the PrismaClient on shutdown */\n async shutdown(): Promise<void> {\n if (typeof this.client.$disconnect === 'function') {\n await this.client.$disconnect()\n log.info('PrismaClient disconnected')\n }\n }\n}\n","import type { QueryBuilderAdapter, ParsedQuery, FilterItem, SortItem } from '@forinda/kickjs'\n\n/**\n * Configuration for the Prisma query builder adapter.\n *\n * Use the generic parameter to constrain `searchColumns` to actual model field names:\n *\n * @example\n * ```ts\n * import type { User } from '@prisma/client'\n *\n * // Type-safe — only User field names are accepted\n * const config: PrismaQueryConfig<User> = {\n * searchColumns: ['name', 'email'], // ✓ valid User fields\n * }\n *\n * // Without generic — accepts any string (backward compatible)\n * const config: PrismaQueryConfig = {\n * searchColumns: ['name', 'email'],\n * }\n * ```\n */\nexport interface PrismaQueryConfig<TModel = Record<string, any>> {\n /** Columns to search across when a search string is provided */\n searchColumns?: (keyof TModel & string)[]\n}\n\n/** Result shape matching Prisma's findMany arguments */\nexport interface PrismaQueryResult {\n where?: Record<string, any>\n orderBy?: Record<string, 'asc' | 'desc'>[]\n skip?: number\n take?: number\n}\n\n/**\n * Translates a ParsedQuery into Prisma-compatible `findMany` arguments.\n *\n * @example\n * ```ts\n * import type { User } from '@prisma/client'\n *\n * const adapter = new PrismaQueryAdapter()\n * const parsed = parseQuery(req.query)\n *\n * // Type-safe — only User fields allowed in searchColumns\n * const args = adapter.build(parsed, { searchColumns: ['name', 'email'] } satisfies PrismaQueryConfig<User>)\n * const users = await prisma.user.findMany(args)\n * ```\n */\nexport class PrismaQueryAdapter implements QueryBuilderAdapter<\n PrismaQueryResult,\n PrismaQueryConfig<any>\n> {\n readonly name = 'PrismaQueryAdapter'\n\n build<TModel = Record<string, any>>(\n parsed: ParsedQuery,\n config: PrismaQueryConfig<TModel> = {},\n ): PrismaQueryResult {\n const result: PrismaQueryResult = {}\n\n // Build where clause from filters and search\n const whereConditions = this.buildFilters(parsed.filters)\n const searchCondition = this.buildSearch(parsed.search, config.searchColumns)\n\n if (whereConditions.length > 0 || searchCondition) {\n const andClauses: any[] = []\n\n if (whereConditions.length > 0) {\n andClauses.push(...whereConditions)\n }\n if (searchCondition) {\n andClauses.push(searchCondition)\n }\n\n result.where = andClauses.length === 1 ? andClauses[0] : { AND: andClauses }\n }\n\n // Build orderBy\n const orderBy = this.buildSort(parsed.sort)\n if (orderBy.length > 0) {\n result.orderBy = orderBy\n }\n\n // Build pagination\n result.skip = parsed.pagination.offset\n result.take = parsed.pagination.limit\n\n return result\n }\n\n /** Map FilterItem[] to Prisma where conditions */\n private buildFilters(filters: FilterItem[]): Record<string, any>[] {\n return filters.map((filter) => {\n const { field, operator, value } = filter\n\n switch (operator) {\n case 'eq':\n return { [field]: { equals: this.coerce(value) } }\n case 'neq':\n return { [field]: { not: this.coerce(value) } }\n case 'gt':\n return { [field]: { gt: this.coerce(value) } }\n case 'gte':\n return { [field]: { gte: this.coerce(value) } }\n case 'lt':\n return { [field]: { lt: this.coerce(value) } }\n case 'lte':\n return { [field]: { lte: this.coerce(value) } }\n case 'contains':\n return { [field]: { contains: value, mode: 'insensitive' } }\n case 'starts':\n return { [field]: { startsWith: value, mode: 'insensitive' } }\n case 'ends':\n return { [field]: { endsWith: value, mode: 'insensitive' } }\n case 'in': {\n const values = value.split(',').map((v) => this.coerce(v.trim()))\n return { [field]: { in: values } }\n }\n case 'between': {\n const [min, max] = value.split(',').map((v) => this.coerce(v.trim()))\n return { [field]: { gte: min, lte: max } }\n }\n default:\n return { [field]: { equals: this.coerce(value) } }\n }\n })\n }\n\n /** Build Prisma orderBy from SortItem[] */\n private buildSort(sort: SortItem[]): Record<string, 'asc' | 'desc'>[] {\n return sort.map((item) => ({ [item.field]: item.direction }))\n }\n\n /** Build a search condition using OR + contains across multiple columns */\n private buildSearch(search: string, searchColumns?: string[]): Record<string, any> | null {\n if (!search || !searchColumns || searchColumns.length === 0) {\n return null\n }\n\n return {\n OR: searchColumns.map((column) => ({\n [column]: { contains: search, mode: 'insensitive' },\n })),\n }\n }\n\n /** Attempt to coerce a string value to a number or boolean if appropriate */\n private coerce(value: string): string | number | boolean {\n if (value === 'true') return true\n if (value === 'false') return false\n const num = Number(value)\n if (!Number.isNaN(num) && value.trim() !== '') return num\n return value\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,gBAAgB,OAAO,eAAe;;;ACbnD,MAAM,MAAM,OAAO,IAAI,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCvC,IAAa,gBAAb,MAAiD;CAC/C,OAAO;CACP;CAEA,YAAY,SAAuC;AAA/B,OAAA,UAAA;AAClB,OAAK,SAAS,QAAQ;;;CAIxB,YAAY,EAAE,aAAmC;AAE/C,MAAI,KAAK,QAAQ;OACX,OAAO,KAAK,OAAO,QAAQ,WAE7B,MAAK,OAAO,IAAI,UAAU,UAAe;AACvC,QAAI,MAAM,UAAU,MAAM,QAAQ;AAClC,QAAI,MAAM,WAAW,MAAM,SAAS;AACpC,QAAI,MAAM,aAAa,MAAM,SAAS,IAAI;KAC1C;YACO,OAAO,KAAK,OAAO,aAAa,WAEzC,MAAK,SAAS,KAAK,OAAO,SAAS,EACjC,OAAO,EACL,eAAe,EAAE,WAAW,OAAO,MAAM,SAAc;IACrD,MAAM,QAAQ,YAAY,KAAK;AAC/B,WAAO,MAAM,KAAK,CAAC,MAAM,WAAgB;KACvC,MAAM,WAAW,KAAK,MAAM,YAAY,KAAK,GAAG,MAAM;AACtD,SAAI,MAAM,GAAG,MAAM,GAAG,UAAU,KAAK,SAAS,IAAI;AAClD,YAAO;MACP;MAEL,EACF,CAAC;;AAKN,YAAU,gBAAgB,qBAAqB,KAAK,QAAQ,MAAM,UAAU;AAE5E,MAAI,KAAK,0CA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,SAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forinda/kickjs-prisma",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "description": "Prisma ORM adapter with DI integration, transaction support, and query building for KickJS",
5
5
  "keywords": [
6
6
  "kickjs",
@@ -40,20 +40,37 @@
40
40
  "vite"
41
41
  ],
42
42
  "type": "module",
43
- "main": "dist/index.js",
44
- "types": "dist/index.d.ts",
43
+ "main": "dist/index.mjs",
44
+ "types": "dist/index.d.mts",
45
45
  "exports": {
46
46
  ".": {
47
- "import": "./dist/index.js",
48
- "types": "./dist/index.d.ts"
47
+ "import": "./dist/index.mjs",
48
+ "types": "./dist/index.d.mts"
49
49
  }
50
50
  },
51
51
  "files": [
52
52
  "dist"
53
53
  ],
54
+ "wireit": {
55
+ "build": {
56
+ "command": "tsdown",
57
+ "files": [
58
+ "src/**/*.ts",
59
+ "tsdown.config.ts",
60
+ "tsconfig.json",
61
+ "package.json"
62
+ ],
63
+ "output": [
64
+ "dist/**"
65
+ ],
66
+ "dependencies": [
67
+ "../core:build"
68
+ ]
69
+ }
70
+ },
54
71
  "dependencies": {
55
72
  "reflect-metadata": "^0.2.2",
56
- "@forinda/kickjs": "2.0.1"
73
+ "@forinda/kickjs": "2.2.0"
57
74
  },
58
75
  "peerDependencies": {
59
76
  "@prisma/client": ">=5.0.0"
@@ -85,11 +102,10 @@
85
102
  "url": "https://github.com/forinda/kick-js/issues"
86
103
  },
87
104
  "scripts": {
88
- "build": "vite build && pnpm build:types",
89
- "build:types": "tsc -p tsconfig.build.json",
90
- "dev": "vite build --watch",
105
+ "build": "wireit",
106
+ "dev": "tsdown --watch",
91
107
  "typecheck": "tsc --noEmit",
92
- "clean": "rm -rf dist .turbo",
108
+ "clean": "rm -rf dist .wireit",
93
109
  "lint": "tsc --noEmit"
94
110
  }
95
111
  }
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { PrismaAdapter } from './prisma.adapter';
2
- export { PrismaQueryAdapter } from './query-adapter';
3
- export { PRISMA_CLIENT } from './types';
4
- export type { PrismaAdapterOptions, PrismaModelDelegate } from './types';
5
- export type { PrismaQueryConfig, PrismaQueryResult } from './query-adapter';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AACxE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA"}
package/dist/index.js DELETED
@@ -1,100 +0,0 @@
1
- import { Logger as u, Scope as l } from "@forinda/kickjs";
2
- var h = /* @__PURE__ */ Symbol("PrismaClient"), c = u.for("PrismaAdapter"), m = class {
3
- name = "PrismaAdapter";
4
- client;
5
- constructor(e) {
6
- this.options = e, this.client = e.client;
7
- }
8
- beforeStart({ container: e }) {
9
- this.options.logging && (typeof this.client.$on == "function" ? this.client.$on("query", (r) => {
10
- c.debug(`Query: ${r.query}`), c.debug(`Params: ${r.params}`), c.debug(`Duration: ${r.duration}ms`);
11
- }) : typeof this.client.$extends == "function" && (this.client = this.client.$extends({ query: { $allOperations({ operation: r, model: t, args: o, query: i }) {
12
- const s = performance.now();
13
- return i(o).then((n) => {
14
- const a = Math.round(performance.now() - s);
15
- return c.debug(`${t}.${r} — ${a}ms`), n;
16
- });
17
- } } }))), e.registerFactory(h, () => this.client, l.SINGLETON), c.info("PrismaClient registered in DI container");
18
- }
19
- async shutdown() {
20
- typeof this.client.$disconnect == "function" && (await this.client.$disconnect(), c.info("PrismaClient disconnected"));
21
- }
22
- }, f = class {
23
- name = "PrismaQueryAdapter";
24
- build(e, r = {}) {
25
- const t = {}, o = this.buildFilters(e.filters), i = this.buildSearch(e.search, r.searchColumns);
26
- if (o.length > 0 || i) {
27
- const n = [];
28
- o.length > 0 && n.push(...o), i && n.push(i), t.where = n.length === 1 ? n[0] : { AND: n };
29
- }
30
- const s = this.buildSort(e.sort);
31
- return s.length > 0 && (t.orderBy = s), t.skip = e.pagination.offset, t.take = e.pagination.limit, t;
32
- }
33
- buildFilters(e) {
34
- return e.map((r) => {
35
- const { field: t, operator: o, value: i } = r;
36
- switch (o) {
37
- case "eq":
38
- return { [t]: { equals: this.coerce(i) } };
39
- case "neq":
40
- return { [t]: { not: this.coerce(i) } };
41
- case "gt":
42
- return { [t]: { gt: this.coerce(i) } };
43
- case "gte":
44
- return { [t]: { gte: this.coerce(i) } };
45
- case "lt":
46
- return { [t]: { lt: this.coerce(i) } };
47
- case "lte":
48
- return { [t]: { lte: this.coerce(i) } };
49
- case "contains":
50
- return { [t]: {
51
- contains: i,
52
- mode: "insensitive"
53
- } };
54
- case "starts":
55
- return { [t]: {
56
- startsWith: i,
57
- mode: "insensitive"
58
- } };
59
- case "ends":
60
- return { [t]: {
61
- endsWith: i,
62
- mode: "insensitive"
63
- } };
64
- case "in": {
65
- const s = i.split(",").map((n) => this.coerce(n.trim()));
66
- return { [t]: { in: s } };
67
- }
68
- case "between": {
69
- const [s, n] = i.split(",").map((a) => this.coerce(a.trim()));
70
- return { [t]: {
71
- gte: s,
72
- lte: n
73
- } };
74
- }
75
- default:
76
- return { [t]: { equals: this.coerce(i) } };
77
- }
78
- });
79
- }
80
- buildSort(e) {
81
- return e.map((r) => ({ [r.field]: r.direction }));
82
- }
83
- buildSearch(e, r) {
84
- return !e || !r || r.length === 0 ? null : { OR: r.map((t) => ({ [t]: {
85
- contains: e,
86
- mode: "insensitive"
87
- } })) };
88
- }
89
- coerce(e) {
90
- if (e === "true") return !0;
91
- if (e === "false") return !1;
92
- const r = Number(e);
93
- return !Number.isNaN(r) && e.trim() !== "" ? r : e;
94
- }
95
- };
96
- export {
97
- h as PRISMA_CLIENT,
98
- m as PrismaAdapter,
99
- f as PrismaQueryAdapter
100
- };
@@ -1,45 +0,0 @@
1
- import { type AppAdapter, type AdapterContext } from '@forinda/kickjs';
2
- import { type PrismaAdapterOptions } from './types';
3
- /**
4
- * Prisma adapter — registers a PrismaClient in the DI container and manages
5
- * its lifecycle (connection setup and teardown).
6
- *
7
- * Works with Prisma 5, 6, and 7+.
8
- *
9
- * @example Prisma 5/6
10
- * ```ts
11
- * import { PrismaClient } from '@prisma/client'
12
- *
13
- * new PrismaAdapter({ client: new PrismaClient(), logging: true })
14
- * ```
15
- *
16
- * @example Prisma 7+ (driver adapters)
17
- * ```ts
18
- * import { PrismaClient } from './generated/prisma'
19
- * import { PrismaPg } from '@prisma/adapter-pg'
20
- * import pg from 'pg'
21
- *
22
- * const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
23
- * const client = new PrismaClient({ adapter: new PrismaPg(pool) })
24
- * new PrismaAdapter({ client, logging: true })
25
- * ```
26
- *
27
- * Inject the client in services:
28
- * ```ts
29
- * @Service()
30
- * class UserService {
31
- * @Inject(PRISMA_CLIENT) private prisma!: PrismaClient
32
- * }
33
- * ```
34
- */
35
- export declare class PrismaAdapter implements AppAdapter {
36
- private options;
37
- name: string;
38
- private client;
39
- constructor(options: PrismaAdapterOptions);
40
- /** Register the PrismaClient in the DI container */
41
- beforeStart({ container }: AdapterContext): void;
42
- /** Disconnect the PrismaClient on shutdown */
43
- shutdown(): Promise<void>;
44
- }
45
- //# sourceMappingURL=prisma.adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prisma.adapter.d.ts","sourceRoot":"","sources":["../src/prisma.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,UAAU,EAAE,KAAK,cAAc,EAAS,MAAM,iBAAiB,CAAA;AACrF,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAIlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,aAAc,YAAW,UAAU;IAIlC,OAAO,CAAC,OAAO;IAH3B,IAAI,SAAkB;IACtB,OAAO,CAAC,MAAM,CAAK;gBAEC,OAAO,EAAE,oBAAoB;IAIjD,oDAAoD;IACpD,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,cAAc,GAAG,IAAI;IAiChD,8CAA8C;IACxC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAMhC"}
@@ -1,60 +0,0 @@
1
- import type { QueryBuilderAdapter, ParsedQuery } from '@forinda/kickjs';
2
- /**
3
- * Configuration for the Prisma query builder adapter.
4
- *
5
- * Use the generic parameter to constrain `searchColumns` to actual model field names:
6
- *
7
- * @example
8
- * ```ts
9
- * import type { User } from '@prisma/client'
10
- *
11
- * // Type-safe — only User field names are accepted
12
- * const config: PrismaQueryConfig<User> = {
13
- * searchColumns: ['name', 'email'], // ✓ valid User fields
14
- * }
15
- *
16
- * // Without generic — accepts any string (backward compatible)
17
- * const config: PrismaQueryConfig = {
18
- * searchColumns: ['name', 'email'],
19
- * }
20
- * ```
21
- */
22
- export interface PrismaQueryConfig<TModel = Record<string, any>> {
23
- /** Columns to search across when a search string is provided */
24
- searchColumns?: (keyof TModel & string)[];
25
- }
26
- /** Result shape matching Prisma's findMany arguments */
27
- export interface PrismaQueryResult {
28
- where?: Record<string, any>;
29
- orderBy?: Record<string, 'asc' | 'desc'>[];
30
- skip?: number;
31
- take?: number;
32
- }
33
- /**
34
- * Translates a ParsedQuery into Prisma-compatible `findMany` arguments.
35
- *
36
- * @example
37
- * ```ts
38
- * import type { User } from '@prisma/client'
39
- *
40
- * const adapter = new PrismaQueryAdapter()
41
- * const parsed = parseQuery(req.query)
42
- *
43
- * // Type-safe — only User fields allowed in searchColumns
44
- * const args = adapter.build(parsed, { searchColumns: ['name', 'email'] } satisfies PrismaQueryConfig<User>)
45
- * const users = await prisma.user.findMany(args)
46
- * ```
47
- */
48
- export declare class PrismaQueryAdapter implements QueryBuilderAdapter<PrismaQueryResult, PrismaQueryConfig<any>> {
49
- readonly name = "PrismaQueryAdapter";
50
- build<TModel = Record<string, any>>(parsed: ParsedQuery, config?: PrismaQueryConfig<TModel>): PrismaQueryResult;
51
- /** Map FilterItem[] to Prisma where conditions */
52
- private buildFilters;
53
- /** Build Prisma orderBy from SortItem[] */
54
- private buildSort;
55
- /** Build a search condition using OR + contains across multiple columns */
56
- private buildSearch;
57
- /** Attempt to coerce a string value to a number or boolean if appropriate */
58
- private coerce;
59
- }
60
- //# sourceMappingURL=query-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query-adapter.d.ts","sourceRoot":"","sources":["../src/query-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAwB,MAAM,iBAAiB,CAAA;AAE7F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC7D,gEAAgE;IAChE,aAAa,CAAC,EAAE,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CAC1C;AAED,wDAAwD;AACxD,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC,EAAE,CAAA;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,kBAAmB,YAAW,mBAAmB,CAC5D,iBAAiB,EACjB,iBAAiB,CAAC,GAAG,CAAC,CACvB;IACC,QAAQ,CAAC,IAAI,wBAAuB;IAEpC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,MAAM,EAAE,WAAW,EACnB,MAAM,GAAE,iBAAiB,CAAC,MAAM,CAAM,GACrC,iBAAiB;IAiCpB,kDAAkD;IAClD,OAAO,CAAC,YAAY;IAqCpB,2CAA2C;IAC3C,OAAO,CAAC,SAAS;IAIjB,2EAA2E;IAC3E,OAAO,CAAC,WAAW;IAYnB,6EAA6E;IAC7E,OAAO,CAAC,MAAM;CAOf"}
package/dist/types.d.ts DELETED
@@ -1,60 +0,0 @@
1
- export interface PrismaAdapterOptions {
2
- /**
3
- * PrismaClient instance — typed as `any` to avoid version coupling.
4
- *
5
- * Prisma 5/6: `new PrismaClient()` from `@prisma/client`
6
- * Prisma 7+: `new PrismaClient({ adapter })` from your generated output path
7
- */
8
- client: any;
9
- /**
10
- * Enable query logging (default: false).
11
- * Uses `$on('query', ...)` for Prisma 5/6 and `$extends` for Prisma 7+.
12
- */
13
- logging?: boolean;
14
- }
15
- /** DI token for resolving the PrismaClient from the container */
16
- export declare const PRISMA_CLIENT: unique symbol;
17
- /**
18
- * Common Prisma model delegate operations.
19
- * Use this to type-narrow the injected PrismaClient to a specific model
20
- * without needing `as any` casts in repositories.
21
- *
22
- * @example
23
- * ```ts
24
- * @Repository()
25
- * export class PrismaUserRepository {
26
- * @Inject(PRISMA_CLIENT) private prisma!: { user: PrismaModelDelegate }
27
- *
28
- * async findById(id: string) {
29
- * return this.prisma.user.findUnique({ where: { id } })
30
- * }
31
- * }
32
- * ```
33
- */
34
- export interface PrismaModelDelegate {
35
- findUnique(args: {
36
- where: Record<string, unknown>;
37
- include?: Record<string, unknown>;
38
- }): Promise<unknown>;
39
- findFirst?(args?: Record<string, unknown>): Promise<unknown>;
40
- findMany(args?: Record<string, unknown>): Promise<unknown[]>;
41
- create(args: {
42
- data: Record<string, unknown>;
43
- }): Promise<unknown>;
44
- update(args: {
45
- where: Record<string, unknown>;
46
- data: Record<string, unknown>;
47
- }): Promise<unknown>;
48
- delete(args: {
49
- where: Record<string, unknown>;
50
- }): Promise<unknown>;
51
- deleteMany(args?: {
52
- where?: Record<string, unknown>;
53
- }): Promise<{
54
- count: number;
55
- }>;
56
- count(args?: {
57
- where?: Record<string, unknown>;
58
- }): Promise<number>;
59
- }
60
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,EAAE,GAAG,CAAA;IACX;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,iEAAiE;AACjE,eAAO,MAAM,aAAa,eAAyB,CAAA;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,IAAI,EAAE;QACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAClC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACpB,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC5D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC5D,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACjE,MAAM,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;I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