@holoyan/adonisjs-permissions 2.0.0-beta.1 → 2.0.1

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/README.md CHANGED
@@ -1,4 +1,9 @@
1
- # Role permissions system for AdonisJS V6+
1
+ # Role permissions system for AdonisJS
2
+
3
+ | Package version | AdonisJS version |
4
+ |----------------|-----------------|
5
+ | v1.x | v6 |
6
+ | v2.x | v7 |
2
7
 
3
8
  Checkout other AdonisJS packages
4
9
 
@@ -14,8 +19,11 @@ Checkout other AdonisJS packages
14
19
 
15
20
  ## Release Notes
16
21
 
17
- Version: >= v1.3.1
18
- * Added [canPartially](#checking-partial-permissions) method
22
+ Version: v2.0.0
23
+ * Added support for AdonisJS v7
24
+
25
+ Version: >= v1.3.2
26
+ * Fixed `permissionQueryHelpers()` mixin leaking internal relations (`_roles`, `_permissions`, `_model_roles`) into the public `related()` API, which caused incorrect IDE type inference on user-defined relations
19
27
 
20
28
  ## Table of Contents
21
29
 
@@ -89,9 +97,15 @@ await user.allow('delete', post)
89
97
  To be able to use the full power of Acl, you should have a clear understanding of how it is structured and how it works. That's why the documentation will be divided into two parts: [Basic usage](#basic-usage) and [Advanced usage](#digging-deeper). For most applications, Basic Usage will be enough.
90
98
 
91
99
  ## Installation
92
-
100
+
101
+ For AdonisJS v7 (latest):
102
+
93
103
  npm i @holoyan/adonisjs-permissions
94
104
 
105
+ For AdonisJS v6:
106
+
107
+ npm i @holoyan/adonisjs-permissions@v1-latest
108
+
95
109
 
96
110
  Next publish config files
97
111
 
@@ -1364,8 +1378,6 @@ await Acl.permission(myPermission).detachFromRole(role_slug)
1364
1378
  |------------------------|-----------------|
1365
1379
  | v20.x | 0.10.x |
1366
1380
  | v21.x | 1.x |
1367
- | v22.x | 2.x |
1368
-
1369
1381
 
1370
1382
 
1371
1383
 
@@ -1,10 +1,8 @@
1
1
  import type { NormalizeConstructor } from '@adonisjs/core/types/helpers';
2
2
  import { BaseModel } from '@adonisjs/lucid/orm';
3
3
  import { AclModel, ModelIdType } from '../types.js';
4
- import type { ManyToMany, HasMany } from '@adonisjs/lucid/types/relations';
5
4
  import Role from '../models/role.js';
6
5
  import { LucidModel, LucidRow, ModelQueryBuilderContract } from '@adonisjs/lucid/types/model';
7
- import { ModelRole, Permission } from '../../index.js';
8
6
  import ModelPermission from '../models/model_permission.js';
9
7
  export declare function hasPermissions(): <Model extends NormalizeConstructor<typeof BaseModel>>(superclass: Model) => {
10
8
  new (...args: any[]): {
@@ -362,11 +360,11 @@ export declare function hasPermissions(): <Model extends NormalizeConstructor<ty
362
360
  } & Model;
363
361
  export declare function permissionQueryHelpers(): <Model extends NormalizeConstructor<typeof BaseModel>>(superclass: Model) => {
364
362
  new (...args: any[]): {
365
- _roles: ManyToMany<typeof Role>;
363
+ _roles: undefined;
366
364
  _whereRoles<TargetClass extends Model>(query: ModelQueryBuilderContract<LucidModel, LucidRow>, targetClass: TargetClass, ...roles: string[]): ModelQueryBuilderContract<LucidModel, LucidRow>;
367
- _permissions: ManyToMany<typeof Permission>;
365
+ _permissions: undefined;
368
366
  _whereDirectPermissions<TargetClass extends Model>(query: ModelQueryBuilderContract<LucidModel, LucidRow>, targetClass: TargetClass, permissions: string[], target?: AclModel | Function): ModelQueryBuilderContract<LucidModel, LucidRow>;
369
- _model_roles: HasMany<typeof ModelRole>;
367
+ _model_roles: undefined;
370
368
  _whereRolePermissions<TargetClass extends Model>(query: ModelQueryBuilderContract<LucidModel, LucidRow>, targetClass: TargetClass, permissions: string[], target?: AclModel | Function): ModelQueryBuilderContract<LucidModel, LucidRow>;
371
369
  _wherePermissions<TargetClass extends Model>(query: ModelQueryBuilderContract<LucidModel, LucidRow>, targetClass: TargetClass, permissions: string[], target?: AclModel | Function): void;
372
370
  $attributes: import("@adonisjs/lucid/types/model").ModelObject;
@@ -401,7 +399,7 @@ export declare function permissionQueryHelpers(): <Model extends NormalizeConstr
401
399
  $hydrateOriginals(): void;
402
400
  fill(value: Partial<import("@adonisjs/lucid/types/model").ModelAttributes</*elided*/ any>>, allowExtraProperties?: boolean): /*elided*/ any;
403
401
  merge(value: Partial<import("@adonisjs/lucid/types/model").ModelAttributes</*elided*/ any>>, allowExtraProperties?: boolean): /*elided*/ any;
404
- isDirty(fields?: undefined[] | undefined): boolean;
402
+ isDirty(fields?: "_roles" | "_permissions" | "_model_roles" | ("_roles" | "_permissions" | "_model_roles" | undefined)[] | undefined): boolean;
405
403
  enableForceUpdate(): /*elided*/ any;
406
404
  save(): Promise</*elided*/ any>;
407
405
  saveQuietly(): Promise</*elided*/ any>;
@@ -425,7 +423,7 @@ export declare function permissionQueryHelpers(): <Model extends NormalizeConstr
425
423
  toObject(): import("@adonisjs/lucid/types/model").ModelObject;
426
424
  toJSON(): import("@adonisjs/lucid/types/model").ModelObject;
427
425
  toAttributes(): Record<string, any>;
428
- related<Name_2 extends import("@adonisjs/lucid/types/relations").ExtractModelRelations</*elided*/ any>>(relation: Name_2): NonNullable</*elided*/ any[Name_2]> extends import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> ? (import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> & /*elided*/ any[Name_2] & {})["client"] : never;
426
+ related<Name_2 extends undefined>(relation: Name_2): NonNullable</*elided*/ any[Name_2]> extends import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> ? (import("@adonisjs/lucid/types/relations").ModelRelations<LucidModel, LucidModel> & /*elided*/ any[Name_2] & {})["client"] : never;
429
427
  };
430
428
  connection?: string | undefined;
431
429
  after: {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@holoyan/adonisjs-permissions",
3
3
  "description": "AdonisJs roles and permissions system",
4
- "version": "2.0.0-beta.1",
4
+ "version": "2.0.1",
5
5
  "engines": {
6
- "node": ">=24.0.0"
6
+ "node": ">=18.16.0"
7
7
  },
8
8
  "type": "module",
9
9
  "files": [
@@ -41,12 +41,12 @@
41
41
  "author": "holoyan",
42
42
  "license": "MIT",
43
43
  "devDependencies": {
44
- "@adonisjs/assembler": "^8.0.0-next.0",
45
- "@adonisjs/core": "^7.0.0-next.0",
44
+ "@adonisjs/assembler": "^8.0.1",
45
+ "@adonisjs/core": "^7.0.1",
46
46
  "@adonisjs/eslint-config": "^1.2.1",
47
- "@adonisjs/lucid": "^22.0.0-next.0",
47
+ "@adonisjs/lucid": "^22.1.1",
48
48
  "@adonisjs/prettier-config": "^1.2.1",
49
- "@adonisjs/tsconfig": "^2.0.0-next.3",
49
+ "@adonisjs/tsconfig": "^2.0.0",
50
50
  "@japa/assert": "^4.2.0",
51
51
  "@japa/runner": "^5.3.0",
52
52
  "@swc/core": "^1.3.102",
@@ -71,20 +71,20 @@
71
71
  "uuid": "^10.0.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "@adonisjs/core": "^7.0.0-next.0",
75
- "@adonisjs/lucid": "^22.0.0-next.0",
74
+ "@adonisjs/core": "^7.0.1",
75
+ "@adonisjs/lucid": "^22.1.1",
76
76
  "@types/uuid": "^10.0.0",
77
- "luxon": "^3.4.4",
77
+ "luxon": "^3.7.2",
78
78
  "uuid": "^10.0.0"
79
79
  },
80
80
  "publishConfig": {
81
81
  "access": "public",
82
- "tag": "beta"
82
+ "tag": "latest"
83
83
  },
84
84
  "np": {
85
85
  "message": "chore(release): %s",
86
- "tag": "beta",
87
- "branch": "2.0.0-beta.1",
86
+ "tag": "latest",
87
+ "branch": "master",
88
88
  "anyBranch": false
89
89
  },
90
90
  "c8": {
@@ -101,7 +101,7 @@
101
101
  },
102
102
  "prettier": "@adonisjs/prettier-config",
103
103
  "dependencies": {
104
- "@holoyan/morph-map-js": "^0.1.2",
104
+ "@holoyan/morph-map-js": "^0.1.1",
105
105
  "@poppinss/hooks": "7.3.0"
106
106
  }
107
107
  }