@nhtio/lucid-resourceful 1.20250718.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 (68) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +5 -0
  3. package/decorator_utils-1yWqd_Gg.cjs +6792 -0
  4. package/decorator_utils-1yWqd_Gg.cjs.map +1 -0
  5. package/decorator_utils-BUuBwQYK.js +6793 -0
  6. package/decorator_utils-BUuBwQYK.js.map +1 -0
  7. package/definitions-B66EPk0H.js +381 -0
  8. package/definitions-B66EPk0H.js.map +1 -0
  9. package/definitions-BrN-oCRI.cjs +380 -0
  10. package/definitions-BrN-oCRI.cjs.map +1 -0
  11. package/definitions.cjs +15 -0
  12. package/definitions.cjs.map +1 -0
  13. package/definitions.d.ts +5 -0
  14. package/definitions.mjs +15 -0
  15. package/definitions.mjs.map +1 -0
  16. package/errors-B1rr67uM.js +3004 -0
  17. package/errors-B1rr67uM.js.map +1 -0
  18. package/errors-D8jb9VxY.cjs +3000 -0
  19. package/errors-D8jb9VxY.cjs.map +1 -0
  20. package/errors.cjs +22 -0
  21. package/errors.cjs.map +1 -0
  22. package/errors.d.ts +94 -0
  23. package/errors.mjs +22 -0
  24. package/errors.mjs.map +1 -0
  25. package/index-Cv6KC1rC.cjs +670 -0
  26. package/index-Cv6KC1rC.cjs.map +1 -0
  27. package/index-DDaZ2qr2.js +671 -0
  28. package/index-DDaZ2qr2.js.map +1 -0
  29. package/index.cjs +12706 -0
  30. package/index.cjs.map +1 -0
  31. package/index.d.ts +14 -0
  32. package/index.mjs +12708 -0
  33. package/index.mjs.map +1 -0
  34. package/joi.cjs +5 -0
  35. package/joi.cjs.map +1 -0
  36. package/joi.d.ts +5 -0
  37. package/joi.mjs +5 -0
  38. package/joi.mjs.map +1 -0
  39. package/package.json +65 -0
  40. package/private/constants.d.ts +11 -0
  41. package/private/controller_factory.d.ts +1 -0
  42. package/private/data_type_schemas.d.ts +12 -0
  43. package/private/data_types.d.ts +437 -0
  44. package/private/decorator_schemas.d.ts +34 -0
  45. package/private/decorator_utils.d.ts +305 -0
  46. package/private/decorators.d.ts +209 -0
  47. package/private/helpers.d.ts +34 -0
  48. package/private/joi/bigint.d.ts +85 -0
  49. package/private/joi/index.d.ts +65 -0
  50. package/private/lucene_to_lucid_translator.d.ts +201 -0
  51. package/private/mixin.d.ts +563 -0
  52. package/private/schema_types.d.ts +157 -0
  53. package/private/type_guards.d.ts +42 -0
  54. package/private/types.d.ts +102 -0
  55. package/private/utils.d.ts +10 -0
  56. package/types.cjs +2 -0
  57. package/types.cjs.map +1 -0
  58. package/types.d.ts +28 -0
  59. package/types.mjs +2 -0
  60. package/types.mjs.map +1 -0
  61. package/utils/casters.d.ts +1 -0
  62. package/utils/consumers.d.ts +1 -0
  63. package/utils/preparers.d.ts +1 -0
  64. package/utils.cjs +50 -0
  65. package/utils.cjs.map +1 -0
  66. package/utils.d.ts +20 -0
  67. package/utils.mjs +51 -0
  68. package/utils.mjs.map +1 -0
@@ -0,0 +1,305 @@
1
+ import { DateTime } from 'luxon';
2
+ import type { LucidBinaryValue, LucidPlainObject } from '@nhtio/lucid-resourceful/types';
3
+ /**
4
+ * Casts an unknown value to a string
5
+ * @param value - The value to cast
6
+ * @returns The value as a string
7
+ * @throws E_UNCASTABLE when the value cannot be cast to a string
8
+ */
9
+ export declare const castValueAsString: (value: unknown) => string;
10
+ /**
11
+ * Casts an unknown value to a Luxon DateTime with enhanced string parsing
12
+ * @param value - The value to cast (string, number, Date, or DateTime)
13
+ * @returns The value as a Luxon DateTime
14
+ * @throws E_UNCASTABLE when the value cannot be cast to a DateTime
15
+ * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing
16
+ */
17
+ export declare const castValueAsDate: (value: unknown) => DateTime;
18
+ /**
19
+ * Casts an unknown value to a Luxon DateTime with enhanced error handling and string parsing
20
+ * @param value - The value to cast (string, number, Date, or DateTime)
21
+ * @returns The value as a Luxon DateTime
22
+ * @throws E_UNCASTABLE when the value cannot be cast to a DateTime
23
+ * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing
24
+ */
25
+ export declare const castValueAsDateTime: (value: unknown) => DateTime;
26
+ /**
27
+ * Casts an unknown value to a Uint8Array (binary data)
28
+ * @param value - The value to cast
29
+ * @returns The value as a Uint8Array
30
+ * @throws E_UNCASTABLE when the value cannot be cast to binary data
31
+ */
32
+ export declare const castValueAsBinary: (value: unknown) => Uint8Array;
33
+ /**
34
+ * Casts an unknown value to a number
35
+ * @param value - The value to cast
36
+ * @returns The value as a number
37
+ * @throws E_UNCASTABLE when the value cannot be cast to a number
38
+ */
39
+ export declare const castValueAsNumber: (value: unknown) => number;
40
+ /**
41
+ * Casts an unknown value to an integer
42
+ * @param value - The value to cast
43
+ * @returns The value as an integer (truncated if necessary)
44
+ * @throws E_UNCASTABLE when the value cannot be cast to an integer
45
+ */
46
+ export declare const castValueAsInteger: (value: unknown) => number;
47
+ /**
48
+ * Casts an unknown value to a bigint
49
+ * @param value - The value to cast
50
+ * @returns The value as a bigint
51
+ * @throws E_UNCASTABLE when the value cannot be cast to a bigint
52
+ */
53
+ export declare const castValueAsBigint: (value: unknown) => bigint;
54
+ /**
55
+ * Casts an unknown value to an unsigned integer
56
+ * @param value - The value to cast
57
+ * @returns The value as an unsigned integer (32-bit)
58
+ * @throws E_UNCASTABLE when the value cannot be cast to an unsigned integer
59
+ */
60
+ export declare const castValueAsUnsignedInt: (value: unknown) => number;
61
+ /**
62
+ * Casts an unknown value to a boolean
63
+ * @param value - The value to cast
64
+ * @returns The value as a boolean
65
+ * @throws E_UNCASTABLE when the value cannot be cast to a boolean
66
+ */
67
+ export declare const castValueAsBoolean: (value: unknown) => boolean;
68
+ /**
69
+ * Casts an unknown value to a plain object
70
+ * @param value - The value to cast
71
+ * @returns The value as a LucidPlainObject
72
+ * @throws E_UNCASTABLE when the value cannot be cast to an object
73
+ */
74
+ export declare const castValueAsObject: (value: unknown) => LucidPlainObject;
75
+ /**
76
+ * Casts an unknown value to an array
77
+ * @param value - The value to cast
78
+ * @returns The value as an array of unknown elements
79
+ * @throws E_UNCASTABLE when the value cannot be cast to an array
80
+ */
81
+ export declare const castValueAsArray: (value: unknown) => Array<unknown>;
82
+ /**
83
+ * Prepares a string value for database storage with nullable support
84
+ * @param key - The field name for error reporting
85
+ * @param value - The value to prepare
86
+ * @param nullable - Whether the field can be null
87
+ * @returns The prepared string value or null if nullable and value is null
88
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
89
+ */
90
+ export declare function prepareString(key: string, value: unknown, nullable: true): string | null;
91
+ export declare function prepareString(key: string, value: unknown, nullable?: false): string;
92
+ /**
93
+ * Prepares a date value for database storage with nullable support and enhanced string parsing
94
+ * @param key - The field name for error reporting
95
+ * @param value - The value to prepare
96
+ * @param nullable - Whether the field can be null
97
+ * @returns The prepared DateTime value or null if nullable and value is null
98
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
99
+ * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing
100
+ */
101
+ export declare function prepareDate(key: string, value: unknown, nullable: true): DateTime | null;
102
+ export declare function prepareDate(key: string, value: unknown, nullable?: false): DateTime;
103
+ /**
104
+ * Prepares a datetime value for database storage with nullable support and enhanced string parsing
105
+ * @param key - The field name for error reporting
106
+ * @param value - The value to prepare
107
+ * @param nullable - Whether the field can be null
108
+ * @returns The prepared DateTime value or null if nullable and value is null
109
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
110
+ * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing
111
+ */
112
+ export declare function prepareDateTime(key: string, value: unknown, nullable: true): DateTime | null;
113
+ export declare function prepareDateTime(key: string, value: unknown, nullable?: false): DateTime;
114
+ /**
115
+ * Prepares a binary value for database storage with nullable support
116
+ * @param key - The field name for error reporting
117
+ * @param value - The value to prepare
118
+ * @param nullable - Whether the field can be null
119
+ * @returns The prepared binary value or null if nullable and value is null
120
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
121
+ */
122
+ export declare function prepareBinary(key: string, value: unknown, nullable: true): LucidBinaryValue | null;
123
+ export declare function prepareBinary(key: string, value: unknown, nullable?: false): LucidBinaryValue;
124
+ /**
125
+ * Prepares a number value for database storage with nullable support
126
+ * @param key - The field name for error reporting
127
+ * @param value - The value to prepare
128
+ * @param nullable - Whether the field can be null
129
+ * @returns The prepared number value or null if nullable and value is null
130
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
131
+ */
132
+ export declare function prepareNumber(key: string, value: unknown, nullable: true): number | null;
133
+ export declare function prepareNumber(key: string, value: unknown, nullable?: false): number;
134
+ /**
135
+ * Prepares an integer value for database storage with nullable support
136
+ * @param key - The field name for error reporting
137
+ * @param value - The value to prepare
138
+ * @param nullable - Whether the field can be null
139
+ * @returns The prepared integer value or null if nullable and value is null
140
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
141
+ */
142
+ export declare function prepareInteger(key: string, value: unknown, nullable: true): number | null;
143
+ export declare function prepareInteger(key: string, value: unknown, nullable?: false): number;
144
+ /**
145
+ * Prepares a bigint value for database storage with nullable support
146
+ * @param key - The field name for error reporting
147
+ * @param value - The value to prepare
148
+ * @param nullable - Whether the field can be null
149
+ * @returns The prepared bigint value or null if nullable and value is null
150
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
151
+ */
152
+ export declare function prepareBigint(key: string, value: unknown, nullable: true): bigint | null;
153
+ export declare function prepareBigint(key: string, value: unknown, nullable?: false): bigint;
154
+ /**
155
+ * Prepares an unsigned integer value for database storage with nullable support
156
+ * @param key - The field name for error reporting
157
+ * @param value - The value to prepare
158
+ * @param nullable - Whether the field can be null
159
+ * @returns The prepared unsigned integer value or null if nullable and value is null
160
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
161
+ */
162
+ export declare function prepareUnsignedint(key: string, value: unknown, nullable: true): number | null;
163
+ export declare function prepareUnsignedint(key: string, value: unknown, nullable?: false): number;
164
+ /**
165
+ * Prepares a boolean value for database storage with nullable support
166
+ * @param key - The field name for error reporting
167
+ * @param value - The value to prepare
168
+ * @param nullable - Whether the field can be null
169
+ * @returns The prepared boolean value or null if nullable and value is null
170
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
171
+ */
172
+ export declare function prepareBoolean(key: string, value: unknown, nullable: true): boolean | null;
173
+ export declare function prepareBoolean(key: string, value: unknown, nullable?: false): boolean;
174
+ /**
175
+ * Prepares an object value for database storage with nullable support
176
+ * @param key - The field name for error reporting
177
+ * @param value - The value to prepare
178
+ * @param nullable - Whether the field can be null
179
+ * @returns The prepared object value or null if nullable and value is null
180
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
181
+ */
182
+ export declare function prepareObject(key: string, value: unknown, nullable: true): LucidPlainObject | null;
183
+ export declare function prepareObject(key: string, value: unknown, nullable?: false): LucidPlainObject;
184
+ /**
185
+ * Prepares an array value for database storage with nullable support
186
+ * @param key - The field name for error reporting
187
+ * @param value - The value to prepare
188
+ * @param nullable - Whether the field can be null
189
+ * @returns The prepared array value or null if nullable and value is null
190
+ * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared
191
+ */
192
+ export declare function prepareArray(key: string, value: unknown, nullable: true): Array<unknown> | null;
193
+ export declare function prepareArray(key: string, value: unknown, nullable?: false): Array<unknown>;
194
+ /**
195
+ * Consumes a string value from database results with nullable support
196
+ * @param key - The field name for error reporting
197
+ * @param value - The value to consume
198
+ * @param nullable - Whether the field can be null
199
+ * @returns The consumed string value or null if nullable and value is null
200
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
201
+ */
202
+ export declare function consumeString(key: string, value: unknown, nullable: true): string | null;
203
+ export declare function consumeString(key: string, value: unknown, nullable?: false): string;
204
+ /**
205
+ * Consumes a date value from database results with nullable support and enhanced string parsing
206
+ * @param key - The field name for error reporting
207
+ * @param value - The value to consume
208
+ * @param nullable - Whether the field can be null
209
+ * @returns The consumed DateTime value or null if nullable and value is null
210
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
211
+ * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing
212
+ */
213
+ export declare function consumeDate(key: string, value: unknown, nullable: true): DateTime | null;
214
+ export declare function consumeDate(key: string, value: unknown, nullable?: false): DateTime;
215
+ /**
216
+ * Consumes a datetime value from database results with nullable support and enhanced string parsing
217
+ * @param key - The field name for error reporting
218
+ * @param value - The value to consume
219
+ * @param nullable - Whether the field can be null
220
+ * @returns The consumed DateTime value or null if nullable and value is null
221
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
222
+ * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing
223
+ */
224
+ export declare function consumeDateTime(key: string, value: unknown, nullable: true): DateTime | null;
225
+ export declare function consumeDateTime(key: string, value: unknown, nullable?: false): DateTime;
226
+ /**
227
+ * Consumes a binary value from database results with nullable support
228
+ * @param key - The field name for error reporting
229
+ * @param value - The value to consume
230
+ * @param nullable - Whether the field can be null
231
+ * @returns The consumed LucidBinaryValue or null if nullable and value is null
232
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
233
+ */
234
+ export declare function consumeBinary(key: string, value: unknown, nullable: true): LucidBinaryValue | null;
235
+ export declare function consumeBinary(key: string, value: unknown, nullable?: false): LucidBinaryValue;
236
+ /**
237
+ * Consumes a number value from database results with nullable support
238
+ * @param key - The field name for error reporting
239
+ * @param value - The value to consume
240
+ * @param nullable - Whether the field can be null
241
+ * @returns The consumed number value or null if nullable and value is null
242
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
243
+ */
244
+ export declare function consumeNumber(key: string, value: unknown, nullable: true): number | null;
245
+ export declare function consumeNumber(key: string, value: unknown, nullable?: false): number;
246
+ /**
247
+ * Consumes an integer value from database results with nullable support
248
+ * @param key - The field name for error reporting
249
+ * @param value - The value to consume
250
+ * @param nullable - Whether the field can be null
251
+ * @returns The consumed integer value or null if nullable and value is null
252
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
253
+ */
254
+ export declare function consumeInteger(key: string, value: unknown, nullable: true): number | null;
255
+ export declare function consumeInteger(key: string, value: unknown, nullable?: false): number;
256
+ /**
257
+ * Consumes a bigint value from database results with nullable support
258
+ * @param key - The field name for error reporting
259
+ * @param value - The value to consume
260
+ * @param nullable - Whether the field can be null
261
+ * @returns The consumed bigint value or null if nullable and value is null
262
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
263
+ */
264
+ export declare function consumeBigint(key: string, value: unknown, nullable: true): bigint | null;
265
+ export declare function consumeBigint(key: string, value: unknown, nullable?: false): bigint;
266
+ /**
267
+ * Consumes an unsigned integer value from database results with nullable support
268
+ * @param key - The field name for error reporting
269
+ * @param value - The value to consume
270
+ * @param nullable - Whether the field can be null
271
+ * @returns The consumed unsigned integer value or null if nullable and value is null
272
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
273
+ */
274
+ export declare function consumeUnsignedint(key: string, value: unknown, nullable: true): number | null;
275
+ export declare function consumeUnsignedint(key: string, value: unknown, nullable?: false): number;
276
+ /**
277
+ * Consumes a boolean value from database results with nullable support
278
+ * @param key - The field name for error reporting
279
+ * @param value - The value to consume
280
+ * @param nullable - Whether the field can be null
281
+ * @returns The consumed boolean value or null if nullable and value is null
282
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
283
+ */
284
+ export declare function consumeBoolean(key: string, value: unknown, nullable: true): boolean | null;
285
+ export declare function consumeBoolean(key: string, value: unknown, nullable?: false): boolean;
286
+ /**
287
+ * Consumes an object value from database results with nullable support
288
+ * @param key - The field name for error reporting
289
+ * @param value - The value to consume
290
+ * @param nullable - Whether the field can be null
291
+ * @returns The consumed LucidPlainObject or null if nullable and value is null
292
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
293
+ */
294
+ export declare function consumeObject(key: string, value: unknown, nullable: true): LucidPlainObject | null;
295
+ export declare function consumeObject(key: string, value: unknown, nullable?: false): LucidPlainObject;
296
+ /**
297
+ * Consumes an array value from database results with nullable support
298
+ * @param key - The field name for error reporting
299
+ * @param value - The value to consume
300
+ * @param nullable - Whether the field can be null
301
+ * @returns The consumed array value or null if nullable and value is null
302
+ * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed
303
+ */
304
+ export declare function consumeArray(key: string, value: unknown, nullable: true): Array<unknown> | null;
305
+ export declare function consumeArray(key: string, value: unknown, nullable?: false): Array<unknown>;
@@ -0,0 +1,209 @@
1
+ import type { LucidModel, ColumnOptions, ComputedOptions } from '@adonisjs/lucid/types/model';
2
+ import type { HasOne, ManyToMany, HasManyThrough, ManyToManyRelationOptions, RelationOptions, ThroughRelationOptions } from '@adonisjs/lucid/types/relations';
3
+ import type { ResourcefulColumnDefinition, ResourcefulComputedAccessorDefinition, ResourcefulRelationshipDefinition, AnySchema, StringSchema, DateSchema, BinarySchema, NumberSchema, BooleanSchema, ObjectSchema, ArraySchema, ResourcefulPropertySchema } from '@nhtio/lucid-resourceful/types';
4
+ /**
5
+ * Options for date columns including autoCreate and autoUpdate flags.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * {
10
+ * autoCreate: true,
11
+ * autoUpdate: false,
12
+ * nullable: false,
13
+ * }
14
+ * ```
15
+ */
16
+ export type DateColumnOptions = DataTypeColumnOptions & {
17
+ autoCreate: boolean;
18
+ autoUpdate: boolean;
19
+ };
20
+ /**
21
+ * Options for relation decorators on related models.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { resourcefulBelongsTo } from '@nhtio/lucid-resourceful'
26
+ *
27
+ * class Post {
28
+ * @resourcefulBelongsTo(() => User, { foreignKey: 'user_id' })
29
+ * public user: User
30
+ * }
31
+ * ```
32
+ */
33
+ export type RelatedModelRelationOptions<RelatedModel extends LucidModel> = RelationOptions<RelatedModel, LucidModel, HasOne<RelatedModel, LucidModel>> | ManyToManyRelationOptions<ManyToMany<RelatedModel>> | Omit<ThroughRelationOptions<RelatedModel, LucidModel, HasManyThrough<RelatedModel>>, 'throughModel'>;
34
+ /**
35
+ * Options for hasManyThrough relation decorators.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { resourcefulHasManyThrough } from '@nhtio/lucid-resourceful'
40
+ *
41
+ * class User {
42
+ * @resourcefulHasManyThrough([
43
+ * () => Role,
44
+ * () => UserRolePivot
45
+ * ], { foreignKey: 'user_id' })
46
+ * public roles: HasManyThrough<typeof Role>
47
+ * }
48
+ * ```
49
+ */
50
+ export type HasManyThroughRelationOptions<RelatedModel extends LucidModel> = Omit<ThroughRelationOptions<RelatedModel, LucidModel, HasManyThrough<RelatedModel>>, 'throughModel'>;
51
+ export type DataTypeColumnOptions = Omit<ColumnOptions, 'prepare' | 'consume'>;
52
+ export type DataTypeComputedOptions = Omit<ComputedOptions, 'prepare' | 'consume'>;
53
+ /**
54
+ * Decorator to define a resourceful column on a Lucid model property.
55
+ * Applies validation, metadata, and Lucid column options.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import { resourcefulColumn, ResourcefulStringType } from '@nhtio/lucid-resourceful'
60
+ *
61
+ * class User {
62
+ * @resourcefulColumn({ type: ResourcefulStringType({ minLength: 1, maxLength: 100 }), nullable: false })
63
+ * public name: string
64
+ * }
65
+ * ```
66
+ *
67
+ * @param options - Resourceful column options and Lucid column options.
68
+ * @returns Property decorator function.
69
+ */
70
+ export declare function resourcefulColumn<Schema extends AnySchema = ResourcefulPropertySchema>(options?: Partial<ColumnOptions> & Partial<ResourcefulColumnDefinition<Schema>>): (target: any, propertyKey: string) => void;
71
+ export declare namespace resourcefulColumn {
72
+ var string: (options?: Partial<DataTypeColumnOptions> & Partial<ResourcefulColumnDefinition<StringSchema>>) => (target: any, propertyKey: string) => void;
73
+ var date: (options?: Partial<DateColumnOptions> & Partial<ResourcefulColumnDefinition<DateSchema>>) => (target: any, propertyKey: string) => void;
74
+ var dateTime: (options?: Partial<DateColumnOptions> & Partial<ResourcefulColumnDefinition<DateSchema>>) => (target: any, propertyKey: string) => void;
75
+ var binary: (options?: Partial<DataTypeColumnOptions> & Partial<ResourcefulColumnDefinition<BinarySchema>>) => (target: any, propertyKey: string) => void;
76
+ var number: (options?: Partial<DataTypeColumnOptions> & Partial<ResourcefulColumnDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
77
+ var integer: (options?: Partial<DataTypeColumnOptions> & Partial<ResourcefulColumnDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
78
+ var bigint: (options?: Partial<DataTypeColumnOptions> & Partial<ResourcefulColumnDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
79
+ var unsignedint: (options?: Partial<DataTypeColumnOptions> & Partial<ResourcefulColumnDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
80
+ var boolean: (options?: Partial<DataTypeColumnOptions> & Partial<ResourcefulColumnDefinition<BooleanSchema>>) => (target: any, propertyKey: string) => void;
81
+ var object: (options?: Partial<ColumnOptions> & Partial<ResourcefulColumnDefinition<ObjectSchema>>) => (target: any, propertyKey: string) => void;
82
+ var array: (options?: Partial<ColumnOptions> & Partial<ResourcefulColumnDefinition<ArraySchema>>) => (target: any, propertyKey: string) => void;
83
+ }
84
+ /**
85
+ * Decorator to define a resourceful computed accessor on a Lucid model property.
86
+ * Applies validation, metadata, and Lucid computed options.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * import { resourcefulComputed, ResourcefulStringType } from '@nhtio/lucid-resourceful'
91
+ *
92
+ * class User {
93
+ * @resourcefulComputed({ type: ResourcefulStringType({ minLength: 1, maxLength: 100 }) })
94
+ * public get fullName() {
95
+ * return `${this.firstName} ${this.lastName}`
96
+ * }
97
+ * }
98
+ * ```
99
+ *
100
+ * @param options - Resourceful computed accessor options and Lucid computed options.
101
+ * @returns Property decorator function.
102
+ */
103
+ export declare function resourcefulComputed<Schema extends AnySchema = ResourcefulPropertySchema>(options?: Partial<ComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<Schema>>): (target: any, propertyKey: string) => void;
104
+ export declare namespace resourcefulComputed {
105
+ var string: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<StringSchema>>) => (target: any, propertyKey: string) => void;
106
+ var date: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<DateSchema>>) => (target: any, propertyKey: string) => void;
107
+ var dateTime: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<DateSchema>>) => (target: any, propertyKey: string) => void;
108
+ var binary: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<DateSchema>>) => (target: any, propertyKey: string) => void;
109
+ var number: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
110
+ var integer: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
111
+ var bigint: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
112
+ var unsignedint: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
113
+ var boolean: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<BooleanSchema>>) => (target: any, propertyKey: string) => void;
114
+ var object: (options?: Partial<ComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<ObjectSchema>>) => (target: any, propertyKey: string) => void;
115
+ var array: (options?: Partial<ComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<ArraySchema>>) => (target: any, propertyKey: string) => void;
116
+ }
117
+ /**
118
+ * Decorator to define a resourceful belongsTo relationship on a Lucid model property.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * import { resourcefulBelongsTo } from '@nhtio/lucid-resourceful'
123
+ *
124
+ * class Post {
125
+ * @resourcefulBelongsTo(() => User, { foreignKey: 'user_id' })
126
+ * public user: User
127
+ * }
128
+ * ```
129
+ *
130
+ * @param model - Function returning the related model class.
131
+ * @param options - Relationship options and resourceful relationship definition.
132
+ * @returns Property decorator function.
133
+ */
134
+ export declare function resourcefulBelongsTo<RelatedModel extends LucidModel>(model: () => RelatedModel, options?: Partial<RelationOptions<RelatedModel, LucidModel, HasOne<RelatedModel, LucidModel>>> & Partial<ResourcefulRelationshipDefinition>): (target: any, propertyKey: string) => void;
135
+ /**
136
+ * Decorator to define a resourceful hasOne relationship on a Lucid model property.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * import { resourcefulHasOne } from '@nhtio/lucid-resourceful'
141
+ *
142
+ * class UserProfile {
143
+ * @resourcefulHasOne(() => User, { foreignKey: 'user_id' })
144
+ * public user: UserProfile
145
+ * }
146
+ * ```
147
+ *
148
+ * @param model - Function returning the related model class.
149
+ * @param options - Relationship options and resourceful relationship definition.
150
+ * @returns Property decorator function.
151
+ */
152
+ export declare function resourcefulHasOne<RelatedModel extends LucidModel>(model: () => RelatedModel, options?: Partial<RelationOptions<RelatedModel, LucidModel, HasOne<RelatedModel, LucidModel>>> & Partial<ResourcefulRelationshipDefinition>): (target: any, propertyKey: string) => void;
153
+ /**
154
+ * Decorator to define a resourceful hasMany relationship on a Lucid model property.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * import { resourcefulHasMany } from '@nhtio/lucid-resourceful'
159
+ *
160
+ * class User {
161
+ * @resourcefulHasMany(() => Post, { foreignKey: 'user_id' })
162
+ * public posts: HasMany<typeof Post>
163
+ * }
164
+ * ```
165
+ *
166
+ * @param model - Function returning the related model class.
167
+ * @param options - Relationship options and resourceful relationship definition.
168
+ * @returns Property decorator function.
169
+ */
170
+ export declare function resourcefulHasMany<RelatedModel extends LucidModel>(model: () => RelatedModel, options?: Partial<RelationOptions<RelatedModel, LucidModel, HasOne<RelatedModel, LucidModel>>> & Partial<ResourcefulRelationshipDefinition>): (target: any, propertyKey: string) => void;
171
+ /**
172
+ * Decorator to define a resourceful manyToMany relationship on a Lucid model property.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * import { resourcefulManyToMany } from '@nhtio/lucid-resourceful'
177
+ *
178
+ * class User {
179
+ * @resourcefulManyToMany(() => Role, { pivotTable: 'role_user' })
180
+ * public roles: ManyToMany<typeof Role>
181
+ * }
182
+ * ```
183
+ *
184
+ * @param model - Function returning the related model class.
185
+ * @param options - ManyToMany relationship options and resourceful relationship definition.
186
+ * @returns Property decorator function.
187
+ */
188
+ export declare function resourcefulManyToMany<RelatedModel extends LucidModel>(model: () => RelatedModel, options?: Partial<ManyToManyRelationOptions<ManyToMany<RelatedModel>>> & Partial<ResourcefulRelationshipDefinition>): (target: any, propertyKey: string) => void;
189
+ /**
190
+ * Decorator to define a resourceful hasManyThrough relationship on a Lucid model property.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * import { resourcefulHasManyThrough } from '@nhtio/lucid-resourceful'
195
+ *
196
+ * class User {
197
+ * @resourcefulHasManyThrough([
198
+ * () => Role,
199
+ * () => UserRolePivot
200
+ * ], { foreignKey: 'user_id' })
201
+ * public roles: HasManyThrough<typeof Role>
202
+ * }
203
+ * ```
204
+ *
205
+ * @param model - Tuple of functions returning the related model and through model classes.
206
+ * @param options - HasManyThrough relationship options and resourceful relationship definition.
207
+ * @returns Property decorator function.
208
+ */
209
+ export declare function resourcefulHasManyThrough<RelatedModel extends LucidModel>(model: [() => RelatedModel, () => LucidModel], options?: Partial<HasManyThroughRelationOptions<RelatedModel>> & Partial<ResourcefulRelationshipDefinition>): (target: any, propertyKey: string) => void;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Removes all properties with undefined values from an object.
3
+ * This utility function creates a new object containing only the properties
4
+ * that have defined values, effectively filtering out any undefined properties.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const input = {
9
+ * name: 'John',
10
+ * age: undefined,
11
+ * email: 'john@example.com',
12
+ * phone: undefined
13
+ * }
14
+ *
15
+ * const result = stripUndefinedValuesFromObject(input)
16
+ * // Result: { name: 'John', email: 'john@example.com' }
17
+ * ```
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // Useful for cleaning up optional parameters before API calls
22
+ * const apiParams = stripUndefinedValuesFromObject({
23
+ * userId: user.id,
24
+ * filter: searchFilter || undefined,
25
+ * limit: pageSize || undefined,
26
+ * offset: currentPage ? currentPage * pageSize : undefined
27
+ * })
28
+ * ```
29
+ *
30
+ * @template T - The type of the input object, must extend Record<string, any>
31
+ * @param {T} obj - The object to filter, removing properties with undefined values
32
+ * @returns {T} A new object of the same type with undefined properties removed
33
+ */
34
+ export declare const stripUndefinedValuesFromObject: <T extends Record<string, any>>(obj: T) => T;
@@ -0,0 +1,85 @@
1
+ import type { AnySchema } from '../schema_types';
2
+ import type { ExtensionFactory, Reference } from 'joi';
3
+ /**
4
+ * A Joi extension that adds support for BigInt validation with comprehensive
5
+ * comparison operations and type coercion.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { joi } from '@nhtio/lucid-resourceful/joi'
10
+ *
11
+ * const schema = joi.bigint()
12
+ * .min(0n)
13
+ * .max(1000n)
14
+ * .required()
15
+ *
16
+ * // Validates and converts to BigInt
17
+ * const result = schema.validate("123") // Returns { value: 123n }
18
+ * ```
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Works with all standard Joi methods
23
+ * const optionalSchema = joi.bigint()
24
+ * .positive()
25
+ * .optional()
26
+ * .allow(null)
27
+ * .default(0n)
28
+ * ```
29
+ *
30
+ * @public
31
+ */
32
+ export declare const bigint: ExtensionFactory;
33
+ /**
34
+ * Joi schema type for BigInt validation with comprehensive comparison operations.
35
+ *
36
+ * This interface extends the base Joi AnySchema to provide BigInt-specific
37
+ * validation methods including range checks, sign validation, and multiple checks.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import { joi } from '@nhtio/lucid-resourceful/joi'
42
+ *
43
+ * const schema: BigIntSchema = joi.bigint()
44
+ * .min(0n)
45
+ * .max(1000n)
46
+ * .positive()
47
+ * ```
48
+ *
49
+ * @public
50
+ */
51
+ export interface BigIntSchema<TSchema = bigint> extends AnySchema<TSchema> {
52
+ /**
53
+ * Validates that the BigInt is greater than the specified threshold
54
+ * @param limit - The threshold value to compare against
55
+ */
56
+ greater(limit: bigint | Reference): this;
57
+ /**
58
+ * Validates that the BigInt is less than the specified threshold
59
+ * @param limit - The threshold value to compare against
60
+ */
61
+ less(limit: bigint | Reference): this;
62
+ /**
63
+ * Validates that the BigInt is less than or equal to the specified maximum
64
+ * @param limit - The maximum allowed value
65
+ */
66
+ max(limit: bigint | Reference): this;
67
+ /**
68
+ * Validates that the BigInt is greater than or equal to the specified minimum
69
+ * @param limit - The minimum allowed value
70
+ */
71
+ min(limit: bigint | Reference): this;
72
+ /**
73
+ * Validates that the BigInt is a multiple of the specified factor
74
+ * @param limit - The factor that the value must be a multiple of
75
+ */
76
+ multiple(limit: bigint | Reference): this;
77
+ /**
78
+ * Validates that the BigInt is negative (less than zero)
79
+ */
80
+ negative(): this;
81
+ /**
82
+ * Validates that the BigInt is positive (greater than zero)
83
+ */
84
+ positive(): this;
85
+ }