@codenameryuu/adonis-lucid-auto-preload 2.9.0 → 2.9.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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # The MIT License
2
2
 
3
- Copyright 2022 Oussama Benhamed, contributors
3
+ Copyright 2026 Codename Ryuu
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
@@ -1,8 +1,8 @@
1
- import type { NormalizeConstructor } from '@adonisjs/core/types/helpers';
2
- import type { LucidModel } from '@adonisjs/lucid/types/model';
1
+ import type { NormalizeConstructor } from "@adonisjs/core/types/helpers";
2
+ import type { LucidModel } from "@adonisjs/lucid/types/model";
3
3
  type GetWith<T> = T extends {
4
4
  $with: Array<infer Item>;
5
- } ? Item extends string ? Item : string : string;
5
+ } ? (Item extends string ? Item : string) : string;
6
6
  export interface AutoPreloadMixin {
7
7
  <T extends NormalizeConstructor<LucidModel>>(superclass: T): T & {
8
8
  $with: ReadonlyArray<string | ((query: any) => void)>;
@@ -1,7 +1,7 @@
1
- import type { AutoPreloadMixin } from './auto_preload.js';
2
- declare module '@adonisjs/core/types' {
1
+ import type { AutoPreloadMixin } from "./auto_preload.js";
2
+ declare module "@adonisjs/core/types" {
3
3
  interface ContainerBindings {
4
- '@codenameryuu/adonis-lucid-auto-preload': {
4
+ "@codenameryuu/adonis-lucid-auto-preload": {
5
5
  AutoPreload: AutoPreloadMixin;
6
6
  };
7
7
  }
@@ -1,2 +1,2 @@
1
- import type Configure from '@adonisjs/core/commands/configure';
1
+ import type Configure from "@adonisjs/core/commands/configure";
2
2
  export declare function configure(command: Configure): Promise<void>;
@@ -4,6 +4,6 @@ export async function configure(command) {
4
4
  * Register the provider inside `adonisrc.ts`
5
5
  */
6
6
  await codemods.updateRcFile((rcFile) => {
7
- rcFile.addProvider('@codenameryuu/adonis-lucid-auto-preload/provider');
7
+ rcFile.addProvider("@codenameryuu/adonis-lucid-auto-preload/provider");
8
8
  });
9
9
  }
package/build/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { configure } from './configure.js';
2
- export { AutoPreload } from './src/mixins/auto_preload.js';
1
+ export { configure } from "./configure.js";
2
+ export { AutoPreload } from "./src/mixins/auto_preload.js";
package/build/index.js CHANGED
@@ -6,5 +6,5 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- export { configure } from './configure.js';
10
- export { AutoPreload } from './src/mixins/auto_preload.js';
9
+ export { configure } from "./configure.js";
10
+ export { AutoPreload } from "./src/mixins/auto_preload.js";
@@ -1,5 +1,5 @@
1
- import type { ApplicationService } from '@adonisjs/core/types';
2
- export { configure } from '../configure.js';
1
+ import type { ApplicationService } from "@adonisjs/core/types";
2
+ export { configure } from "../configure.js";
3
3
  export default class AutoPreloadProvider {
4
4
  protected app: ApplicationService;
5
5
  static needsApplication: boolean;
@@ -1,5 +1,5 @@
1
- import { AutoPreload } from '../src/mixins/auto_preload.js';
2
- export { configure } from '../configure.js';
1
+ import { AutoPreload } from "../src/mixins/auto_preload.js";
2
+ export { configure } from "../configure.js";
3
3
  export default class AutoPreloadProvider {
4
4
  app;
5
5
  static needsApplication = true;
@@ -7,7 +7,7 @@ export default class AutoPreloadProvider {
7
7
  this.app = app;
8
8
  }
9
9
  register() {
10
- this.app.container.singleton('@codenameryuu/adonis-lucid-auto-preload', () => {
10
+ this.app.container.singleton("@codenameryuu/adonis-lucid-auto-preload", () => {
11
11
  return { AutoPreload };
12
12
  });
13
13
  }
@@ -1,4 +1,4 @@
1
- import { Exception } from '@adonisjs/core/exceptions';
1
+ import { Exception } from "@adonisjs/core/exceptions";
2
2
  export default class WrongArgumentTypeException extends Exception {
3
3
  static invoke(method: string): WrongArgumentTypeException;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { Exception } from '@adonisjs/core/exceptions';
1
+ import { Exception } from "@adonisjs/core/exceptions";
2
2
  export default class WrongArgumentTypeException extends Exception {
3
3
  static invoke(method) {
4
4
  return new this(`The method ${method} accepts only an array of strings`);
@@ -1,4 +1,4 @@
1
- import { Exception } from '@adonisjs/core/exceptions';
1
+ import { Exception } from "@adonisjs/core/exceptions";
2
2
  export default class WrongRelationshipTypeException extends Exception {
3
3
  static invoke(model: string): WrongRelationshipTypeException;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { Exception } from '@adonisjs/core/exceptions';
1
+ import { Exception } from "@adonisjs/core/exceptions";
2
2
  export default class WrongRelationshipTypeException extends Exception {
3
3
  static invoke(model) {
4
4
  return new this(`The model "${model}" has wrong relationships to be auto-preloaded. Only string and function types are allowed`);
@@ -1,5 +1,5 @@
1
- import type { NormalizeConstructor } from '@adonisjs/core/types/helpers';
2
- import type { LucidModel, ModelQueryBuilderContract } from '@adonisjs/lucid/types/model';
1
+ import type { NormalizeConstructor } from "@adonisjs/core/types/helpers";
2
+ import type { LucidModel, ModelQueryBuilderContract } from "@adonisjs/lucid/types/model";
3
3
  type PreloadEntry = string | ((query: ModelQueryBuilderContract<any, any>) => void);
4
4
  export declare function AutoPreload<T extends NormalizeConstructor<LucidModel>>(superclass: T): {
5
5
  new (...args: any[]): {
@@ -13,9 +13,9 @@ export function AutoPreload(superclass) {
13
13
  return;
14
14
  this.$autoPreloadHooksRegistered = true;
15
15
  // Register hooks on the actual model subclass.
16
- this.before('find', this.beforeFindHook.bind(this));
17
- this.before('fetch', this.beforeFetchHook.bind(this));
18
- this.before('paginate', this.beforePaginateHook.bind(this));
16
+ this.before("find", this.beforeFindHook.bind(this));
17
+ this.before("fetch", this.beforeFetchHook.bind(this));
18
+ this.before("paginate", this.beforePaginateHook.bind(this));
19
19
  }
20
20
  static beforeFindHook(query) {
21
21
  this.applyAutoPreload(query);
@@ -24,7 +24,7 @@ export function AutoPreload(superclass) {
24
24
  this.applyAutoPreload(query);
25
25
  }
26
26
  static beforePaginateHook(queries) {
27
- const main = Array.isArray(queries) ? (queries[1] ?? queries[0]) : queries;
27
+ const main = Array.isArray(queries) ? queries[1] ?? queries[0] : queries;
28
28
  this.applyAutoPreload(main);
29
29
  }
30
30
  static applyAutoPreload(query) {
@@ -38,19 +38,19 @@ export function AutoPreload(superclass) {
38
38
  const skipList = query.$skipPreloads || [];
39
39
  const onlyList = query.$onlyPreloads || [];
40
40
  for (const relation of relations) {
41
- if (typeof relation === 'string') {
41
+ if (typeof relation === "string") {
42
42
  if (onlyList.length > 0 && !onlyList.includes(relation))
43
43
  continue;
44
44
  if (skipList.includes(relation))
45
45
  continue;
46
- if (relation.includes('.')) {
47
- this.handleNestedPreload(query, relation.split('.'));
46
+ if (relation.includes(".")) {
47
+ this.handleNestedPreload(query, relation.split("."));
48
48
  }
49
49
  else {
50
50
  query.preload(relation);
51
51
  }
52
52
  }
53
- else if (typeof relation === 'function') {
53
+ else if (typeof relation === "function") {
54
54
  relation(query);
55
55
  }
56
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codenameryuu/adonis-lucid-auto-preload",
3
- "version": "2.9.0",
3
+ "version": "2.9.2",
4
4
  "description": "Auto-preload (eager loading) multiple relationships when retrieving Lucid models on Adonis JS",
5
5
  "author": "codenameryuu",
6
6
  "license": "MIT",
@@ -38,9 +38,8 @@
38
38
  "scripts": {
39
39
  "clean": "del-cli build",
40
40
  "typecheck": "tsc --noEmit",
41
- "lint": "eslint . --ext=.ts",
42
41
  "format": "prettier --write .",
43
- "prebuild": "npm run lint && npm run clean",
42
+ "prebuild": "npm run clean",
44
43
  "build": "npm run clean && tsc",
45
44
  "release": "release-it",
46
45
  "version": "npm run build",
@@ -49,7 +48,6 @@
49
48
  "devDependencies": {
50
49
  "@adonisjs/assembler": "^7.7.0",
51
50
  "@adonisjs/core": "^7.0.0",
52
- "@adonisjs/eslint-config": "^3.0.0",
53
51
  "@adonisjs/lucid": "^22.0.0",
54
52
  "@adonisjs/prettier-config": "^1.4.5",
55
53
  "@adonisjs/tsconfig": "^2.0.0",
@@ -65,7 +63,6 @@
65
63
  "c8": "^9.1.0",
66
64
  "copyfiles": "^2.4.1",
67
65
  "del-cli": "^5.0.0",
68
- "eslint": "^10.0.2",
69
66
  "prettier": "^3.8.1",
70
67
  "reflect-metadata": "^0.2.2",
71
68
  "tsup": "^8.5.1",