@codenameryuu/adonis-lucid-auto-preload 1.2.6 → 1.5.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { AutoPreloadMixin } from './auto-preload';
1
+ import type { AutoPreloadMixin } from './auto_preload.js';
2
2
  declare module '@adonisjs/core/types' {
3
3
  interface ContainerBindings {
4
4
  '@codenameryuu/adonis-lucid-auto-preload': {
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,4 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /// <reference path="./auto-preload.ts" />
1
+ export {};
2
+ /// <reference path="./auto_preload.ts" />
4
3
  /// <reference path="./container.ts" />
@@ -0,0 +1,2 @@
1
+ declare const _default: never[];
2
+ export default _default;
@@ -0,0 +1,10 @@
1
+ /*
2
+ |--------------------------------------------------------------------------
3
+ | Exporting an array of commands
4
+ |--------------------------------------------------------------------------
5
+ |
6
+ | This package currently ships without Ace commands. Keep the command
7
+ | index in place and export an empty array to satisfy the expected API.
8
+ |
9
+ */
10
+ export default [];
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configure = configure;
4
- async function configure(command) {
1
+ export async function configure(command) {
5
2
  const codemods = await command.createCodemods();
6
3
  /**
7
4
  * Register the provider inside `adonisrc.ts`
@@ -0,0 +1,2 @@
1
+ export { configure } from './configure.js';
2
+ export { AutoPreload } from './src/mixins/auto_preload.ts';
package/build/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /*
2
+ * adonis-lucid-soft-deletes
3
+ *
4
+ * (c) Lookin Anton <alsd@lookinlab.ru>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export { configure } from './configure.js';
10
+ export { AutoPreload } from "./src/mixins/auto_preload.js";
@@ -1,4 +1,5 @@
1
- import type { ApplicationService } from "@adonisjs/core/types";
1
+ import type { ApplicationService } from '@adonisjs/core/types';
2
+ export { configure } from '../configure.js';
2
3
  export default class AutoPreloadProvider {
3
4
  protected app: ApplicationService;
4
5
  static needsApplication: boolean;
@@ -0,0 +1,17 @@
1
+ import { AutoPreload } from '../src/mixins/auto_preload.js';
2
+ export { configure } from '../configure.js';
3
+ export default class AutoPreloadProvider {
4
+ app;
5
+ static needsApplication = true;
6
+ constructor(app) {
7
+ this.app = app;
8
+ }
9
+ register() {
10
+ this.app.container.singleton('@codenameryuu/adonis-lucid-auto-preload', () => {
11
+ return { AutoPreload };
12
+ });
13
+ }
14
+ async boot() { }
15
+ async ready() { }
16
+ async shutdown() { }
17
+ }
@@ -0,0 +1,6 @@
1
+ import { Exception } from '@adonisjs/core/exceptions';
2
+ export default class WrongArgumentTypeException extends Exception {
3
+ static invoke(method) {
4
+ return new this(`The method ${method} accepts only an array of strings`);
5
+ }
6
+ }
@@ -0,0 +1,6 @@
1
+ import { Exception } from '@adonisjs/core/exceptions';
2
+ export default class WrongRelationshipTypeException extends Exception {
3
+ static invoke(model) {
4
+ return new this(`The model "${model}" has wrong relationships to be auto-preloaded. Only string and function types are allowed`);
5
+ }
6
+ }
@@ -1,12 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AutoPreload = void 0;
7
- const WrongRelationshipTypeException_1 = __importDefault(require("../Exceptions/WrongRelationshipTypeException"));
8
- const WrongArgumentTypeException_1 = __importDefault(require("../Exceptions/WrongArgumentTypeException"));
9
- const AutoPreload = (superclass) => {
1
+ import WrongRelationshipTypeException from '../exceptions/wrong_relationship_type_exception.js';
2
+ import WrongArgumentTypeException from '../exceptions/wrong_argument_type_exception.js';
3
+ export const AutoPreload = (superclass) => {
10
4
  class AutoPreloadModel extends superclass {
11
5
  static $with = [];
12
6
  static $originalWith = [];
@@ -19,7 +13,7 @@ const AutoPreload = (superclass) => {
19
13
  return !['function', 'string'].includes(typeof relationship);
20
14
  });
21
15
  if (isWrongType) {
22
- throw WrongRelationshipTypeException_1.default.invoke(this.name);
16
+ throw WrongRelationshipTypeException.invoke(this.name);
23
17
  }
24
18
  }
25
19
  super.boot();
@@ -43,7 +37,7 @@ const AutoPreload = (superclass) => {
43
37
  return relationship;
44
38
  }
45
39
  else {
46
- throw WrongArgumentTypeException_1.default.invoke(relationship);
40
+ throw WrongArgumentTypeException.invoke(relationship);
47
41
  }
48
42
  });
49
43
  return this;
@@ -58,7 +52,7 @@ const AutoPreload = (superclass) => {
58
52
  return relationship;
59
53
  }
60
54
  else {
61
- throw WrongArgumentTypeException_1.default.invoke(relationship);
55
+ throw WrongArgumentTypeException.invoke(relationship);
62
56
  }
63
57
  });
64
58
  return this;
@@ -109,11 +103,10 @@ const AutoPreload = (superclass) => {
109
103
  return !['function', 'string'].includes(typeof relationship);
110
104
  });
111
105
  if (isWrongType) {
112
- throw WrongArgumentTypeException_1.default.invoke(method);
106
+ throw WrongArgumentTypeException.invoke(method);
113
107
  }
114
108
  }
115
109
  }
116
110
  }
117
111
  return AutoPreloadModel;
118
112
  };
119
- exports.AutoPreload = AutoPreload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codenameryuu/adonis-lucid-auto-preload",
3
- "version": "1.2.6",
3
+ "version": "1.5.0",
4
4
  "description": "Auto-preload multiple relationships when retrieving Lucid models on Adonis JS 7",
5
5
  "author": "codenameryuu",
6
6
  "license": "MIT",
@@ -12,23 +12,28 @@
12
12
  "engines": {
13
13
  "node": ">=24.0.0"
14
14
  },
15
- "keywords": [
16
- "adonis",
17
- "adonisjs",
18
- "auto-preload"
15
+ "type": "module",
16
+ "files": [
17
+ "build",
18
+ "!build/bin",
19
+ "!build/tests"
19
20
  ],
21
+ "exports": {
22
+ ".": "./build/index.js",
23
+ "./adonis-typings": "./build/adonis-typings/*.js",
24
+ "./exceptions": "./build/exceptions/*.js",
25
+ "./providers": "./build/providers/auto_preload_provider.js"
26
+ },
20
27
  "scripts": {
21
- "dev": "node ace serve --watch",
22
- "build": "npm run clean && tsc",
23
- "start": "node server.js",
28
+ "clean": "del-cli build",
29
+ "typecheck": "tsc --noEmit",
24
30
  "lint": "eslint . --ext=.ts",
25
31
  "format": "prettier --write .",
26
- "pretest": "npm run lint",
27
- "test": "node -r @adonisjs/require-ts/build/register bin",
28
- "clean": "del-cli build",
29
- "copyfiles": "copyfiles \"templates/**/*.txt\" \"instructions.md\" build",
30
- "compile": "npm run lint && npm run clean && tsc && npm run copyfiles",
31
- "commit": "git-cz"
32
+ "prebuild": "npm run lint && npm run clean",
33
+ "build": "npm run clean && tsc",
34
+ "release": "release-it",
35
+ "version": "npm run build",
36
+ "prepublishOnly": "npm run build"
32
37
  },
33
38
  "devDependencies": {
34
39
  "@adonisjs/assembler": "^7.7.0",
@@ -41,64 +46,49 @@
41
46
  "@japa/expect": "^3.0.7",
42
47
  "@japa/expect-type": "^2.0.4",
43
48
  "@japa/file-system": "^3.0.0",
44
- "@japa/run-failed-tests": "^1.1.1",
45
49
  "@japa/runner": "^5.3.0",
46
50
  "@japa/snapshot": "^2.0.5",
47
51
  "@japa/spec-reporter": "^1.3.3",
48
52
  "@poppinss/dev-utils": "^2.0.3",
49
53
  "@types/node": "^25.5.0",
54
+ "c8": "^9.1.0",
50
55
  "copyfiles": "^2.4.1",
51
56
  "del-cli": "^5.0.0",
52
57
  "eslint": "^10.0.2",
53
58
  "prettier": "^3.8.1",
54
- "sqlite3": "^5.0.11",
59
+ "reflect-metadata": "^0.2.2",
60
+ "tsup": "^8.5.1",
55
61
  "typescript": "^5.3.3",
56
62
  "youch": "^4.1.0"
57
63
  },
58
- "dependencies": {
59
- "reflect-metadata": "^0.2.2"
60
- },
61
64
  "peerDependencies": {
62
65
  "@adonisjs/core": "^7.0.0",
63
66
  "@adonisjs/lucid": "^22.0.0"
64
67
  },
65
- "eslintConfig": {
66
- "extends": "@adonisjs/eslint-config/package"
67
- },
68
- "eslintIgnore": [
69
- "build"
68
+ "keywords": [
69
+ "adonis",
70
+ "adonisjs",
71
+ "auto-preload"
70
72
  ],
71
73
  "prettier": "@adonisjs/prettier-config",
72
74
  "publishConfig": {
73
75
  "tag": "latest",
74
76
  "access": "public"
75
77
  },
76
- "main": "./build/providers/AutoPreloadProvider.js",
77
- "types": "./build/adonis-typings/index.d.ts",
78
- "files": [
79
- "build/adonis-typings",
80
- "build/providers",
81
- "build/src",
82
- "build/configure.js",
83
- "build/configure.d.ts",
84
- "build/instructions.md"
85
- ],
86
- "exports": {
87
- ".": {
88
- "types": "./build/adonis-typings/index.d.ts",
89
- "default": "./build/providers/AutoPreloadProvider.js"
90
- },
91
- "./mixins": {
92
- "types": "./build/src/Mixins/AutoPreload.d.ts",
93
- "default": "./build/src/Mixins/AutoPreload.js"
94
- },
95
- "./provider": {
96
- "types": "./build/providers/AutoPreloadProvider.d.ts",
97
- "default": "./build/providers/AutoPreloadProvider.js"
98
- },
99
- "./configure": {
100
- "types": "./build/configure.d.ts",
101
- "default": "./build/configure.js"
102
- }
78
+ "np": {
79
+ "message": "chore(release): %s",
80
+ "tag": "latest",
81
+ "branch": "main",
82
+ "anyBranch": false
83
+ },
84
+ "c8": {
85
+ "reporter": [
86
+ "text",
87
+ "html"
88
+ ],
89
+ "exclude": [
90
+ "tests/**",
91
+ "bin/**"
92
+ ]
103
93
  }
104
94
  }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const AutoPreload_1 = require("../src/Mixins/AutoPreload");
4
- class AutoPreloadProvider {
5
- app;
6
- static needsApplication = true;
7
- constructor(app) {
8
- this.app = app;
9
- }
10
- register() {
11
- this.app.container.singleton("@codenameryuu/adonis-lucid-auto-preload", () => {
12
- return { AutoPreload: AutoPreload_1.AutoPreload };
13
- });
14
- }
15
- async boot() { }
16
- async ready() { }
17
- async shutdown() { }
18
- }
19
- exports.default = AutoPreloadProvider;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const exceptions_1 = require("@adonisjs/core/exceptions");
4
- class WrongArgumentTypeException extends exceptions_1.Exception {
5
- static invoke(method) {
6
- return new this(`The method ${method} accepts only an array of strings`);
7
- }
8
- }
9
- exports.default = WrongArgumentTypeException;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const exceptions_1 = require("@adonisjs/core/exceptions");
4
- class WrongRelationshipTypeException extends exceptions_1.Exception {
5
- static invoke(model) {
6
- return new this(`The model "${model}" has wrong relationships to be auto-preloaded. Only string and function types are allowed`);
7
- }
8
- }
9
- exports.default = WrongRelationshipTypeException;