express-model-binding 1.0.0 → 1.1.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.
Files changed (51) hide show
  1. package/dist/{BaseAdapter-BjvLQijd.d.mts → BaseAdapter-Dr9a8ZUY.d.mts} +17 -1
  2. package/dist/{BaseAdapter-BjvLQijd.d.ts → BaseAdapter-Dr9a8ZUY.d.ts} +17 -1
  3. package/dist/adapters/KnexAdapter.d.mts +1 -1
  4. package/dist/adapters/KnexAdapter.d.ts +1 -1
  5. package/dist/adapters/KnexAdapter.js +1 -257
  6. package/dist/adapters/KnexAdapter.mjs +1 -229
  7. package/dist/adapters/MongooseAdapter.d.mts +1 -1
  8. package/dist/adapters/MongooseAdapter.d.ts +1 -1
  9. package/dist/adapters/MongooseAdapter.js +1 -245
  10. package/dist/adapters/MongooseAdapter.mjs +1 -225
  11. package/dist/adapters/PrismaAdapter.d.mts +1 -1
  12. package/dist/adapters/PrismaAdapter.d.ts +1 -1
  13. package/dist/adapters/PrismaAdapter.js +1 -247
  14. package/dist/adapters/PrismaAdapter.mjs +1 -220
  15. package/dist/adapters/SequelizeAdapter.d.mts +1 -1
  16. package/dist/adapters/SequelizeAdapter.d.ts +1 -1
  17. package/dist/adapters/SequelizeAdapter.js +1 -280
  18. package/dist/adapters/SequelizeAdapter.mjs +1 -260
  19. package/dist/adapters/TypeORMAdapter.d.mts +1 -1
  20. package/dist/adapters/TypeORMAdapter.d.ts +1 -1
  21. package/dist/adapters/TypeORMAdapter.js +1 -294
  22. package/dist/adapters/TypeORMAdapter.mjs +1 -267
  23. package/dist/chunk-7I3EYD6K.js +1 -0
  24. package/dist/chunk-7OR75DD2.mjs +1 -0
  25. package/dist/chunk-A7LUHNSI.mjs +1 -0
  26. package/dist/chunk-B3DBSP2J.mjs +1 -0
  27. package/dist/chunk-CKT6LD2K.js +1 -0
  28. package/dist/chunk-DBYMXDVA.mjs +1 -0
  29. package/dist/chunk-EEPSARTF.js +1 -0
  30. package/dist/chunk-ISSVD3WP.js +1 -0
  31. package/dist/chunk-LLYCNTZ7.mjs +1 -0
  32. package/dist/chunk-OKPAWWZN.js +1 -0
  33. package/dist/chunk-Z6WU7X3A.mjs +1 -0
  34. package/dist/chunk-ZJ2WW53U.js +1 -0
  35. package/dist/index.d.mts +4 -3
  36. package/dist/index.d.ts +4 -3
  37. package/dist/index.js +1 -1514
  38. package/dist/index.mjs +1 -1450
  39. package/package.json +5 -3
  40. package/dist/adapters/KnexAdapter.js.map +0 -1
  41. package/dist/adapters/KnexAdapter.mjs.map +0 -1
  42. package/dist/adapters/MongooseAdapter.js.map +0 -1
  43. package/dist/adapters/MongooseAdapter.mjs.map +0 -1
  44. package/dist/adapters/PrismaAdapter.js.map +0 -1
  45. package/dist/adapters/PrismaAdapter.mjs.map +0 -1
  46. package/dist/adapters/SequelizeAdapter.js.map +0 -1
  47. package/dist/adapters/SequelizeAdapter.mjs.map +0 -1
  48. package/dist/adapters/TypeORMAdapter.js.map +0 -1
  49. package/dist/adapters/TypeORMAdapter.mjs.map +0 -1
  50. package/dist/index.js.map +0 -1
  51. package/dist/index.mjs.map +0 -1
@@ -1,294 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/adapters/TypeORMAdapter.ts
21
- var TypeORMAdapter_exports = {};
22
- __export(TypeORMAdapter_exports, {
23
- TypeORMAdapter: () => TypeORMAdapter
24
- });
25
- module.exports = __toCommonJS(TypeORMAdapter_exports);
26
-
27
- // src/errors/index.ts
28
- var BindingError = class extends Error {
29
- constructor(message, originalError) {
30
- super(message);
31
- this.name = "BindingError";
32
- this.originalError = originalError;
33
- Error.captureStackTrace(this, this.constructor);
34
- }
35
- toJSON() {
36
- return {
37
- name: this.name,
38
- message: this.message,
39
- originalError: this.originalError?.message
40
- };
41
- }
42
- };
43
- var InvalidModelError = class extends Error {
44
- constructor(message, model) {
45
- super(message);
46
- this.name = "InvalidModelError";
47
- this.model = model;
48
- Error.captureStackTrace(this, this.constructor);
49
- }
50
- toJSON() {
51
- return {
52
- name: this.name,
53
- message: this.message,
54
- model: typeof this.model === "string" ? this.model : String(this.model)
55
- };
56
- }
57
- };
58
-
59
- // src/core/BaseAdapter.ts
60
- var BaseAdapter = class {
61
- transformValue(_model, _key, value) {
62
- if (/^\d+$/.test(value)) {
63
- const num = parseInt(value, 10);
64
- if (!isNaN(num) && Number.isSafeInteger(num)) {
65
- return num;
66
- }
67
- }
68
- return value;
69
- }
70
- supportsSoftDeletes(_model) {
71
- return false;
72
- }
73
- getModelMetadata(model) {
74
- return {
75
- name: this.getModelName(model),
76
- primaryKey: this.getPrimaryKeyName(model),
77
- softDeletes: this.supportsSoftDeletes(model),
78
- adapter: this.name
79
- };
80
- }
81
- validateModel(model) {
82
- if (!this.isValidModel(model)) {
83
- throw new InvalidModelError(`Invalid model for ${this.name} adapter`, model);
84
- }
85
- }
86
- getModelName(model) {
87
- if (typeof model === "string") {
88
- return model;
89
- }
90
- if (model && typeof model === "object") {
91
- const obj = model;
92
- if (typeof obj.name === "string") return obj.name;
93
- if (typeof obj.modelName === "string") return obj.modelName;
94
- if (typeof obj.tableName === "string") return obj.tableName;
95
- }
96
- if (model && typeof model === "function") {
97
- return model.name || "Unknown";
98
- }
99
- return "Unknown";
100
- }
101
- applySoftDeleteFilter(queryBuilder, _options) {
102
- return queryBuilder;
103
- }
104
- applyIncludes(queryBuilder, _includes) {
105
- return queryBuilder;
106
- }
107
- applySelect(queryBuilder, _select) {
108
- return queryBuilder;
109
- }
110
- applyWhereConditions(queryBuilder, _where) {
111
- return queryBuilder;
112
- }
113
- applyCustomQuery(queryBuilder, queryFn) {
114
- if (queryFn) {
115
- return queryFn(queryBuilder);
116
- }
117
- return queryBuilder;
118
- }
119
- };
120
-
121
- // src/utils/validators.ts
122
- var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
123
- function isUUID(value) {
124
- return UUID_REGEX.test(value);
125
- }
126
-
127
- // src/adapters/TypeORMAdapter.ts
128
- var TypeORMAdapter = class extends BaseAdapter {
129
- constructor(dataSource) {
130
- super();
131
- this.dataSource = dataSource;
132
- this.name = "typeorm";
133
- }
134
- getDataSource() {
135
- return this.dataSource;
136
- }
137
- async findByKey(entity, key, value, options = {}) {
138
- this.validateModel(entity);
139
- try {
140
- const repository = this.dataSource.getRepository(entity);
141
- const metadata = repository.metadata;
142
- const transformedValue = this.transformValue(entity, key, value);
143
- if (options.query || options.lock || options.onlyTrashed) {
144
- return await this.findWithQueryBuilder(repository, key, transformedValue, options);
145
- }
146
- const findOptions = {
147
- where: { [key]: transformedValue }
148
- };
149
- if (options.select && options.select.length > 0) {
150
- findOptions.select = options.select.reduce((acc, field) => {
151
- acc[field] = true;
152
- return acc;
153
- }, {});
154
- }
155
- if (options.include) {
156
- findOptions.relations = Array.isArray(options.include) ? options.include : Object.keys(options.include);
157
- }
158
- if (options.where) {
159
- findOptions.where = {
160
- ...findOptions.where,
161
- ...options.where
162
- };
163
- }
164
- if (options.withTrashed && metadata.deleteDateColumn) {
165
- findOptions.withDeleted = true;
166
- }
167
- const result = await repository.findOne(findOptions);
168
- return result;
169
- } catch (error) {
170
- throw new BindingError(`Failed to fetch entity: ${error.message}`, error);
171
- }
172
- }
173
- getPrimaryKeyName(entity) {
174
- try {
175
- const repository = this.dataSource.getRepository(entity);
176
- const metadata = repository.metadata;
177
- if (metadata.primaryColumns.length > 0) {
178
- return metadata.primaryColumns[0].propertyName;
179
- }
180
- } catch {
181
- }
182
- return "id";
183
- }
184
- isValidModel(model) {
185
- try {
186
- this.dataSource.getRepository(model);
187
- return true;
188
- } catch {
189
- return false;
190
- }
191
- }
192
- transformValue(entity, key, value) {
193
- try {
194
- const repository = this.dataSource.getRepository(entity);
195
- const metadata = repository.metadata;
196
- const column = metadata.findColumnWithPropertyName(key);
197
- if (!column) {
198
- if (isUUID(value)) {
199
- return value;
200
- }
201
- const num = parseInt(value, 10);
202
- if (!isNaN(num) && num.toString() === value) {
203
- return num;
204
- }
205
- return value;
206
- }
207
- const columnType = String(column.type).toLowerCase();
208
- if (["int", "integer", "smallint", "bigint", "number"].includes(columnType)) {
209
- const num = parseInt(value, 10);
210
- return isNaN(num) ? value : num;
211
- }
212
- if (columnType === "uuid") {
213
- return value;
214
- }
215
- if (columnType === "boolean" || columnType === "bool") {
216
- return value === "true" || value === "1";
217
- }
218
- return value;
219
- } catch {
220
- return value;
221
- }
222
- }
223
- supportsSoftDeletes(entity) {
224
- try {
225
- const repository = this.dataSource.getRepository(entity);
226
- const metadata = repository.metadata;
227
- return !!metadata.deleteDateColumn;
228
- } catch {
229
- return false;
230
- }
231
- }
232
- getModelMetadata(entity) {
233
- try {
234
- const repository = this.dataSource.getRepository(entity);
235
- const metadata = repository.metadata;
236
- return {
237
- name: metadata.name,
238
- primaryKey: this.getPrimaryKeyName(entity),
239
- tableName: metadata.tableName,
240
- softDeletes: this.supportsSoftDeletes(entity),
241
- relations: metadata.relations.map((r) => r.propertyName),
242
- adapter: this.name
243
- };
244
- } catch {
245
- return {
246
- name: "Unknown",
247
- primaryKey: "id",
248
- softDeletes: false,
249
- adapter: this.name
250
- };
251
- }
252
- }
253
- async findWithQueryBuilder(repository, key, value, options) {
254
- const metadata = repository.metadata;
255
- const alias = metadata.name.toLowerCase();
256
- let queryBuilder = repository.createQueryBuilder(alias).where(`${alias}.${key} = :value`, { value });
257
- if (options.include) {
258
- const relations = Array.isArray(options.include) ? options.include : Object.keys(options.include);
259
- relations.forEach((relation) => {
260
- queryBuilder = queryBuilder.leftJoinAndSelect(`${alias}.${relation}`, relation);
261
- });
262
- }
263
- if (options.where) {
264
- Object.entries(options.where).forEach(([field, val]) => {
265
- queryBuilder = queryBuilder.andWhere(`${alias}.${field} = :${field}`, { [field]: val });
266
- });
267
- }
268
- if (options.select && options.select.length > 0) {
269
- queryBuilder = queryBuilder.select(options.select.map((field) => `${alias}.${field}`));
270
- }
271
- if (options.withTrashed) {
272
- queryBuilder = queryBuilder.withDeleted();
273
- } else if (options.onlyTrashed && metadata.deleteDateColumn) {
274
- queryBuilder = queryBuilder.withDeleted().andWhere(`${alias}.${metadata.deleteDateColumn.propertyName} IS NOT NULL`);
275
- }
276
- if (options.lock === "forUpdate") {
277
- queryBuilder = queryBuilder.setLock("pessimistic_write");
278
- } else if (options.lock === "forShare") {
279
- queryBuilder = queryBuilder.setLock("pessimistic_read");
280
- }
281
- if (options.query) {
282
- queryBuilder = this.applyCustomQuery(
283
- queryBuilder,
284
- options.query
285
- );
286
- }
287
- return await queryBuilder.getOne();
288
- }
289
- };
290
- // Annotate the CommonJS export names for ESM import in node:
291
- 0 && (module.exports = {
292
- TypeORMAdapter
293
- });
294
- //# sourceMappingURL=TypeORMAdapter.js.map
1
+ 'use strict';var chunkZJ2WW53U_js=require('../chunk-ZJ2WW53U.js');require('../chunk-7I3EYD6K.js');Object.defineProperty(exports,"TypeORMAdapter",{enumerable:true,get:function(){return chunkZJ2WW53U_js.a}});
@@ -1,267 +1 @@
1
- // src/errors/index.ts
2
- var BindingError = class extends Error {
3
- constructor(message, originalError) {
4
- super(message);
5
- this.name = "BindingError";
6
- this.originalError = originalError;
7
- Error.captureStackTrace(this, this.constructor);
8
- }
9
- toJSON() {
10
- return {
11
- name: this.name,
12
- message: this.message,
13
- originalError: this.originalError?.message
14
- };
15
- }
16
- };
17
- var InvalidModelError = class extends Error {
18
- constructor(message, model) {
19
- super(message);
20
- this.name = "InvalidModelError";
21
- this.model = model;
22
- Error.captureStackTrace(this, this.constructor);
23
- }
24
- toJSON() {
25
- return {
26
- name: this.name,
27
- message: this.message,
28
- model: typeof this.model === "string" ? this.model : String(this.model)
29
- };
30
- }
31
- };
32
-
33
- // src/core/BaseAdapter.ts
34
- var BaseAdapter = class {
35
- transformValue(_model, _key, value) {
36
- if (/^\d+$/.test(value)) {
37
- const num = parseInt(value, 10);
38
- if (!isNaN(num) && Number.isSafeInteger(num)) {
39
- return num;
40
- }
41
- }
42
- return value;
43
- }
44
- supportsSoftDeletes(_model) {
45
- return false;
46
- }
47
- getModelMetadata(model) {
48
- return {
49
- name: this.getModelName(model),
50
- primaryKey: this.getPrimaryKeyName(model),
51
- softDeletes: this.supportsSoftDeletes(model),
52
- adapter: this.name
53
- };
54
- }
55
- validateModel(model) {
56
- if (!this.isValidModel(model)) {
57
- throw new InvalidModelError(`Invalid model for ${this.name} adapter`, model);
58
- }
59
- }
60
- getModelName(model) {
61
- if (typeof model === "string") {
62
- return model;
63
- }
64
- if (model && typeof model === "object") {
65
- const obj = model;
66
- if (typeof obj.name === "string") return obj.name;
67
- if (typeof obj.modelName === "string") return obj.modelName;
68
- if (typeof obj.tableName === "string") return obj.tableName;
69
- }
70
- if (model && typeof model === "function") {
71
- return model.name || "Unknown";
72
- }
73
- return "Unknown";
74
- }
75
- applySoftDeleteFilter(queryBuilder, _options) {
76
- return queryBuilder;
77
- }
78
- applyIncludes(queryBuilder, _includes) {
79
- return queryBuilder;
80
- }
81
- applySelect(queryBuilder, _select) {
82
- return queryBuilder;
83
- }
84
- applyWhereConditions(queryBuilder, _where) {
85
- return queryBuilder;
86
- }
87
- applyCustomQuery(queryBuilder, queryFn) {
88
- if (queryFn) {
89
- return queryFn(queryBuilder);
90
- }
91
- return queryBuilder;
92
- }
93
- };
94
-
95
- // src/utils/validators.ts
96
- var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
97
- function isUUID(value) {
98
- return UUID_REGEX.test(value);
99
- }
100
-
101
- // src/adapters/TypeORMAdapter.ts
102
- var TypeORMAdapter = class extends BaseAdapter {
103
- constructor(dataSource) {
104
- super();
105
- this.dataSource = dataSource;
106
- this.name = "typeorm";
107
- }
108
- getDataSource() {
109
- return this.dataSource;
110
- }
111
- async findByKey(entity, key, value, options = {}) {
112
- this.validateModel(entity);
113
- try {
114
- const repository = this.dataSource.getRepository(entity);
115
- const metadata = repository.metadata;
116
- const transformedValue = this.transformValue(entity, key, value);
117
- if (options.query || options.lock || options.onlyTrashed) {
118
- return await this.findWithQueryBuilder(repository, key, transformedValue, options);
119
- }
120
- const findOptions = {
121
- where: { [key]: transformedValue }
122
- };
123
- if (options.select && options.select.length > 0) {
124
- findOptions.select = options.select.reduce((acc, field) => {
125
- acc[field] = true;
126
- return acc;
127
- }, {});
128
- }
129
- if (options.include) {
130
- findOptions.relations = Array.isArray(options.include) ? options.include : Object.keys(options.include);
131
- }
132
- if (options.where) {
133
- findOptions.where = {
134
- ...findOptions.where,
135
- ...options.where
136
- };
137
- }
138
- if (options.withTrashed && metadata.deleteDateColumn) {
139
- findOptions.withDeleted = true;
140
- }
141
- const result = await repository.findOne(findOptions);
142
- return result;
143
- } catch (error) {
144
- throw new BindingError(`Failed to fetch entity: ${error.message}`, error);
145
- }
146
- }
147
- getPrimaryKeyName(entity) {
148
- try {
149
- const repository = this.dataSource.getRepository(entity);
150
- const metadata = repository.metadata;
151
- if (metadata.primaryColumns.length > 0) {
152
- return metadata.primaryColumns[0].propertyName;
153
- }
154
- } catch {
155
- }
156
- return "id";
157
- }
158
- isValidModel(model) {
159
- try {
160
- this.dataSource.getRepository(model);
161
- return true;
162
- } catch {
163
- return false;
164
- }
165
- }
166
- transformValue(entity, key, value) {
167
- try {
168
- const repository = this.dataSource.getRepository(entity);
169
- const metadata = repository.metadata;
170
- const column = metadata.findColumnWithPropertyName(key);
171
- if (!column) {
172
- if (isUUID(value)) {
173
- return value;
174
- }
175
- const num = parseInt(value, 10);
176
- if (!isNaN(num) && num.toString() === value) {
177
- return num;
178
- }
179
- return value;
180
- }
181
- const columnType = String(column.type).toLowerCase();
182
- if (["int", "integer", "smallint", "bigint", "number"].includes(columnType)) {
183
- const num = parseInt(value, 10);
184
- return isNaN(num) ? value : num;
185
- }
186
- if (columnType === "uuid") {
187
- return value;
188
- }
189
- if (columnType === "boolean" || columnType === "bool") {
190
- return value === "true" || value === "1";
191
- }
192
- return value;
193
- } catch {
194
- return value;
195
- }
196
- }
197
- supportsSoftDeletes(entity) {
198
- try {
199
- const repository = this.dataSource.getRepository(entity);
200
- const metadata = repository.metadata;
201
- return !!metadata.deleteDateColumn;
202
- } catch {
203
- return false;
204
- }
205
- }
206
- getModelMetadata(entity) {
207
- try {
208
- const repository = this.dataSource.getRepository(entity);
209
- const metadata = repository.metadata;
210
- return {
211
- name: metadata.name,
212
- primaryKey: this.getPrimaryKeyName(entity),
213
- tableName: metadata.tableName,
214
- softDeletes: this.supportsSoftDeletes(entity),
215
- relations: metadata.relations.map((r) => r.propertyName),
216
- adapter: this.name
217
- };
218
- } catch {
219
- return {
220
- name: "Unknown",
221
- primaryKey: "id",
222
- softDeletes: false,
223
- adapter: this.name
224
- };
225
- }
226
- }
227
- async findWithQueryBuilder(repository, key, value, options) {
228
- const metadata = repository.metadata;
229
- const alias = metadata.name.toLowerCase();
230
- let queryBuilder = repository.createQueryBuilder(alias).where(`${alias}.${key} = :value`, { value });
231
- if (options.include) {
232
- const relations = Array.isArray(options.include) ? options.include : Object.keys(options.include);
233
- relations.forEach((relation) => {
234
- queryBuilder = queryBuilder.leftJoinAndSelect(`${alias}.${relation}`, relation);
235
- });
236
- }
237
- if (options.where) {
238
- Object.entries(options.where).forEach(([field, val]) => {
239
- queryBuilder = queryBuilder.andWhere(`${alias}.${field} = :${field}`, { [field]: val });
240
- });
241
- }
242
- if (options.select && options.select.length > 0) {
243
- queryBuilder = queryBuilder.select(options.select.map((field) => `${alias}.${field}`));
244
- }
245
- if (options.withTrashed) {
246
- queryBuilder = queryBuilder.withDeleted();
247
- } else if (options.onlyTrashed && metadata.deleteDateColumn) {
248
- queryBuilder = queryBuilder.withDeleted().andWhere(`${alias}.${metadata.deleteDateColumn.propertyName} IS NOT NULL`);
249
- }
250
- if (options.lock === "forUpdate") {
251
- queryBuilder = queryBuilder.setLock("pessimistic_write");
252
- } else if (options.lock === "forShare") {
253
- queryBuilder = queryBuilder.setLock("pessimistic_read");
254
- }
255
- if (options.query) {
256
- queryBuilder = this.applyCustomQuery(
257
- queryBuilder,
258
- options.query
259
- );
260
- }
261
- return await queryBuilder.getOne();
262
- }
263
- };
264
- export {
265
- TypeORMAdapter
266
- };
267
- //# sourceMappingURL=TypeORMAdapter.mjs.map
1
+ export{a as TypeORMAdapter}from'../chunk-A7LUHNSI.mjs';import'../chunk-DBYMXDVA.mjs';
@@ -0,0 +1 @@
1
+ 'use strict';var y=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var i=class extends Error{constructor(t,n){super(t),this.name="BindingError",this.originalError=n,Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message,originalError:this.originalError?.message}}},a=class extends Error{constructor(n,r,o,p){super(p||`${o} not found with ${n} = ${r}`);this.statusCode=404;this.name="ModelNotFoundError",this.paramName=n,this.paramValue=r,this.modelName=o,Error.captureStackTrace(this,this.constructor);}toJSON(){return {error:"Not Found",message:this.message,statusCode:this.statusCode,param:this.paramName,value:this.paramValue,model:this.modelName}}},u=class extends Error{constructor(t="No adapter set. Call ModelBinder.setAdapter() before using model binding."){super(t),this.name="AdapterNotSetError",Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message}}},s=class extends Error{constructor(t,n){super(t),this.name="InvalidModelError",this.model=n,Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message,model:typeof this.model=="string"?this.model:String(this.model)}}},l=class extends Error{constructor(t,n=400,r){super(t),this.name="ValidationError",this.statusCode=n,this.details=r,Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message,statusCode:this.statusCode,details:this.details}}};var c=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,g=/^[0-9a-f]{24}$/i;function w(e){return e.length!==36?false:c.test(e)}function T(e){return e.length!==24?false:g.test(e)}function b(e){return e.length>20?false:/^-?\d+$/.test(e)}function M(e){return e.length>19?false:/^\d+$/.test(e)&&parseInt(e,10)>0}function R(e){return e.length>1024?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)}function x(e){return e.length>254?false:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function E(e){return e==null?false:typeof e=="string"?e.trim().length>0:true}function N(e){return typeof e=="string"&&e.trim().length>0}function _(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function B(e){return typeof e=="function"}var m=new Set(["__proto__","constructor","prototype","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]);function O(e){return e.length===0||e.length>64||m.has(e)?false:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}var d=class{transformValue(t,n,r){if(/^\d+$/.test(r)){let o=parseInt(r,10);if(!isNaN(o)&&Number.isSafeInteger(o))return o}return r}supportsSoftDeletes(t){return false}getModelMetadata(t){return {name:this.getModelName(t),primaryKey:this.getPrimaryKeyName(t),softDeletes:this.supportsSoftDeletes(t),adapter:this.name}}validateModel(t){if(!this.isValidModel(t))throw new s(`Invalid model for ${this.name} adapter`,t)}getModelName(t){if(typeof t=="string")return t;if(t&&typeof t=="object"){let n=t;if(typeof n.name=="string")return n.name;if(typeof n.modelName=="string")return n.modelName;if(typeof n.tableName=="string")return n.tableName}return t&&typeof t=="function"&&t.name||"Unknown"}applySoftDeleteFilter(t,n){return t}applyIncludes(t,n){return t}applySelect(t,n){return t}applyWhereConditions(t,n){return t}applyCustomQuery(t,n){return n?n(t):t}};var f=new Set(["=","!=","<>","<",">","<=",">=","like","ilike","not like","not ilike","in","not in","between","not between","is","is not","is null","is not null"]);function q(e){return !e||e.length>128?false:/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(e)}function I(e){if(typeof e!="object"||e===null||!("operator"in e)||!("value"in e))return false;let t=e.operator;return typeof t!="string"?false:f.has(t.toLowerCase().trim())}exports.a=y;exports.b=i;exports.c=a;exports.d=u;exports.e=s;exports.f=l;exports.g=w;exports.h=T;exports.i=b;exports.j=M;exports.k=R;exports.l=x;exports.m=E;exports.n=N;exports.o=_;exports.p=B;exports.q=O;exports.r=d;exports.s=q;exports.t=I;
@@ -0,0 +1 @@
1
+ import {r,s,b,a,g}from'./chunk-DBYMXDVA.mjs';function h(c){if(!c||typeof c!="function")return false;let u=c;return typeof u.findOne=="function"&&typeof u.findAll=="function"&&typeof u.rawAttributes=="object"}var S=class extends r{constructor(e){super();this.sequelize=e;this.name="sequelize";}getSequelize(){return this.sequelize}async findByKey(e,i,t,r={}){this.validateModel(e);try{let s$1=this.transformValue(e,i,t),n={where:{[i]:s$1}};if(r.select&&r.select.length>0&&(n.attributes=r.select),r.include&&(n.include=this.buildIncludes(r.include)),r.where){for(let o of Object.keys(r.where))if(!s(o))throw new b(`Invalid field name '${o}': contains disallowed characters`,new Error("SQL injection attempt detected"));n.where={...n.where,...r.where};}if(e.options?.paranoid){if(r.withTrashed)n.paranoid=!1;else if(r.onlyTrashed){n.paranoid=!1;let{Op:o}=a("sequelize"),w=n.where;w.deletedAt={[o.ne]:null};}}if(r.lock==="forUpdate")n.lock=!0;else if(r.lock==="forShare"){let{Transaction:o}=a("sequelize");n.lock=o.LOCK.SHARE;}let a$1=await e.findOne(n);return r.query&&!a$1&&(a$1=await this.findWithCustomQuery(e,i,s$1,r)),a$1}catch(s){throw new b(`Failed to fetch ${e.name}: ${s.message}`,s)}}getPrimaryKeyName(e){return e.primaryKeyAttribute||"id"}isValidModel(e){return h(e)}transformValue(e,i,t){let s=e.rawAttributes?.[i];if(!s){if(g(t))return t;let a=parseInt(t,10);return !isNaN(a)&&a.toString()===t?a:t}let n=s.type;switch(n?.constructor?.name||String(n)){case "INTEGER":case "BIGINT":case "SMALLINT":{let a=parseInt(t,10);return isNaN(a)?t:a}case "FLOAT":case "DOUBLE":case "DECIMAL":{let a=parseFloat(t);return isNaN(a)?t:a}case "BOOLEAN":return t==="true"||t==="1";case "UUID":return t;default:return t}}supportsSoftDeletes(e){return !!e.options?.paranoid}getModelMetadata(e){let i=e.tableName||e.name,t=Object.keys(e.associations||{});return {name:e.name,primaryKey:this.getPrimaryKeyName(e),tableName:i,softDeletes:this.supportsSoftDeletes(e),relations:t,adapter:this.name}}buildIncludes(e){return Array.isArray(e)?e.map(i=>({association:i})):Object.entries(e).map(([i,t])=>typeof t=="boolean"&&t?{association:i}:typeof t=="object"&&t!==null?{association:i,...t}:{association:i})}async findWithCustomQuery(e,i,t,r){let s={where:{[i]:t}};return r.query&&r.query(s),await e.findOne(s)}};export{S as a};
@@ -0,0 +1 @@
1
+ import {r,s,b,g}from'./chunk-DBYMXDVA.mjs';var h=class extends r{constructor(i){super();this.dataSource=i;this.name="typeorm";}getDataSource(){return this.dataSource}async findByKey(i,o,r,e={}){this.validateModel(i);try{let n=this.dataSource.getRepository(i),s$1=n.metadata,t=this.transformValue(i,o,r);if(e.query||e.lock||e.onlyTrashed)return await this.findWithQueryBuilder(n,o,t,e);let a={where:{[o]:t}};if(e.select&&e.select.length>0&&(a.select=e.select.reduce((l,f)=>(l[f]=!0,l),{})),e.include&&(a.relations=Array.isArray(e.include)?e.include:Object.keys(e.include)),e.where){for(let l of Object.keys(e.where))if(!s(l))throw new b(`Invalid field name '${l}': contains disallowed characters`,new Error("SQL injection attempt detected"));a.where={...a.where,...e.where};}return e.withTrashed&&s$1.deleteDateColumn&&(a.withDeleted=!0),await n.findOne(a)}catch(n){throw new b(`Failed to fetch entity: ${n.message}`,n)}}getPrimaryKeyName(i){try{let r=this.dataSource.getRepository(i).metadata;if(r.primaryColumns.length>0)return r.primaryColumns[0].propertyName}catch{}return "id"}isValidModel(i){try{return this.dataSource.getRepository(i),!0}catch{return false}}transformValue(i,o,r){try{let s=this.dataSource.getRepository(i).metadata.findColumnWithPropertyName(o);if(!s){if(g(r))return r;let a=parseInt(r,10);return !isNaN(a)&&a.toString()===r?a:r}let t=String(s.type).toLowerCase();if(["int","integer","smallint","bigint","number"].includes(t)){let a=parseInt(r,10);return isNaN(a)?r:a}return t==="uuid"?r:t==="boolean"||t==="bool"?r==="true"||r==="1":r}catch{return r}}supportsSoftDeletes(i){try{return !!this.dataSource.getRepository(i).metadata.deleteDateColumn}catch{return false}}getModelMetadata(i){try{let r=this.dataSource.getRepository(i).metadata;return {name:r.name,primaryKey:this.getPrimaryKeyName(i),tableName:r.tableName,softDeletes:this.supportsSoftDeletes(i),relations:r.relations.map(e=>e.propertyName),adapter:this.name}}catch{return {name:"Unknown",primaryKey:"id",softDeletes:false,adapter:this.name}}}async findWithQueryBuilder(i,o,r,e){let n=i.metadata,s=n.name.toLowerCase(),t=i.createQueryBuilder(s).where(`${s}.${o} = :value`,{value:r});return e.include&&(Array.isArray(e.include)?e.include:Object.keys(e.include)).forEach(c=>{t=t.leftJoinAndSelect(`${s}.${c}`,c);}),e.where&&Object.entries(e.where).forEach(([a,c])=>{t=t.andWhere(`${s}.${a} = :${a}`,{[a]:c});}),e.select&&e.select.length>0&&(t=t.select(e.select.map(a=>`${s}.${a}`))),e.withTrashed?t=t.withDeleted():e.onlyTrashed&&n.deleteDateColumn&&(t=t.withDeleted().andWhere(`${s}.${n.deleteDateColumn.propertyName} IS NOT NULL`)),e.lock==="forUpdate"?t=t.setLock("pessimistic_write"):e.lock==="forShare"&&(t=t.setLock("pessimistic_read")),e.query&&(t=this.applyCustomQuery(t,e.query)),await t.getOne()}};export{h as a};
@@ -0,0 +1 @@
1
+ import {r,s,b,h as h$1,a}from'./chunk-DBYMXDVA.mjs';function y(i){return typeof i=="object"&&i!==null&&"instance"in i}var h=class extends r{constructor(){super(...arguments);this.name="mongoose";}async findByKey(e,n,o,t={}){this.validateModel(e);try{let r=this.transformValue(e,n,o),s$1=e.findOne({[n]:r});t.select&&t.select.length>0&&(s$1=s$1.select(t.select.join(" "))),t.include&&(s$1=this.applyIncludes(s$1,t.include)),t.where&&Object.entries(t.where).forEach(([a,l])=>{if(!s(a))throw new b(`Invalid field name '${a}': contains disallowed characters`,new Error("NoSQL injection attempt detected"));s$1=s$1.where(a).equals(l);}),t.query&&(s$1=this.applyCustomQuery(s$1,t.query));let d=await s$1.exec();if(d&&this.supportsSoftDeletes(e)){let a=d,l=a.deleted||a.deletedAt||a.isDeleted;if(!t.withTrashed&&!t.onlyTrashed&&l||t.onlyTrashed&&!l)return null}return d}catch(r){throw new b(`Failed to fetch ${e.modelName}: ${r.message}`,r)}}getPrimaryKeyName(e){return "_id"}isValidModel(e){if(!e||typeof e!="function")return false;let n=e;return typeof n.findOne=="function"&&typeof n.modelName=="string"&&n.schema!==void 0}transformValue(e,n,o){if(n==="_id"||n==="id"){if(h$1(o))try{let r=a("mongoose");return new r.Types.ObjectId(o)}catch{return o}return o}let t=e.schema.path(n);if(y(t)&&t.instance==="Number"){let r=parseInt(o,10);if(!isNaN(r))return r}return o}supportsSoftDeletes(e){let n=e.schema;return n.path("deleted")!==void 0||n.path("deletedAt")!==void 0||n.path("isDeleted")!==void 0}getModelMetadata(e){let n=e.schema,o=Object.keys(n.paths);return {name:e.modelName,primaryKey:"_id",tableName:e.collection.name,softDeletes:this.supportsSoftDeletes(e),fields:o,adapter:this.name}}applyIncludes(e,n){return Array.isArray(n)?n.forEach(o=>{e=e.populate(o);}):Object.entries(n).forEach(([o,t])=>{typeof t=="boolean"&&t?e=e.populate(o):typeof t=="object"&&t!==null&&(e=e.populate({path:o,...t}));}),e}};export{h as a};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk7I3EYD6K_js=require('./chunk-7I3EYD6K.js');function y(i){return typeof i=="object"&&i!==null&&"instance"in i}var h=class extends chunk7I3EYD6K_js.r{constructor(){super(...arguments);this.name="mongoose";}async findByKey(e,n,o,t={}){this.validateModel(e);try{let r=this.transformValue(e,n,o),s=e.findOne({[n]:r});t.select&&t.select.length>0&&(s=s.select(t.select.join(" "))),t.include&&(s=this.applyIncludes(s,t.include)),t.where&&Object.entries(t.where).forEach(([a,l])=>{if(!chunk7I3EYD6K_js.s(a))throw new chunk7I3EYD6K_js.b(`Invalid field name '${a}': contains disallowed characters`,new Error("NoSQL injection attempt detected"));s=s.where(a).equals(l);}),t.query&&(s=this.applyCustomQuery(s,t.query));let d=await s.exec();if(d&&this.supportsSoftDeletes(e)){let a=d,l=a.deleted||a.deletedAt||a.isDeleted;if(!t.withTrashed&&!t.onlyTrashed&&l||t.onlyTrashed&&!l)return null}return d}catch(r){throw new chunk7I3EYD6K_js.b(`Failed to fetch ${e.modelName}: ${r.message}`,r)}}getPrimaryKeyName(e){return "_id"}isValidModel(e){if(!e||typeof e!="function")return false;let n=e;return typeof n.findOne=="function"&&typeof n.modelName=="string"&&n.schema!==void 0}transformValue(e,n,o){if(n==="_id"||n==="id"){if(chunk7I3EYD6K_js.h(o))try{let r=chunk7I3EYD6K_js.a("mongoose");return new r.Types.ObjectId(o)}catch{return o}return o}let t=e.schema.path(n);if(y(t)&&t.instance==="Number"){let r=parseInt(o,10);if(!isNaN(r))return r}return o}supportsSoftDeletes(e){let n=e.schema;return n.path("deleted")!==void 0||n.path("deletedAt")!==void 0||n.path("isDeleted")!==void 0}getModelMetadata(e){let n=e.schema,o=Object.keys(n.paths);return {name:e.modelName,primaryKey:"_id",tableName:e.collection.name,softDeletes:this.supportsSoftDeletes(e),fields:o,adapter:this.name}}applyIncludes(e,n){return Array.isArray(n)?n.forEach(o=>{e=e.populate(o);}):Object.entries(n).forEach(([o,t])=>{typeof t=="boolean"&&t?e=e.populate(o):typeof t=="object"&&t!==null&&(e=e.populate({path:o,...t}));}),e}};exports.a=h;
@@ -0,0 +1 @@
1
+ var y=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var i=class extends Error{constructor(t,n){super(t),this.name="BindingError",this.originalError=n,Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message,originalError:this.originalError?.message}}},a=class extends Error{constructor(n,r,o,p){super(p||`${o} not found with ${n} = ${r}`);this.statusCode=404;this.name="ModelNotFoundError",this.paramName=n,this.paramValue=r,this.modelName=o,Error.captureStackTrace(this,this.constructor);}toJSON(){return {error:"Not Found",message:this.message,statusCode:this.statusCode,param:this.paramName,value:this.paramValue,model:this.modelName}}},u=class extends Error{constructor(t="No adapter set. Call ModelBinder.setAdapter() before using model binding."){super(t),this.name="AdapterNotSetError",Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message}}},s=class extends Error{constructor(t,n){super(t),this.name="InvalidModelError",this.model=n,Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message,model:typeof this.model=="string"?this.model:String(this.model)}}},l=class extends Error{constructor(t,n=400,r){super(t),this.name="ValidationError",this.statusCode=n,this.details=r,Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message,statusCode:this.statusCode,details:this.details}}};var c=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,g=/^[0-9a-f]{24}$/i;function w(e){return e.length!==36?false:c.test(e)}function T(e){return e.length!==24?false:g.test(e)}function b(e){return e.length>20?false:/^-?\d+$/.test(e)}function M(e){return e.length>19?false:/^\d+$/.test(e)&&parseInt(e,10)>0}function R(e){return e.length>1024?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)}function x(e){return e.length>254?false:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function E(e){return e==null?false:typeof e=="string"?e.trim().length>0:true}function N(e){return typeof e=="string"&&e.trim().length>0}function _(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function B(e){return typeof e=="function"}var m=new Set(["__proto__","constructor","prototype","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]);function O(e){return e.length===0||e.length>64||m.has(e)?false:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}var d=class{transformValue(t,n,r){if(/^\d+$/.test(r)){let o=parseInt(r,10);if(!isNaN(o)&&Number.isSafeInteger(o))return o}return r}supportsSoftDeletes(t){return false}getModelMetadata(t){return {name:this.getModelName(t),primaryKey:this.getPrimaryKeyName(t),softDeletes:this.supportsSoftDeletes(t),adapter:this.name}}validateModel(t){if(!this.isValidModel(t))throw new s(`Invalid model for ${this.name} adapter`,t)}getModelName(t){if(typeof t=="string")return t;if(t&&typeof t=="object"){let n=t;if(typeof n.name=="string")return n.name;if(typeof n.modelName=="string")return n.modelName;if(typeof n.tableName=="string")return n.tableName}return t&&typeof t=="function"&&t.name||"Unknown"}applySoftDeleteFilter(t,n){return t}applyIncludes(t,n){return t}applySelect(t,n){return t}applyWhereConditions(t,n){return t}applyCustomQuery(t,n){return n?n(t):t}};var f=new Set(["=","!=","<>","<",">","<=",">=","like","ilike","not like","not ilike","in","not in","between","not between","is","is not","is null","is not null"]);function q(e){return !e||e.length>128?false:/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(e)}function I(e){if(typeof e!="object"||e===null||!("operator"in e)||!("value"in e))return false;let t=e.operator;return typeof t!="string"?false:f.has(t.toLowerCase().trim())}export{y as a,i as b,a as c,u as d,s as e,l as f,w as g,T as h,b as i,M as j,R as k,x as l,E as m,N as n,_ as o,B as p,O as q,d as r,q as s,I as t};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk7I3EYD6K_js=require('./chunk-7I3EYD6K.js');function o(s){return typeof s=="object"&&s!==null&&typeof s.tableName=="string"}var h=class extends chunk7I3EYD6K_js.r{constructor(e){super();this.knex=e;this.name="knex";}getKnex(){return this.knex}async findByKey(e,i,n,t={}){this.validateModel(e);let a=this.getTableName(e);try{let r=this.knex(a);if(r=r.where(i,n),this.supportsSoftDeletes(e)&&!t.withTrashed&&!t.onlyTrashed){let l=this.getSoftDeleteColumn(e);r=r.whereNull(l);}else if(t.onlyTrashed&&this.supportsSoftDeletes(e)){let l=this.getSoftDeleteColumn(e);r=r.whereNotNull(l);}return t.where&&(r=this.applyWhereConditions(r,t.where)),t.select&&t.select.length>0?r=r.select(t.select):r=r.select("*"),t.query&&(r=this.applyCustomQuery(r,t.query)),t.lock==="forUpdate"?r=r.forUpdate():t.lock==="forShare"&&(r=r.forShare()),await r.first()||null}catch(r){throw new chunk7I3EYD6K_js.b(`Failed to fetch ${this.getModelName(e)}: ${r.message}`,r)}}getPrimaryKeyName(e){return o(e)&&e.primaryKey?e.primaryKey:"id"}isValidModel(e){return typeof e=="string"||o(e)}transformValue(e,i,n){let t=this.getPrimaryKeyName(e);if(i===t||i==="id"){let a=parseInt(n,10);if(!isNaN(a)&&a.toString()===n&&Number.isSafeInteger(a))return a}return chunk7I3EYD6K_js.g(n),n}supportsSoftDeletes(e){return o(e)&&!!e.softDeleteColumn}getModelMetadata(e){return {name:this.getModelName(e),primaryKey:this.getPrimaryKeyName(e),tableName:this.getTableName(e),softDeletes:this.supportsSoftDeletes(e),adapter:this.name}}getTableName(e){return typeof e=="string"?e:e.tableName}getSoftDeleteColumn(e){return o(e)&&e.softDeleteColumn?e.softDeleteColumn:"deleted_at"}applyWhereConditions(e,i){return Object.entries(i).forEach(([n,t])=>{if(!chunk7I3EYD6K_js.s(n))throw new chunk7I3EYD6K_js.b(`Invalid column name '${n}': contains disallowed characters`,new Error("SQL injection attempt detected"));t===null?e=e.whereNull(n):Array.isArray(t)?e=e.whereIn(n,t):chunk7I3EYD6K_js.t(t)?e=e.where(n,t.operator,t.value):e=e.where(n,t);}),e}};function D(s){return {tableName:s.tableName,primaryKey:s.primaryKey||"id",softDeleteColumn:s.softDeleteColumn}}exports.a=h;exports.b=D;
@@ -0,0 +1 @@
1
+ 'use strict';var chunk7I3EYD6K_js=require('./chunk-7I3EYD6K.js');function h(c){if(!c||typeof c!="function")return false;let u=c;return typeof u.findOne=="function"&&typeof u.findAll=="function"&&typeof u.rawAttributes=="object"}var S=class extends chunk7I3EYD6K_js.r{constructor(e){super();this.sequelize=e;this.name="sequelize";}getSequelize(){return this.sequelize}async findByKey(e,i,t,r={}){this.validateModel(e);try{let s=this.transformValue(e,i,t),n={where:{[i]:s}};if(r.select&&r.select.length>0&&(n.attributes=r.select),r.include&&(n.include=this.buildIncludes(r.include)),r.where){for(let o of Object.keys(r.where))if(!chunk7I3EYD6K_js.s(o))throw new chunk7I3EYD6K_js.b(`Invalid field name '${o}': contains disallowed characters`,new Error("SQL injection attempt detected"));n.where={...n.where,...r.where};}if(e.options?.paranoid){if(r.withTrashed)n.paranoid=!1;else if(r.onlyTrashed){n.paranoid=!1;let{Op:o}=chunk7I3EYD6K_js.a("sequelize"),w=n.where;w.deletedAt={[o.ne]:null};}}if(r.lock==="forUpdate")n.lock=!0;else if(r.lock==="forShare"){let{Transaction:o}=chunk7I3EYD6K_js.a("sequelize");n.lock=o.LOCK.SHARE;}let a=await e.findOne(n);return r.query&&!a&&(a=await this.findWithCustomQuery(e,i,s,r)),a}catch(s){throw new chunk7I3EYD6K_js.b(`Failed to fetch ${e.name}: ${s.message}`,s)}}getPrimaryKeyName(e){return e.primaryKeyAttribute||"id"}isValidModel(e){return h(e)}transformValue(e,i,t){let s=e.rawAttributes?.[i];if(!s){if(chunk7I3EYD6K_js.g(t))return t;let a=parseInt(t,10);return !isNaN(a)&&a.toString()===t?a:t}let n=s.type;switch(n?.constructor?.name||String(n)){case "INTEGER":case "BIGINT":case "SMALLINT":{let a=parseInt(t,10);return isNaN(a)?t:a}case "FLOAT":case "DOUBLE":case "DECIMAL":{let a=parseFloat(t);return isNaN(a)?t:a}case "BOOLEAN":return t==="true"||t==="1";case "UUID":return t;default:return t}}supportsSoftDeletes(e){return !!e.options?.paranoid}getModelMetadata(e){let i=e.tableName||e.name,t=Object.keys(e.associations||{});return {name:e.name,primaryKey:this.getPrimaryKeyName(e),tableName:i,softDeletes:this.supportsSoftDeletes(e),relations:t,adapter:this.name}}buildIncludes(e){return Array.isArray(e)?e.map(i=>({association:i})):Object.entries(e).map(([i,t])=>typeof t=="boolean"&&t?{association:i}:typeof t=="object"&&t!==null?{association:i,...t}:{association:i})}async findWithCustomQuery(e,i,t,r){let s={where:{[i]:t}};return r.query&&r.query(s),await e.findOne(s)}};exports.a=S;
@@ -0,0 +1 @@
1
+ import {r,e,s,b,g}from'./chunk-DBYMXDVA.mjs';var c=class extends r{constructor(e){super();this.prisma=e;this.name="prisma";}getPrisma(){return this.prisma}async findByKey(e$1,n,t,r={}){this.validateModel(e$1);try{let i=this.prisma[e$1];if(!i)throw new e(`Model '${e$1}' not found in Prisma schema`,e$1);let m=this.transformValue(e$1,n,t),s$1={where:{[n]:m}};if(r.where){for(let o of Object.keys(r.where))if(!s(o))throw new b(`Invalid field name '${o}': contains disallowed characters`,new Error("Injection attempt detected"));s$1.where={...s$1.where,...r.where};}r.select&&r.select.length>0&&(s$1.select=r.select.reduce((o,w)=>(o[w]=!0,o),{})),r.include&&(s$1.include=this.buildIncludeOptions(r.include),delete s$1.select),r.query&&r.query(s$1);let a=null;try{a=await i.findUnique(s$1);}catch{a=await i.findFirst(s$1);}return !a&&n!==this.getPrimaryKeyName(e$1)&&(a=await i.findFirst(s$1)),a}catch(i){throw i instanceof e?i:new b(`Failed to fetch ${e$1}: ${i.message}`,i)}}getPrimaryKeyName(e){return "id"}isValidModel(e){return typeof e!="string"||e.startsWith("$")?false:!!this.prisma[e]}transformValue(e,n,t){if(n==="id"||n.endsWith("Id")){let r=parseInt(t,10);if(!isNaN(r)&&r.toString()===t&&Number.isSafeInteger(r))return r}return g(t),t}supportsSoftDeletes(e){return false}getModelMetadata(e){return {name:e,primaryKey:this.getPrimaryKeyName(e),softDeletes:false,adapter:this.name}}buildIncludeOptions(e){return Array.isArray(e)?e.reduce((n,t)=>(n[t]=true,n),{}):Object.entries(e).reduce((n,[t,r])=>{if(typeof r=="boolean")n[t]=r;else if(typeof r=="object"&&r!==null){let i=r;n[t]={...i,include:i.include?this.buildIncludeOptions(i.include):void 0};}return n},{})}};export{c as a};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk7I3EYD6K_js=require('./chunk-7I3EYD6K.js');var c=class extends chunk7I3EYD6K_js.r{constructor(e){super();this.prisma=e;this.name="prisma";}getPrisma(){return this.prisma}async findByKey(e,n,t,r={}){this.validateModel(e);try{let i=this.prisma[e];if(!i)throw new chunk7I3EYD6K_js.e(`Model '${e}' not found in Prisma schema`,e);let m=this.transformValue(e,n,t),s={where:{[n]:m}};if(r.where){for(let o of Object.keys(r.where))if(!chunk7I3EYD6K_js.s(o))throw new chunk7I3EYD6K_js.b(`Invalid field name '${o}': contains disallowed characters`,new Error("Injection attempt detected"));s.where={...s.where,...r.where};}r.select&&r.select.length>0&&(s.select=r.select.reduce((o,w)=>(o[w]=!0,o),{})),r.include&&(s.include=this.buildIncludeOptions(r.include),delete s.select),r.query&&r.query(s);let a=null;try{a=await i.findUnique(s);}catch{a=await i.findFirst(s);}return !a&&n!==this.getPrimaryKeyName(e)&&(a=await i.findFirst(s)),a}catch(i){throw i instanceof chunk7I3EYD6K_js.e?i:new chunk7I3EYD6K_js.b(`Failed to fetch ${e}: ${i.message}`,i)}}getPrimaryKeyName(e){return "id"}isValidModel(e){return typeof e!="string"||e.startsWith("$")?false:!!this.prisma[e]}transformValue(e,n,t){if(n==="id"||n.endsWith("Id")){let r=parseInt(t,10);if(!isNaN(r)&&r.toString()===t&&Number.isSafeInteger(r))return r}return chunk7I3EYD6K_js.g(t),t}supportsSoftDeletes(e){return false}getModelMetadata(e){return {name:e,primaryKey:this.getPrimaryKeyName(e),softDeletes:false,adapter:this.name}}buildIncludeOptions(e){return Array.isArray(e)?e.reduce((n,t)=>(n[t]=true,n),{}):Object.entries(e).reduce((n,[t,r])=>{if(typeof r=="boolean")n[t]=r;else if(typeof r=="object"&&r!==null){let i=r;n[t]={...i,include:i.include?this.buildIncludeOptions(i.include):void 0};}return n},{})}};exports.a=c;
@@ -0,0 +1 @@
1
+ import {r,b,g,s,t}from'./chunk-DBYMXDVA.mjs';function o(s){return typeof s=="object"&&s!==null&&typeof s.tableName=="string"}var h=class extends r{constructor(e){super();this.knex=e;this.name="knex";}getKnex(){return this.knex}async findByKey(e,i,n,t={}){this.validateModel(e);let a=this.getTableName(e);try{let r=this.knex(a);if(r=r.where(i,n),this.supportsSoftDeletes(e)&&!t.withTrashed&&!t.onlyTrashed){let l=this.getSoftDeleteColumn(e);r=r.whereNull(l);}else if(t.onlyTrashed&&this.supportsSoftDeletes(e)){let l=this.getSoftDeleteColumn(e);r=r.whereNotNull(l);}return t.where&&(r=this.applyWhereConditions(r,t.where)),t.select&&t.select.length>0?r=r.select(t.select):r=r.select("*"),t.query&&(r=this.applyCustomQuery(r,t.query)),t.lock==="forUpdate"?r=r.forUpdate():t.lock==="forShare"&&(r=r.forShare()),await r.first()||null}catch(r){throw new b(`Failed to fetch ${this.getModelName(e)}: ${r.message}`,r)}}getPrimaryKeyName(e){return o(e)&&e.primaryKey?e.primaryKey:"id"}isValidModel(e){return typeof e=="string"||o(e)}transformValue(e,i,n){let t=this.getPrimaryKeyName(e);if(i===t||i==="id"){let a=parseInt(n,10);if(!isNaN(a)&&a.toString()===n&&Number.isSafeInteger(a))return a}return g(n),n}supportsSoftDeletes(e){return o(e)&&!!e.softDeleteColumn}getModelMetadata(e){return {name:this.getModelName(e),primaryKey:this.getPrimaryKeyName(e),tableName:this.getTableName(e),softDeletes:this.supportsSoftDeletes(e),adapter:this.name}}getTableName(e){return typeof e=="string"?e:e.tableName}getSoftDeleteColumn(e){return o(e)&&e.softDeleteColumn?e.softDeleteColumn:"deleted_at"}applyWhereConditions(e,i){return Object.entries(i).forEach(([n,t$1])=>{if(!s(n))throw new b(`Invalid column name '${n}': contains disallowed characters`,new Error("SQL injection attempt detected"));t$1===null?e=e.whereNull(n):Array.isArray(t$1)?e=e.whereIn(n,t$1):t(t$1)?e=e.where(n,t$1.operator,t$1.value):e=e.where(n,t$1);}),e}};function D(s){return {tableName:s.tableName,primaryKey:s.primaryKey||"id",softDeleteColumn:s.softDeleteColumn}}export{h as a,D as b};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk7I3EYD6K_js=require('./chunk-7I3EYD6K.js');var h=class extends chunk7I3EYD6K_js.r{constructor(i){super();this.dataSource=i;this.name="typeorm";}getDataSource(){return this.dataSource}async findByKey(i,o,r,e={}){this.validateModel(i);try{let n=this.dataSource.getRepository(i),s=n.metadata,t=this.transformValue(i,o,r);if(e.query||e.lock||e.onlyTrashed)return await this.findWithQueryBuilder(n,o,t,e);let a={where:{[o]:t}};if(e.select&&e.select.length>0&&(a.select=e.select.reduce((l,f)=>(l[f]=!0,l),{})),e.include&&(a.relations=Array.isArray(e.include)?e.include:Object.keys(e.include)),e.where){for(let l of Object.keys(e.where))if(!chunk7I3EYD6K_js.s(l))throw new chunk7I3EYD6K_js.b(`Invalid field name '${l}': contains disallowed characters`,new Error("SQL injection attempt detected"));a.where={...a.where,...e.where};}return e.withTrashed&&s.deleteDateColumn&&(a.withDeleted=!0),await n.findOne(a)}catch(n){throw new chunk7I3EYD6K_js.b(`Failed to fetch entity: ${n.message}`,n)}}getPrimaryKeyName(i){try{let r=this.dataSource.getRepository(i).metadata;if(r.primaryColumns.length>0)return r.primaryColumns[0].propertyName}catch{}return "id"}isValidModel(i){try{return this.dataSource.getRepository(i),!0}catch{return false}}transformValue(i,o,r){try{let s=this.dataSource.getRepository(i).metadata.findColumnWithPropertyName(o);if(!s){if(chunk7I3EYD6K_js.g(r))return r;let a=parseInt(r,10);return !isNaN(a)&&a.toString()===r?a:r}let t=String(s.type).toLowerCase();if(["int","integer","smallint","bigint","number"].includes(t)){let a=parseInt(r,10);return isNaN(a)?r:a}return t==="uuid"?r:t==="boolean"||t==="bool"?r==="true"||r==="1":r}catch{return r}}supportsSoftDeletes(i){try{return !!this.dataSource.getRepository(i).metadata.deleteDateColumn}catch{return false}}getModelMetadata(i){try{let r=this.dataSource.getRepository(i).metadata;return {name:r.name,primaryKey:this.getPrimaryKeyName(i),tableName:r.tableName,softDeletes:this.supportsSoftDeletes(i),relations:r.relations.map(e=>e.propertyName),adapter:this.name}}catch{return {name:"Unknown",primaryKey:"id",softDeletes:false,adapter:this.name}}}async findWithQueryBuilder(i,o,r,e){let n=i.metadata,s=n.name.toLowerCase(),t=i.createQueryBuilder(s).where(`${s}.${o} = :value`,{value:r});return e.include&&(Array.isArray(e.include)?e.include:Object.keys(e.include)).forEach(c=>{t=t.leftJoinAndSelect(`${s}.${c}`,c);}),e.where&&Object.entries(e.where).forEach(([a,c])=>{t=t.andWhere(`${s}.${a} = :${a}`,{[a]:c});}),e.select&&e.select.length>0&&(t=t.select(e.select.map(a=>`${s}.${a}`))),e.withTrashed?t=t.withDeleted():e.onlyTrashed&&n.deleteDateColumn&&(t=t.withDeleted().andWhere(`${s}.${n.deleteDateColumn.propertyName} IS NOT NULL`)),e.lock==="forUpdate"?t=t.setLock("pessimistic_write"):e.lock==="forShare"&&(t=t.setLock("pessimistic_read")),e.query&&(t=this.applyCustomQuery(t,e.query)),await t.getOne()}};exports.a=h;