@anu8151/adonisjs-blueprint 0.5.2 → 0.5.4
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.
|
@@ -16,12 +16,16 @@ var PolicyGenerator = class extends BaseGenerator {
|
|
|
16
16
|
actions.push({
|
|
17
17
|
name: policyAction,
|
|
18
18
|
modelName: entity.className,
|
|
19
|
-
variableName: string.camelCase(entity.className)
|
|
19
|
+
variableName: string.camelCase(entity.className || "")
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
+
const actionLines = actions.map((action) => {
|
|
23
|
+
return `${action.name}(user: User, ${action.variableName}: ${action.modelName}): AuthorizerResponse {\n return true\n }`;
|
|
24
|
+
}).join("\n\n ");
|
|
22
25
|
await this.generateStub("make/policy/main.stub", {
|
|
23
26
|
entity,
|
|
24
|
-
actions
|
|
27
|
+
actions,
|
|
28
|
+
actionLines
|
|
25
29
|
});
|
|
26
30
|
}
|
|
27
31
|
};
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
{{{
|
|
2
2
|
exports({
|
|
3
|
-
to: app.makePath('app/policies', entity.path, string.snakeCase(entity.name) + '_policy.ts')
|
|
3
|
+
to: app.makePath('app/policies', entity.path, string.snakeCase(entity.name || '') + '_policy.ts')
|
|
4
4
|
})
|
|
5
5
|
}}}
|
|
6
6
|
import User from '#models/user'
|
|
7
|
-
import {{ entity.className }} from '#models/{{ string.snakeCase(entity.name) }}'
|
|
7
|
+
import {{ entity.className }} from '#models/{{ string.snakeCase(entity.name || '') }}'
|
|
8
8
|
import { BasePolicy } from '@adonisjs/bouncer'
|
|
9
9
|
import { AuthorizerResponse } from '@adonisjs/bouncer/types'
|
|
10
10
|
|
|
11
11
|
export default class {{ entity.className }}Policy extends BasePolicy {
|
|
12
|
-
|
|
13
|
-
{{ action.name }}(user: User, {{ action.variableName }}: {{ action.modelName }}): AuthorizerResponse {
|
|
14
|
-
return true
|
|
15
|
-
}
|
|
16
|
-
@end
|
|
12
|
+
{{{ actionLines }}}
|
|
17
13
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
{{{
|
|
2
2
|
exports({
|
|
3
|
-
to: app.makePath('app/policies', entity.path, string.snakeCase(entity.name) + '_policy.ts')
|
|
3
|
+
to: app.makePath('app/policies', entity.path, string.snakeCase(entity.name || '') + '_policy.ts')
|
|
4
4
|
})
|
|
5
5
|
}}}
|
|
6
6
|
import User from '#models/user'
|
|
7
|
-
import {{ entity.className }} from '#models/{{ string.snakeCase(entity.name) }}'
|
|
7
|
+
import {{ entity.className }} from '#models/{{ string.snakeCase(entity.name || '') }}'
|
|
8
8
|
import { BasePolicy } from '@adonisjs/bouncer'
|
|
9
9
|
import { AuthorizerResponse } from '@adonisjs/bouncer/types'
|
|
10
10
|
|
|
11
11
|
export default class {{ entity.className }}Policy extends BasePolicy {
|
|
12
|
-
|
|
13
|
-
{{ action.name }}(user: User, {{ action.variableName }}: {{ action.modelName }}): AuthorizerResponse {
|
|
14
|
-
return true
|
|
15
|
-
}
|
|
16
|
-
@end
|
|
12
|
+
{{{ actionLines }}}
|
|
17
13
|
}
|