@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.
- package/LICENSE.md +9 -0
- package/README.md +5 -0
- package/decorator_utils-1yWqd_Gg.cjs +6792 -0
- package/decorator_utils-1yWqd_Gg.cjs.map +1 -0
- package/decorator_utils-BUuBwQYK.js +6793 -0
- package/decorator_utils-BUuBwQYK.js.map +1 -0
- package/definitions-B66EPk0H.js +381 -0
- package/definitions-B66EPk0H.js.map +1 -0
- package/definitions-BrN-oCRI.cjs +380 -0
- package/definitions-BrN-oCRI.cjs.map +1 -0
- package/definitions.cjs +15 -0
- package/definitions.cjs.map +1 -0
- package/definitions.d.ts +5 -0
- package/definitions.mjs +15 -0
- package/definitions.mjs.map +1 -0
- package/errors-B1rr67uM.js +3004 -0
- package/errors-B1rr67uM.js.map +1 -0
- package/errors-D8jb9VxY.cjs +3000 -0
- package/errors-D8jb9VxY.cjs.map +1 -0
- package/errors.cjs +22 -0
- package/errors.cjs.map +1 -0
- package/errors.d.ts +94 -0
- package/errors.mjs +22 -0
- package/errors.mjs.map +1 -0
- package/index-Cv6KC1rC.cjs +670 -0
- package/index-Cv6KC1rC.cjs.map +1 -0
- package/index-DDaZ2qr2.js +671 -0
- package/index-DDaZ2qr2.js.map +1 -0
- package/index.cjs +12706 -0
- package/index.cjs.map +1 -0
- package/index.d.ts +14 -0
- package/index.mjs +12708 -0
- package/index.mjs.map +1 -0
- package/joi.cjs +5 -0
- package/joi.cjs.map +1 -0
- package/joi.d.ts +5 -0
- package/joi.mjs +5 -0
- package/joi.mjs.map +1 -0
- package/package.json +65 -0
- package/private/constants.d.ts +11 -0
- package/private/controller_factory.d.ts +1 -0
- package/private/data_type_schemas.d.ts +12 -0
- package/private/data_types.d.ts +437 -0
- package/private/decorator_schemas.d.ts +34 -0
- package/private/decorator_utils.d.ts +305 -0
- package/private/decorators.d.ts +209 -0
- package/private/helpers.d.ts +34 -0
- package/private/joi/bigint.d.ts +85 -0
- package/private/joi/index.d.ts +65 -0
- package/private/lucene_to_lucid_translator.d.ts +201 -0
- package/private/mixin.d.ts +563 -0
- package/private/schema_types.d.ts +157 -0
- package/private/type_guards.d.ts +42 -0
- package/private/types.d.ts +102 -0
- package/private/utils.d.ts +10 -0
- package/types.cjs +2 -0
- package/types.cjs.map +1 -0
- package/types.d.ts +28 -0
- package/types.mjs +2 -0
- package/types.mjs.map +1 -0
- package/utils/casters.d.ts +1 -0
- package/utils/consumers.d.ts +1 -0
- package/utils/preparers.d.ts +1 -0
- package/utils.cjs +50 -0
- package/utils.cjs.map +1 -0
- package/utils.d.ts +20 -0
- package/utils.mjs +51 -0
- package/utils.mjs.map +1 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Root } from 'joi';
|
|
2
|
+
import type { BigIntSchema } from './bigint';
|
|
3
|
+
/**
|
|
4
|
+
* Extended Joi root interface that includes custom schema types for
|
|
5
|
+
* lucid-resourceful validation scenarios.
|
|
6
|
+
*
|
|
7
|
+
* This interface extends the standard Joi Root interface to include
|
|
8
|
+
* additional schema types specifically designed for AdonisJS Lucid
|
|
9
|
+
* model validation requirements.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { joi } from '@nhtio/lucid-resourceful/joi'
|
|
14
|
+
*
|
|
15
|
+
* const schema = joi.object({
|
|
16
|
+
* id: joi.bigint().positive().required(),
|
|
17
|
+
* balance: joi.bigint().min(0n).optional()
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export interface ExtendedJoiRoot extends Root {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a BigInt schema type for validation
|
|
26
|
+
* @returns A new BigInt schema instance
|
|
27
|
+
*/
|
|
28
|
+
bigint(): BigIntSchema;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Extended Joi instance with custom schema types for lucid-resourceful.
|
|
32
|
+
*
|
|
33
|
+
* This instance includes all standard Joi functionality plus additional
|
|
34
|
+
* schema types optimized for AdonisJS Lucid model validation scenarios.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { joi } from '@nhtio/lucid-resourceful/joi'
|
|
39
|
+
*
|
|
40
|
+
* // Standard Joi usage
|
|
41
|
+
* const userSchema = joi.object({
|
|
42
|
+
* name: joi.string().required(),
|
|
43
|
+
* age: joi.number().min(0),
|
|
44
|
+
* balance: joi.bigint().positive() // Custom BigInt type
|
|
45
|
+
* })
|
|
46
|
+
*
|
|
47
|
+
* // Use in resourceful decorators
|
|
48
|
+
* @resourceful({
|
|
49
|
+
* type: 'bigint',
|
|
50
|
+
* validate: {
|
|
51
|
+
* create: joi.bigint().positive(),
|
|
52
|
+
* update: joi.bigint().min(0n)
|
|
53
|
+
* }
|
|
54
|
+
* })
|
|
55
|
+
* public balance: bigint
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare const joi: ExtendedJoiRoot;
|
|
61
|
+
/**
|
|
62
|
+
* Re-export of the BigIntSchema interface for external use
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export type { BigIntSchema };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { ModelKeysContract } from '@adonisjs/lucid/types/model';
|
|
2
|
+
import type { QueryClientContract } from '@adonisjs/lucid/types/database';
|
|
3
|
+
import type { DatabaseQueryBuilderContract } from '@adonisjs/lucid/types/querybuilder';
|
|
4
|
+
import type { ComparisonOperatorToken, EmptyExpression, FieldToken, ImplicitFieldToken, LiteralExpressionToken, LogicalExpressionToken, RangeExpressionToken, RegexExpressionToken, TagToken, UnaryOperatorToken, ParenthesizedExpressionToken, ExpressionToken, ParserAst } from 'liqe';
|
|
5
|
+
/**
|
|
6
|
+
* Database query builder contract extended for Lucene filtering capabilities.
|
|
7
|
+
*
|
|
8
|
+
* @template Result - The result type for the query builder
|
|
9
|
+
*/
|
|
10
|
+
export interface LuceneFilteredDatabaseQueryBuilderContract extends DatabaseQueryBuilderContract {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Applies an empty expression AST node to a database query.
|
|
14
|
+
* Empty expressions are no-op operations that don't modify the query.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The result type for the query builder
|
|
17
|
+
* @param _ast - The empty expression AST node
|
|
18
|
+
* @param _query - The database query builder to modify
|
|
19
|
+
* @param _attributesToColumns - Mapping of model attributes to database columns
|
|
20
|
+
* @param _primaryKey - The primary key column name
|
|
21
|
+
* @param _tableName - The table name
|
|
22
|
+
* @param _allowedColumns - Optional array of allowed column names for filtering
|
|
23
|
+
*/
|
|
24
|
+
export declare const applyLuceneEmptyExpressionAst: (_ast: EmptyExpression, _query: LuceneFilteredDatabaseQueryBuilderContract, _attributesToColumns: ModelKeysContract, _primaryKey: string, _tableName: string, _allowedColumns?: string[] | undefined) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Applies a logical expression AST node (AND/OR) to a database query.
|
|
27
|
+
* Handles logical operations between two expressions with proper SQL grouping.
|
|
28
|
+
*
|
|
29
|
+
* @template T - The result type for the query builder
|
|
30
|
+
* @param ast - The logical expression AST node containing left/right operands and operator
|
|
31
|
+
* @param query - The database query builder to modify
|
|
32
|
+
* @param attributesToColumns - Mapping of model attributes to database columns
|
|
33
|
+
* @param primaryKey - The primary key column name
|
|
34
|
+
* @param tableName - The table name
|
|
35
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
36
|
+
*/
|
|
37
|
+
export declare const applyLuceneLogicalExpressionAst: (ast: LogicalExpressionToken, query: LuceneFilteredDatabaseQueryBuilderContract, attributesToColumns: ModelKeysContract, primaryKey: string, tableName: string, allowedColumns?: string[] | undefined) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Applies a parenthesized expression AST node to a database query.
|
|
40
|
+
* Maintains logical grouping by wrapping the inner expression in a WHERE clause.
|
|
41
|
+
*
|
|
42
|
+
* @template T - The result type for the query builder
|
|
43
|
+
* @param ast - The parenthesized expression AST node containing the inner expression
|
|
44
|
+
* @param query - The database query builder to modify
|
|
45
|
+
* @param attributesToColumns - Mapping of model attributes to database columns
|
|
46
|
+
* @param primaryKey - The primary key column name
|
|
47
|
+
* @param tableName - The table name
|
|
48
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
49
|
+
*/
|
|
50
|
+
export declare const applyLuceneParenthesizedExpressionAst: (ast: ParenthesizedExpressionToken, query: LuceneFilteredDatabaseQueryBuilderContract, attributesToColumns: ModelKeysContract, primaryKey: string, tableName: string, allowedColumns?: string[] | undefined) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Applies an empty expression to a database query for a specific column.
|
|
53
|
+
* Handles queries for null or empty values.
|
|
54
|
+
*
|
|
55
|
+
* @template T - The result type for the query builder
|
|
56
|
+
* @param column - The database column name to query
|
|
57
|
+
* @param _expression - The empty expression (unused)
|
|
58
|
+
* @param operator - The comparison operator token
|
|
59
|
+
* @param query - The database query builder to modify
|
|
60
|
+
* @param _attributesToColumns - Mapping of model attributes to database columns (unused)
|
|
61
|
+
* @param _primaryKey - The primary key column name (unused)
|
|
62
|
+
* @param _tableName - The table name (unused)
|
|
63
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
64
|
+
*/
|
|
65
|
+
export declare const applyLuceneEmptyExpression: (column: string, _expression: EmptyExpression, operator: ComparisonOperatorToken, query: LuceneFilteredDatabaseQueryBuilderContract, _attributesToColumns: ModelKeysContract, _primaryKey: string, _tableName: string, _allowedColumns?: string[] | undefined) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Applies a literal expression to a database query for a specific column.
|
|
68
|
+
* Handles string, boolean, and null values with appropriate SQL operations.
|
|
69
|
+
* Supports quote stripping and handles different comparison operators.
|
|
70
|
+
*
|
|
71
|
+
* @template T - The result type for the query builder
|
|
72
|
+
* @param column - The database column name to query
|
|
73
|
+
* @param expression - The literal expression containing the value and quote information
|
|
74
|
+
* @param operator - The comparison operator token
|
|
75
|
+
* @param query - The database query builder to modify
|
|
76
|
+
* @param _attributesToColumns - Mapping of model attributes to database columns (unused)
|
|
77
|
+
* @param _primaryKey - The primary key column name (unused)
|
|
78
|
+
* @param _tableName - The table name (unused)
|
|
79
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
80
|
+
*/
|
|
81
|
+
export declare const applyLuceneLiteralExpression: (column: string, expression: LiteralExpressionToken, operator: ComparisonOperatorToken, query: LuceneFilteredDatabaseQueryBuilderContract, _attributesToColumns: ModelKeysContract, _primaryKey: string, _tableName: string, _allowedColumns?: string[] | undefined) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Applies a range expression to a database query for a specific column.
|
|
84
|
+
* Converts Lucene range syntax to SQL BETWEEN operations with proper inclusive/exclusive handling.
|
|
85
|
+
*
|
|
86
|
+
* @template T - The result type for the query builder
|
|
87
|
+
* @param column - The database column name to query
|
|
88
|
+
* @param expression - The range expression containing min/max values and inclusivity flags
|
|
89
|
+
* @param operator - The comparison operator token
|
|
90
|
+
* @param query - The database query builder to modify
|
|
91
|
+
* @param _attributesToColumns - Mapping of model attributes to database columns (unused)
|
|
92
|
+
* @param _primaryKey - The primary key column name (unused)
|
|
93
|
+
* @param _tableName - The table name (unused)
|
|
94
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
95
|
+
*/
|
|
96
|
+
export declare const applyLuceneRangeExpression: (column: string, expression: RangeExpressionToken, operator: ComparisonOperatorToken, query: LuceneFilteredDatabaseQueryBuilderContract, _attributesToColumns: ModelKeysContract, _primaryKey: string, _tableName: string, _allowedColumns?: string[] | undefined) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Applies a regex expression to a database query for a specific column.
|
|
99
|
+
* Converts regex patterns to SQL LIKE patterns with proper escaping.
|
|
100
|
+
* Transforms * to % and ? to _ for SQL pattern matching.
|
|
101
|
+
*
|
|
102
|
+
* @template T - The result type for the query builder
|
|
103
|
+
* @param column - The database column name to query
|
|
104
|
+
* @param expression - The regex expression containing the pattern
|
|
105
|
+
* @param operator - The comparison operator token
|
|
106
|
+
* @param query - The database query builder to modify
|
|
107
|
+
* @param _attributesToColumns - Mapping of model attributes to database columns (unused)
|
|
108
|
+
* @param _primaryKey - The primary key column name (unused)
|
|
109
|
+
* @param _tableName - The table name (unused)
|
|
110
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
111
|
+
*/
|
|
112
|
+
export declare const applyLuceneRegexExpression: (column: string, expression: RegexExpressionToken, operator: ComparisonOperatorToken, query: LuceneFilteredDatabaseQueryBuilderContract, _attributesToColumns: ModelKeysContract, _primaryKey: string, _tableName: string, _allowedColumns?: string[] | undefined) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Applies an implicit field AST node to a database query.
|
|
115
|
+
* Implicit fields use the primary key column when no specific field is specified.
|
|
116
|
+
*
|
|
117
|
+
* @template T - The result type for the query builder
|
|
118
|
+
* @param _field - The implicit field token (unused)
|
|
119
|
+
* @param expression - The expression to apply to the primary key column
|
|
120
|
+
* @param operator - The comparison operator token
|
|
121
|
+
* @param query - The database query builder to modify
|
|
122
|
+
* @param attributesToColumns - Mapping of model attributes to database columns
|
|
123
|
+
* @param primaryKey - The primary key column name to use for implicit fields
|
|
124
|
+
* @param tableName - The table name
|
|
125
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
126
|
+
*/
|
|
127
|
+
export declare const applyLuceneImplicitFieldAst: (_field: ImplicitFieldToken, expression: ExpressionToken, operator: ComparisonOperatorToken | undefined, query: LuceneFilteredDatabaseQueryBuilderContract, attributesToColumns: ModelKeysContract, primaryKey: string, tableName: string, allowedColumns?: string[] | undefined) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Applies a field AST node to a database query.
|
|
130
|
+
* Maps the field name to the corresponding database column and applies the expression.
|
|
131
|
+
*
|
|
132
|
+
* @template T - The result type for the query builder
|
|
133
|
+
* @param field - The field token containing the field name
|
|
134
|
+
* @param expression - The expression to apply to the mapped column
|
|
135
|
+
* @param operator - The comparison operator token
|
|
136
|
+
* @param query - The database query builder to modify
|
|
137
|
+
* @param attributesToColumns - Mapping of model attributes to database columns
|
|
138
|
+
* @param primaryKey - The primary key column name
|
|
139
|
+
* @param tableName - The table name
|
|
140
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
141
|
+
*/
|
|
142
|
+
export declare const applyLuceneFieldAst: (field: FieldToken, expression: ExpressionToken, operator: ComparisonOperatorToken, query: LuceneFilteredDatabaseQueryBuilderContract, attributesToColumns: ModelKeysContract, primaryKey: string, tableName: string, allowedColumns?: string[] | undefined) => void;
|
|
143
|
+
/**
|
|
144
|
+
* Applies a tag AST node to a database query.
|
|
145
|
+
* Tags represent field:expression pairs in Lucene syntax.
|
|
146
|
+
* Delegates to either implicit field or explicit field handlers based on the field type.
|
|
147
|
+
*
|
|
148
|
+
* @template T - The result type for the query builder
|
|
149
|
+
* @param ast - The tag AST node containing field, expression, and operator
|
|
150
|
+
* @param query - The database query builder to modify
|
|
151
|
+
* @param attributesToColumns - Mapping of model attributes to database columns
|
|
152
|
+
* @param primaryKey - The primary key column name
|
|
153
|
+
* @param tableName - The table name
|
|
154
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
155
|
+
*/
|
|
156
|
+
export declare const applyLuceneTagAst: (ast: TagToken, query: LuceneFilteredDatabaseQueryBuilderContract, attributesToColumns: ModelKeysContract, primaryKey: string, tableName: string, allowedColumns?: string[] | undefined) => void;
|
|
157
|
+
/**
|
|
158
|
+
* Applies a unary operator AST node to a database query.
|
|
159
|
+
* Handles NOT and negation (-) operators by wrapping the operand in a WHERE NOT clause.
|
|
160
|
+
*
|
|
161
|
+
* @template T - The result type for the query builder
|
|
162
|
+
* @param ast - The unary operator AST node containing operator and operand
|
|
163
|
+
* @param query - The database query builder to modify
|
|
164
|
+
* @param attributesToColumns - Mapping of model attributes to database columns
|
|
165
|
+
* @param primaryKey - The primary key column name
|
|
166
|
+
* @param tableName - The table name
|
|
167
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
168
|
+
*/
|
|
169
|
+
export declare const applyLuceneUnaryOperatorAst: (ast: UnaryOperatorToken, query: LuceneFilteredDatabaseQueryBuilderContract, attributesToColumns: ModelKeysContract, primaryKey: string, tableName: string, allowedColumns?: string[] | undefined) => void;
|
|
170
|
+
/**
|
|
171
|
+
* Applies any Lucene AST node to a database query.
|
|
172
|
+
* This is the main dispatcher function that routes different AST node types
|
|
173
|
+
* to their appropriate handler functions.
|
|
174
|
+
*
|
|
175
|
+
* @template T - The result type for the query builder
|
|
176
|
+
* @param ast - The AST node to apply
|
|
177
|
+
* @param query - The database query builder to modify
|
|
178
|
+
* @param attributesToColumns - Mapping of model attributes to database columns
|
|
179
|
+
* @param primaryKey - The primary key column name
|
|
180
|
+
* @param tableName - The table name
|
|
181
|
+
* @param allowedColumns - Optional array of allowed column names for filtering
|
|
182
|
+
* @param throwOnInvalidType - Whether to throw an error for unrecognized AST node types
|
|
183
|
+
*/
|
|
184
|
+
export declare const applyLuceneAst: (ast: ParserAst, query: LuceneFilteredDatabaseQueryBuilderContract, attributesToColumns: ModelKeysContract, primaryKey: string, tableName: string, allowedColumns: string[] | undefined, throwOnInvalidType?: boolean) => void;
|
|
185
|
+
/**
|
|
186
|
+
* Converts a Lucene query string to a Lucid database query builder.
|
|
187
|
+
* Parses the Lucene syntax and applies the resulting AST to generate SQL conditions.
|
|
188
|
+
*
|
|
189
|
+
* @template T - The result type for the query builder
|
|
190
|
+
* @param luceneQuery - The Lucene query string to parse and convert
|
|
191
|
+
* @param connection - The database connection client for creating queries
|
|
192
|
+
* @param attributesToColumns - Mapping of model attributes to database columns
|
|
193
|
+
* @param primaryKey - The primary key column name for implicit field queries
|
|
194
|
+
* @param tableName - The database table name to query
|
|
195
|
+
* @param allowedColumns - Optional array of allowed column names for security filtering
|
|
196
|
+
* @returns A database query builder with the Lucene conditions applied
|
|
197
|
+
* @throws {E_LUCENE_SYNTAX_EXCEPTION} When the Lucene query has syntax errors
|
|
198
|
+
* @throws {E_LUCENE_UNEXPECTED_EXCEPTION} When an unexpected error occurs during parsing
|
|
199
|
+
* @throws {E_LUCENE_INVALID_TYPE} When an unrecognized AST node type is encountered
|
|
200
|
+
*/
|
|
201
|
+
export declare const luceneToLucid: (luceneQuery: string, connection: QueryClientContract, attributesToColumns: ModelKeysContract, primaryKey: string, tableName: string, allowedColumns?: string[] | undefined) => LuceneFilteredDatabaseQueryBuilderContract;
|