@nhtio/lucid-resourceful 1.20250718.1 → 1.20250724.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/{decorator_utils-1yWqd_Gg.cjs → decorator_utils-U_rZo8tv.cjs} +47 -3
- package/decorator_utils-U_rZo8tv.cjs.map +1 -0
- package/{decorator_utils-BUuBwQYK.js → decorator_utils-YSb1EGJ6.js} +50 -4
- package/decorator_utils-YSb1EGJ6.js.map +1 -0
- package/{definitions-B66EPk0H.js → definitions-B88XBTUF.js} +119 -119
- package/{definitions-B66EPk0H.js.map → definitions-B88XBTUF.js.map} +1 -1
- package/{definitions-BrN-oCRI.cjs → definitions-DgI468dW.cjs} +119 -119
- package/{definitions-BrN-oCRI.cjs.map → definitions-DgI468dW.cjs.map} +1 -1
- package/definitions.cjs +1 -1
- package/definitions.mjs +1 -1
- package/index.cjs +401 -378
- package/index.cjs.map +1 -1
- package/index.mjs +376 -353
- package/index.mjs.map +1 -1
- package/joi.cjs +12389 -2
- package/joi.cjs.map +1 -1
- package/joi.mjs +12391 -2
- package/joi.mjs.map +1 -1
- package/package.json +1 -1
- package/private/decorators.d.ts +1 -1
- package/private/joi/index.d.ts +3 -65
- package/private/mixin.d.ts +4 -1
- package/private/prepare_consume_chain_builder.d.ts +36 -0
- package/private/types.d.ts +3 -0
- package/utils.cjs +1 -1
- package/utils.mjs +2 -2
- package/decorator_utils-1yWqd_Gg.cjs.map +0 -1
- package/decorator_utils-BUuBwQYK.js.map +0 -1
- package/index-Cv6KC1rC.cjs +0 -670
- package/index-Cv6KC1rC.cjs.map +0 -1
- package/index-DDaZ2qr2.js +0 -671
- package/index-DDaZ2qr2.js.map +0 -1
- package/private/joi/bigint.d.ts +0 -85
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nhtio/lucid-resourceful",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20250724.0",
|
|
4
4
|
"description": "A decorator-driven AdonisJS library that lets you annotate Lucid ORM models with metadata to automatically generate CRUD controllers, validation rules, OpenAPI schemas, and a unified query interface.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Jak Giveon <jak@nht.io>",
|
package/private/decorators.d.ts
CHANGED
|
@@ -105,7 +105,7 @@ export declare namespace resourcefulComputed {
|
|
|
105
105
|
var string: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<StringSchema>>) => (target: any, propertyKey: string) => void;
|
|
106
106
|
var date: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<DateSchema>>) => (target: any, propertyKey: string) => void;
|
|
107
107
|
var dateTime: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<DateSchema>>) => (target: any, propertyKey: string) => void;
|
|
108
|
-
var binary: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<
|
|
108
|
+
var binary: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<BinarySchema>>) => (target: any, propertyKey: string) => void;
|
|
109
109
|
var number: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
|
|
110
110
|
var integer: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
|
|
111
111
|
var bigint: (options?: Partial<DataTypeComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<NumberSchema>>) => (target: any, propertyKey: string) => void;
|
package/private/joi/index.d.ts
CHANGED
|
@@ -1,65 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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 };
|
|
1
|
+
export * from '@nhtio/validation';
|
|
2
|
+
import { validator } from '@nhtio/validation';
|
|
3
|
+
export { validator as joi };
|
package/private/mixin.d.ts
CHANGED
|
@@ -280,7 +280,10 @@ export interface ResourcefulModel extends LucidModel {
|
|
|
280
280
|
* );
|
|
281
281
|
* ```
|
|
282
282
|
*/
|
|
283
|
-
$onResourcefulIndex<SelectedFields extends Array<keyof ResourcefulModelSerializableAttributes<InstanceType<LucidModel>>>, ReturnType = Pick<ResourcefulModelSerializableAttributes<InstanceType<LucidModel>>, SelectedFields[number]>>(filter: string | null | undefined, page: number, perPage: number, fields: SelectedFields | null | undefined,
|
|
283
|
+
$onResourcefulIndex<SelectedFields extends Array<keyof ResourcefulModelSerializableAttributes<InstanceType<LucidModel>>>, SelectedSingleField extends keyof ResourcefulModelSerializableAttributes<InstanceType<LucidModel>>, ReturnType = Pick<ResourcefulModelSerializableAttributes<InstanceType<LucidModel>>, SelectedFields[number]>>(filter: string | null | undefined, page: number, perPage: number, fields: SelectedFields | SelectedSingleField | null | undefined, sort: Array<[
|
|
284
|
+
Extract<keyof ResourcefulModelSerializableAttributes<InstanceType<LucidModel>>, string>,
|
|
285
|
+
'asc' | 'desc'
|
|
286
|
+
]> | null | undefined, ctx: HttpContext, app: ApplicationService, hooks?: ResourcefulScopeHooks): Promise<ResourcefulIndexResult<ReturnType>>;
|
|
284
287
|
/**
|
|
285
288
|
* Retrieves a single model record by its unique identifier with access control.
|
|
286
289
|
*
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function types for prepare and consume operations
|
|
3
|
+
*/
|
|
4
|
+
export type CustomPrepareFunction = (value: unknown) => unknown;
|
|
5
|
+
export type CustomConsumeFunction = (value: unknown) => unknown;
|
|
6
|
+
export type DefaultPrepareFunction<T = unknown> = (key: string, value: unknown, nullable?: boolean) => T;
|
|
7
|
+
export type DefaultConsumeFunction<T = unknown> = (key: string, value: unknown, nullable?: boolean) => T;
|
|
8
|
+
/**
|
|
9
|
+
* Utility class for building chained prepare and consume functions.
|
|
10
|
+
*
|
|
11
|
+
* The chaining order reflects the data flow:
|
|
12
|
+
* - Prepare chain: Default → Custom (data flows TO database)
|
|
13
|
+
* - Consume chain: Custom → Default (data flows FROM database)
|
|
14
|
+
*/
|
|
15
|
+
export declare class PrepareConsumeChainBuilder {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a chained prepare function that calls default first, then custom.
|
|
18
|
+
*
|
|
19
|
+
* @param propertyKey - The property name for error context
|
|
20
|
+
* @param nullable - Whether the field accepts null values
|
|
21
|
+
* @param defaultPrepare - The default prepare function from decorator
|
|
22
|
+
* @param customPrepare - The custom prepare function from options
|
|
23
|
+
* @returns A chained prepare function or undefined if no functions provided
|
|
24
|
+
*/
|
|
25
|
+
static chainPrepare<T>(propertyKey: string, nullable: boolean, defaultPrepare?: DefaultPrepareFunction<T> | undefined, customPrepare?: CustomPrepareFunction | undefined): CustomPrepareFunction | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a chained consume function that calls custom first, then default.
|
|
28
|
+
*
|
|
29
|
+
* @param propertyKey - The property name for error context
|
|
30
|
+
* @param nullable - Whether the field accepts null values
|
|
31
|
+
* @param defaultConsume - The default consume function from decorator
|
|
32
|
+
* @param customConsume - The custom consume function from options
|
|
33
|
+
* @returns A chained consume function or undefined if no functions provided
|
|
34
|
+
*/
|
|
35
|
+
static chainConsume<T>(propertyKey: string, nullable: boolean, defaultConsume?: DefaultConsumeFunction<T>, customConsume?: CustomConsumeFunction): CustomConsumeFunction | undefined;
|
|
36
|
+
}
|
package/private/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CustomConsumeFunction, CustomPrepareFunction } from '@/private/prepare_consume_chain_builder.ts';
|
|
1
2
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
3
|
import type { HttpContext } from '@adonisjs/core/http';
|
|
3
4
|
import type { ApplicationService } from '@adonisjs/core/types';
|
|
@@ -30,6 +31,8 @@ export interface ResourcefulPropertyDefinition {
|
|
|
30
31
|
externalDocs?: ExternalDocumentationObject;
|
|
31
32
|
example?: string;
|
|
32
33
|
deprecated?: boolean;
|
|
34
|
+
prepare?: CustomPrepareFunction;
|
|
35
|
+
consume?: CustomConsumeFunction;
|
|
33
36
|
}
|
|
34
37
|
export interface ValidationScoper<BaseSchema extends AnySchema> {
|
|
35
38
|
(schema: BaseSchema): void;
|
package/utils.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const decorator_utils = require("./decorator_utils-
|
|
3
|
+
const decorator_utils = require("./decorator_utils-U_rZo8tv.cjs");
|
|
4
4
|
const casters = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5
5
|
__proto__: null,
|
|
6
6
|
castValueAsArray: decorator_utils.castValueAsArray,
|
package/utils.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as castValueAsArray, a as castValueAsBigint, b as castValueAsBinary, d as castValueAsBoolean, e as castValueAsDate, f as castValueAsDateTime, g as castValueAsInteger, h as castValueAsNumber, i as castValueAsObject, j as castValueAsString, k as castValueAsUnsignedInt, p as prepareArray, l as prepareBigint, m as prepareBinary, n as prepareBoolean, o as prepareDate, q as prepareDateTime, r as prepareInteger, s as prepareNumber, t as prepareObject, u as prepareString, v as prepareUnsignedint, w as consumeArray, x as consumeBigint, y as consumeBinary, z as consumeBoolean, A as consumeDate, B as consumeDateTime, C as consumeInteger, D as consumeNumber, E as consumeObject, F as consumeString, G as consumeUnsignedint } from "./decorator_utils-
|
|
2
|
-
import { H } from "./decorator_utils-
|
|
1
|
+
import { c as castValueAsArray, a as castValueAsBigint, b as castValueAsBinary, d as castValueAsBoolean, e as castValueAsDate, f as castValueAsDateTime, g as castValueAsInteger, h as castValueAsNumber, i as castValueAsObject, j as castValueAsString, k as castValueAsUnsignedInt, p as prepareArray, l as prepareBigint, m as prepareBinary, n as prepareBoolean, o as prepareDate, q as prepareDateTime, r as prepareInteger, s as prepareNumber, t as prepareObject, u as prepareString, v as prepareUnsignedint, w as consumeArray, x as consumeBigint, y as consumeBinary, z as consumeBoolean, A as consumeDate, B as consumeDateTime, C as consumeInteger, D as consumeNumber, E as consumeObject, F as consumeString, G as consumeUnsignedint } from "./decorator_utils-YSb1EGJ6.js";
|
|
2
|
+
import { H } from "./decorator_utils-YSb1EGJ6.js";
|
|
3
3
|
const casters = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4
4
|
__proto__: null,
|
|
5
5
|
castValueAsArray,
|