Skip to content

Commit 475df43

Browse files
authored
doc: publish packages and finish changelog documentation (#511)
1 parent 707cd83 commit 475df43

File tree

57 files changed

+410
-251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+410
-251
lines changed

MIGRATING.md

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,59 @@
11
# Migrating Between Major Versions
22

3-
## Migrating from Brick 3 to Brick 4
3+
In preparation for Brick 4, `Query` is migrating away from loosely-defined arguments in favor of standardized fields that can be easily deprecated and discovered by analysis.
44

5-
Brick 4 away from loosely-defined `Query` arguments in favor of standardized fields that can be easily deprecated and discovered by analysis.
5+
**`providerArgs` will be supported until Brick 4 is officially released**.
66

7-
### Breaking Changes
7+
It is still recommended you migrate to the new `Query` for new features and long-term support.
88

9-
**`providerArgs` will be supported until Brick 4 is officially released**. It is still recommended you migrate to the new `Query` for better `orderBy` and `limitBy`.
9+
## Improvements
1010

11-
- `Query(providerArgs: {'limit':})` is now `Query(limit:)`
12-
- `Query(providerArgs: {'offset':})` is now `Query(offset:)`
13-
- `Query(providerArgs: {'orderBy':})` is now `Query(orderBy:)`. This is a more significant change than `limit` or `offset`. `orderBy` is now defined by a class that permits multiple commands. For example, `'orderBy': 'name ASC'` becomes `[OrderBy('name', ascending: true)]`. First-class Brick providers (SQLite and Supabase) also support association-based querying by declaring a `model:`.
11+
- `Query#orderBy` will support association ordering and multiple values
12+
- `Query` is constructed with `const`
13+
- `Query#offset` no longer requires companion `limit` parameter
14+
- `brick_sqlite` and `brick_supabase` support association ordering. For example, `Query(orderBy: [OrderBy.desc('assoc', associationField: 'name')])` on `DemoModel` will produce the following SQL statement:
15+
```sql
16+
'SELECT DISTINCT `DemoModel`.* FROM `DemoModel` ORDER BY `DemoModelAssoc`.name DESC'
17+
```
18+
- `brick_supabase` supports advanced limiting. For example, `Query(limitBy: [LimitBy(1, evaluatedField: 'assoc'))` is the equivalent of `.limit(1, referencedTable: 'demo_model')`
1419

15-
#### brick_graphql
20+
## Universal Deprecations
1621

17-
- `Query(providerArgs: {'context':})` is now `Query(forProviders: [GraphqlProviderQuery(context:)])`
18-
- `Query(providerArgs: {'operation':})` is now `Query(forProviders: [GraphqlProviderQuery(operation:)])`
22+
| Old | New | Notes |
23+
| ----------------------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
24+
| `Query(providerArgs: {'limit':})` | `Query(limit:)` | `limit` and `limitBy` may be used together, however, `limitBy` will only limit `evaluatedField:` associations |
25+
| `Query(providerArgs: {'offset':})` | `Query(offset:)` | |
26+
| `Query(providerArgs: {'orderBy':})` | `Query(orderBy:)` | `orderBy` is now defined by a class that permits multiple commands. For example, `'orderBy': 'name ASC'` becomes `[OrderBy('name', ascending: true)]`. First-class Brick providers (SQLite and Supabase) also support association-based querying by declaring a `associationField:`. This `associationField` is optional in Supabase but required for `SQLite`. |
1927

20-
#### brick_rest
28+
## Package-specific deprecations
2129

22-
- `Query(providerArgs: {'request':})` is now `Query(forProviders: [RestProviderQuery(request:)])`. This is a similarly significant chang that allows providers to be detected by static analysis and reduces the need for manual documentation.
30+
### brick_graphql
2331

24-
#### brick_sqlite
32+
| Old | New | Notes |
33+
| ------------------------------------- | --------------------------------------------------------- | ----- |
34+
| `Query(providerArgs: {'context':})` | `Query(forProviders: [GraphqlProviderQuery(context:)])` |
35+
| `Query(providerArgs: {'operation':})` | `Query(forProviders: [GraphqlProviderQuery(operation:)])` |
2536

26-
- `Query(providerArgs: {'collate':})` is now `Query(forProviders: [SqliteProviderQuery(collate:)])`
27-
- `Query(providerArgs: {'having':})` is now `Query(forProviders: [SqliteProviderQuery(having:)])`
28-
- `Query(providerArgs: {'groupBy':})` is now `Query(forProviders: [SqliteProviderQuery(groupBy:)])`
37+
### brick_rest
2938

30-
#### brick_supabase
39+
| Old | New | Notes |
40+
| ----------------------------------- | ---------------------------------------------------- | ----- |
41+
| `Query(providerArgs: {'request':})` | `Query(forProviders: [RestProviderQuery(request:)])` | |
3142

32-
- `Query(providerArgs: {'limitReferencedTable':})` has been removed in favor of `Query(limitBy:)`
33-
- `Query(providerArgs: {'orderByReferencedTable':})` has been removed in favor of `Query(orderBy:)`
43+
### brick_sqlite
3444

35-
### Improvements
45+
| Old | New | Notes |
46+
| ----------------------------------- | ------------------------------------------------------ | ----- |
47+
| `Query(providerArgs: {'collate':})` | `Query(forProviders: [SqliteProviderQuery(collate:)])` |
48+
| `Query(providerArgs: {'having':})` | `Query(forProviders: [SqliteProviderQuery(having:)])` |
49+
| `Query(providerArgs: {'groupBy':})` | `Query(forProviders: [SqliteProviderQuery(groupBy:)])` |
3650

37-
- `OrderBy` will support association ordering and multiple values
38-
- `Query` is constructed with `const`
39-
- `Query#offset` no longer requires companion `limit` parameter
40-
- `brick_sqlite` and `brick_supabase` support association ordering. For example, `Query(orderBy: [OrderBy.desc('name', model: DemoModelAssoc)])` on `DemoModel` will produce the following SQL statement:
41-
```sql
42-
'SELECT DISTINCT `DemoModel`.* FROM `DemoModel` ORDER BY `DemoModelAssoc`.name DESC'
43-
```
44-
- `brick_supabase` supports advanced limiting. For example, `Query(limitBy: [LimitBy(1, model: DemoModel))` is the equivalent of `.limit(1, referencedTable: 'demo_model')`
51+
### brick_supabase
52+
53+
| Old | New | Notes |
54+
| -------------------------------------------------- | --- | ------------------------------------- |
55+
| `Query(providerArgs: {'limitReferencedTable':})` | | Removed in favor of `Query(limitBy:)` |
56+
| `Query(providerArgs: {'orderByReferencedTable':})` | | Removed in favor of `Query(orderBy:)` |
4557

4658
## Migrating from Brick 2 to Brick 3
4759

packages/brick_build/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
## Unreleased
22

3+
## 3.3.0
4+
35
- Add documentation to increase pub.dev score
6+
- Update minimum `brick_core` to `1.3.0`
7+
- Update analysis to modern lints
48

59
## 3.2.1
610

packages/brick_build/lib/src/builders/adapter_builder.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:brick_build/src/utils/string_helpers.dart';
33
import 'package:build/build.dart';
44

55
/// Writes adapter code (model serialization/deserialization).
6-
/// Outputs to brick/adapters/<MODEL>_adapter.g.dart
6+
/// Outputs to brick/adapters/{MODEL}_adapter.g.dart
77
class AdapterBuilder<_ClassAnnotation> extends BaseBuilder<_ClassAnnotation> {
88
///
99
final AnnotationSuperGenerator generator;
@@ -12,7 +12,7 @@ class AdapterBuilder<_ClassAnnotation> extends BaseBuilder<_ClassAnnotation> {
1212
final outputExtension = '.adapter_builder.dart';
1313

1414
/// Writes adapter code (model serialization/deserialization).
15-
/// Outputs to brick/adapters/<MODEL>_adapter.g.dart
15+
/// Outputs to brick/adapters/{MODEL}_adapter.g.dart
1616
AdapterBuilder(this.generator);
1717

1818
@override

packages/brick_build/pubspec.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ homepage: https://github.com/GetDutchie/brick/tree/main/packages/brick_build
44
issue_tracker: https://github.com/GetDutchie/brick/issues
55
repository: https://github.com/GetDutchie/brick
66

7-
version: 3.2.1
7+
version: 3.3.0
88

99
environment:
1010
sdk: ">=2.18.0 <4.0.0"
1111

1212
dependencies:
1313
analyzer: ">=6.0.0 <7.0.0"
14-
brick_core: ^1.1.1
14+
brick_core: ^1.3.0
1515
build: ^2.3.0
1616
dart_style: ">=2.0.0 <3.0.0"
1717
glob: ">=2.1.0 <3.0.0"
@@ -23,6 +23,6 @@ dependencies:
2323
dev_dependencies:
2424
brick_build_test:
2525
path: ../brick_build_test
26-
build_verify: ^2.0.0
27-
lints: ^2.0.1
28-
test: ^1.20.1
26+
build_verify:
27+
lints:
28+
test:

packages/brick_core/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
## Unreleased
22

3+
## 1.3.1
4+
5+
- `const`antize `Where.exactly` and `OrderBy.{desc|asc}`
6+
- Add deprecation annotation to `Query#copyWith#providerArgs`
7+
8+
## 1.3.0
9+
10+
- **DEPRECATION** `Query(providerArgs: {'limit':})` is now `Query(limit:)`
11+
- **DEPRECATION** `Query(providerArgs: {'offset':})` is now `Query(offset:)`
12+
- **DEPRECATION** `Query(providerArgs: {'orderBy':})` is now `Query(orderBy:)`. `orderBy` is now defined by a class that permits multiple commands. For example, `'orderBy': 'name ASC'` becomes `[OrderBy('name', ascending: true)]`.
13+
- **DEPRECATION** `providerArgs` will be removed in the next major release
14+
- `OrderBy` will support association ordering and multiple values
15+
- `Query` is constructed with `const`
16+
- `Query#offset` no longer requires companion `limit` parameter
17+
318
## 1.2.1
419

520
- Add `FieldRename` to `FieldSerializable`
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
import 'dart:convert';
22

3-
import 'package:brick_core/src/model.dart';
4-
import 'package:brick_core/src/model_dictionary.dart';
5-
import 'package:brick_core/src/provider.dart';
3+
import 'package:brick_core/src/adapter.dart';
64

75
/// Construct directions for a provider to limit its results.
86
class LimitBy {
9-
/// The ceiling for how many results can be returned for a [model].
7+
/// The ceiling for how many results can be returned for [evaluatedField].
108
final int amount;
119

1210
/// Some providers may support limiting based on a model retrieved by the query.
13-
/// This [Model] should be accessible to the [Provider]'s [ModelDictionary].
14-
final Type model;
11+
/// This Dart field name should be accessible to the [Adapter]'s definitions
12+
/// (e.g. a `RuntimeSqliteColumnDefinition` map).
13+
final String evaluatedField;
1514

1615
/// Construct directions for a provider to limit its results.
1716
const LimitBy(
1817
this.amount, {
19-
required this.model,
18+
required this.evaluatedField,
2019
});
2120

2221
/// Construct a [LimitBy] from a JSON map.
2322
factory LimitBy.fromJson(Map<String, dynamic> json) => LimitBy(
2423
json['amount'],
25-
model: json['model'],
24+
evaluatedField: json['evaluatedField'],
2625
);
2726

2827
/// Serialize to JSON
2928
Map<String, dynamic> toJson() => {
3029
'amount': amount,
31-
'model': model,
30+
'evaluatedField': evaluatedField,
3231
};
3332

3433
@override
3534
String toString() => jsonEncode(toJson());
3635

3736
@override
3837
bool operator ==(Object other) =>
39-
identical(this, other) || other is LimitBy && amount == other.amount && model == other.model;
38+
identical(this, other) ||
39+
other is LimitBy && amount == other.amount && evaluatedField == other.evaluatedField;
4040

4141
@override
42-
int get hashCode => amount.hashCode ^ model.hashCode;
42+
int get hashCode => amount.hashCode ^ evaluatedField.hashCode;
4343
}
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import 'package:brick_core/src/model.dart';
2-
import 'package:brick_core/src/model_dictionary.dart';
31
import 'package:brick_core/src/provider.dart';
4-
import 'package:meta/meta.dart';
52

63
/// Construct directions for a provider to sort its results.
7-
@immutable
84
class OrderBy {
95
/// Defaults to `true`.
106
final bool ascending;
@@ -15,36 +11,37 @@ class OrderBy {
1511
/// and the remote source's expected name.
1612
final String evaluatedField;
1713

18-
/// Some providers may support ordering based on a model retrieved by the query.
19-
/// This [Model] should be accessible to the [Provider]'s [ModelDictionary].
20-
final Type? model;
14+
/// The Dart name of the field of the association model
15+
/// if the [evaluatedField] is an association.
16+
///
17+
/// If [evaluatedField] is not an association, this should be `null`.
18+
final String? associationField;
2119

2220
/// Construct directions for a provider to sort its results.
2321
const OrderBy(
2422
this.evaluatedField, {
2523
this.ascending = true,
26-
this.model,
24+
this.associationField,
2725
});
2826

2927
/// Sort by [ascending] order (A-Z).
30-
factory OrderBy.asc(String evaluatedField, {Type? model}) =>
31-
OrderBy(evaluatedField, model: model);
28+
const OrderBy.asc(this.evaluatedField, {this.associationField}) : ascending = true;
3229

3330
/// Sort by descending order (Z-A).
34-
factory OrderBy.desc(String evaluatedField, {Type? model}) =>
35-
OrderBy(evaluatedField, ascending: false, model: model);
31+
const OrderBy.desc(this.evaluatedField, {this.associationField}) : ascending = false;
3632

3733
/// Construct an [OrderBy] from a JSON map.
3834
factory OrderBy.fromJson(Map<String, dynamic> json) => OrderBy(
3935
json['evaluatedField'],
4036
ascending: json['ascending'],
37+
associationField: json['associationField'],
4138
);
4239

4340
/// Serialize to JSON
4441
Map<String, dynamic> toJson() => {
4542
'ascending': ascending,
43+
if (associationField != null) 'associationField': associationField,
4644
'evaluatedField': evaluatedField,
47-
if (model != null) 'model': model?.toString(),
4845
};
4946

5047
@override
@@ -56,8 +53,8 @@ class OrderBy {
5653
other is OrderBy &&
5754
evaluatedField == other.evaluatedField &&
5855
ascending == other.ascending &&
59-
model == other.model;
56+
associationField == other.associationField;
6057

6158
@override
62-
int get hashCode => evaluatedField.hashCode ^ ascending.hashCode ^ model.hashCode;
59+
int get hashCode => evaluatedField.hashCode ^ ascending.hashCode ^ associationField.hashCode;
6360
}

packages/brick_core/lib/src/query/query.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class Query {
129129
List<LimitBy>? limitBy,
130130
int? offset,
131131
List<OrderBy>? orderBy,
132+
@Deprecated('Use limit, offset, limitBy, orderBy, or forProviders instead.')
132133
Map<String, dynamic>? providerArgs,
133134
List<WhereCondition>? where,
134135
}) =>

packages/brick_core/lib/src/query/where.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ class Where extends WhereCondition {
136136
conditions = null;
137137

138138
/// A condition written with brevity. [isRequired] defaults `true`.
139-
factory Where.exact(String evaluatedField, value, {bool isRequired = true}) =>
140-
Where(evaluatedField, value: value, compare: Compare.exact, isRequired: isRequired);
139+
const Where.exact(this.evaluatedField, this.value, {this.isRequired = true})
140+
: compare = Compare.exact,
141+
conditions = null;
141142

142143
/// Convenience function to create a [Where] with [Compare.exact].
143144
Where isExactly(dynamic value) =>

packages/brick_core/pubspec.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ homepage: https://github.com/GetDutchie/brick/tree/main/packages/brick_core
44
issue_tracker: https://github.com/GetDutchie/brick/issues
55
repository: https://github.com/GetDutchie/brick
66

7-
version: 2.0.0
7+
version: 1.3.1
88

99
environment:
1010
sdk: ">=3.0.0 <4.0.0"
@@ -13,7 +13,6 @@ dependencies:
1313
collection: ">=1.15.0 <2.0.0"
1414

1515
dev_dependencies:
16-
dart_style: ">=2.0.0 <3.0.0"
17-
lints: ">=4.0.0 <6.0.0"
18-
mockito: ^5.0.0
19-
test: ^1.16.5
16+
lints:
17+
mockito:
18+
test:

0 commit comments

Comments
 (0)