lantern 0.0.6+3

  • Readme
  • Changelog
  • Installing
  • 66

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 Rank {free, purchased} memberRank
    enum<Rank>                  anotherRank
    reference<DocumentName>     relatedDocument
    struct<DocumentName>        embeddedDocument
    struct S { string a }       embeddedStruct
Lantern TypeFirestore TypeSwift TypeDart typeTypeScript Type
mapmap[String : Any]Map<String, dynamic>{}
reference<T>referenceDocumentReference (T will be omitted)DocumentRefernce (T will be omitted)DocumentRefernce (T will be omitted)
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)
enum<T>stringT (T should be enum)T (T should be enum)T (T should be enum)
struct S {fields...}mapS (Codable class will be generated)SModel (Model class will be generated)S (interface will be generated)

0.0.6+3 #

  • Hotfix: fix mistake that DocumentSnapshot and DocumentReference.

0.0.6+2 #

  • Hotfix: fix mistake that type parameters of reference is not optional.
    • Now, type parameter of reference is optional.

0.0.6+1 #

  • Hotfix: fix mistake that enum referencing type field is not supported.

0.0.6 #

  • Support enum referencing enum<T> type.

0.0.5 #

  • Allow nulls of Document parameters on Dart.

0.0.4+4 #

0.0.4+3 #

  • Hotfix: to separate schema class and model class of Struct on Dart

0.0.4+2 #

  • Hotfix: fixing runtime errors when you save the Document contains nullable enum field.

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:

  lantern: ^0.0.6+3

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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6

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 202 col 13: This function has a return type of 'Reference', but doesn't end with a return statement.

line 271 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 17 col 10: This function has a return type of 'String', but doesn't end with a return statement.

line 66 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 lib/src/generator/security_rules_generator.dart. (-0.50 points)

Analysis of lib/src/generator/security_rules_generator.dart reported 1 hint:

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

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/

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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
args ^1.6.0 1.6.0
code_builder ^3.2.1 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.2
Transitive dependencies
_fe_analyzer_shared 2.0.0
analyzer 0.39.5
async 2.4.1
built_collection 4.3.2
built_value 7.0.9
charcode 1.1.3
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.9.3
path 1.6.4
pub_semver 1.4.4
quiver 2.1.3
source_span 1.7.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+14
yaml 2.2.0
Dev dependencies
pedantic ^1.9.0 1.9.0
test ^1.14.2