Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.27.2

- `APICronStoreDB.buildRepositories` returns `List<DBSQLEntityRepository>`
(was `List<EntityRepository<Object>>`): it can be added to a provider's
list of `DBSQLEntityRepository` with no cast, and still to a list of
`EntityRepository` (lists are covariant).

## 1.27.1

- Cron time zones: the full `timezone` database is used
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bones_api_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef APILogger =
/// Bones API Library class.
class BonesAPI {
// ignore: constant_identifier_names
static const String VERSION = '1.27.1';
static const String VERSION = '1.27.2';

static bool _boot = false;

Expand Down
31 changes: 17 additions & 14 deletions lib/src/bones_api_cron_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -516,20 +516,23 @@ class APICronStoreDB extends APICronStore {

/// The repositories of the cron tables for [adapter], to be returned by
/// [DBRelationalEntityRepositoryProvider.buildRepositories].
static List<EntityRepository<Object>> buildRepositories(
DBSQLAdapter adapter,
) => [
DBSQLEntityRepository<APICronJobRun>(
adapter,
runsTable,
apiCronJobRunEntityHandler,
),
DBSQLEntityRepository<APICronJobLock>(
adapter,
locksTable,
apiCronJobLockEntityHandler,
),
];
///
/// A `List<DBSQLEntityRepository>`: it can be added to a list of
/// [DBSQLEntityRepository] or of [EntityRepository] (the list is
/// covariant), with no cast.
static List<DBSQLEntityRepository> buildRepositories(DBSQLAdapter adapter) =>
[
DBSQLEntityRepository<APICronJobRun>(
adapter,
runsTable,
apiCronJobRunEntityHandler,
),
DBSQLEntityRepository<APICronJobLock>(
adapter,
locksTable,
apiCronJobLockEntityHandler,
),
];

/// An [APICronStoreDB] with the repositories of the cron entities known by
/// the entity handlers (registered with [buildRepositories]), or `null`.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bones_api
description: Bones_API - A powerful API backend framework for Dart. It comes with a built-in HTTP Server, route handler, entity handler, SQL translator, and DB adapters.
version: 1.27.1
version: 1.27.2
homepage: https://github.com/Colossus-Services/bones_api

environment:
Expand Down
13 changes: 12 additions & 1 deletion test/bones_api_cron_db_tests_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class CronDBProvider
@override
FutureOr<DBSQLAdapter> buildAdapter() => adapterCreator(this);

List<EntityRepository<Object>>? _repositories;
/// SQL repositories (no cast: see [APICronStoreDB.buildRepositories]),
/// returned as the generic list of the override.
List<DBSQLEntityRepository>? _repositories;

@override
List<EntityRepository<Object>> buildRepositories(DBAdapter adapter) =>
Expand Down Expand Up @@ -117,6 +119,15 @@ void runCronStoreDBTests(
// Each test with its own job names (the tables are shared):
setUp(() => job = 'job${++jobCount}');

test('buildRepositories: the SQL repositories of the cron tables', () {
var repositories = provider._repositories!;
expect(repositories.map((r) => r.tableName), [
APICronStoreDB.runsTable,
APICronStoreDB.locksTable,
]);
expect(repositories.map((r) => r.type), [APICronJobRun, APICronJobLock]);
});

test('tryResolve: the registered repositories', () async {
var resolved = APICronStoreDB.tryResolve()!;
var t = _utc(2026, 10, 18, 10);
Expand Down
11 changes: 11 additions & 0 deletions test/bones_api_cron_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,17 @@ void main() {
expect(APICronStoreDB.tryResolve(), isNull);
});

test('APICronStoreDB.buildRepositories: SQL repositories, no cast', () {
// Both kinds of provider lists, with no cast (checked by the compiler):
List<DBSQLEntityRepository> Function(DBSQLAdapter) sql =
APICronStoreDB.buildRepositories;
List<EntityRepository<Object>> Function(DBSQLAdapter) generic =
APICronStoreDB.buildRepositories;
expect(sql, same(generic));
// No repository built here: it would register the cron entities for
// the other tests (see `bones_api_cron_db_tests_base.dart`).
});

test('APIAuthentication.system', () {
var auth = APIAuthentication.system('cron:x');
expect(auth.isSystem, isTrue);
Expand Down
Loading