Coder Social home page Coder Social logo

getdutchie / brick Goto Github PK

View Code? Open in Web Editor NEW
286.0 286.0 26.0 9.62 MB

An intuitive way to work with persistent data in Dart

Home Page: https://getdutchie.github.io/brick/#/

Dart 99.91% JavaScript 0.09%
dart flutter graphql mobile-development offline rest sqlite

brick's People

Contributors

devj3ns avatar ericwindmill avatar haknt avatar jhuizingh avatar jnhuynh avatar josiassejod1 avatar mateominato avatar polrk avatar porfirioribeiro avatar tolgakartal avatar tshedor avatar victorrent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brick's Issues

Relationships

If I have two models
class Project extends OfflineFirstWithRestModel {
@sqlite(unique: true)
final String id;
...

class Job extends OfflineFirstWithRestModel {
@sqlite(unique: true)
final String id;
final String projectId;
...
What is the best way to get

class ProjectWithJobs {
final Project project;
final List jobs;

ProjectWithJobs(this.project, this.jobs);
}

for presentation layer?

Expected an identifier after flutter upgrade

Get
flutter/bin/cache/dart-sdk/lib/core/uri.dart:3259:39 - Expected an identifier.
[SEVERE] brick_offline_first_with_rest_build:brickAdaptersBuilder on

After flutter upgrade

[✓] Flutter (Channel stable, 1.20.2, on Linux, locale en_US.UTF-8)
• Flutter version 1.20.2 at /home/pako/flutter
• Framework revision bbfbf1770c (16 hours ago), 2020-08-13 08:33:09 -0700
• Engine revision 9d5b21729f
• Dart version 2.9.1

Ability not to await of remoteProvider upsert

According to the concept offline first i want immediately after sqliteProvider upsert get actual associations.
For example I show Customers with its pizzas, and then according with my UX change some pizza name and immediately(after sqliteProvider.upsert) show Customers with new pizzas.(I assume that pizzas has one to many relationships)

Store blob in database

I have some models that returns base64 encoded images from REST and i want to store them on the database.
I can do it, storing it as a plain string, but it would be nice to convert it to Uint8List store it that way on the db but if i add:

Uint8List image;

To my model it stops being recognized by brick.

Improve My Understanding of Domains

Hi @tshedor ,

I am still fuzzy about the definition of "domain". The glossary says they are the encompassing system. I think that Rest, Sqlite, Offline First, and Offline First with Rest are all domains. Is that correct? Does off-the-shelf Brick provide any other domains?

How is a domain manifested in the application code? Is it something like "Each model that Brick will manage must have an annotation indicating the domain to which it belongs, and each repository must have an annotation indicating the domain for which it provides processing"?

Does Brick look for cases where the annotations match, for example: @ConnectOfflineFirstWithRest on the model matches OfflineFirstWithRestRepository on the repository? And when it finds a match does Brick generate the appropriate code for the model given its domain, and associate that code with the corresponding repository?

Thanks very much.

-Dan

How can i delete associations in database

One Task has many project.

final task = Task(projects: [Project()],);

If I delete all projects

task.projects.clear();

call update

update<Task>(task);

And
brick does not delete the associations in the database

Suport with OfflineFirstSerdes

Some serdes might already extend a different class, in my understanding OfflineFirstSerdes could be used as a mixin, but the builder will not detect it.

class MySerde extends SomeBaseClass with OfflineFirstSerdes<String, String>

I guess it's a matter of changing how the builder detects this?

Is there any way to tell why I got an empty array from a get?

Issue: when I'm loading a list of jobs with requireRemote = true, I get an empty list of jobs when any error happens at all. An empty list of jobs due to no work to be done and an empty list because there was an http error is very different.

I would like to be able to catch http errors or at least receive null to know something went wrong. Is this possible?

Query Argument for Get Method

Hello,
I want to pass an entity to a Repository.get method so I can use a field from the entity as a query parameter. From the example program on Flutter by Example it seems that I should be able to do that, but my get method doesn't accept an instance variable:

//I can't do this:
Repository().get<MyModelType>(myModelInstance);
because I get:

Too many positional arguments: 0 expected, but 1 found.

Is passing instance variables to Repository.get methods supported? How can I pass a value to be used as a query parameter for a get?
Thanks.
-Dan

Not Seeing Customers

I worked through the example by following the tutorial on "Flutter by Example" and so far I have not seen any customers in my Flutter app. The app builds cleanly (after I remove the pizza import mentioned below), and starts and runs without incident. When it starts I get the "migrating message". Then some print statements I added tell me that it is inside the migrated==true builder but customerList.data is first null and then becomes an empty list: []. My server.d console output doesn't show any activity from the app. The server, however, is responding correctly to others customers requests:

dan@psl64b1:/repos/kokodoko20191207/Kokodoko - Dec 7$ wget -nv -O - http://localhost:8080/customers
{
"customers": [
{
"id": 1,
"pizza_ids": [
1
],
"firstName": "Wallace",
"lastName": "Wallaceton"
}
]
}2020-12-03 12:44:28 URL:http://localhost:8080/customers [152/152] -> "-" [1]
dan@psl64b1:
/repos/kokodoko20191207/Kokodoko - Dec 7$

I can see that the query.action == QueryAction.get case is executed in customer_adapter.g.dart, but I haven't been able to figure out what is happening next. My guess, for what it's worth, is that Brick is successfully querying SQLite and getting no rows back, but I don't know how to investigate that possibility. Any thoughts on how I can track down the issue?

Thanks.

REST API Authentication with OAuth or JWT Token

Is there a way to configure the Brick RestProvider to handle authentication with the API endpoint?

As an example, I have a published web API, but it only responds to authorized app requests. To authenticate, our app will need to send a POST to /token with encrypted credentials in body. If validated, the API returns a token good for 4 hours. On all subsequent requests, the app will include this token in the request Header.

I was unable to find any good examples or docs on how to accomplish this. I'm curious to hear if this is possible. or if there are maybe other options for adding security for the REST interface.

RuntimeSqliteColumnDefinition is not a type.

Hi @tshedor ,

I am getting some errors after generating adapters on latest Flutter stable channel, this is a new project.

pubspec:

dependencies:
  brick_offline_first: ^0.1.0
dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: '>= 1.10.1'
  brick_offline_first_with_rest_build:
    git:
      url: https://github.com/greenbits/brick.git
      path: packages/brick_offline_first_with_rest_build
Flutter 1.22.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7891006299 (5 weeks ago) • 2020-12-10 11:54:40 -0800
Engine • revision ae90085a84
Tools • Dart 2.10.4

Thanks in advance.

How to send parameters to the API endpoint?

I'm using the OfflineFirstWithRestModel in my application, but I still couldn't configure my model in the expected way.

What is the correct way to send parameters to the API endpoint? I need to filter calls according to some fields returned by the endpoints

I've tried to send by query -> providerArgs and query -> where. But in both cases, when the app is offline I don't get a response from the db, affecting the functioning of the app.

Bi-Modal Data Access

The data that is returned by my API may be changed (items added, updated and deleted) from outside of my app. I am looking for a way to resync the contents of the applications's Brick sqlite database from REST from time to time to reflect those external changes. I think I can force new items to be added to the sqlite database and existing items to be updated in the sqlite database by doing a get with requireRemote set to true, although I am not 100% confident about my testing methodology. The same testing seems to indicate that doing a get with requireRemote set to true will not cause items that have been removed from outside of the application to be removed in the application's Brick sqlite database.

Do my conclusions sound correct? If so, is there a way to get the items that were deleted from outside of the app to be removed from the application's Brick sqlite database?

Many thanks.

-Dan

Table Not Found

Hello,

I am using offline-first-with-rest. My app. has been working well with one model. I added a second model ('Kokoer') and when I try to execute a query against it I get an exception:

E/flutter (  423): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: DatabaseException(no such table: Kokoer (code 1): , while compiling: SELECT COUNT(*) FROM `Kokoer`) sql 'SELECT COUNT(*) FROM `Kokoer`' args []}

If I remove the attempt to execute the query against the second model type the app again works as expected.

I am initiating queries against both models through the same Repository. I can see that the new table and its columns are referenced in the migration code and in schema.g.dart. I can also see that build_runner created a .g.dart and an adapter for the new model type, and I can see that migration is running each time I run the app.

I have tried flushing the app's storage and also uninstalling and reinstalling the app.

Any thoughts on where my mistake might be?

Thank you for your help.

-Dan

Why does this query return empty list of models?

The my api for getting jobs expects a date range. The query below successfully gets the jobs from REST. However, when I run the same query without internet, I receive an empty list of jobs.

    List<Job> jobs = await repository.get<Job>(
            query: Query(action: QueryAction.get, providerArgs: {
          "start": dateTime.toIso8601String(),
          "end": dateTime.add(Duration(days: 1)).toIso8601String()
        }));

If I comment that out and run this without internet, I receive all the jobs which are saved in Sqlite:

    List<Job> jobs = await repository.get<Job>();

Why am I receiving an empty list of jobs from the first query? How can I change it to return all jobs which are saved in the table?

Field Level Annotations

Hi @tshedor ,

I have puzzled repeatedly over this section of the doc:

Annotations
As providers are ultimately responsible for converting raw data into model data, a description of fields on models is overly generic. Field-level annotations always override class-level annotations/configuration. However, providers should adhere to some standards of annotations:

After much head scratching here is what I think it means:

Annotations
This section discusses Brick's built-in annotations that can be used on model fields.

Brick's field level annotations are applied selectively to the providers that process the annotated models. Each type of annotation can be applied to any provider type, and each occurrence of an annotation includes the provider type to which that occurrence applies. For example, this annotation occurrence :

@Rest(ignore: true)

instructs Rest providers to ignore the annotated field, while this one:

@Sqlite(ignore: true)

tells Sqlite providers to do the same.

When a provider is processing a model that includes a field level annotation referring to that type of provider, it is the job of the provider to act on the annotated field in a way that is consistent with the annotation's meaning. Each provider included with Brick processes model fields in accordance with the Brick's built-in field level annotations. Implementers of new provider types should ensure that their providers also react appropriately to the field level annotations built into Brick.

Some field level annotations control properties that can also be managed using class level annotations or equivalent configurations. In those cases, the field level annotations override the corresponding class level annotations or configuration.

Is that correct? If not and if you let me know what have I misunderstood, I will update my explanation

Thanks.

-Dan

Best practices on managing ids

The tutorials don't really mention how the application ids are managed. It looks like brick uses an internal primary key, but in the pizza example, there is also an application level id that is also used in the rest calls. Are there any best practices on managing those ids?

Ideally that id would not be generated by the flutter client, as two different clients could create conflicting records with the same id if I used some sort of auto increment scheme. The problem with this method is that since the rest endpoint is called after it's saved locally, it needs an id when I do the upsert.

I also thought about not using surrogate keys, and instead using a natural key, but that would require multiple pieces of information (like customer name and pizza order timestamp) but I'm not sure I have access to all that in the rest endpoint configuration. I was thinking something like this, but not sure this is even possible.

  {
    if (query.action == QueryAction.upsert) {
      return "/customers/<somehow_put_customer_id_here>/pizzas";
    }

    if (query.action == QueryAction.get && query?.where != null) {
      final byCustomerId = Where.firstByField('customer_id', query.where);
      final byOrderDate = Where.firstByField('order_date', query.where);      
      // member endpoint
      if (byCustomerId.value != null && byOrderDate != null) {
        return "/customers/${byCustomerId.value}/pizzas/${byOrderDate.value}";
      }
    }

    if (query.action == QueryAction.get) {
      return "/customers/<somehow_put_customer_id_here>/pizzas";
    }

    return null;
  }

Version solving failed

  brick_offline_first: ^0.1.0
  brick_sqlite: ^0.1.7
Because brick_sqlite >=0.1.7 depends on brick_sqlite_abstract 0.1.0 and brick_offline_first >=0.1.0 depends on brick_sqlite_abstract ^0.0.8+1, brick_sqlite >=0.1.7 is incompatible with brick_offline_first >=0.1.0.
So, because listta depends on both brick_offline_first ^0.1.0 and brick_sqlite ^0.1.7, version solving failed.
Running "flutter pub get" in listta-mobile-app...                       
pub get failed (1; So, because listta depends on both brick_offline_first ^0.1.0 and brick_sqlite ^0.1.7, version solving failed.)

When are Requets Removed With "Offline First With Rest" Repository?

Hello,
I have had trouble understanding this section of the doc:

Offline First With Rest Repository
OfflineFirstWithRestRepository streamlines the REST integration with an OfflineFirstRepository. A serial queue is included to track REST requests in a separate SQLite database, only removing requests when a response is not returned from the host (i.e. the device has lost internet connectivity).

I would have thought that requests would be removed when a response (perhaps only some kinds of responses; maybe not a 500) is returned from the host. Do I have this backwards?
Thanks.
-Dan

Delete error: cannot be deleted because it does not exist in the SQLite database.

My code

  @override
  Future<bool> deleteTask(TaskDto task) {
    return delete<TaskDto>(task);
  }
[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: Invalid argument(s): TaskDto{id: fee0dd3e-ea4e-4900-a651-06c6d5f5f9ee, createdAt: 2020-11-14 11:23:42.878768Z, updatedAt: 2020-11-14 11:23:42.878769Z} cannot be deleted because it does not exist in the SQLite database.
#0      SqliteProvider.delete (package:brick_sqlite/sqlite.dart:75:7)
<asynchronous suspension>
#1      OfflineFirstRepository.delete (package:brick_offline_first/offline_first.dart:101:46)
#2      OfflineFirstWithRestRepository.delete (package:brick_offline_first/offline_first_with_rest.dart:95:26)
#3      TasksRepositoryIml.deleteTask
#4      _TasksStore.deleteTask

But in sqlite the object exists

Screenshot 2020-11-28 at 16 04 56

Multi level in 'fromKey'

Backend service send me data as

"result": {
  "items": [
    {

I want to specify one common fromKey for RestProvider('result') and another one for each model(items), or have ability to specify fromKey as path 'result/items'.

Models in sub folders

I would like to structure models using folders.
But putting models inside a folder do not work.
When you start getting many models might be hard to have them all in the same place

Associations are not being sent to rest endpoint

I'm confused how adding children of a parent object is supposed to work. In the example project I added the following code to the top of the build method in _MyHomePageState.

    if (migrated) {
      Repository().get<Customer>().then((customers) {
        customers[0].pizzas.add(Pizza(id: 5, toppings: [Topping.pepperoni], frozen: false));
        Repository().upsert(customers[0]);
      });
    }

The app does not ever post to /pizzas. If I upsert the pizza first, then it does, but brick isn't sending any information to the rest server that tells it which customer the pizza is associated to. Am I doing something wrong?

How can i change model for my repository

I documentation, I can define my model, but I can't do it with OfflineFirstWithRestRepository

RepositoryImpl extends OfflineFirstWithRestRepository

abstract class OfflineFirstWithRestRepository
    extends OfflineFirstRepository<OfflineFirstWithRestModel> {

Store in sqlite parameters used to rest so we can query from db

I have requests that are queried with some parameter, and that parameter is sent to the rest endpoint as a query parameter.
But that endpoint result does not include that parameter, so it makes it impossible to query it from the database.

In some situations i ended up changing the backend to include that parameter as a field in the response, but in this case would be hard to do it.

I have here a small resume of what i have:

String getEntityEndpoint(Query query) {
  final parentId = Where.firstByField('parentId', query.where)?.value;
  return (parentId != null) ? '/entities/${parentId}' : null;
}

@ConnectOfflineFirstWithRest(
  restConfig: RestSerializable(
    endpoint: '''=> getEntityEndpoint(query)''',
    fieldRename: FieldRename.none,
  ),
)
class Entity extends OfflineFirstWithRestModel {
  @Sqlite(unique: true)
  String id;

  @Rest(ignore: true)
  String parentId;
  
  String name;
  
  Entity({
    @required this.id,
    @required this.parentId,
    @required this.name,
  });
}

void fun(){
  repository.get<Entity>(
    query: Query(where: [Where.exact('parentId', parentId)]),
  );
}

My initial idea was having a fromGenerator in that parentId field but then i realized that i have no access to the Query.
So maybe changing adapter.fromRest to also pass the query parameter?
I could try to do PR on that, but i have no idea how to change the generated code.

Or maybe there is a different way to intercept the response and add that?

When brick.g imports cloud firestore, there is a conflict for the name "Query"

I have a model which imports cloud firestore, which causes brick.g to also import firestore. This creates a conflict for the name Query, since firestore also has a Query class.

The result is that any adapter code which uses bricks Query does not compile. In my use, I can simply delete the firestore import from brick.g and everything works fine, however it says not to modify that file.

I have tried adding an alias the import in my model file, but brick doesn't add in the same alias automatically

import 'package:cloud_firestore/cloud_firestore.dart' as firestore;

Crash on upsert with nullable object

I have field in my model
@rest(nullable: true)
final Attachment logoAttachment;

When trying upsert with null value get error:
Unhandled Exception: Unhandled error type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Attachment'
In _$SoemThingToRest in adapter on line

'logoAttachment':
await AttachmentAdapter().toRest(instance.logoAttachment ?? {}),

Specify Sqlite datatype

As we have fromGenerator and toGenerator to completely change the was we store and retrieve from the database would be nice to be able to specify the column type in the database

Like:
Sqlite(type: Column.text)

This would give more flexibility and let do some advanced stuff

the example doesn't work

Download, I followed the steps to run the example but it doesn't work correctly, it doesn't load the data from the local server

Question: Best practices for handling Offline/Rest with nested objects

Hi @tshedor , got another question for you.

I'm working with an existing API. I'm dealing with an endpoint that returns a list of Share objects. The attached is an example of the JSON result. Is this supported by Brick, and if so, how would I go about telling the REST provider to parse JSON from the response, and not to perform get() on the /request, /member, or /update endpoints?

Side note: I feel like a better solution would be change the API response, such that request_id is returned, then I could let Brick be responsible for hydrating memory or SQL before using REST. Talking to management, that might be an option.

json.txt

Data in _$FromRest is missing keys which causes crash

Issue: some keys are missing in the data object when I reach the from rest method. The api I'm using returns complete objects within a job, opposed to only an id. These objects used to be created properly when using JsonSerializable:

    template: json['template'] == null
        ? null
        : Template.fromJson(json['template'] as Map<String, dynamic>),
    company: json['company'] == null
        ? null
        : Company.fromJson(json['company'] as Map<String, dynamic>),

Now when switching to brick offline, these object are missing completely from the data map. They aren't even null, the keys don't exist.

Future<Ticket> _$TicketFromRest(Map<String, dynamic> data,
    {RestProvider provider, OfflineFirstWithRestRepository repository}) async {
  print("company: ${data.containsKey("company")}");
  print("template: ${data.containsKey("template")}");
I/flutter (29717): company: false
I/flutter (29717): template: false
E/flutter (29717): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method '[]' was called on null.
E/flutter (29717): Receiver: null
E/flutter (29717): Tried calling: []("id")
E/flutter (29717): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (29717): #1      _$CompanyFromJson (package:my_app/app/models/company.g.dart:11:13)

This causes a crash whenever _$TicketFromRest is called, because it attempts to calls TemplateAdapter().fromRest(data['template'], and data['template'] is null.

Sanity check: it 100% exists on the payload the app receives:

image

Usage example

Where can I get a usage example, which allows reading data from an api rest server and doing CRUD operations?

Feedback on the new docs site

Hey @SubutaDan @mrmeyers99 @polRk @cleanstartgit, I've finally put together a documentation website: https://greenbits.github.io/brick/#/

I'm pinging you because I've previously gone back and forth with each of you on issues that could have likely been resolved with better documentation and clarity. Hopefully this presentation will improve the experience for other users of Brick. Specifically, I'd like to know:

  • Is the documentation is easy to navigate?
  • Are the pages properly prioritized?
  • Where did you get stuck when you first used Brick? Would you have been able to resolve that problem with this documentation site?
  • How did you first come across Brick?
  • What is missing?

I'll close this issue in a week, and no hard feelings if you'd rather not respond or have moved on from using Brick.

Also tagging @porfirioribeiro @pkozlovskiy @carlos-labrador since you've been using Brick for a while and will have good insight.

Can't build the app

[WARNING] No actions completed for 15.0s, waiting on:
  - brick_offline_first_with_rest_build:brickAdaptersBuilder on lib/app/models/user_dto.dart
  - brick_offline_first_with_rest_build:brickAdaptersBuilder on lib/app/models/task_dto.dart

[INFO] 1h 56m elapsed, 1/3 actions completed.

How to force SQLite to synchronize with the data coming from remote

Hi, we're currently trying to find a way to implement the following use-case using brick:

  • We create a resource from the web interface and get it in the mobile app (works)
  • We create a second resource from the web interface and get it in the mobile app (the list gets updated correctly)
  • We now delete the first resource from the web interface and perform a GET request.

What we can see is that the request returns only one item, but the the app still shows two items (because it fetched the deleted one in the SQLite database). We would like to force the sqlite to synchronize with the latest data we received from our API, could you please help us with that matter?
How would you approach this? Is there something in the documentation we missed or is it just not possible?

Thanks for the help,
Arnaud

How to properly change associated data

I use associations like in example
@offlinefirst(where: {'id': "data['pizza_ids']"})
@rest(name: 'pizza_ids')
final List pizzas;

First I upsert Customer with some pizzas, and then I want to change his list of pizzas, I try to upsert this Customer with new list of pizzas, but when I fetch this customer after that it has ALL pizzas from first and second lists, but I expect only second.

How to configure with Dio?

I am looking at trying to use this plugin with Dio as my api client. Currently, I have all the api working with Dio, and now want to do offline as the next step.

Just starting on this, haven't configured much of anything yet, but I think I ran into an issue where Dio is using HttpClient and your RestProvider expects a Client

From the example project

class Cache extends OfflineFirstWithRestRepository {
  Cache._(String baseUrl, Client client, String databaseName)
      : super(
          restProvider: RestProvider(
            baseUrl, client: client,
            modelDictionary: restModelDictionary,
          ),
          sqliteProvider: SqliteProvider(
            databaseName,
            modelDictionary: sqliteModelDictionary,
          ),
          memoryCacheProvider: MemoryCacheProvider(),
          migrations: migrations,
        );

  factory Cache() => _singleton ?? Exception("Must call configure first");

  static Cache _singleton;

  static void configure(String baseUrl, Client client, String databaseName) {
    _singleton = Cache._(
      baseUrl,
      client,
      databaseName,
    );
  }
}
    (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
        (client) {
      Cache.configure(dio.options.baseUrl, client, "database.db");
    };

image

So it appears as though I cannot give the api client in Dio to the RestProvider. Any ideas? Sorry if I'm missing something obvious

Problem with headersForQuery

Hi!
I use my http client for RestProvider where i get actual token and add Authorization header BUT in this way offlineRequestQueue was broken, because in OfflineQueueHttpClient we cache request (without auth header) and only after call
_inner.send
wich add new Authorization header, and there fore RequestSqliteCache cant`t delete success response because headers not the same(
I try use defaultHeaders, but token can be changed.

I think ovveride of headersForQuery is the best way for this problem ( but it protected)

Best practices for managing server's database schema and objects

The documentation doesn't cover much about implementing the server for the REST endpoints. I'm wondering if it would be a good idea to somehow share the model and the persistence code between the flutter app and the central rest server that clients are syncing too. I think I'd have to write a mysql provider for brick since it's not a good idea to run a sqlite database in production, and I'd need to use a repository that doesn't do any remote hydration from another source (since it is the source of truth).

Is this a good idea or would it be better to completely separate my server and client code?

Handling 401 Unauthorized Response

I am using passport for api connection, but when client response 401 due to an expired token , brick ignore this response and continue retrieve data from local.

it seems brick ignore 401 http code , It is possible to get an Unauthorized exception ?

I have to say , brick is a really nice package. helps me a lot.

Thanks in advance

Support generics on types

I want to add a type that has generic argument on my model.

  final Geometry<dynamic> geometry;
[SEVERE] brick_offline_first_with_rest_build:brickAdaptersBuilder on lib/app/models/field.dart:

Could not format because the source could not be parsed:

line 125, column 37: A comparison expression can't be an operand of another comparison expression.
    ╷
125 │             'type': Geometry<dynamic>,
    │                                     ^
    ╵
line 125, column 38: Expected an identifier.
    ╷
125 │             'type': Geometry<dynamic>,
    │                                      ^
    ╵

Error in RestSerializable when hydrating after deletion

TaskDto

@ConnectOfflineFirstWithRest(
  restConfig: RestSerializable(
    fieldRename: FieldRename.none,
    fromKey: 'items',
    endpoint: r'''{
      if (query.action == QueryAction.get && query?.where != null) {
        final byId = Where.firstByField('id', query.where);

        if (byId?.value != null) {
          return "/tasks/${byId.value}";
        }
      }

      if (query?.action == QueryAction.delete) {
        return "/tasks/${instance.id}";
      }

      return "/tasks";
    }''',
  ),
)

flutter: FINEST: 2020-12-10 11:37:36.095433: #delete: url= statusCode=200 body=
flutter: FINEST: 2020-12-10 11:37:36.096858: #hydrate: TaskDto {"action":4,"providerArgs":{}}
[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The getter 'id' was called on null.
Receiver: null
Tried calling: id

Error in this line

      if (query?.action == QueryAction.delete) {
        return "/tasks/${instance.id}";
      }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.