lantern 0.0.4+1

  • Readme
  • Changelog
  • Installing
  • 65

Lantern 🔆 #

Firebase Cloud Firestore's data structure definition language and code generator. Lantern lights bright future of your project.

Features #

Definition Language #

Have you ever been confused sharing collections / document structure in team? Or forgetting the structure by your self?

No problem. Lantern is simple data structure definition language to write down your Firestore structure.

It's easy to lean, to read, to use.

collection users {
    document User {
        string name
        array<string> attributes
        timestamp lastLogined

        collection tweets {
            document Tweet {
                string body
                reference<Tweet> referring
            }
        }
    }
}

Code Generation Toolkit #

Is hard for you that writing both code for iOS and Android? Have you ever mistook spelling between source code and security rule?

Lantern has code generation toolkit. You can concentrate to using defined data structure. It can provide code for ...

Install #

$ pub global activate lantern

Usage #

$ lantern <your_definition_file>

Grammar #

collection #

collection nameOfCollection(autoId = true) {
    ...
}

collection must have name and just one document. Parameters are optional.

document #

document NameOfDocument(saveCreatedDate = true) {
    ...
}

document have name and parameters (optional). And have fields and collections in body.

Fields and Types #

    string                  name
    boolean                 isAdult
    integer                 level
    number                  score
    url                     blogUrl
    array<string>           appeals
    map                     history
    timestamp               birthday
    geopoint                lastUsedFrom
    enum {free, purchased}  memberRank
    reference<DocumentName> relatedDocument
    struct<DocumentName>    embeddedDocument
    struct { string a }     embeddedStruct
Lantern TypeFirestore TypeSwift TypeDart typeTypeScript Type
stringstringStringStringstring
booleanbooleanBoolboolboolean
integernumberIntintnumber
numbernumberDoubledoublenumber
urlstringURLUristring
array<T>array[T]List<T>[T]
mapmap[String : Any]Map<String, dynamic>{}
timestamptimestampTimestampTimestampTimestamp
geopointgeopointGeoPointGeoPointGeoPoint
reference<T>referenceDocument<T>TDocument (Document referencing class will be generated)DocumentRefernce
struct<T>mapT (T should be Codable)T (Document)T (Document)
filemap (file will be uploaded to Cloud Storage)FileStorageFileFile
enum{elements...}stringenum (enum classes will be generated)enum(enum classes will be generated)enum(const enum of string will be generated)
struct S {fields...}mapS (Codable class will be generated)SModel (Model class will be generated)S (interface will be generated)

0.0.4+1 #

  • Hotfix: to generate @Subcollections as field of Documents on TypeScript

0.0.4 #

  • Supports TypeScript code generation

0.0.3 #

  • Breaking change
    • Now generated Dart codes depend on flamingo
    • Lantern generates classes for flamingo's Document and Model.
    • Generated files are separated into each collection.
  • Supports enum{} and struct{}
    • enum{} will generate enum values.
    • struct{} will generate Codable/Model classes.

0.0.2 #

  • Omit Firestore rule file generation.
  • Supports file and struct<>
    • file expresses the file uploaded on Cloud Storage, based on File of Ballcap-iOS.
    • struct<> expressed the struct of specified Document.
  • Breaking changes of DocumentSnapshot returned from DocumentReference on generated Dart file.

0.0.1 #

  • Initial version, dart/swift/rule generating

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate lantern

2. Use it

The package has the following executables:


$ lantern

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  lantern: ^0.0.4+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:lantern/lantern.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
95
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health issues and suggestions

Document public APIs. (-1 points)

2 out of 2 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/generator/dart_generator.dart. (-1 points)

Analysis of lib/src/generator/dart_generator.dart reported 2 hints:

line 185 col 13: This function has a return type of 'Reference', but doesn't end with a return statement.

line 250 col 10: This function has a return type of 'String', but doesn't end with a return statement.

Fix lib/src/generator/swift_generator.dart. (-1 points)

Analysis of lib/src/generator/swift_generator.dart reported 2 hints:

line 15 col 10: This function has a return type of 'String', but doesn't end with a return statement.

line 62 col 10: This function has a return type of 'String', but doesn't end with a return statement.

Fix bin/main.dart. (-0.50 points)

Analysis of bin/main.dart reported 1 hint:

line 3 col 8: Unused import: 'package:args/args.dart'.

Fix additional 3 files with analysis or formatting issues. (-1.50 points)

Additional issues in the following files:

  • lib/lantern.dart (1 hint)
  • lib/src/generator/generator.dart (1 hint)
  • lib/src/generator/security_rules_generator.dart (1 hint)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (petitparser).

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and lantern.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
args ^1.5.2 1.5.2
code_builder ^3.2.0 3.2.1
collection ^1.14.12 1.14.12
dart_style ^1.3.3 1.3.3
petitparser ^2.4.0 2.4.0 3.0.0
Transitive dependencies
_fe_analyzer_shared 1.0.3
analyzer 0.39.4
async 2.4.0
built_collection 4.3.2
built_value 7.0.8
charcode 1.1.2
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
fixnum 0.10.11
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
matcher 0.12.6
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
path 1.6.4
pub_semver 1.4.2
quiver 2.1.2+1
source_span 1.6.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+13
yaml 2.2.0
Dev dependencies
pedantic ^1.8.0 1.9.0
test ^1.6.0