@nhtio/lucid-resourceful 1.20250718.1 → 1.20250718.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nhtio/lucid-resourceful",
3
- "version": "1.20250718.1",
3
+ "version": "1.20250718.2",
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>",
@@ -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<DateSchema>>) => (target: any, propertyKey: string) => void;
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;
@@ -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
+ }
@@ -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-1yWqd_Gg.cjs");
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-BUuBwQYK.js";
2
- import { H } from "./decorator_utils-BUuBwQYK.js";
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,