GithubHelp home page GithubHelp logo

conduit-dart / conduit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stablekernel/aqueduct

449.0 449.0 43.0 14.29 MB

Dart HTTP server framework for building REST APIs. Includes PostgreSQL ORM and OAuth2 provider.

Home Page: https://theconduit.dev

License: BSD 2-Clause "Simplified" License

Dart 99.91% HTML 0.08% Dockerfile 0.01%
dart null-safety orm postgres webserver

conduit's People

Contributors

allcontributors[bot] avatar anachlas avatar bartonhammond avatar benbarbersmith avatar bsutton avatar caffeineflo avatar crifurch avatar deathman92 avatar dimoshka avatar erikist avatar github-actions[bot] avatar j4qfrost avatar jadengis avatar jesseblack82 avatar jodinathan avatar joeconwaystk avatar kevmoo avatar lieblb avatar marcussmith avatar mhelmetag avatar neterror avatar pschiffmann avatar reductions avatar robertblackhart avatar sergeshkurko avatar stablekernel-admin avatar sudolibre avatar terrencepreilly avatar tgercek avatar xvld 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

conduit's Issues

Is it possible to separate the ORM into a separate dependency?

I really like the ORM in conduit but I don't need the webserver part. Is it possible to use the ORM without the rest of Conduit?

Has any work or design work been done already to extract this into a separate dependency?

I have managed to link to a conduit app dependency very easily:

  final dataModel = ManagedDataModel.fromCurrentMirrorSystem();
  final persistentStore = PostgreSQLPersistentStore //
      .fromConnectionInfo("postgres", "password", "localhost", 5432, "postgres");
  var context = ManagedContext(dataModel, persistentStore);

  final heroQuery = Query<Hero>(context);
  final heroes = await heroQuery.fetch();

Do you seen any problems with this approach?

One problem I have found already is the dependency on mirrors. In a conduit app (eg 'heroes') you can use the conduit build cli command to create a binary. However, if I have a dependency on a 'heroes' project and I need to compile it, I'm not sure how I would do this.

Any thoughts?

Review documentation

Post the core migration of code from aqueduct to conduit we need to review the documenation.

Change Aqueduct to Conduit

Change any url references to the appropriate conduit site.

Other actions?

Double where query[BUG]

Hi how do we do a double where query, i have the following query

final isDecryptorFollowing = Query<Following>(context)
          ..where((i) => i.follower?.id).equalTo(request!.authorization!.ownerID)
          ..where((i) => i.chatter?.id).equalTo(follow.follower?.id);

but if one out of the 2 satisfies it does return a value but i only want a result if they both satisfy, can anyone help me?

[BUG] When starting the conduit server a NoSuchMethodError on didAddToChannel occurs

Unhandled exception:
NoSuchMethodError: The method 'didAddToChannel' was called on null.
Receiver: null
Tried calling: didAddToChannel()
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1 ApplicationServer.start
package:conduit/…/application/application_server.dart:70

#2 ApplicationIsolateServer.start
package:conduit/…/application/isolate_application_server.dart:34

Custom header CorsPolicy [BUG]

As soon as i give an extra custom header the cors policy blocks it eventhough if i devine the policy in prepare like
CORSPolicy.defaultPolicy.allowedRequestHeaders = ["*"]; or with the names of the headers it keeps on throwing

[INFO] conduit: OPTIONS /auth/token 21ms 403 {user-agent : Mozilla/5.0 (X11; CrOS x86_64 14816.82.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36\nconnection : keep-alive\nsec-fetch-dest : empty\naccept-encoding : gzip, deflate, br\nsec-fetch-site : same-site\nreferer : http://localhost:4200/\naccept : */*\nsec-fetch-mode : cors\naccept-language : nl,en;q=0.9\norigin : http://localhost:4200\nhost : localhost:8888\naccess-control-request-headers : authorization,x-first-password,x-second-password,x-username\naccess-control-request-method : POST\n}

heres my full channel.dart

import 'package:baschack/baschack.dart';
import 'package:baschack/controllers/cards_controller.dart';
import 'package:baschack/controllers/cards_subdomain_controller.dart';
import 'package:baschack/controllers/confirm_controller.dart';
import 'package:baschack/controllers/double_password_controller.dart';
import 'package:baschack/controllers/register_shop_controller.dart';
import 'package:baschack/controllers/register_shopper_controller.dart';
import 'package:baschack/controllers/user_controller.dart';
import 'package:baschack/models/config.dart';
import 'package:baschack/models/user.dart';
import 'package:conduit/managed_auth.dart';
import 'package:mailer/smtp_server.dart';

/// This type initializes an application.
///
/// Override methods in this class to set up routes and initialize services like
/// database connections. See http://conduit.io/docs/http/channel/.
class BaschackChannel extends ApplicationChannel {
  /// Initialize services in this method.
  ///
  /// Implement this method to initialize services, read values from [options]
  /// and any other initialization required before constructing [entryPoint].
  ///
  /// This method is invoked prior to [entryPoint] being accessed.
  ManagedContext? context;
  AuthServer? authServer;
  Config? config;
  SmtpServer? smtp;
  @override
  Future prepare() async {
    logger.onRecord.listen(
        (rec) => print("$rec ${rec.error ?? ""} ${rec.stackTrace ?? ""}"));
    config = Config(options!.configurationFilePath!);
    CORSPolicy.defaultPolicy.allowedOrigins = ["*"];
    CORSPolicy.defaultPolicy.allowedRequestHeaders = ["*"];
    CORSPolicy.defaultPolicy.exposedResponseHeaders = ["*"];
    final dataModel = ManagedDataModel.fromCurrentMirrorSystem();
    final store = PostgreSQLPersistentStore.fromConnectionInfo(
      config!.database!.username, 
      config!.database!.password!, 
      config!.database!.host, 
      config!.database!.port, 
      config!.database!.dbName);
    context = ManagedContext(dataModel, store);

    final authStorage = ManagedAuthDelegate<User>(context);
    authServer = AuthServer(authStorage);
    smtp = gmail(config!.smtp!.username!, config!.smtp!.password!);
  }

  /// Construct the request channel.
  ///
  /// Return an instance of some [Controller] that will be the initial receiver
  /// of all [Request]s.
  ///
  /// This method is invoked after [prepare].
  @override
  Controller get entryPoint {
    final router = Router();

    // Prefer to use `link` instead of `linkFunction`.
    // See: https://conduit.io/docs/http/request_controller/
    router.route("/example").linkFunction((request) async {
      return Response.ok({"key": "value"});
    });
    router.route('/register-shop').link(() => RegisterShopController(context!, authServer!, config!, smtp!));
    router.route('/register-shopper').link(() => RegisterShopperController(context!, config!, smtp!, authServer!)); 
    router.route('/confirm/:confirmation').link(() => ConfirmController(context!));
    router.route('/auth/token').link(() => DoublePasswordController(context!, authServer!))!.link(() => AuthController(authServer!));
    router.route('/user').link(() => Authorizer.bearer(authServer!))!.link(() => UserController(context!));
    router.route('/cards').link(() => Authorizer.bearer(authServer!))!.link(() => CardsController(context!));
    router.route('/cards-subdomain/:subdomain').link(() => CardsSubdomainController(context!));
    return router;
  }
}

and the doublepassword controller

import 'package:baschack/models/user.dart';
import 'package:conduit/conduit.dart';
class DoublePasswordController extends Controller {
  final ManagedContext context;
  final AuthServer authServer;
  DoublePasswordController(this.context, this.authServer);

  @override
  Future<RequestOrResponse> handle(Request request) async {
    final userQuery = Query<User>(context)..where((u) => u.username).equalTo(request.raw.headers.value('username')!);
    final user = await userQuery.fetchOne();
    if (user!.firstPassword == authServer.hashPassword(request.raw.headers.value('first-password')!, user.salt!) && (user.lock == null || user.lock!.isAfter(DateTime.now()))) {
      if (user.hashedPassword == authServer.hashPassword(request.raw.headers.value('second-password')!, user.salt!)) {
        return request;
      } else {
        final timelockUserQuery = Query<User>(context)..where((i) => i.id).equalTo(user.id)..values.lock = DateTime.now().add(const Duration(hours: 1));
        await timelockUserQuery.updateOne();
      }
    } 
    return Response.badRequest(body: {
      "error": "invalid credentials or account is still locked for one hour"
    });
  }
}

[BUG] conduit build

Error on conduit build.

To Reproduce
Steps to reproduce the behavior:

  1. run conduit build

Fetching dependencies (--offline --no-precompile)...
Finished fetching dependencies.
Compiling...
*** Uncaught error
Bad state: Bad state: 'dart2native' failed with the following message: Could not find a command named "compilie".

  • OS: Linux/Debian

[BUG] Uncaught error thrown when debugging `conduit.dart create list-templates`

Describe the bug

Whenever trying to debug conduit.dart (packages/conduit/bin/conduit.dart) using IntelliJ and run it with create list-templates arguments I get the following stacktrace.

-- Conduit CLI Version: 3.1.2
*** Uncaught error
    Bad state: No element
  **** Stacktrace
  * #0      ListMixin.firstWhere (dart:collection/list.dart:167:5)
  * #1      CLIConduitGlobal.conduitPackageRef (package:conduit/src/cli/commands/create.dart:388:10)
  * #2      CLIConduitGlobal.templateDirectory (package:conduit/src/cli/commands/create.dart:393:12)
  * #3      CLITemplateList.handle (package:conduit/src/cli/commands/create.dart:341:53)
  * #4      CLICommand.process (package:conduit/src/cli/command.dart:219:20)
  * <asynchronous suspension>
  * #5      main (file:///Users/mos/IdeaProjects/Work/conduit/packages/conduit/bin/conduit.dart:9:14)
  * <asynchronous suspension>
  ****

To Reproduce
Steps to reproduce the behavior:

  1. Clone master
  2. Open project on IntelliJ
  3. Setup run configuration to debug conduit.dart
  4. Click button to start debugging
  5. Uncaught error will be thrown

I have not globally activated conduit so the getter for conduitPackageRef returns null

Expected behavior

I should be able to debug conduit.dart without errors and should conduit not have been installed globally, then the templates would be found in the cloned conduit repo.

Desktop (please complete the following information):

  • OS: [e.g. iOS] MacOS 12.2

Rethink the name "conduit"

Hello,
Sorry if this has already been discussed, I haven't been in any discussion regarding this project.
But as someone from the outside, I'm wondering if "Conduit" is a good name for this project. A quick google search gave these other software projects with the same name:

So it might be unfortunate for search engine optimization and possible confusion with the other conduit framework.

[Feature] Watch mode

Is your feature request related to a problem? Please describe.
During development I'm constantly stopping and restarting the server.

Describe the solution you'd like
A watch mode, e.g. conduit serve --watch, that recursively watches all Dart files in the current directory and subdirectories and restarts the server when any of them change.

Describe alternatives you've considered
I may end up using a command-line tool from some other ecosystem (like Node) to watch files and restart the process.

Additional context
I'm a Dart newbie, I may be missing something obvious.

Unable to build to exe

Describe the bug
I cannot compile the source to exe using (dart compile exe SOURCE.dart)

To Reproduce
Steps to reproduce the behavior:

  1. dart create project
  2. Copy 'conduit: ^3.1.2' to pubspec.yaml
  3. Copy some code from document + add some route to resource controllers
  4. dart compile exe SOURCE.dart

Error

error: import of dart:mirrors is not supported in the current Dart runtime

Error: AOT compilation failed
Generating AOT snapshot failed!

Desktop:

  • OS: Windows 11 Pro
  • Dart SDK version: 2.17.5 (stable) (Tue Jun 21 11:05:10 2022 +0200) on "windows_x64"

[proposal] deployment process in CLI conduit app

Hi maintainers!

This is a proposal and after agreement, I can implement it in framework

I am a fan of CLI and Backend related Techs. As I saw in the documentation conduit provides some templates for deploying with Docker and Kubernetes and I am interested to make deployment operations (like creating docker files, services, Kubernetes objects, configs) automate in a simple and interesting way which provides config of famous CI/CD platforms (like GitHub actions).

Solution
We can handle this by adding a command to the CLI app called deploy and after that, we can manage and configure files based on settings provided in config.yaml.

For example like below:
First of all we config the operations in config.yaml:

# database setting and other ...
deploy:
  sdk_version: stable # version or channel
  platform: docker
  gen_env: .env # creates .env file spreatly for your env configs
  # by default .env contains database configs but you can add more like:
  env:
    - PAGINATION=15
    - HAS_CURL=true

After that, we start out operations

$ conduit deploy config # genrates deployment configs based on `config.yaml`
$ conduit deploy up # looks for associated files based on config and up the services

Generated docker file will be:

FROM dart:stable
# this is app name in pubspec.yaml
WORKDIR /conduit_test_server
ADD . /conduit_test_server
EXPOSE 80
# and so on for other configurations

Also, I can help you to manage and develop the framework CLI app and other parts, you can count on me guys! =))) I will be so happy to contribute with you on this great project!

Missing "conduit" command

Hi,

after

pub global activate conduit

I don't find command "conduit" under .pub-cache/bin .

I find only the dir ./.pub-cache/global_packages/conduit with this content

pdifeo@bcdevel conduit]$ ls -la
total 12
drwxrwxr-x. 3 pdifeo pdifeo 61 Apr 21 13:59 .
drwxrwxr-x. 4 pdifeo pdifeo 37 Apr 21 13:59 ..
drwxrwxr-x. 2 pdifeo pdifeo 33 Apr 21 13:59 .dart_tool
-rw-rw-r--. 1 pdifeo pdifeo 3478 Apr 22 10:28 .packages
-rw-rw-r--. 1 pdifeo pdifeo 6146 Apr 22 10:28 pubspec.lock

Dart SDK version: 2.12.3 (stable) (Wed Apr 14 11:02:39 2021 +0200) on "linux_x64"
CentOS Linux release 7.9.2009 (Core)

Can you help me ?
Regards
Pasquale

[BUG] Postgres 14 (14beta2) not supported by `conduit db upgrade`

Current postgres 14 beta is not supported by conduit db upgrade.

To Reproduce
Steps to reproduce the behavior:

  1. conduit create test

  2. Create simple model, therefore a controller and export them

model:

import 'package:conduit/conduit.dart';

class Hero extends ManagedObject<_Hero> implements _Hero {}

class _Hero {
  @primaryKey
  late int id;

  @Column(unique: true)
  late String name;
}

controller:


import 'package:conduit/conduit.dart';
import 'package:server/models/heroe.dart';

class HeroesController extends ResourceController {
  HeroesController(this.context);

  final ManagedContext context;

  @Operation.get()
  Future<Response> getAllHeroes() async {
    final heroQuery = Query<Hero>(context);
    final heroes = await heroQuery.fetch();

    return Response.ok(heroes);
  }
}

exporting:

/// server
///
/// A conduit web server.
library server;

export 'dart:async';
export 'dart:io';

export 'package:conduit/conduit.dart';

export 'channel.dart';
export 'controllers/heroe_controller.dart';
export 'models/heroe.dart';
  1. Create migration file with: conduit db generate

  2. Run postgres:14beta2 locally, e.G. docker run --name postgres14_test --rm -e POSTGRES_DB=test -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test -p 5432:5432 -d postgres:14beta2

  3. Run conduit db upgrade --connect postgres://test:test@localhost:5432/test

  4. See error:

-- Conduit CLI Version: 3.0.11
-- Conduit project version: 3.0.11
*** There was an error connecting to the database 'test:test@localhost:5432/test'. Reason: unable to connect to database.

Expected behavior

-- Conduit CLI Version: 3.0.11
-- Conduit project version: 3.0.11
-- Updating to version 2 on new database...
    PostgreSQL connecting, test@localhost:5432/test.
    Initializating database...
    	CREATE TABLE _conduit_version_pgsql (versionNumber INT NOT NULL UNIQUE,dateOfUpgrade TIMESTAMP NOT NULL)
    Applying migration version 1...
    Seeding data from migration version 1...
    Applied schema version 1 successfully.
    Applying migration version 2...
    	CREATE TABLE _Hero (id BIGSERIAL PRIMARY KEY,name TEXT NOT NULL UNIQUE)
    Seeding data from migration version 2...
    Applied schema version 2 successfully.

Desktop (please complete the following information):

  • OS: macOS BigSur 11.4

[FEATURE] Cannot change Relationship inverse of

When attempting to run 'conduit db generate' the following error was generated:

*** Cannot change Relationship inverse of '_Test.student'

On investigation the problem was that the user was trying to change a string column into a foreign key column.

It would appear that this is not supported by conduit at this point in time.

At the least we need to improve the error message so that it is more obvious what is wrong.

For the moment I've changed the message to:

*** Cannot change existing column '_Test.student' to  an inverse Relationship

If you see this error the work around is to do a two step migration.

  1. delete the existing column
    2 ) run conduit db generate
  2. add the column as a inverse relationship
  3. run conduit db generate.

[BUG] error when Isolates cannot be started up

Describe the bug

Inside the Application.start method, when there's a TimeoutException due to a failure to start an Isolate, the server will be stopped using this code:

    } catch (e, st) {
      logger.severe("$e", this, st);
      await stop().timeout(const Duration(seconds: 5));
      rethrow;
    }

This, however, fails on the call to stop() because of this error:

LateInitializationError: Field '_serverSendPort@884428277' has not been initialized.
#0      ApplicationIsolateSupervisor._serverSendPort (package:conduit/src/application/isolate_supervisor.dart)
#1      ApplicationIsolateSupervisor.stop (package:conduit/src/application/isolate_supervisor.dart:70:5)

To Reproduce

Run this code (and please tell me why does it fail to start up isolates??):

import 'dart:io';
import 'package:conduit/conduit.dart' as conduit;

void main() {
  runConduitServer(Platform.numberOfProcessors);
}

void runConduitServer(int cores) async {
  final app = conduit.Application<_StaticBenchmarkChannel>()
    ..options.address = InternetAddress.anyIPv6
    ..options.port = 8080;

  await app.start(numberOfInstances: cores);
}

class _StaticBenchmarkChannel extends conduit.ApplicationChannel {
  @override
  conduit.Controller get entryPoint {
    final router = conduit.Router();

    router
        .route("/")
        .linkFunction((request) async => conduit.Response.ok('Hello World!\n'));

    return router;
  }
}

Expected behavior

This exception should not occur even when an Isolate fails to start (why it failed to start is a separate problem... it might be due to the fact I have no config file? Should I file a separate bug for reporting that, if so?).

It would be very good to have roadmap

The Conduit project is awesome! It is very big deal for whole dart community and it can make the dart the most convinience platform for fast development of client-server applications and microservices.

I am thinking to try it in a startup but I don't know perspectives of Conduit and it is hard to make the decision.

To make the Conduit project living and growing it would be good to write and publish annual roadmap file and per-month roadmap. It will show the main purposes of the project, its progress. So more developers will be using the Conduit in their projects and more developers will be contributing to such stable and perspective project.

Very good per-month roadmaps has Vscode project:
microsoft/vscode#136630
And their annual roadmaps are also perfect: https://github.com/microsoft/vscode/wiki/Roadmap

Review orm fields types options ? or late.

With nnbd any orm class is going to have to declare every field as either nullable or late.

We need to review this and make recommendations as which way to proceed.

late would be nicer for fields where the underlying db file is not nullable.

[BUG] conduit create not working on Windows

Describe the bug
When trying to use conduit from PowerShell 7.2.4 on Windows 11, the "create" method does not seem to work out of the box. (I assume some sort of path issue, as always when trying to code on Windows.)

Here's the console output:

PS D:\Home\Git> conduit create waid_server
-- Conduit CLI Version: 3.1.2
*** No template at .

I wasn't bothering much with trying to fix it, as I could simply install conduit in my Ubuntu on Bash on Windows and create the project from within that, but that should be looked into at some point, I think.

[Feature] Change Serializable.asMap return type

I stumbled over the return type of the Serializable.asMap() method. It's Map<String?, dynamic> instead of Map<String, dynamic>. I see no reason why the key of that map can be null and would suggest to change it.

[BUG] overriding ManagedObject.documentSchema doesn't change the openapi document

I followed the steps for the authentication setup. That works fine but in the generated documentation file, the tokens are part of the User.

"User": {
  "title": "User",
  "type": "object",
  "properties": {
    "password": {
      "title": "password",
      "type": "string",
      "nullable": false,
      "writeOnly": true
    },
    "id": {
      "title": "id",
      "type": "integer",
      "description": "This is the primary identifier for this object.\n",
      "nullable": false
    },
    "username": {
      "title": "username",
      "type": "string",
      "description": "No two objects may have the same value for this field.\n",
      "nullable": false
    },
    "tokens": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/ManagedAuthToken"
      },
      "nullable": true,
      "readOnly": true
    }
  },
  "description": ""
},

So I wanted hide it by overriding the documentSchema method like this:

class User extends ManagedObject<_User> implements _User, ManagedAuthResourceOwner<_User> {
 
  @Serialize(input: true, output: false)
  String? password;

  @override
  APISchemaObject documentSchema(APIDocumentContext context) {
    final schema = super.documentSchema(context);
    schema.properties!.remove('tokens');
    return schema;
  }
}

But this doesn't change anything in the generated openapi file. Even returning APISchemaObject.empty() doesn't change anything.

[BUG] Connection to postgres 13 with ssl enabled fails.

If postgres has ssl enabled (which apparent aws systems have by default) then conduit will fail to connect.

This is apparently because the conduit postgres connector is using an old md5 hash method.

We need to resolve this as postgres ssl connections should work out of the box.

[BUG] QueryExpression w/ late field (and null safety) failed

How to issue a query expression (filtering) on a "late" field ?

On this data:

@Table(name: "data")
class _Data {
  @primaryKey   
   late int id;
  @Column()  
   late String key;
  @Column(nullable: true)   
   late String something_else;
}

this query:

var query = Query<Data>(context)
    ..where((p) => p.key).equalTo(the_key_i_want);
return await query.fetch();

yields to:

type 'Null' is not a subtype of type 'String' #0

due to the fact that p.key is null at the time of the request.
I tried to set key column as nullable.
It is worth to mention that inserting data and fetching w/o query expression are OK.

Thanks for any input !

Can't even get started with conduit create [BUG]

Listing Templates

% conduit create list-templates

Results in:

-- Conduit CLI Version: 3.0.11
*** Uncaught error
    Bad state: No element
  **** Stacktrace
  * #0      ListMixin.firstWhere (dart:collection/list.dart:167:5)
  * #1      CLIConduitGlobal.conduitPackageRef (package:conduit/src/cli/commands/create.dart:388:10)
  * #2      CLIConduitGlobal.templateDirectory (package:conduit/src/cli/commands/create.dart:393:12)
  * #3      CLITemplateList.handle (package:conduit/src/cli/commands/create.dart:341:53)
  * #4      CLICommand.process (package:conduit/src/cli/command.dart:219:20)
  * <asynchronous suspension>
  * #5      main (file:///Users/kodemunki/Development/flutter/.pub-cache/hosted/pub.dartlang.org/conduit-3.0.11/bin/conduit.dart:9:14)
  * <asynchronous suspension>
  ****

Creating Project

% conduit create -t db restapi

Results in:

-- Conduit CLI Version: 3.0.11
*** Uncaught error
    Bad state: No element
  **** Stacktrace
  * #0      ListMixin.firstWhere (dart:collection/list.dart:167:5)
  * #1      CLIConduitGlobal.conduitPackageRef (package:conduit/src/cli/commands/create.dart:388:10)
  * #2      CLIConduitGlobal.templateDirectory (package:conduit/src/cli/commands/create.dart:393:12)
  * #3      CLIConduitGlobal.getTemplateLocation (package:conduit/src/cli/commands/create.dart:397:12)
  * #4      CLITemplateCreator.handle (package:conduit/src/cli/commands/create.dart:52:27)
  * #5      CLICommand.process (package:conduit/src/cli/command.dart:219:20)
  * <asynchronous suspension>
  * #6      main (file:///Users/kodemunki/Development/flutter/.pub-cache/hosted/pub.dartlang.org/conduit-3.0.11/bin/conduit.dart:9:14)
  * <asynchronous suspension>
  ****

Desktop

  • OS: macOS (Big Sur) 11.2 (20D64)
  • dart: Dart SDK version: 2.13.3 (stable) (Wed Jun 9 12:44:44 2021 +0200) on "macos_x64"
  • flutter: Flutter 2.2.2 • channel stable • https://github.com/flutter/flutter.git Framework • revision d79295af24 (3 weeks ago) • 2021-06-11 08:56:01 -0700 Engine • revision 91c9fc8fe0
  • zshrc: export PATH="$PATH:$HOME/Development/flutter/bin" export PATH="$PATH":"$HOME/.pub-cache/bin" export PATH="$PATH":"$HOME/Development/flutter/.pub-cache/bin"

"fresh" or "rebuild" option for "conduit db"

Hi guys,

first of all: Nice job! I love it :-)

However, I am facing the problem that when developing an API using Conduit, I often have to update my models/add new ones etc. This usually would lead into tons of unnecessary migrations files. At the moment, I remove the initial migration file by hand and create a new one using conduit db generate (This, by the way, also removes all seeds, which I also have to copy by hand). Then I drop the db-tables and re-run the upgrade-command.

To avoid this, it would be nice to have a command to re-create the initial migration file. In addition, it would also be helpful to have an option for "conduit db upgrade" to drop all tables from DB first and then apply the migration files (something like '--fresh'?).

Or is there already a solution I did not found yet?

Best regards,
Tobi

[BUG] PORT NUMBER DOESNT CHANCE

here's my main.dart

import 'package:gladiators/gladiators.dart';
import 'package:args/args.dart';
Future main() async {
    // var parser = ArgParser();
    // parser.addOption('publica-clavis');
    // parser.addOption('bootnode');
    // parser.addOption('max-pares', defaultsTo: '50');
    // parser.addOption('p2p-portus', defaultsTo: '5151');
    // parser.addOption('rpc-portus', defaultsTo: '1515');
    // parser.addOption('internum-ip', mandatory: true);
    // parser.addOption('external-ip', mandatory: true);
    // parser.addOption('novus', help: 'Do you want to start a new chain?', mandatory: true);
    // parser.addOption('directory', help: 'where should we save the blocks', mandatory: true);

  final app = Application<GladiatorsChannel>()
    ..options.port = 1515
    ..options.configurationFilePath = "config.yaml";

  await app.startOnCurrentIsolate();

  print("Application started on port: ${app.options.port}.");
  print("Use Ctrl-C (SIGINT) to stop running the application.");
}

but as soon as i run conduit serve it launches on 8888

conduit version Conduit CLI version: 3.1.2

[BUG] Can't return `null` from linkFunction when upgrading to WebSocket

Describe the bug
Because of null safety, the return type of linkFunction handler is Future<Response>?, so null can't be returned from it, but when upgrading to a websocket, null should be returned as there is no response

To Reproduce
Steps to reproduce the behavior:

router
  .route("/connect")
  .linkFunction((request) async {
    var socket = await WebSocketTransformer.upgrade(request.raw);
    socket.listen(listener);

    return null; // This is not allowed
  });

Expected behavior
Should be able to return null.

JWT with Auth0

I want to authenticate with JWT, is there any tutorial or example on how I can integrate Conduit with JWT tokens?

I intend to use https://auth.com/ to generate the tokens, but I know how you are going to validate these tokens on the server, is there any possible way to use external users?

[BUG] conduit create heroes fails on windows

Describe the bug
When conduit create heroes is run on windows the following stack trace is generated:

The problem appears to be with the pub-cache package as it assumes that pub cache is under APPDATA when on most windows systems it is actually on LOCALAPPDATA.

This issues describes the problem:

google/pub_cache#40

The work around is to set the environment variable PUB_CACHE to C:\Users\USER\AppData\Local\Pub\Cache

[BUG] The getter 'haveAtLeastOneWhere' isn't defined

Describe the bug
So I was trying to use the ORM and add relationships between models using this documentation.
I have the below models:

subject.dart

class Subject extends ManagedObject<_Subject> implements _Subject {}

class _Subject {
  @primaryKey
  int? id;

  @Column(nullable: false)
  String? name;

  ManagedSet<SubjectUnit>? subjectUnits;
}

subject_unit.dart

class SubjectUnit extends ManagedObject<_SubjectUnit> implements _SubjectUnit {}

class _SubjectUnit {
  @primaryKey
  int? id;

  @Relate(#subjectUnits)
  Unit? unit;

  @Relate(#subjectUnits)
  Subject? subject;
}

Now basically, I was trying to make a join statement like below:

final subjectQuery = Query<Subject>(context)
      ..where((h) => h.subjectUnits?.haveAtLeastOneWhere.unit.id)
          .equalTo(unitId)
      ..join(set: (u) => u.subjectUnits);

But when I try to do this, I get the error: The getter 'haveAtLeastOneWhere' isn't defined for the type 'ManagedSet<SubjectUnit>'.
I thought I was following the docs properly, but did I miss something here perhaps?

WebSocket upgrade not working

When trying to upgrade HTTP connection to WebSocket, the following exception is thrown:

[SEVERE] conduit: Failed to send response, draining request. Reason: Bad state: Header already sent

To Reproduce

  1. ResourceController handler in conduit
    final httpRequest = request?.raw;
    if (httpRequest == null) {
      return Response(400, {}, null); //400 - bad request
    }
    _socket = await WebSocketTransformer.upgrade(httpRequest);
    int counter = 0;
    Stream.periodic(const Duration(seconds: 1)).take(5).listen((event) {
      counter += 1;
      _socket?.add('message ${counter}');
    });

/// the doc says:
/// It's important that a request that is upgraded to a websocket is removed from the channel 
/// by returning null from the controller. 
    return null;
  1. Client flutter web application invokes
    final socket = WebSocketChannel.connect(Uri.parse('ws://localhost:8888/something'));

Expected behavior
Upgrade to websocket and send 5 messages to the client

How can I get the refresh token?

Just finished the Conduit tutorial. There is a question. There is no 'refresh_token' within the /auth/token response. How can I enable this field ? No clue from the tutorial.

Thx for help.

[BUG] Fix documentation issues

First of all thanks for this great framework

Describe the bug
Documentation is great, extremely well documented but it has some issues:

  • Some links are broken (404) specially links that points to github. i.e https://github.com/conduit.dart/tour-of-heroes-dart and http://conduit-tutorial.conduit.dart.io/
  • Sometimes when changing between sections in the gitbook itself it shows an error page saying: "Something went wrong" forcing to click reload button to be able to load the page.
  • In the section Deploying a Conduit Application refers to a project different than the one that was used in the whole tutorial. I mean the tutorial is based in the heroes project with its database configurations and its logic, then suddenly this section of deploying refers to the quiz project.

[BUG] Postgresql Builder Column with cast operator incomplete

Cannot cast to the column type - cast operator is incomplete
When the variable/parameter of a column is build, it concatenate a suffix type using only one colon ':' prevent to cast to proper type.
The correct syntax in PostgreSQL is with two colons '::'

To Reproduce

  • I'm using conduit 3.1.2 with a legacy database in PostgreSQL 10.

    • This database has a specific notation modeling on
      • table names, indexes, constraints
      • PostgreSQL schemas,
      • composite keys etc.
  • I made a Data class from one of its table, in specific schema

    • I had to set @Table(name='myschema.mytable')
  • I list all of the records from the table.

  • The problem shows when I try to list just one record by his id

  • Depuring with VsCode, I finded:

    • the method sqlTypeSuffix
    • from ColumnBuilder class
    • in file ~/.pub-cache/hosted/pub.dartlang.org/conduit-3.1.2/lib/src/db/postgresql/builders/column.dart
  • I apply this fix on line 131: return ":$type"; -> return "::$type";

Expected behavior

  • Get just one record by his id

Screenshots

  • None

Desktop (please complete the following information):

  • OS: Fedora 35
  • Browser: Chrome
    • Version 103.0.5060.114
  • VsCode 1.69.1
    • with Dart Plugin v3.44.0

Broken links within README

Describe the bug

The hyperlinks for 'Install Dart' and 'Our main docs live here' do not work

To Reproduce
Steps to reproduce the behavior:

  1. Go to README for the project
  2. Click on both hyperlinks
  3. Neither will load the proper webpage

Expected behavior

The correct web pages are displayed

[Feature] @Column() naming convention should be improved

Is your feature request related to a problem? Please describe.

Currently the naming conventions used when creating a column from a model property after conduit db upgrade is not camelCase nor snake_case it's in fact the property's name toLowerCase(). Lets say we have this model:

@Table(name: 'venue')
class _Venue {
  @primaryKey int id;
  String name;
  @Column(nullable: true) String? shortDescription;
}

Here the shortDescription is a two words property so for better reading and understanding the expected column name should be camelCase -> shortDescription or snake_case -> short_description, but instead the column name ends up being the two words in lower case with no separation.

Describe the solution you'd like

In Postgres documentation the naming convention used is snake_case so maybe this should be the default one.

Anyway in order to be impartial on this matter, maybe the best way for naming columns after a model property should be using the same name used in the property... so if developer uses camelCase on his model properties then columns should be named using camelCase if developer uses snake_case for properties the same should be used for columns... just mirroring the property name to the column name.

In addition the developer should be able to name table columns with a naming convention different than model properties.
For instance using the same sample from above:

@Table(name: 'venue')
class _Venue {
  @primaryKey int id;
  String name;
  @Column(name: 'short_description', nullable: true) String? shortDescription;
}

The same way @Table() allows to set a custom name @Column() should allow the same.

[BUG] Dart 2.17.0 enhanced enums breaks conduit ORM for conduit build

Incredible work so far with the project. I implemented enhanced enums and discovered this reproducible error when using my postgresql database.

"conduit build" WILL work in these circumstances:

  • Create a model
  • Link a function without database connectivity

"conduit build" WILL NOT work in this circumstance:

  • Creation of a database model with various GET and POST request handling

To Reproduce
Steps to reproduce the behavior:

  1. Create a sample enum
enum SampleEnum {
  one,
  two,
  three,
  four,
  five,
  six,
  seven;

  static SampleEnum parse(String value) {
    switch (value) {
      case 'one':
        return SampleEnum.one;
      case 'two':
        return SampleEnum.two;
      case 'three':
        return SampleEnum.three;
      case 'four':
        return SampleEnum.four;
      case 'five':
        return SampleEnum.five;
      case 'six':
        return SampleEnum.six;
      case 'seven':
        return SampleEnum.seven;
      default:
        throw Exception('Unknown enum value: $value');
    }
  }

  @override
  String toString() {
    switch (this) {
      case SampleEnum.one:
        return 'one';
      case SampleEnum.two:
        return 'two';
      case SampleEnum.three:
        return 'three';
      case SampleEnum.four:
        return 'four';
      case SampleEnum.five:
        return 'five';
      case SampleEnum.six:
        return 'six';
      case SampleEnum.seven:
        return 'seven';
    }
  }
}
  1. Create a test model
import 'package:conduit/conduit.dart';
import 'package:conduit_bug/sample_enum.dart';

class TestModel extends ManagedObject<_TestModel> implements _TestModel {}

@Table(name: "Tests")
class _TestModel {
  @primaryKey
  int? id;
  SampleEnum? testValue;
}
  1. Create a test controller
import 'package:conduit/conduit.dart';
import 'package:conduit_bug/sample_enum.dart';
import 'package:conduit_bug/test_model.model.dart';

class TestController extends ResourceController {
  TestController(this.context);

  final ManagedContext context;

  @Operation.get()
  Future<Response> getAll() async {
    final query = Query<TestModel>(context);

    final results = await query.fetch();

    return Response.ok(results);
  }

  @Operation.post()
  Future<Response> handleCreation() async {
    if (request != null) {
      final Map<String, dynamic> map = request!.body.as<Map<String, dynamic>>();

      final query = Query<TestModel>(context)
        ..values.testValue = SampleEnum.parse(map['value'] as String? ?? "");

      final result = await query.insert();

      print("Object ${result.id} created");
      return Response.ok(result);
    } else {
      logger.log(Level.WARNING, 'Invalid request received');
      return Response.badRequest(body: {"error": "request is invalid"});
    }
  }
}
  1. Update the channel
import 'package:conduit_bug/conduit_bug.dart';
import 'package:conduit_bug/sample_enum.dart';
import 'package:conduit_bug/test_controller.dart';

class ConduitBugChannel extends ApplicationChannel {
  late ManagedContext context;
  @override
  Future prepare() async {
    print("Application started on port: ${options!.port}.");

    logger.onRecord.listen(
        (rec) => print("$rec ${rec.error ?? ""} ${rec.stackTrace ?? ""}"));

    final persistentStore = PostgreSQLPersistentStore.fromConnectionInfo(
      "postgres",
      "",
      "localhost",
      5432,
      "bug_submission",
    );

    context = ManagedContext(
        ManagedDataModel.fromCurrentMirrorSystem(), persistentStore);
  }

  @override
  Controller get entryPoint {
    final router = Router();

    router.route("handle").link(() => TestController(context));

    return router;
  }
}
  1. Execute conduit build
conduit build

Expected behavior
AOT compilation is expected to compile successfully

Output

➜ conduit_bug conduit build
-- Conduit CLI Version: 3.1.2
-- Conduit project version: 3.1.2
Resolving ASTs...
Generating runtime...
Generated runtime at 'file:///..../conduit_bug/build/generated_runtime/'.
Compiling package 'conduit_runtime'...
Package 'conduit_runtime' compiled to 'file:///...../conduit_bug/build/packages/conduit_runtime/'.
Compiling package 'conduit'...
Package 'conduit' compiled to 'file:///...../conduit_bug/build/packages/conduit/'.
Compiling package 'conduit_config'...
Package 'conduit_config' compiled to 'file:///...../conduit_bug/build/packages/conduit_config/'.
Copying application package (from 'file:///...../conduit_bug/')...
Application packaged copied to 'file:///....../conduit_bug/build/packages/conduit_bug/'.
Fetching dependencies (--offline --no-precompile)...
Finished fetching dependencies.
Compiling...
*** Uncaught error
Bad state: Bad state: 'dart2native' failed with the following message: Info: Compiling with sound null safety
../../generated_runtime/lib/src/testmodel.dart:31:53: Error: 'SampleEnum' isn't a type.
, 'testValue': ManagedAttributeDescription.make(entity, 'testValue',
^^^^^^^^^^
../../generated_runtime/lib/src/testmodel.dart:32:22: Error: 'SampleEnum' isn't a type.
ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}),
^^^^^^^^^^
../../generated_runtime/lib/src/testmodel.dart:43:46: Error: 'SampleEnum' isn't a type.
final state = v.compile(ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}), relationshipInverseType: null);
^^^^^^^^^^
../../generated_runtime/lib/src/testmodel.dart:32:76: Error: The getter 'one' isn't defined for the class 'ManagedEntityRuntimeImpl'.

  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'one'.
    ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}),
    ^^^
    ../../generated_runtime/lib/src/testmodel.dart:32:87: Error: The getter 'two' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'two'.
    ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}),
    ^^^
    ../../generated_runtime/lib/src/testmodel.dart:32:100: Error: The getter 'three' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'three'.
    ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}),
    ^^^^^
    ../../generated_runtime/lib/src/testmodel.dart:32:114: Error: The getter 'four' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'four'.
    ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}),
    ^^^^
    ../../generated_runtime/lib/src/testmodel.dart:32:127: Error: The getter 'five' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'five'.
    ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}),
    ^^^^
    ../../generated_runtime/lib/src/testmodel.dart:32:139: Error: The getter 'six' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'six'.
    ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}),
    ^^^
    ../../generated_runtime/lib/src/testmodel.dart:32:152: Error: The getter 'seven' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'seven'.
    ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}),
    ^^^^^
    ../../generated_runtime/lib/src/testmodel.dart:42:27: Error: The getter 'one' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'one'.
    return [Validate.oneOf([one,two,three,four,five,six,seven])].map((v) {
    ^^^
    ../../generated_runtime/lib/src/testmodel.dart:42:31: Error: The getter 'two' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'two'.
    return [Validate.oneOf([one,two,three,four,five,six,seven])].map((v) {
    ^^^
    ../../generated_runtime/lib/src/testmodel.dart:42:35: Error: The getter 'three' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'three'.
    return [Validate.oneOf([one,two,three,four,five,six,seven])].map((v) {
    ^^^^^
    ../../generated_runtime/lib/src/testmodel.dart:42:41: Error: The getter 'four' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'four'.
    return [Validate.oneOf([one,two,three,four,five,six,seven])].map((v) {
    ^^^^
    ../../generated_runtime/lib/src/testmodel.dart:42:46: Error: The getter 'five' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'five'.
    return [Validate.oneOf([one,two,three,four,five,six,seven])].map((v) {
    ^^^^
    ../../generated_runtime/lib/src/testmodel.dart:42:51: Error: The getter 'six' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'six'.
    return [Validate.oneOf([one,two,three,four,five,six,seven])].map((v) {
    ^^^
    ../../generated_runtime/lib/src/testmodel.dart:42:55: Error: The getter 'seven' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'seven'.
    return [Validate.oneOf([one,two,three,four,five,six,seven])].map((v) {
    ^^^^^
    ../../generated_runtime/lib/src/testmodel.dart:43:100: Error: The getter 'one' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'one'.
    final state = v.compile(ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}), relationshipInverseType: null);
    ^^^
    ../../generated_runtime/lib/src/testmodel.dart:43:111: Error: The getter 'two' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'two'.
    final state = v.compile(ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}), relationshipInverseType: null);
    ^^^
    ../../generated_runtime/lib/src/testmodel.dart:43:124: Error: The getter 'three' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'three'.
    final state = v.compile(ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}), relationshipInverseType: null);
    ^^^^^
    ../../generated_runtime/lib/src/testmodel.dart:43:138: Error: The getter 'four' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'four'.
    final state = v.compile(ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}), relationshipInverseType: null);
    ^^^^
    ../../generated_runtime/lib/src/testmodel.dart:43:151: Error: The getter 'five' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'five'.
    final state = v.compile(ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}), relationshipInverseType: null);
    ^^^^
    ../../generated_runtime/lib/src/testmodel.dart:43:163: Error: The getter 'six' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'six'.
    final state = v.compile(ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}), relationshipInverseType: null);
    ^^^
    ../../generated_runtime/lib/src/testmodel.dart:43:176: Error: The getter 'seven' isn't defined for the class 'ManagedEntityRuntimeImpl'.
  • 'ManagedEntityRuntimeImpl' is from 'package:generated_runtime/src/testmodel.dart' ('../../generated_runtime/lib/src/testmodel.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'seven'.
    final state = v.compile(ManagedType.make(ManagedPropertyType.string, null, {'one': one,'two': two,'three': three,'four': four,'five': five,'six': six,'seven': seven}), relationshipInverseType: null);
    ^^^^^
    Error: AOT compilation failed
    Generating AOT kernel dill failed!

**** Stacktrace

  • #0 Build.compile (package:conduit_runtime/src/build.dart:150:7)
  • #1 Build.execute (package:conduit_runtime/src/build.dart:114:7)
  • #2 BuildExecutable.execute (data:application/dart:13:252)
  • #3 main (data:application/dart:9:18)

Desktop (please complete the following information):

Macbook M1
MacOs Monterey 12.3.1
Dart SDK version: 2.17.6 (stable) (Tue Jul 12 12:54:37 2022 +0200) on "macos_arm64"
Pubspec.yml

environment:
sdk: ">=2.17.0 <3.0.0"

dependencies:
conduit: ^3.0.0

dev_dependencies:
test: ^1.16.5
conduit_test: ^3.0.0

[BUG] conduit create reporting that it can't find conduit.

conduit create home

-- Conduit CLI Version: 2.0.0-b9
Template source is: /home/bsutton/.pub-cache/hosted/pub.dartlang.org/conduit-2.0.0-b9/templates/default/
See more templates with 'conduit create list-templates'
-- Copying template files to project directory (/home/bsutton/home)...
Copying contents of /home/bsutton/.pub-cache/hosted/pub.dartlang.org/conduit-2.0.0-b9/templates/default/.gitignore
Copying contents of /home/bsutton/.pub-cache/hosted/pub.dartlang.org/conduit-2.0.0-b9/templates/default/.travis.yml
Copying contents of /home/bsutton/.pub-cache/hosted/pub.dartlang.org/conduit-2.0.0-b9/templates/default/config.src.yaml
Copying contents of /home/bsutton/.pub-cache/hosted/pub.dartlang.org/conduit-2.0.0-b9/templates/default/analysis_options.yaml
Copying contents of /home/bsutton/.pub-cache/hosted/pub.dartlang.org/conduit-2.0.0-b9/templates/default/pubspec.yaml
Copying contents of /home/bsutton/.pub-cache/hosted/pub.dartlang.org/conduit-2.0.0-b9/templates/default/bin
Copying contents of /home/bsutton/.pub-cache/hosted/pub.dartlang.org/conduit-2.0.0-b9/templates/default/lib
Copying contents of /home/bsutton/.pub-cache/hosted/pub.dartlang.org/conduit-2.0.0-b9/templates/default/test
Copying contents of /home/bsutton/.pub-cache/hosted/pub.dartlang.org/conduit-2.0.0-b9/templates/default/README.md
Generating config.yaml from config.src.yaml.
*** We can't find conduit in the pub cache. Check that your PUB_CACHE is set correctly.

[FEATURE] Support changing column types when migrating a database

Is your feature request related to a problem? Please describe.
Assuming you have an existing database with a table backed by your Dart model: Changing the type of one of the properties of your model (ex. a int to double) will cause an error when trying to generate a database migration. The resulting error is: *** Cannot change type of '_Model.property'

Describe the solution you'd like
For simple conversions of datatypes like int to double should be supported. If there does not exist a conversion / casting option built in to both Dart and the Postgres engine, perhaps an override method (similar to onDelete or validators) can be used to allow the developer to provide their own conversion function.

Describe alternatives you've considered
The current "solution" is to drop the column using a migration and then add it back as the correct type. Obviously this incurs data loss unless you hand modify the migration files to temporarily store the data in a temporary table.

Additional context
N/A

[BUG] PostgreSQL tables from a different schema than public aren't found

Tables from a different schema than public aren't found
When define a table name with his specific schema, the framework cannot found the table in that schema, throwing an error

To Reproduce

  • I'm using conduit 3.1.2 with a legacy database in PostgreSQL 10.

    • This database has a specific notation modeling on
      • table names, indexes, constraints
      • PostgreSQL schemas,
      • composite keys etc.
  • I made a Data class from one of its table, in specific schema

    • I had to set @Table(name='myschema.mytable')
  • I list all of the records from the table.

  • The problem shows when I try to list just one record by his id

  • Depuring with VsCode, I finded:

    • the member defaultPrefix
    • from ColumnExpressionBuilder class
    • in file ~/.pub-cache/hosted/pub.dartlang.org/conduit-3.1.2/lib/src/db/postgresql/builders/expression.dart
  • I apply this fix on line 16:

String get defaultPrefix => "$prefix${table!.sqlTableReference}_" -> String get defaultPrefix => "$prefix${table!.sqlTableReference}_".replaceAll('.', '');

Expected behavior
Get just one record by his id

Screenshots

  • None

Desktop (please complete the following information):

  • OS: Fedora 35
  • Browser: Chrome
    • Version 103.0.5060.114
  • VsCode 1.69.1
    • with Dart Plugin v3.44.0

Self generated String as primarykey in ResourceOwnerTableDefenition

Hi i would like to override the id of the resourceownertabledefenition from an integer to a generated String is this possible?

class MyResource implements ResourceOwnerTableDefinition {
  @override
  String? hashedPassword;

  @override
  String? id;

  @override
  String? salt;

  @override
  ManagedSet<ManagedAuthToken>? tokens;

  @override
  String? username;

}

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.