Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Brian Blanchard
@briblanch
Yeah that was it. Dang, sorry about that
And thanks for the help
Anatoly Pulyaevskiy
@pulyaevskiy
no problem, glad it works now!
Paul DeMarco
@pauldemarco
@pulyaevskiy thanks again for the awesome library! Do you have any advice for the pain of having to deploy every time in order to test? I need some faster iteration...
I guess my question is.. does there exist any libs out there to mock Database calls, etc
Anatoly Pulyaevskiy
@pulyaevskiy
Hey @pauldemarco ! I very simple hack I had is to create some regular main scripts (e.g. node/my_test.dart) and invoke my app's logic there. You can compile those files as usual and run with node build/node/my_test.dart.js. This does not cover the Cloud Functions part of things but that's low risk comparing to the rest of the app code. You can even convert those files to real Dart tests and run with pub run test.
Paul DeMarco
@pauldemarco
@pulyaevskiy Ok very cool. thanks again
Anatoly Pulyaevskiy
@pulyaevskiy
No problem. As for mock libs - I'm not aware if there are any, unfortunately.
Ghost
@ghost~5c13de90d73408ce4fb1f4ae
is there any released app which is using dart for running Firebase Functions?
Anatoly Pulyaevskiy
@pulyaevskiy
I’m not aware of any particular, but quite a few people are using it. Would love to learn about some apps out there though!
Paul DeMarco
@pauldemarco
What's a typical size when deploying? (I'm seeing a bundle of about 79 MB)
Paul DeMarco
@pauldemarco
Where does FCM fit into this?
Ahh i see, there's firebase_admin_interop package
Paul DeMarco
@pauldemarco
So i switched back to a nodejs pure project, with typescript, and man do I miss Dart
I would love to just continue ahead with Dart and firebase_functions_interop, but I'm worried I'll run into a situation where a JS library exists and a Dart library does not
I'm curious that if I reach that point, is it possible to interface to that JS library from Dart, and if so, how much of a pain is it?
Serena
@serenity-luna

Greetings.

Please I need some help:
Can I do "Collection group queries" to Firestore from Cloud Function using firebase_functions_interop?

Thanks in advance.

Basketball ICO
@BasketballICO_twitter

Hello when usar firebase init functions

do you want to use eslint to catch probable bugs and enforce style?

This is true or false, i think is false, because we don't write any javascript, but i want to be sure.
Thanks

Basketball ICO
@BasketballICO_twitter
Also, can you recommend structure folder/files for all functions.
I really like if you share a link of a project that use this, i want to see its folder/files structure
thanks :D
Basketball ICO
@BasketballICO_twitter
Other question, can I use flutter packages pub ... instead of pub...?
Anatoly Pulyaevskiy
@pulyaevskiy

I'm curious that if I reach that point, is it possible to interface to that JS library from Dart, and if so, how much of a pain is it?

@pauldemarco sorry for late reply. The answer is two fold. Is it possible to interface with a JS library? Definitely YES, this is exactly what this project is doing. How hard or easy is it to interface? It depends. It could definitely be a bit confusing in the beginning, JS interop is not very well documented and there are some nuances specific to Node.js packages. The good news though you guys now have a very good example to base your work on. Both firebase_admin_interop and firebase_functions_interop provide a lot of use cases, so you just need to look inside. Don't forget to look at the node_interop, node_io and node_http for examples on how to use regular Node.js APIs and define bindings.

@serenity-luna could you point at the docs on this feature (collection group queries)? I can take a look into this later
Anatoly Pulyaevskiy
@pulyaevskiy
@BasketballICO_twitter look at the test functions subfolder in this repo: https://github.com/pulyaevskiy/firebase-functions-interop/tree/master/functions It's the bare minimum required. The only structure item I recommend to follow is to put entrypoint dart files inside node/ folder. The rest of the code can (and probably should) live inside lib/ and lib/src/ as in any other Dart project.

Other question, can I use flutter packages pub ... instead of pub...?

No, unfortunately. Flutter's version of Dart does not have web components required by JS interop. I have Dart SDK installed as the default in my shell.

Basketball ICO
@BasketballICO_twitter

@pulyaevskiy thanks, i am trying to use but cant't get it work,
is normal that dart analysis show this errors in packages folder?

https://github.com/pulyaevskiy/firebase-functions-interop/issues/58#issuecomment-527363229

fail.png
Basketball ICO
@BasketballICO_twitter

@pulyaevskiy I fix the analysis by exclude this folder like your project

https://github.com/pulyaevskiy/firebase-functions-interop/blob/master/analysis_options.yaml

This is correct?

But can't deploy with the same error

Could not read source directory. Remove links and shortcuts and try again.

https://github.com/pulyaevskiy/firebase-functions-interop/issues/58#issue-467039814

Thanks

Serena
@serenity-luna

@pulyaevskiy Thank you!

Here is the documentation you asked for:
https://googleapis.dev/nodejs/firestore/latest/Firestore.html#collectionGroup

Collection Group Queries is a new feature in Cloud Firestore:
https://firebase.googleblog.com/2019/06/understanding-collection-group-queries.html

Anatoly Pulyaevskiy
@pulyaevskiy
Thanks @serenity-luna for providing the details. This looks like a small addition, i should be able to push an update tonight, if I have some time.
Serena
@serenity-luna
@pulyaevskiy Thank you. It is a very useful feature.
Anatoly Pulyaevskiy
@pulyaevskiy

I just released firebase_admin_interop 2.0.0 with support for Collection Groups. Please read the CHANGELOG.md since this is a breaking change release and requires upgrading your npm dependencies. There are some breaking changes in the code as well.

I might need to do a follow up release for firebase_functions_interop to match new npm dependencies though. Will take a look tomorrow

Basketball ICO
@BasketballICO_twitter

@pulyaevskiy
hello firebase_admin_interop not support messaging, how can i send push notification?,
can I create a javascript function with this functionality and call in dart code?
What is the best way to do this currently?

Thanks

Thanks

void main() {
  functions['sendNewTripNotification'] = functions.firestore
      .document('/{uid}/shared_trips/')
      .onWrite(sendNewTripNotification);
}

FutureOr<void> sendNewTripNotification(
    Change<DocumentSnapshot> change, EventContext context) async {
  final uid = change.after.data.getString('userId');

  final app = FirebaseAdmin.instance.initializeApp();
  final user = User.fromMap(
      (await app.firestore().document('Users/${uid}/token').get())
          .data
          .toMap());

  // ********** JAVASCRIPT CODE
  sendNotification(user.tokenId, notification: {
    title: 'You have been invited to a trip.',
    body: 'Tap here to check it out!'
  });
  // ********** JAVASCRIPT CODE
}
Anatoly Pulyaevskiy
@pulyaevskiy
@BasketballICO_twitter yeah, I haven't got around to implement messaging portion of Admin SDK, so this still needs to be done. There is no blockers for this work aside from the fact that my free time is pretty limited. If you feeling adventurous you are welcome to submit a pull request to firebase_admin_interop with this change.
I don't see sendNotification method in the docs though. Which one are you referring to exactly? I'm looking at https://firebase.google.com/docs/reference/admin/node/admin.messaging.Messaging.html?hl=en#methods
Basketball ICO
@BasketballICO_twitter
@pulyaevskiy send notification is only a shortcut function for sendToDevice
function sendNotification(tokenId, payload) {
    admin.messaging().sendToDevice(tokenId, payload).then((response) => {
        // Response is a message ID string.
        console.log('Successfully sent message:', response);
    })
        .catch((error) => {
            console.log('Error sending message:', error);
        });
}
I'm going to look at the repository to see if I can do something
Anatoly Pulyaevskiy
@pulyaevskiy
I see. Yeah, take a look, it should be fairly straightforward if you follow examples in other namespaces. In short this would involve:
  1. Adding new bindings (type declarations) in lib/src/bindings.dart. Bare minimum would be Messaging class with sendToDevice method + MessagingPayload, MessagingOptions, MessagingDevicesResponse(which are used in this method arguments) + any other type that these classes depend on.
  2. Adding new lib/src/messaging.dart file. This one would have the same classes as above, but these would actually have all methods implemented to proxy all calls to the bindings. Just look at lib/src/auth.dart follow similar pattern.
  3. Adding new method messaging to the App class in both bindings and lib/src/app.dart, which is again a simple proxy to native JS method.
Basketball ICO
@BasketballICO_twitter
😵 It's late here, I try to follow this steps tomorrow, thanks
Anatoly Pulyaevskiy
@pulyaevskiy
sure, no rush on my end :D
Luke Pighetti
@lukepighetti
Hey @pulyaevskiy thanks for making a Dart option for firebase functions
I tried following your example for setup and build_runner just spits out a index.dart file instead of index.dart.js
if you have any thuoghts on how to proceed i would much appreciate it :)
Anatoly Pulyaevskiy
@pulyaevskiy
Hey Luke, thanks for checking it out. I’ll take a look tonight. I just released an update to build_node_compilers which could be the reason. Do you see any errors or warnings in build runner output?
Feel free to submit a GitHub issue with more details as well
Luke Pighetti
@lukepighetti
I didn't see any errors or warnings tbh
just followed the directions exactly and it produced an index.dart file with the original source not transformed in any way
as a note, due to dart's tree shaking have you seen improved cold starts over JS functions?
Anatoly Pulyaevskiy
@pulyaevskiy
@lukepighetti could you confirm if you see this warning in the build output pulyaevskiy/node-interop#67 ?
sorry for late reply
I looked at it tonight and it seems like the issue is in just released build_node_compilers not happy with node_io.