add: adding contracts to project
This commit is contained in:
parent
c79a572a06
commit
c900303ee8
19 changed files with 64 additions and 29 deletions
0
packages/contracts/example/.gitkeep
Normal file
0
packages/contracts/example/.gitkeep
Normal file
|
@ -1,6 +0,0 @@
|
|||
import 'package:fabric_contracts/fabric_contracts.dart';
|
||||
|
||||
void main() {
|
||||
var awesome = Awesome();
|
||||
print('awesome: ${awesome.isAwesome}');
|
||||
}
|
|
@ -3,6 +3,6 @@
|
|||
/// More dartdocs go here.
|
||||
library;
|
||||
|
||||
export 'src/fabric_contracts_base.dart';
|
||||
// export 'src/fabric_contracts_base.dart';
|
||||
|
||||
// TODO: Export any libraries intended for clients of this package.
|
9
packages/contracts/lib/src/auth/access/authorizable.dart
Normal file
9
packages/contracts/lib/src/auth/access/authorizable.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
abstract class Authorizable {
|
||||
/// Determine if the entity has a given ability.
|
||||
///
|
||||
/// [abilities] can be an Iterable or a String.
|
||||
/// [arguments] can be a List or a dynamic type.
|
||||
///
|
||||
/// Returns a boolean indicating if the entity has the given ability.
|
||||
bool can(dynamic abilities, [List<dynamic> arguments = const []]);
|
||||
}
|
51
packages/contracts/lib/src/auth/access/gate.dart
Normal file
51
packages/contracts/lib/src/auth/access/gate.dart
Normal file
|
@ -0,0 +1,51 @@
|
|||
// import 'package:meta/meta.dart';
|
||||
|
||||
abstract class Gate {
|
||||
/// Determine if a given ability has been defined.
|
||||
bool has(String ability);
|
||||
|
||||
/// Define a new ability.
|
||||
Gate define(String ability, dynamic callback);
|
||||
|
||||
/// Define abilities for a resource.
|
||||
Gate resource(String name, String className, [List<String>? abilities]);
|
||||
|
||||
/// Define a policy class for a given class type.
|
||||
Gate policy(String className, String policy);
|
||||
|
||||
/// Register a callback to run before all Gate checks.
|
||||
Gate before(Function callback);
|
||||
|
||||
/// Register a callback to run after all Gate checks.
|
||||
Gate after(Function callback);
|
||||
|
||||
/// Determine if all of the given abilities should be granted for the current user.
|
||||
bool allows(dynamic ability, [dynamic arguments]);
|
||||
|
||||
/// Determine if any of the given abilities should be denied for the current user.
|
||||
bool denies(dynamic ability, [dynamic arguments]);
|
||||
|
||||
/// Determine if all of the given abilities should be granted for the current user.
|
||||
bool check(dynamic abilities, [dynamic arguments]);
|
||||
|
||||
/// Determine if any one of the given abilities should be granted for the current user.
|
||||
bool any(dynamic abilities, [dynamic arguments]);
|
||||
|
||||
/// Determine if the given ability should be granted for the current user.
|
||||
dynamic authorize(String ability, [dynamic arguments]);
|
||||
|
||||
/// Inspect the user for the given ability.
|
||||
dynamic inspect(String ability, [dynamic arguments]);
|
||||
|
||||
/// Get the raw result from the authorization callback.
|
||||
dynamic raw(String ability, [dynamic arguments]);
|
||||
|
||||
/// Get a policy instance for a given class.
|
||||
dynamic getPolicyFor(dynamic className);
|
||||
|
||||
/// Get a guard instance for the given user.
|
||||
Gate forUser(dynamic user);
|
||||
|
||||
/// Get all of the defined abilities.
|
||||
List<String> abilities();
|
||||
}
|
0
packages/contracts/lib/src/auth/authenticatable.dart
Normal file
0
packages/contracts/lib/src/auth/authenticatable.dart
Normal file
0
packages/contracts/lib/src/auth/can_reset_password.dart
Normal file
0
packages/contracts/lib/src/auth/can_reset_password.dart
Normal file
0
packages/contracts/lib/src/auth/factory.dart
Normal file
0
packages/contracts/lib/src/auth/factory.dart
Normal file
0
packages/contracts/lib/src/auth/guard.dart
Normal file
0
packages/contracts/lib/src/auth/guard.dart
Normal file
|
@ -0,0 +1,3 @@
|
|||
abstract class AuthenticatesRequests {
|
||||
// Define abstract methods or properties if needed
|
||||
}
|
0
packages/contracts/lib/src/auth/must_verify_email.dart
Normal file
0
packages/contracts/lib/src/auth/must_verify_email.dart
Normal file
0
packages/contracts/lib/src/auth/password_broker.dart
Normal file
0
packages/contracts/lib/src/auth/password_broker.dart
Normal file
0
packages/contracts/lib/src/auth/stateful_guard.dart
Normal file
0
packages/contracts/lib/src/auth/stateful_guard.dart
Normal file
0
packages/contracts/lib/src/auth/supports_basic_auth.dart
Normal file
0
packages/contracts/lib/src/auth/supports_basic_auth.dart
Normal file
0
packages/contracts/lib/src/auth/user_provider.dart
Normal file
0
packages/contracts/lib/src/auth/user_provider.dart
Normal file
|
@ -1,6 +0,0 @@
|
|||
// TODO: Put public facing types in this file.
|
||||
|
||||
/// Checks if you are awesome. Spoiler: you are.
|
||||
class Awesome {
|
||||
bool get isAwesome => true;
|
||||
}
|
0
packages/contracts/test/.gitkeep
Normal file
0
packages/contracts/test/.gitkeep
Normal file
|
@ -1,16 +0,0 @@
|
|||
import 'package:fabric_contracts/fabric_contracts.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('A group of tests', () {
|
||||
final awesome = Awesome();
|
||||
|
||||
setUp(() {
|
||||
// Additional setup goes here.
|
||||
});
|
||||
|
||||
test('First Test', () {
|
||||
expect(awesome.isAwesome, isTrue);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue