Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Firebase Extensionsを自作して迅速にアプリケーションを開発する

Firebase Extensionsを自作して迅速にアプリケーションを開発する

2023.07.07に開催された PORT Firebase Meetup にて登壇
https://connpass.com/event/285741/

ツルオカ

July 07, 2023
Tweet

More Decks by ツルオカ

Other Decks in Technology

Transcript

  1. 2 πϧΦΧ • גࣜձࣾNTTυίϞͷ৽نࣄۀ෦໳ʹॴଐ • Flutter / Dart / Firebaseத৺ͷιϑτ΢ΣΞΤϯδχΞ

    • ΤϯδχΞϦϯά×σβΠϯͷڥքྖҬʹؔ৺ • Perfume͕޷͖ Self-Introduction @h_tsuruo
  2. 8 Resize Images(Made by Firebase): Cloud StorageʹΞοϓϩʔυ͞Ε ͨϑΝΠϧΛࢦఆͨ͠αΠζʹϦαΠζ͢Δ֦ு Firebase Extensionsͷྫ

    • εϚʔτϑΥϯαΠζͰͷදࣔ࠷దԽ΍ɺαϜωΠϧը૾ͷੜ੒ͳͲʹར༻Ͱ͖Δ • ֦ுΛΠϯετʔϧ͢ΔͱɺΞοϓϩʔυΛτϦΨʔʹCloud Functions্ཱ͕͕ͪΓॲཧ • ϦαΠζ͞Εͨը૾͕ಉ͡όέοτʹ֨ೲ͞ΕΔ࡞Γ Original Image Resized Images Ωϟϓνϟࢀর: [Firebase Resize ImagesΛ࢖ͬͯΈͨ - Qiita](https://qiita.com/butterv/items/2194a776f55023ccd485)
  3. 9 Google I/O 2022ͰϚʔέςΟϯάɺݕࡧɺܾࡁܥͷ֦ு͕ެ։͞ΕڧԽ Firebase Extensionsͱ͸ - Google I/O 2022

    • ܾࡁɿStripeʹՃ͑ɺRevenueCat͕௥Ճ͞Εબ୒ࢶ͕޿͕Δ • ݕࡧɿAlgoliaɺElasticʹՃ͑Typesense͕௥Ճ͞ΕɺFirebase Summit 2022ͰMeilisearch΋௥Ճ MeilisearchΛ࢖ͬͨશจݕࡧʹ͍ͭͯهࣄΛެ։͍ͯ͠·͢
  4. 10 Google I/O 2023Ͱ͸Generative AIීٴͷӨڹ΋ड͚ɺ ࿩୊ͷPaLMΛ࢖ͬͨAPIͳͲAIΧςΰϦͷ֦ு΋ॆ࣮ Firebase Extensionsͱ͸ - Google

    I/O 2023 • GoogleΛ͸͡Ίɺ3rdύʔςΟձࣾ΍ίϛϡχςΟͳͲ͕։ൃ͠৽͘͠20ͷ֦ு͕௥Ճ • ͦͯ͠ɺݸਓͰͷ։ൃɾެ։΋͜ͷλΠϛϯάͰՄೳʹʢޙड़ʣ
  5. 12 ֎͔ΒݟͨFirebase Extensionsͷઓུ FirebaseϓϩμΫτͰΧόʔ͖͠Εͳ͍ྖҬΛɺ σϕϩού΍ίϛϡχςΟͷྗΛआΓͳ͕ΒΤίγεςϜΛେ͖͘͢Δ • SupabaseΛ͸͡Ίͱ͢ΔmBaaSͷ୆಄ʹΑΓɺਖ਼௚एׯͷ෺଍Γͳ͞Λײ࢝͡Ί͍ͯͨ • SupabaseͷTypeScriptؔ਺͸DenoϏϧτΠϯͳҰํɺFirebase͸Node.jsͳͲ •

    ྑ͘΋ѱ͘΋Google Cloud͸େ͖ͳϓϥοτϑΥʔϜͰྺ࢙͕͋Γɺେ͖ͳվม͕Ͱ͖ͳ͍ͷͰ͸ • ύʔτφʔ΍ίϛϡχςΟͷྗΛआΓͯɺαʔϏεΛ֦ுͯ͠ΤίγεςϜΛେ͖͘͢Δํ਑ʁ ͜ͷπΠʔτͷ໿൒೥ޙɺ࣮ࡍʹݸਓ͕഑෍Ͱ͖ΔΑ͏ʹͳΓ·ͨ͠
  6. 13 ୈ2ੈ୅ͷCloud RunԽʹ൐͏࣮ߦ࣌ؒͷԆ௕ɺ Eventarc ରԠͳͲτϦΨʔൣғ͕֦ॆ͞Ε͞ΒʹύϫʔΞοϓ ୈ2ੈ୅ Cloud Functions ͷԸܙ •

    Cloud Functions ͷਐԽ͸ Firebase Extensions ͷਐԽʹ௚݁͢Δ • HTTPɾCallableؔ਺Λච಄ʹFirebaseɾGoogle CloudαʔϏεͷτϦΨʔ΋ର৅ [Cloud Functionsʢ2nd genʣͱ Cloud Run ͷؔ܎ੑΛ஌Δ](https://zenn.dev/cloud_ace/articles/b30971199b392c)
  7. 15 αʔϏεΞΧ΢ϯτͷ࡞੒ͳͲͷηοτΞοϓΛ͢΂ͯεΩοϓ͠ɺ ίϯιʔϧͷίϚϯυϙνϙνͰ࠶ར༻Ͱ͖Δ͜ͱ ֦ுΛࣗ࡞ʢ։ൃɾެ։ʣ͢ΔϝϦοτ • Firebase / Google CloudͷެࣜυΩϡϝϯτʹ༷ʑͳCookbook΋঺հ͞Ε͍ͯΔ͕ࣄલ४උ͕ඞཁ •

    ྫ͑͹ʮ͜ͷϦιʔεΛ࢖͏ʹ͸͜ͷIAM͕ඞཁͰɺαʔϏεΞΧ΢ϯτͷ໊લ͸ʓʓʹͯ͠…ʯ • ֦ுΛΠϯετʔϧ͢Ε͹ɺཪଆͰࣗಈͰαʔϏεΞΧ΢ϯτͷ࡞੒·Ͱࡁ·ͤͯ͘ΕΔ • ౰વɺϩδοΫؚ͕·ΕΔCloud Functions΋ࣗಈͰ্ཱ͕ͪΔͷͰ࠶ར༻ੑ͕ߴ͍ • ֦ுΛΞϯΠϯετʔϧ͢Ε͹ɺؔ࿈͢ΔϦιʔε΋͢΂ͯ࡟আ͞ΕΔಉظੑ΋͋Δ
  8. 16 Cloud SchedulerΛ࢖ͬͯFirestoreͷυΩϡϝϯτΛ ఆظతʹόοΫΞοϓ͢Δ֦ுɺBack up Firestore to StorageΛެ։ Back up

    Firestore to Storage • ެࣜͷCookbook΍ઌਓͨͪͷهࣄ͕ͨ͘͞Μ͋Γχʔζ͸͋Δ΋ͷͷެࣜఏڙ͕ͳ͔ͥͳ͍ػೳ • ॻ͘ίʔυྔ΋গͳ͘೉қ౓͸௿͍͕ɺαʔϏεΞΧ΢ϯτͷ࡞੒΍gcloudίϚϯυ๨Ε͕ͪͳखؒ • ֦ுͱͯ͠ެ։͢Ε͹ΫϦοΫͻͱͭͰಋೖͰָ͖ͯ ຊ֨ாͷ࢖͍ํʹ͍ͭͯ΋هࣄΛެ։͍ͯ͠·͢ ެࣜυΩϡϝϯτͰ঺հ͞Ε͍ͯΔCookbook
  9. 20 Firebase CLIΛ࢖ͬͯinitίϚϯυΛୟ͘ͱɺ ։ൃʹඞཁͳςϯϓϨʔτσΟϨΫτϦ͕ੜ੒͞ΕΔ ExtensionͷσΟϨΫτϦߏ଄ • TypeScript or JavaScriptΛબ୒Ͱ͖Δ •

    extensions.yaml͸Permissions΍ύϥϝʔλͳͲΛࢦఆ͢Δɺ࠷΋ར༻͢ΔϝλσʔλϑΝΠϧ • ݟͯͷ௨ΓυΩϡϝϯτϑΝΠϧ͕ଟ਺ੜ੒͞ΕΔ Source: https://github.com/firebase/firebase-tools/blob/ 34f4d953f111db4f8a8479746bee0b44b46d3a35/src/commands/ ext-dev-init.ts#L40
  10. 21 ։ൃ͸جຊతʹϩʔΧϧͷEmulator Suiteʹͯߦ͏ ։ൃαΠΫϧ① - Firebase Emulator Suite • Cloud

    Functions؀ڥͳͷͰɺैདྷ௨ΓEmulator SuiteΛ্ཱͪ͛ͯ։ൃΛ͢Δ • ͨͩ͠ɺGoogle API΍αʔυύʔςΟAPIͳͲEmulator SuiteͰ࠶ݱͰ͖ͳ͍৔߹͸ɺ࣮ϓϩδΣΫτͰ֬ೝ • TypeScriptͷ৔߹͸`.ts`ϑΝΠϧͱ`extensions.yaml`ͷϑΝΠϧΛओʹ࿔Δ͜ͱʹͳΔ ௨ৗ௨Γؔ਺Λ༻ҙͯ͠ϩδοΫΛॻ͘ ࣮ߦ͍ͨؔ͠਺໊Λࢦఆͯ͠ɺ ϓϩύςΟ΍ύϥϝʔλΛࢦఆ͢Δ
  11. 22 Emulator SuiteͰ࠶ݱͰ͖ͳ͍৔߹΍ɺ ΞυϗοΫͳςετΛߦ͍͍ͨ৔߹͸֦ுΛΞοϓϩʔυ͢Δ ։ൃαΠΫϧ② - ext:dev:upload • Ξοϓϩʔυํ๏͸ɺGitHubͷύϒϦοΫϨϙδτϦ͔ϩʔΧϧ͔બͿ͜ͱ͕Ͱ͖Δ •

    ݸਓతʹ͸Ξοϓϩʔυ଎౓͕ૣ͍ʢͱײ͡ΔʣͷͰɺϩʔΧϧࢦఆ͕͓͢͢Ί • ϦϦʔεεςʔδ͸ɺalphaɾbetaɾrcͷ3εςʔδ͕ϓϨϦϦʔε൛ͱͯ͠ଘࡏ͢Δ • े෼ͳςετ͕׬ྃͯ͠৹ࠪʹग़͢৔߹͸stableεςʔδʹΞοϓϩʔυ͢Δ ext:dev:upload ίϚϯυΛୟ͘ͱϦϦʔεεςʔδ͕໰ΘΕ ΞοϓϩʔυͰ͖Δʢ`--stage`ͰলུͰ͖Δʣ ϓϨϦϦʔε൛ʢstableҎ֎ʣ͸ɺ৽͘͠Ξοϓϩʔυ͢ΔࡍʹΘ͟Θ͟όʔδϣϯΛ্͛Δඞཁ͸ͳ͘ɺ εςʔδ໊ͱΞοϓϩʔυ൪߸͕ࣗಈతʹ෇༩͞ΕΔʢΠϯΫϦϝϯτॲཧΛؾʹ͠ͳͯ͘ྑ͍ʣ
  12. 25 ֦ுΛΠϯετʔϧ͢ΔલͱޙͰɺͦΕͧΕυΩϡϝϯτ͕ඞཁ υΩϡϝϯτ `ext:info` ίϚϯυΛ࢖͏ͱPREINSTALL.md΍extensions.yamlͷத਎Λ݁߹ͯ͠ॻ͖ग़͢͜ͱ͕Ͱ͖Δɻ ϑΝΠϧ໊ ಺༰ ܝࡌՕॴ PREINSTALL ར༻ऀ͕Extensions

    HubͰ֦ுΛݟ͚ͭͯɺৄࡉϖʔδʹભҠ ͨ͠ࡍʹදࣔ͞ΕΔɺΠϯετʔϧલʹ఻͑Δ಺༰ɻ ྫʣ֦ுͷ֓ཁɺඞཁͳύϥϝʔλɺύʔϛγϣϯɺྉۚͳͲ POSTINSTALL ར༻ऀ͕֦ுΛΠϯετʔϧͨ͠ޙʹɺ࣮ߦ͢Δ·Ͱͷεςο ϓͳͲΛ఻͑Δ಺༰ɻMarkdownͰ͸͋Δ͕ɺextensions.yaml Ͱࢦఆͨ͠ϝλσʔλΛม਺ͱͯ͠ར༻Ͱ͖Δͷ͕ಛ௃ɻ ྫʣνϡʔτϦΞϧɺϩάͷ֬ೝํ๏ͳͲ • PREINSTALLɾPOSTINSTALLɾCHANGELOG͕࠷௿ݶඞཁͳυΩϡϝϯτϑΝΠϧ • README͸ੜ੒͞Εͳ͍ͷͰɺඞཁͰ͋Ε͹ӈԼͷίϚϯυͰੜ੒͢Δͱྑ͍
  13. 26 Extensions Hub΁ͷެ։ʹ͸৹͕ࠪඞཁͰɺ ݸਓͷ࣮੷ϕʔεͰ͸ฏۉͯ͠2~3೔͔͔ΔΠϝʔδ ެ։ͷ৹ࠪ • աෆ଍ͳ͘ద੾ͳPermissions͕ઃఆ͞Ε͍ͯΔ͔ • PREINSTALL /

    POSTINSTALL / READMEͳͲυΩϡϝϯτ͕ద੾ʹهࡌ͞Ε͍ͯΔ͔ • ෆదࣄ߲͕͋Δͱཧ༝ͱͱ΋ʹ൱ೝ͞Εͯࠩ͠໭͞ΕΔʢApp Store৹ࠪͱಉ༷ʣ
  14. 30 ެࣜυΩϡϝϯτҎ֎Ͱ͸ɺInvertaseࣾͷهࣄ͕͓͢͢Ί ਪ঑هࣄ • Export User Data΍Image Processing APIͳͲ֦ுΛෳ਺ެ։ •

    Invertase͸։ൃऀͷͨΊͷπʔϧ΍Φʔϓϯιʔεͷ։ൃΛಘҙͱ͢Δاۀ • React Native΍FlutterͷFirebase SDKͷ։ൃɾϝϯςφϯε͕༗໊ͳྫ ৹ࠪϨϏϡʔ΋InveratseͷMaisࢯ͕ஸೡʹϑΟʔυόοΫ͘Ε·ͨ͠ https://invertase.io/category/firebase-extensions
  15. 32 Appendix • [Extension publisher overview | Firebase Extensions](https://firebase.google.com/docs/extensions/publishers) •

    [What's new at Google I/O 2023](https://firebase.blog/posts/2023/05/whats-new-at-google-io/) • [Google Developers Japan: Google I/O 2022 Ͱൃද͞Εͨ Firebase ͷ৽ػೳ](https://developers- jp.googleblog.com/2022/06/io22-firebase.html) • [Firebase Extensions - Invertase blog](https://invertase.io/category/firebase-extensions) • [Firebase Extensions ͸͡ΊͷҰา](https://www.slideshare.net/kenichitatsuhama/firebase-extensions) • [Firebase Resize ImagesΛ࢖ͬͯΈͨ - Qiita](https://qiita.com/butterv/items/2194a776f55023ccd485) • [firebase/extensions: Source code for official Firebase extensions](https://github.com/firebase/extensions) • [invertase/firebase-extensions: A collection of Firebase Extensions built by Invertase.](https://github.com/ invertase/firebase-extensions) • [rowyio/firebase-extensions: A collection of Firebase Extensions built by the Rowy team, designed to help you build your app faster.](https://github.com/rowyio/firebase-extensions) • [yamankatby/firebase-extensions: A collection of Firebase Extensions designed to help you build better apps faster.](https://github.com/yamankatby/firebase-extensions)