appwrite / sdk-for-dart

[READ-ONLY] Official Appwrite Dart SDK πŸ’™
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
113 stars 17 forks source link

Why are parameters not strongly typed ? #13

Closed orevial closed 1 year ago

orevial commented 2 years ago

πŸ‘Ÿ Reproduction steps

Not really a bug but I was wondering if there was a specific reason to not add strongly typing to all services parameters ?

Examples for database service :

Future<models.DocumentList> listDocuments(
      {required String collectionId,
      List? filters,
      int? limit,
      int? offset,
      String? orderField,
      String? orderType,
      String? orderCast,
      String? search})

where filters list is not typed, or :

Future<models.Document> createDocument(
      {required String collectionId,
      required Map data,
      List? read,
      List? write,
      String? parentDocument,
      String? parentProperty,
      String? parentPropertyType})

where data, read and write are not typed either.

Same goes for certain responses that simply return a Response or sometimes just an untyped Future.

This makes the SDK really hard to use as we have to always refer to the documentation and hope that stuff we are looking for is defined there.

πŸ‘ Expected behavior

As a developer, I would expect following typing for examples above:

Future<models.DocumentList> listDocuments(
      {required String collectionId,
      List<Filter>? filters,
      int? limit,
      int? offset,
      String? orderField,
      String? orderType,
      String? orderCast,
      String? search})

where filters list is not typed, or :

Future<models.Document> createDocument(
      {required String collectionId,
      required Map<String, dynamic> data,
      List<Rule>? read,
      List<Rule>? write,
      String? parentDocument,
      String? parentProperty,
      String? parentPropertyType})

πŸ‘Ž Actual Behavior

Many methods are not strongly typed as explained in introduction.

🎲 Appwrite version

Different version (specify in environment)

πŸ’» Operating system

MacOS

🧱 Your Environment

Tested on AppWrite 0.11.0 with following Dart packages:

(similar problems for Dart or Flutter package).

πŸ‘€ Have you spent some time to check if this issue has been raised before?

🏒 Have you read the Code of Conduct?

eldadfux commented 2 years ago

The new Dart SDK with structured response models is now available: https://dev.to/appwrite/announcing-appwrite-dart-sdk-20-50a1

Strong typed DB filters will be introduced with the release of Appwrite 0.12

lohanidamodar commented 2 years ago

@orevial Thank you for your issue. We are aware of this. As our SDKs are generated using Swagger specs using our sdk-generator, there are certain limitations at the moment. But we are working to improve typing for Map and List param as well

TheMaverickProgrammer commented 1 year ago

How is this going? I second this ticket.

lohanidamodar commented 1 year ago

@orevial @TheMaverickProgrammer Most of the issues have already been resolved in the latest version of the SDK. If you still find some params missing proper type definition (except the data attribute in the createDocument method for now), please let us know and we will try to resolve it as soon as possible. Thank you.

lohanidamodar commented 1 year ago

Closing this issue as it should already be resolved. If you still have the issues feel free to reopen.