Skip to content

Commit fe0c05b

Browse files
authored
eng: add query v1.3 (#504)
2 parents bd57c28 + 475df43 commit fe0c05b

File tree

375 files changed

+4454
-2361
lines changed

Some content is hidden

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

375 files changed

+4454
-2361
lines changed

MIGRATING.md

Lines changed: 131 additions & 76 deletions
Large diffs are not rendered by default.

analysis_options.yaml

Lines changed: 189 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,234 @@
11
include: package:lints/recommended.yaml
22

3-
# Additional information about this file can be found at
4-
# https://dart.dev/guides/language/analysis-options
5-
63
linter:
74
rules:
5+
# This list is derived from the list of all available lints located at
6+
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
87
- always_declare_return_types
8+
# - always_put_control_body_on_new_line
9+
# - always_put_required_named_parameters_first
10+
# - always_specify_types
911
- always_use_package_imports
12+
- annotate_overrides
13+
# - avoid_annotating_with_dynamic
1014
- avoid_bool_literals_in_conditional_expressions
15+
# - avoid_catches_without_on_clauses
16+
# - avoid_catching_errors
17+
- avoid_classes_with_only_static_members
18+
- avoid_double_and_int_checks
19+
# - avoid_dynamic_calls
20+
- avoid_empty_else
21+
# - avoid_equals_and_hash_code_on_mutable_classes
1122
- avoid_escaping_inner_quotes
23+
- avoid_field_initializers_in_const_classes
24+
# - avoid_final_parameters
25+
- avoid_function_literals_in_foreach_calls
26+
- avoid_implementing_value_types
27+
- avoid_init_to_null
28+
- avoid_js_rounded_ints
29+
- avoid_multiple_declarations_per_line
30+
- avoid_null_checks_in_equality_operators
31+
# - avoid_positional_boolean_parameters
32+
- avoid_print
33+
- avoid_private_typedef_functions
34+
- avoid_redundant_argument_values
35+
- avoid_relative_lib_imports
36+
- avoid_renaming_method_parameters
37+
- avoid_return_types_on_setters
38+
- avoid_returning_null_for_void
39+
- avoid_returning_this
40+
- avoid_setters_without_getters
41+
- avoid_shadowing_type_parameters
42+
- avoid_single_cascade_in_expression_statements
43+
- avoid_slow_async_io
44+
- avoid_type_to_string
45+
- avoid_types_as_parameter_names
46+
# - avoid_types_on_closure_parameters
47+
- avoid_unnecessary_containers
48+
- avoid_unused_constructor_parameters
1249
- avoid_void_async
50+
- avoid_web_libraries_in_flutter
51+
- await_only_futures
1352
- camel_case_extensions
1453
- camel_case_types
54+
- cancel_subscriptions
55+
- cascade_invocations
56+
- cast_nullable_to_non_nullable
57+
# - close_sinks
58+
- collection_methods_unrelated_type
59+
- combinators_ordering
60+
- comment_references
61+
- conditional_uri_does_not_exist
62+
- constant_identifier_names
63+
- control_flow_in_finally
1564
- curly_braces_in_flow_control_structures
65+
- dangling_library_doc_comments
66+
- depend_on_referenced_packages
67+
- deprecated_consistency
68+
- deprecated_member_use_from_same_package
69+
# - diagnostic_describe_all_properties
1670
- directives_ordering
1771
- discarded_futures
72+
- do_not_use_environment
73+
- empty_catches
74+
- empty_constructor_bodies
75+
- empty_statements
1876
- eol_at_end_of_file
77+
- exhaustive_cases
1978
- file_names
79+
- flutter_style_todos
80+
- hash_and_equals
81+
- implementation_imports
82+
- implicit_call_tearoffs
83+
- implicit_reopen
2084
- invalid_case_patterns
85+
- join_return_with_assignment
86+
# - leading_newlines_in_multiline_strings
87+
- library_annotations
88+
- library_names
89+
- library_prefixes
90+
- library_private_types_in_public_api
91+
# - lines_longer_than_80_chars
92+
- literal_only_boolean_expressions
2193
- matching_super_parameters
94+
- missing_whitespace_between_adjacent_strings
95+
- no_adjacent_strings_in_list
96+
- no_default_cases
97+
- no_duplicate_case_values
98+
- no_leading_underscores_for_library_prefixes
99+
- no_leading_underscores_for_local_identifiers
22100
- no_literal_bool_comparisons
101+
- no_logic_in_create_state
102+
- no_runtimeType_toString
103+
- no_self_assignments
104+
- no_wildcard_variable_uses
105+
- non_constant_identifier_names
106+
- noop_primitive_operations
107+
- null_check_on_nullable_type_parameter
108+
- null_closures
109+
- omit_local_variable_types
110+
- one_member_abstracts
111+
- only_throw_errors
112+
- overridden_fields
113+
- package_api_docs
114+
- package_names
115+
- package_prefixed_library_names
116+
- parameter_assignments
117+
- prefer_adjacent_string_concatenation
118+
- prefer_asserts_in_initializer_lists
119+
- prefer_asserts_with_message
120+
- prefer_collection_literals
121+
- prefer_conditional_assignment
122+
- prefer_const_constructors
123+
- prefer_const_constructors_in_immutables
124+
- prefer_const_declarations
125+
- prefer_const_literals_to_create_immutables
126+
- prefer_constructors_over_static_methods
127+
- prefer_contains
128+
# - prefer_double_quotes
129+
# - prefer_expression_function_bodies
130+
- prefer_final_fields
131+
- prefer_final_in_for_each
23132
- prefer_final_locals
133+
# - prefer_final_parameters
134+
- prefer_for_elements_to_map_fromIterable
135+
- prefer_foreach
136+
- prefer_function_declarations_over_variables
137+
- prefer_generic_function_type_aliases
138+
- prefer_if_elements_to_conditional_expressions
139+
- prefer_if_null_operators
140+
- prefer_initializing_formals
141+
- prefer_inlined_adds
142+
- prefer_int_literals
143+
- prefer_interpolation_to_compose_strings
24144
- prefer_is_empty
25145
- prefer_is_not_empty
146+
- prefer_is_not_operator
147+
- prefer_iterable_whereType
148+
- prefer_mixin
149+
- prefer_null_aware_method_calls
150+
- prefer_null_aware_operators
151+
# - prefer_relative_imports
26152
- prefer_single_quotes
153+
- prefer_spread_collections
154+
- prefer_typing_uninitialized_variables
155+
- prefer_void_to_null
156+
- provide_deprecation_message
157+
- public_member_api_docs
158+
- recursive_getters
27159
- require_trailing_commas
160+
- secure_pubspec_urls
161+
- sized_box_for_whitespace
162+
- sized_box_shrink_expand
163+
- slash_for_doc_comments
164+
- sort_child_properties_last
165+
# - sort_constructors_first
166+
- sort_pub_dependencies
167+
- sort_unnamed_constructors_first
168+
- test_types_in_equals
169+
- throw_in_finally
170+
- tighten_type_of_initializing_formals
171+
- type_annotate_public_apis
172+
- type_init_formals
28173
- type_literal_in_constant_pattern
29174
- unawaited_futures
175+
# - unnecessary_await_in_return
176+
- unnecessary_brace_in_string_interps
177+
- unnecessary_breaks
178+
- unnecessary_const
179+
- unnecessary_constructor_name
180+
# - unnecessary_final
181+
- unnecessary_getters_setters
30182
- unnecessary_lambdas
183+
- unnecessary_late
184+
- unnecessary_library_directive
185+
- unnecessary_new
186+
- unnecessary_null_aware_assignments
187+
- unnecessary_null_aware_operator_on_extension_on_nullable
188+
- unnecessary_null_checks
189+
- unnecessary_null_in_if_null_operators
190+
- unnecessary_nullable_for_final_variable_declarations
191+
- unnecessary_overrides
31192
- unnecessary_parenthesis
32193
- unnecessary_raw_strings
33194
- unnecessary_statements
195+
- unnecessary_string_escapes
196+
- unnecessary_string_interpolations
197+
- unnecessary_this
34198
- unnecessary_to_list_in_spreads
199+
# - unreachable_from_main
200+
- unrelated_type_equality_checks
201+
- unsafe_html
202+
- use_build_context_synchronously
203+
- use_colored_box
204+
- use_decorated_box
205+
- use_enums
206+
- use_full_hex_values_for_flutter_colors
207+
- use_function_type_syntax_for_parameters
35208
- use_if_null_to_convert_nulls_to_bools
209+
- use_is_even_rather_than_modulo
210+
- use_key_in_widget_constructors
211+
- use_late_for_private_fields_and_variables
212+
- use_named_constants
36213
- use_raw_strings
214+
- use_rethrow_when_possible
215+
- use_setters_to_change_properties
216+
- use_string_buffers
217+
- use_string_in_part_of_directives
37218
- use_super_parameters
219+
- use_test_throws_matchers
38220
- use_to_and_as_if_applicable
39-
- unnecessary_breaks
221+
- valid_regexps
222+
- void_checks
40223

41224
analyzer:
42-
exclude:
225+
exclude:
43226
- example/
44227
- "**/example/"
45228
- example_rest
46229
- example_graphql
47230
- "**/*.g.dart"
48-
231+
49232
errors:
50233
# override custom
51234
always_use_package_imports: error

docs/data/providers.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,25 @@ Underscore prefixing of type declarations ensure that 1) they will likely not co
3131

3232
Every public instance method should support a named argument of `{Query query}`. `Query` is the glue between an application and an abstracted provider or repository. It is accessed by both the repository and the provider, but as the last mile, the provider should interpret the `Query` at its barest level.
3333

34-
### `providerArgs:`
34+
### `limit:`
3535

36-
`providerArgs` describe how to interact with a provider's source.
36+
The ceiling for how many results a provider should return from the source.
37+
38+
```
39+
Query(limit: 10)
40+
```
41+
42+
### `offset:`
43+
44+
The starting index for a provider's search for results.
3745

38-
```dart
39-
providerArgs: {
40-
// limit describes how many results the provider requires from the source
41-
'limit': 10,
42-
},
4346
```
47+
Query(offset: 10)
48+
```
49+
50+
### `forProviders:`
4451

45-
As `providerArgs` can vary from provider to provider and IDE suggestions are unavailable to a string-key map, `providerArgs` should be clearly and accessibly documented within every new provider.
52+
Available arguments can vary from provider to provider; this allows implementations to query exclusive statements from a specific source.
4653

4754
### `where:`
4855

docs/graphql/query.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ query MyOperation($vars: MyInputClass!) {
1919
}
2020
```
2121

22-
?> `providerArgs['operation'].variables` will **never** be wrapped by `variablesNamespace`
22+
?> `GraphqlProviderQuery#.variables` will **never** be wrapped by `variablesNamespace`
2323

2424
## `where:`
2525

docs/sqlite/query.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
The following map exactly to their SQLite keywords. The values will be inserted into a SQLite statement **without being prepared**.
66

7-
* `collate`
8-
* `having`
9-
* `groupBy`
10-
* `limit`
11-
* `offset`
12-
* `orderBy`
7+
- `collate`
8+
- `having`
9+
- `groupBy`
10+
- `limit`
11+
- `offset`
12+
- `orderBy`
1313

1414
As the values are directly inserted, use the field name:
1515

@@ -20,7 +20,7 @@ final String lastName;
2020
2121
Query(
2222
where: [Where.exact('lastName', 'Mustermann')],
23-
providerArgs: {'orderBy': 'lastName ASC'},
23+
orderBy: [OrderBy('lastName', ascending: true)]
2424
)
2525
```
2626

docs/supabase/query.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
# `Query` Configuration
22

3-
## `providerArgs:`
3+
## `limit`
44

5-
| Name | Type | Description |
6-
| -------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
7-
| `'limit'` | `int` | Forwards to Supabase's `limit` [param](https://supabase.com/docs/reference/dart/limit) in Brick's `#get` action |
8-
| `'limitByReferencedTable'` | `String?` | Forwards to Supabase's `referencedTable` [property](https://supabase.com/docs/reference/dart/limit) |
9-
| `'offset'` | `int` | Start from a specific offset, inclusive. |
10-
| `'orderBy'` | `String` | Use field names not column names and always specify direction.For example, given a `final DateTime createdAt;` field: `{'orderBy': 'createdAt ASC'}`. |
11-
| `'orderByReferencedTable'` | `String?` | Forwards to Supabase's `referencedTable` [property](https://supabase.com/docs/reference/dart/order) |
5+
Forwards to Supabase's `limit` [param](https://supabase.com/docs/reference/dart/limit) in Brick's `#get` action
126

13-
?> The `ReferencedTable` naming convention is awkward but necessary to not collide with other providers (like `SqliteProvider`) that also use `orderBy` and `limit`. While a `foreign_table.foreign_column` syntax is more Supabase-like, it is not supported in `orderBy` and `limit`.
7+
## `offset`
8+
9+
Start from a specific offset, inclusive.
1410

1511
## `where:`
1612

example_supabase/lib/brick/db/20240920063917.migration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// GENERATED CODE EDIT WITH CAUTION
22
// THIS FILE **WILL NOT** BE REGENERATED
33
// This file should be version controlled and can be manually edited.
4+
// ignore_for_file: public_member_api_docs, constant_identifier_names
5+
46
part of 'schema.g.dart';
57

68
// While migrations are intelligently created, the difference between some commands, such as
@@ -21,8 +23,6 @@ const List<MigrationCommand> _migration_20240920063917_up = [
2123
'Pizza',
2224
'Customer',
2325
foreignKeyColumn: 'customer_Customer_brick_id',
24-
onDeleteCascade: false,
25-
onDeleteSetDefault: false,
2626
),
2727
];
2828

example_supabase/lib/brick/models/customer.model.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: public_member_api_docs
2+
13
import 'package:brick_offline_first_with_supabase/brick_offline_first_with_supabase.dart';
24
import 'package:brick_sqlite/brick_sqlite.dart';
35

example_supabase/lib/brick/models/pizza.model.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
// ignore_for_file: public_member_api_docs
2+
13
import 'package:brick_offline_first_with_supabase/brick_offline_first_with_supabase.dart';
24
import 'package:brick_sqlite/brick_sqlite.dart';
35
import 'package:brick_supabase/brick_supabase.dart';
46
import 'package:pizza_shoppe/brick/models/customer.model.dart';
57

68
@ConnectOfflineFirstWithSupabase(
7-
supabaseConfig: SupabaseSerializable(),
9+
supabaseConfig: SupabaseSerializable.defaults,
810
)
911
class Pizza extends OfflineFirstWithSupabaseModel {
1012
/// Read more about `@Sqlite`: https://github.com/GetDutchie/brick/tree/main/packages/brick_sqlite#fields

example_supabase/lib/brick/repository.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: public_member_api_docs
2+
13
import 'package:brick_offline_first_with_supabase/brick_offline_first_with_supabase.dart';
24
import 'package:brick_sqlite/brick_sqlite.dart';
35
import 'package:brick_sqlite/memory_cache_provider.dart';
@@ -10,6 +12,8 @@ import 'package:supabase_flutter/supabase_flutter.dart';
1012
class Repository extends OfflineFirstWithSupabaseRepository {
1113
static late Repository? _singleton;
1214

15+
factory Repository() => _singleton!;
16+
1317
Repository._({
1418
required super.supabaseProvider,
1519
required super.sqliteProvider,
@@ -18,8 +22,6 @@ class Repository extends OfflineFirstWithSupabaseRepository {
1822
super.memoryCacheProvider,
1923
});
2024

21-
factory Repository() => _singleton!;
22-
2325
static Future<void> initializeSupabaseAndConfigure({
2426
required String supabaseUrl,
2527
required String supabaseAnonKey,

0 commit comments

Comments
 (0)