prisma-dt 1.0.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.
- package/LICENSE +21 -0
- package/README.md +245 -0
- package/dist/DTReqAdapter.d.ts +26 -0
- package/dist/DTReqAdapter.d.ts.map +1 -0
- package/dist/DTReqAdapter.js +396 -0
- package/dist/DTReqAdapter.js.map +1 -0
- package/dist/DTResAdapter.d.ts +13 -0
- package/dist/DTResAdapter.d.ts.map +1 -0
- package/dist/DTResAdapter.js +37 -0
- package/dist/DTResAdapter.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +39 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 [Your Name]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# Prisma DataTable
|
|
2
|
+
|
|
3
|
+
A powerful and type-safe DataTable integration for Prisma ORM with advanced filtering, sorting, pagination, global search, and relation support.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
✨ **Advanced Filtering** - 12 filter types (eq, neq, like, gt, gte, lt, lte, in, notIn, between, isNull, isNotNull)
|
|
8
|
+
🔍 **Global Search** - Search across multiple fields with a single query
|
|
9
|
+
📊 **Smart Pagination** - Built-in pagination with metadata
|
|
10
|
+
🔗 **Relation Support** - Filter and search through nested relations
|
|
11
|
+
📦 **Column Selection** - Control which fields to return
|
|
12
|
+
🛡️ **SQL Injection Safe** - All queries are parameterized through Prisma
|
|
13
|
+
📝 **TypeScript First** - Full type safety with TypeScript
|
|
14
|
+
🎯 **Array Relations** - Proper support for one-to-many relations
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @your-org/prisma-datatable
|
|
20
|
+
# or
|
|
21
|
+
yarn add @your-org/prisma-datatable
|
|
22
|
+
# or
|
|
23
|
+
pnpm add @your-org/prisma-datatable
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### 1. Define Your Schema Config
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { SchemaConfig } from "@your-org/prisma-datatable";
|
|
32
|
+
|
|
33
|
+
const USER_SCHEMA: SchemaConfig = {
|
|
34
|
+
model: "User",
|
|
35
|
+
searchableFields: ["name", "email", "posts.title"],
|
|
36
|
+
relations: {
|
|
37
|
+
posts: {
|
|
38
|
+
model: "Post",
|
|
39
|
+
isArray: true, // One-to-many relation
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Create DataTable Endpoint
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { DTReqAdapter, DTResAdapter } from "@your-org/prisma-datatable";
|
|
49
|
+
import { prisma } from "./prisma";
|
|
50
|
+
|
|
51
|
+
async function getUsersDataTable(request: DataTableRequest) {
|
|
52
|
+
const adapter = new DTReqAdapter(request, USER_SCHEMA);
|
|
53
|
+
const prismaQuery = adapter.toPrismaQuery();
|
|
54
|
+
|
|
55
|
+
const [data, total] = await Promise.all([
|
|
56
|
+
prisma.user.findMany(prismaQuery),
|
|
57
|
+
prisma.user.count({ where: prismaQuery.where }),
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
return DTResAdapter.fromPrisma(data, total, request);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 3. Use in Your API
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// Express example
|
|
68
|
+
app.post("/users/datatable", async (req, res) => {
|
|
69
|
+
const result = await getUsersDataTable(req.body);
|
|
70
|
+
res.json(result);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Fastify example
|
|
74
|
+
fastify.post("/users/datatable", async (request, reply) => {
|
|
75
|
+
const result = await getUsersDataTable(request.body);
|
|
76
|
+
return reply.send(result);
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Request Examples
|
|
81
|
+
|
|
82
|
+
### Basic Pagination
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"page": 1,
|
|
87
|
+
"perPage": 10
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Global Search
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"globalSearch": "john",
|
|
96
|
+
"page": 1,
|
|
97
|
+
"perPage": 10
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Searches across all fields defined in `searchableFields`.
|
|
102
|
+
|
|
103
|
+
### Advanced Filtering
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"filters": {
|
|
108
|
+
"status": { "type": "eq", "value": "active" },
|
|
109
|
+
"age": { "type": "gte", "value": 18 },
|
|
110
|
+
"email": { "type": "like", "value": "@gmail.com" },
|
|
111
|
+
"posts.published": { "type": "eq", "value": true }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Sorting
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"sort": [
|
|
121
|
+
{ "column": "createdAt", "direction": "desc" },
|
|
122
|
+
{ "column": "name", "direction": "asc" }
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Include Relations
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"includeRelations": ["posts", "profile"],
|
|
132
|
+
"page": 1
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Select Specific Columns
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"selectColumns": ["id", "name", "email", "posts.title", "posts.createdAt"]
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Combined Example
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"page": 1,
|
|
149
|
+
"perPage": 20,
|
|
150
|
+
"globalSearch": "developer",
|
|
151
|
+
"filters": {
|
|
152
|
+
"status": { "type": "eq", "value": "active" },
|
|
153
|
+
"posts.published": { "type": "eq", "value": true }
|
|
154
|
+
},
|
|
155
|
+
"sort": [{ "column": "createdAt", "direction": "desc" }],
|
|
156
|
+
"includeRelations": ["posts", "profile"]
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Response Format
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"data": [...],
|
|
165
|
+
"meta": {
|
|
166
|
+
"current_page": 1,
|
|
167
|
+
"per_page": 10,
|
|
168
|
+
"from": 1,
|
|
169
|
+
"to": 10,
|
|
170
|
+
"total": 45,
|
|
171
|
+
"last_page": 5
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Filter Types
|
|
177
|
+
|
|
178
|
+
| Type | Description | Example |
|
|
179
|
+
| ----------- | --------------------------- | -------------------------------------------------- |
|
|
180
|
+
| `eq` | Equals | `{ "type": "eq", "value": "active" }` |
|
|
181
|
+
| `neq` | Not equals | `{ "type": "neq", "value": "deleted" }` |
|
|
182
|
+
| `like` | Contains (case-insensitive) | `{ "type": "like", "value": "john" }` |
|
|
183
|
+
| `gt` | Greater than | `{ "type": "gt", "value": 18 }` |
|
|
184
|
+
| `gte` | Greater than or equal | `{ "type": "gte", "value": 18 }` |
|
|
185
|
+
| `lt` | Less than | `{ "type": "lt", "value": 65 }` |
|
|
186
|
+
| `lte` | Less than or equal | `{ "type": "lte", "value": 65 }` |
|
|
187
|
+
| `in` | In array | `{ "type": "in", "value": ["active", "pending"] }` |
|
|
188
|
+
| `notIn` | Not in array | `{ "type": "notIn", "value": ["deleted"] }` |
|
|
189
|
+
| `between` | Between range | `{ "type": "between", "value": [18, 65] }` |
|
|
190
|
+
| `isNull` | Is null | `{ "type": "isNull" }` |
|
|
191
|
+
| `isNotNull` | Is not null | `{ "type": "isNotNull" }` |
|
|
192
|
+
|
|
193
|
+
## Schema Config Options
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
interface SchemaConfig {
|
|
197
|
+
model: string; // Prisma model name
|
|
198
|
+
jsonFields?: string[]; // JSON field names for JSON filtering
|
|
199
|
+
relations?: Record<string, SchemaConfig>; // Nested relations
|
|
200
|
+
searchableFields?: string[]; // Fields for global search
|
|
201
|
+
isArray?: boolean; // Mark as array relation (one-to-many)
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## TypeScript Support
|
|
206
|
+
|
|
207
|
+
Full TypeScript support with type inference:
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
import type {
|
|
211
|
+
DataTableRequest,
|
|
212
|
+
DataTableResponse,
|
|
213
|
+
} from "@your-org/prisma-datatable";
|
|
214
|
+
|
|
215
|
+
// Type-safe request
|
|
216
|
+
const request: DataTableRequest = {
|
|
217
|
+
page: 1,
|
|
218
|
+
perPage: 10,
|
|
219
|
+
filters: {
|
|
220
|
+
status: { type: "eq", value: "active" },
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// Type-safe response
|
|
225
|
+
const response: DataTableResponse<User> = await getUsersDataTable(request);
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Security
|
|
229
|
+
|
|
230
|
+
- ✅ **SQL Injection Safe** - All values are parameterized through Prisma
|
|
231
|
+
- ✅ **Type Validation** - Use Zod or similar for request validation
|
|
232
|
+
- ✅ **Field Whitelisting** - Control searchable fields via schema config
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
MIT
|
|
237
|
+
|
|
238
|
+
## Contributing
|
|
239
|
+
|
|
240
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
|
241
|
+
|
|
242
|
+
## Support
|
|
243
|
+
|
|
244
|
+
- GitHub Issues: https://github.com/yourusername/prisma-datatable/issues
|
|
245
|
+
- Documentation: https://github.com/yourusername/prisma-datatable#readme
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DataTableRequest, SchemaConfig } from "./types";
|
|
2
|
+
export declare class DTReqAdapter {
|
|
3
|
+
private request;
|
|
4
|
+
private baseUrl;
|
|
5
|
+
private schema;
|
|
6
|
+
constructor(request: DataTableRequest, schema: SchemaConfig, baseUrl?: string);
|
|
7
|
+
getWhereClause(): any;
|
|
8
|
+
private buildGlobalSearchCondition;
|
|
9
|
+
private buildNestedSearchCondition;
|
|
10
|
+
private buildFilterCondition;
|
|
11
|
+
private isJsonField;
|
|
12
|
+
private buildJsonFilter;
|
|
13
|
+
private buildDirectFilter;
|
|
14
|
+
private buildNestedFilter;
|
|
15
|
+
getOrderByClause(): any[];
|
|
16
|
+
getSkip(): number;
|
|
17
|
+
getTake(): number;
|
|
18
|
+
getPage(): number;
|
|
19
|
+
getPerPage(): number;
|
|
20
|
+
getIncludeClause(): any;
|
|
21
|
+
private buildNestedInclude;
|
|
22
|
+
getSelectClause(): any;
|
|
23
|
+
private buildNestedSelect;
|
|
24
|
+
toPrismaQuery(customInclude?: any): any;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=DTReqAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTReqAdapter.d.ts","sourceRoot":"","sources":["../src/DTReqAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAU,YAAY,EAAE,MAAM,SAAS,CAAC;AAEtE,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAe;gBAG3B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,MAAW;IAUtB,cAAc,IAAI,GAAG;IA6BrB,OAAO,CAAC,0BAA0B;IA6DlC,OAAO,CAAC,0BAA0B;IAsClC,OAAO,CAAC,oBAAoB;IAuB5B,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,eAAe;IA6FvB,OAAO,CAAC,iBAAiB;IAmDzB,OAAO,CAAC,iBAAiB;IAgEzB,gBAAgB,IAAI,GAAG,EAAE;IAoBzB,OAAO,IAAI,MAAM;IAMjB,OAAO,IAAI,MAAM;IAIjB,OAAO,IAAI,MAAM;IAIjB,UAAU,IAAI,MAAM;IAOpB,gBAAgB,IAAI,GAAG;IAkBvB,OAAO,CAAC,kBAAkB;IAqB1B,eAAe,IAAI,GAAG;IAkBtB,OAAO,CAAC,iBAAiB;IAmBzB,aAAa,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,GAAG;CAmBxC"}
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DTReqAdapter = void 0;
|
|
4
|
+
const client_1 = require("@prisma/client");
|
|
5
|
+
class DTReqAdapter {
|
|
6
|
+
constructor(request, schema, baseUrl = "") {
|
|
7
|
+
this.request = request;
|
|
8
|
+
this.schema = schema;
|
|
9
|
+
this.baseUrl = baseUrl;
|
|
10
|
+
}
|
|
11
|
+
getWhereClause() {
|
|
12
|
+
const where = { AND: [] };
|
|
13
|
+
if (this.request.globalSearch && this.schema.searchableFields) {
|
|
14
|
+
const globalSearchCondition = this.buildGlobalSearchCondition(this.request.globalSearch);
|
|
15
|
+
if (globalSearchCondition) {
|
|
16
|
+
where.AND.push(globalSearchCondition);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (this.request.filters) {
|
|
20
|
+
for (const [key, filter] of Object.entries(this.request.filters)) {
|
|
21
|
+
const condition = this.buildFilterCondition(key, filter);
|
|
22
|
+
if (condition) {
|
|
23
|
+
where.AND.push(condition);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return where.AND.length > 0 ? where : {};
|
|
28
|
+
}
|
|
29
|
+
buildGlobalSearchCondition(searchTerm) {
|
|
30
|
+
if (!this.schema.searchableFields ||
|
|
31
|
+
this.schema.searchableFields.length === 0) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const orConditions = [];
|
|
35
|
+
for (const field of this.schema.searchableFields) {
|
|
36
|
+
const parts = field.split(".");
|
|
37
|
+
if (parts.length === 1) {
|
|
38
|
+
orConditions.push({
|
|
39
|
+
[field]: { contains: searchTerm, mode: "insensitive" },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const [relation, ...restParts] = parts;
|
|
44
|
+
const relationSchema = this.schema.relations?.[relation];
|
|
45
|
+
if (restParts.length === 1) {
|
|
46
|
+
if (relationSchema?.isArray) {
|
|
47
|
+
orConditions.push({
|
|
48
|
+
[relation]: {
|
|
49
|
+
some: {
|
|
50
|
+
[restParts[0]]: { contains: searchTerm, mode: "insensitive" },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
orConditions.push({
|
|
57
|
+
[relation]: {
|
|
58
|
+
[restParts[0]]: { contains: searchTerm, mode: "insensitive" },
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const nestedCondition = this.buildNestedSearchCondition(parts, searchTerm);
|
|
65
|
+
if (nestedCondition) {
|
|
66
|
+
orConditions.push(nestedCondition);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return orConditions.length > 0 ? { OR: orConditions } : null;
|
|
72
|
+
}
|
|
73
|
+
buildNestedSearchCondition(parts, searchTerm) {
|
|
74
|
+
const [relation, ...restParts] = parts;
|
|
75
|
+
const relationSchema = this.schema.relations?.[relation];
|
|
76
|
+
if (restParts.length === 1) {
|
|
77
|
+
if (relationSchema?.isArray) {
|
|
78
|
+
return {
|
|
79
|
+
[relation]: {
|
|
80
|
+
some: {
|
|
81
|
+
[restParts[0]]: { contains: searchTerm, mode: "insensitive" },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return {
|
|
88
|
+
[relation]: {
|
|
89
|
+
[restParts[0]]: { contains: searchTerm, mode: "insensitive" },
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
if (relationSchema?.isArray) {
|
|
96
|
+
return {
|
|
97
|
+
[relation]: {
|
|
98
|
+
some: this.buildNestedSearchCondition(restParts, searchTerm),
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return {
|
|
104
|
+
[relation]: this.buildNestedSearchCondition(restParts, searchTerm),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
buildFilterCondition(key, filter) {
|
|
110
|
+
const parts = key.split(".");
|
|
111
|
+
if (parts.length === 1) {
|
|
112
|
+
return this.buildDirectFilter(key, filter);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const firstPart = parts[0];
|
|
116
|
+
if (this.isJsonField(firstPart, this.schema)) {
|
|
117
|
+
return this.buildJsonFilter(parts, filter);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return this.buildNestedFilter(parts, filter, this.schema);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
isJsonField(fieldName, schema) {
|
|
125
|
+
return schema.jsonFields?.includes(fieldName) || false;
|
|
126
|
+
}
|
|
127
|
+
buildJsonFilter(parts, filter) {
|
|
128
|
+
const [fieldName, ...pathParts] = parts;
|
|
129
|
+
const jsonPath = pathParts;
|
|
130
|
+
switch (filter.type) {
|
|
131
|
+
case "eq":
|
|
132
|
+
return {
|
|
133
|
+
[fieldName]: {
|
|
134
|
+
path: jsonPath,
|
|
135
|
+
equals: filter.value,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
case "neq":
|
|
139
|
+
return {
|
|
140
|
+
[fieldName]: {
|
|
141
|
+
path: jsonPath,
|
|
142
|
+
not: filter.value,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
case "like":
|
|
146
|
+
return {
|
|
147
|
+
[fieldName]: {
|
|
148
|
+
path: jsonPath,
|
|
149
|
+
string_contains: filter.value,
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
case "gt":
|
|
153
|
+
return {
|
|
154
|
+
[fieldName]: {
|
|
155
|
+
path: jsonPath,
|
|
156
|
+
gt: filter.value,
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
case "gte":
|
|
160
|
+
return {
|
|
161
|
+
[fieldName]: {
|
|
162
|
+
path: jsonPath,
|
|
163
|
+
gte: filter.value,
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
case "lt":
|
|
167
|
+
return {
|
|
168
|
+
[fieldName]: {
|
|
169
|
+
path: jsonPath,
|
|
170
|
+
lt: filter.value,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
case "lte":
|
|
174
|
+
return {
|
|
175
|
+
[fieldName]: {
|
|
176
|
+
path: jsonPath,
|
|
177
|
+
lte: filter.value,
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
case "in":
|
|
181
|
+
return {
|
|
182
|
+
[fieldName]: {
|
|
183
|
+
path: jsonPath,
|
|
184
|
+
in: filter.value,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
case "isNull":
|
|
188
|
+
return {
|
|
189
|
+
[fieldName]: {
|
|
190
|
+
path: jsonPath,
|
|
191
|
+
equals: client_1.Prisma.JsonNull,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
case "isNotNull":
|
|
195
|
+
return {
|
|
196
|
+
[fieldName]: {
|
|
197
|
+
path: jsonPath,
|
|
198
|
+
not: client_1.Prisma.JsonNull,
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
default:
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
buildDirectFilter(field, filter) {
|
|
206
|
+
switch (filter.type) {
|
|
207
|
+
case "eq":
|
|
208
|
+
return { [field]: { equals: filter.value } };
|
|
209
|
+
case "neq":
|
|
210
|
+
return { [field]: { not: filter.value } };
|
|
211
|
+
case "like":
|
|
212
|
+
return { [field]: { contains: filter.value, mode: "insensitive" } };
|
|
213
|
+
case "gt":
|
|
214
|
+
return { [field]: { gt: filter.value } };
|
|
215
|
+
case "gte":
|
|
216
|
+
return { [field]: { gte: filter.value } };
|
|
217
|
+
case "lt":
|
|
218
|
+
return { [field]: { lt: filter.value } };
|
|
219
|
+
case "lte":
|
|
220
|
+
return { [field]: { lte: filter.value } };
|
|
221
|
+
case "in":
|
|
222
|
+
return { [field]: { in: filter.value } };
|
|
223
|
+
case "notIn":
|
|
224
|
+
return { [field]: { notIn: filter.value } };
|
|
225
|
+
case "between":
|
|
226
|
+
return {
|
|
227
|
+
AND: [
|
|
228
|
+
{ [field]: { gte: filter.value[0] } },
|
|
229
|
+
{ [field]: { lte: filter.value[1] } },
|
|
230
|
+
],
|
|
231
|
+
};
|
|
232
|
+
case "isNull":
|
|
233
|
+
return { [field]: null };
|
|
234
|
+
case "isNotNull":
|
|
235
|
+
return { [field]: { not: null } };
|
|
236
|
+
default:
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
buildNestedFilter(parts, filter, currentSchema) {
|
|
241
|
+
const [relation, ...restParts] = parts;
|
|
242
|
+
const relationSchema = currentSchema.relations?.[relation];
|
|
243
|
+
if (!relationSchema) {
|
|
244
|
+
throw new Error(`Relation '${relation}' not found in schema config for model '${currentSchema.model}'. ` +
|
|
245
|
+
`Please add it to the relations config.`);
|
|
246
|
+
}
|
|
247
|
+
if (restParts.length === 1) {
|
|
248
|
+
const field = restParts[0];
|
|
249
|
+
let condition;
|
|
250
|
+
if (this.isJsonField(field, relationSchema)) {
|
|
251
|
+
condition = this.buildJsonFilter([field], filter);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
condition = this.buildDirectFilter(field, filter);
|
|
255
|
+
}
|
|
256
|
+
if (relationSchema.isArray) {
|
|
257
|
+
return {
|
|
258
|
+
[relation]: { some: condition },
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
return {
|
|
263
|
+
[relation]: condition,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
const nextPart = restParts[0];
|
|
269
|
+
let nestedCondition;
|
|
270
|
+
if (this.isJsonField(nextPart, relationSchema)) {
|
|
271
|
+
nestedCondition = this.buildJsonFilter(restParts, filter);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
nestedCondition = this.buildNestedFilter(restParts, filter, relationSchema);
|
|
275
|
+
}
|
|
276
|
+
if (relationSchema.isArray) {
|
|
277
|
+
return {
|
|
278
|
+
[relation]: { some: nestedCondition },
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
return {
|
|
283
|
+
[relation]: nestedCondition,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
getOrderByClause() {
|
|
289
|
+
if (!this.request.sort || this.request.sort.length === 0) {
|
|
290
|
+
return [];
|
|
291
|
+
}
|
|
292
|
+
return this.request.sort.map((sortItem) => {
|
|
293
|
+
if (sortItem.relation) {
|
|
294
|
+
return {
|
|
295
|
+
[sortItem.relation]: {
|
|
296
|
+
[sortItem.column]: sortItem.direction,
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
return {
|
|
302
|
+
[sortItem.column]: sortItem.direction,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
getSkip() {
|
|
308
|
+
const page = this.request.page || 1;
|
|
309
|
+
const perPage = this.request.perPage || 10;
|
|
310
|
+
return (page - 1) * perPage;
|
|
311
|
+
}
|
|
312
|
+
getTake() {
|
|
313
|
+
return this.request.perPage || 10;
|
|
314
|
+
}
|
|
315
|
+
getPage() {
|
|
316
|
+
return this.request.page || 1;
|
|
317
|
+
}
|
|
318
|
+
getPerPage() {
|
|
319
|
+
return this.request.perPage || 10;
|
|
320
|
+
}
|
|
321
|
+
getIncludeClause() {
|
|
322
|
+
if (!this.request.includeRelations ||
|
|
323
|
+
this.request.includeRelations.length === 0) {
|
|
324
|
+
return undefined;
|
|
325
|
+
}
|
|
326
|
+
const include = {};
|
|
327
|
+
for (const relation of this.request.includeRelations) {
|
|
328
|
+
const parts = relation.split(".");
|
|
329
|
+
this.buildNestedInclude(include, parts);
|
|
330
|
+
}
|
|
331
|
+
return include;
|
|
332
|
+
}
|
|
333
|
+
buildNestedInclude(target, parts) {
|
|
334
|
+
const [current, ...rest] = parts;
|
|
335
|
+
if (rest.length === 0) {
|
|
336
|
+
if (!target[current]) {
|
|
337
|
+
target[current] = true;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
if (!target[current]) {
|
|
342
|
+
target[current] = { include: {} };
|
|
343
|
+
}
|
|
344
|
+
else if (target[current] === true) {
|
|
345
|
+
target[current] = { include: {} };
|
|
346
|
+
}
|
|
347
|
+
this.buildNestedInclude(target[current].include, rest);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
getSelectClause() {
|
|
351
|
+
if (!this.request.selectColumns ||
|
|
352
|
+
this.request.selectColumns.length === 0) {
|
|
353
|
+
return undefined;
|
|
354
|
+
}
|
|
355
|
+
const select = {};
|
|
356
|
+
for (const column of this.request.selectColumns) {
|
|
357
|
+
const parts = column.split(".");
|
|
358
|
+
this.buildNestedSelect(select, parts);
|
|
359
|
+
}
|
|
360
|
+
return select;
|
|
361
|
+
}
|
|
362
|
+
buildNestedSelect(target, parts) {
|
|
363
|
+
const [current, ...rest] = parts;
|
|
364
|
+
if (rest.length === 0) {
|
|
365
|
+
target[current] = true;
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
if (!target[current]) {
|
|
369
|
+
target[current] = { select: {} };
|
|
370
|
+
}
|
|
371
|
+
else if (target[current] === true) {
|
|
372
|
+
target[current] = { select: {} };
|
|
373
|
+
}
|
|
374
|
+
this.buildNestedSelect(target[current].select, rest);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
toPrismaQuery(customInclude) {
|
|
378
|
+
const include = customInclude || this.getIncludeClause();
|
|
379
|
+
const select = this.getSelectClause();
|
|
380
|
+
const query = {
|
|
381
|
+
where: this.getWhereClause(),
|
|
382
|
+
orderBy: this.getOrderByClause(),
|
|
383
|
+
skip: this.getSkip(),
|
|
384
|
+
take: this.getTake(),
|
|
385
|
+
};
|
|
386
|
+
if (select) {
|
|
387
|
+
query.select = select;
|
|
388
|
+
}
|
|
389
|
+
else if (include) {
|
|
390
|
+
query.include = include;
|
|
391
|
+
}
|
|
392
|
+
return query;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
exports.DTReqAdapter = DTReqAdapter;
|
|
396
|
+
//# sourceMappingURL=DTReqAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTReqAdapter.js","sourceRoot":"","sources":["../src/DTReqAdapter.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAGxC,MAAa,YAAY;IAKvB,YACE,OAAyB,EACzB,MAAoB,EACpB,UAAkB,EAAE;QAEpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAKD,cAAc;QACZ,MAAM,KAAK,GAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;QAG/B,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC9D,MAAM,qBAAqB,GAAG,IAAI,CAAC,0BAA0B,CAC3D,IAAI,CAAC,OAAO,CAAC,Y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AAC;QACvD,CAAC;IACH,CAAC;IAKD,aAAa,CAAC,aAAmB;QAC/B,MAAM,OAAO,GAAG,aAAa,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAEtC,MAAM,KAAK,GAAQ;YACjB,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE;YAC5B,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE;YAChC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;YACpB,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAC;QAEF,IAAI,MAAM,EAAE,CAAC;YACX,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;QACxB,CAAC;aAAM,IAAI,OAAO,EAAE,CAAC;YACnB,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;QAC1B,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAxgBD,oCAwgBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DataTableRequest, DataTableResponse } from "./types";
|
|
2
|
+
export declare class DTResAdapter<T = any> {
|
|
3
|
+
private data;
|
|
4
|
+
private total;
|
|
5
|
+
private page;
|
|
6
|
+
private perPage;
|
|
7
|
+
private baseUrl;
|
|
8
|
+
constructor(data: T[], total: number, page: number, perPage: number, baseUrl?: string);
|
|
9
|
+
private getMeta;
|
|
10
|
+
toResponse(): DataTableResponse<T>;
|
|
11
|
+
static fromPrisma<T>(data: T[], total: number, request: DataTableRequest, baseUrl?: string): DataTableResponse<T>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=DTResAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTResAdapter.d.ts","sourceRoot":"","sources":["../src/DTResAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,SAAS,CAAC;AAEjB,qBAAa,YAAY,CAAC,CAAC,GAAG,GAAG;IAC/B,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;gBAGtB,IAAI,EAAE,CAAC,EAAE,EACT,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,MAAW;IAYtB,OAAO,CAAC,OAAO;IAkBf,UAAU,IAAI,iBAAiB,CAAC,CAAC,CAAC;IAUlC,MAAM,CAAC,UAAU,CAAC,CAAC,EACjB,IAAI,EAAE,CAAC,EAAE,EACT,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,MAAW,GACnB,iBAAiB,CAAC,CAAC,CAAC;CAUxB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DTResAdapter = void 0;
|
|
4
|
+
class DTResAdapter {
|
|
5
|
+
constructor(data, total, page, perPage, baseUrl = "") {
|
|
6
|
+
this.data = data;
|
|
7
|
+
this.total = total;
|
|
8
|
+
this.page = page;
|
|
9
|
+
this.perPage = perPage;
|
|
10
|
+
this.baseUrl = baseUrl;
|
|
11
|
+
}
|
|
12
|
+
getMeta() {
|
|
13
|
+
const lastPage = Math.ceil(this.total / this.perPage);
|
|
14
|
+
const from = this.total === 0 ? 0 : (this.page - 1) * this.perPage + 1;
|
|
15
|
+
const to = Math.min(this.page * this.perPage, this.total);
|
|
16
|
+
return {
|
|
17
|
+
current_page: this.page,
|
|
18
|
+
per_page: this.perPage,
|
|
19
|
+
from,
|
|
20
|
+
to,
|
|
21
|
+
total: this.total,
|
|
22
|
+
last_page: lastPage,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
toResponse() {
|
|
26
|
+
return {
|
|
27
|
+
data: this.data,
|
|
28
|
+
meta: this.getMeta(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
static fromPrisma(data, total, request, baseUrl = "") {
|
|
32
|
+
const adapter = new DTResAdapter(data, total, request.page || 1, request.perPage || 10, baseUrl);
|
|
33
|
+
return adapter.toResponse();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.DTResAdapter = DTResAdapter;
|
|
37
|
+
//# sourceMappingURL=DTResAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTResAdapter.js","sourceRoot":"","sources":["../src/DTResAdapter.ts"],"names":[],"mappings":";;;AAMA,MAAa,YAAY;IAOvB,YACE,IAAS,EACT,KAAa,EACb,IAAY,EACZ,OAAe,EACf,UAAkB,EAAE;QAEpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAKO,OAAO;QACb,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACvE,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAE1D,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,IAAI;YACvB,QAAQ,EAAE,IAAI,CAAC,OAAO;YACtB,IAAI;YACJ,EAAE;YACF,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,QAAQ;SACpB,CAAC;IACJ,CAAC;IAKD,UAAU;QACR,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAC;IACJ,CAAC;IAKD,MAAM,CAAC,UAAU,CACf,IAAS,EACT,KAAa,EACb,OAAyB,EACzB,UAAkB,EAAE;QAEpB,MAAM,OAAO,GAAG,IAAI,YAAY,CAC9B,IAAI,EACJ,KAAK,EACL,OAAO,CAAC,IAAI,IAAI,CAAC,EACjB,OAAO,CAAC,OAAO,IAAI,EAAE,EACrB,OAAO,CACR,CAAC;QACF,OAAO,OAAO,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;CACF;AAnED,oCAmEC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,UAAU,EACV,cAAc,EACd,YAAY,EACZ,QAAQ,GACT,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DTResAdapter = exports.DTReqAdapter = void 0;
|
|
4
|
+
var DTReqAdapter_1 = require("./DTReqAdapter");
|
|
5
|
+
Object.defineProperty(exports, "DTReqAdapter", { enumerable: true, get: function () { return DTReqAdapter_1.DTReqAdapter; } });
|
|
6
|
+
var DTResAdapter_1 = require("./DTResAdapter");
|
|
7
|
+
Object.defineProperty(exports, "DTResAdapter", { enumerable: true, get: function () { return DTResAdapter_1.DTResAdapter; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type FilterType = "eq" | "neq" | "like" | "gt" | "gte" | "lt" | "lte" | "in" | "notIn" | "between" | "isNull" | "isNotNull";
|
|
2
|
+
export interface Filter {
|
|
3
|
+
type: FilterType;
|
|
4
|
+
value?: any;
|
|
5
|
+
}
|
|
6
|
+
export interface SortItem {
|
|
7
|
+
column: string;
|
|
8
|
+
direction: "asc" | "desc";
|
|
9
|
+
relation?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DataTableRequest {
|
|
12
|
+
page?: number;
|
|
13
|
+
perPage?: number;
|
|
14
|
+
filters?: Record<string, Filter>;
|
|
15
|
+
sort?: SortItem[];
|
|
16
|
+
globalSearch?: string;
|
|
17
|
+
includeRelations?: string[];
|
|
18
|
+
selectColumns?: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface PaginationMeta {
|
|
21
|
+
current_page: number;
|
|
22
|
+
per_page: number;
|
|
23
|
+
from: number;
|
|
24
|
+
to: number;
|
|
25
|
+
total: number;
|
|
26
|
+
last_page: number;
|
|
27
|
+
}
|
|
28
|
+
export interface DataTableResponse<T> {
|
|
29
|
+
data: T[];
|
|
30
|
+
meta: PaginationMeta;
|
|
31
|
+
}
|
|
32
|
+
export interface SchemaConfig {
|
|
33
|
+
model: string;
|
|
34
|
+
jsonFields?: string[];
|
|
35
|
+
relations?: Record<string, SchemaConfig>;
|
|
36
|
+
searchableFields?: string[];
|
|
37
|
+
isArray?: boolean;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.d.ts.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AAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "prisma-dt",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A powerful DataTable integration for Prisma ORM with advanced filtering, sorting, pagination, global search, and relation support",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"prepublishOnly": "npm run build",
|
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"prisma",
|
|
19
|
+
"datatable",
|
|
20
|
+
"pagination",
|
|
21
|
+
"filtering",
|
|
22
|
+
"sorting",
|
|
23
|
+
"orm",
|
|
24
|
+
"typescript",
|
|
25
|
+
"database"
|
|
26
|
+
],
|
|
27
|
+
"author": "Your Name",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@prisma/client": "^5.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@prisma/client": "^5.22.0",
|
|
34
|
+
"typescript": "^5.3.3"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/yourusername/prisma-datatable.git"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/yourusername/prisma-datatable/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/yourusername/prisma-datatable#readme"
|
|
44
|
+
}
|