firestore-meilisearch 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/.editorconfig +20 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +26 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +18 -0
  4. package/.github/ISSUE_TEMPLATE/other.md +7 -0
  5. package/.github/dependatbot.yml +23 -0
  6. package/.github/release-draft-template.yml +33 -0
  7. package/.github/scripts/check-release.sh +42 -0
  8. package/.github/workflows/publish.yml +30 -0
  9. package/.github/workflows/release-drafter.yml +16 -0
  10. package/.github/workflows/test.yml +42 -0
  11. package/CHANGELOG.md +3 -0
  12. package/CONTRIBUTING.md +236 -0
  13. package/LICENSE +201 -0
  14. package/POSTINSTALL.md +40 -0
  15. package/PREINSTALL.md +42 -0
  16. package/README.md +128 -0
  17. package/bors.toml +8 -0
  18. package/dataset/firebase-export-metadata.json +8 -0
  19. package/dataset/firestore_export/all_namespaces/all_kinds/all_namespaces_all_kinds.export_metadata +0 -0
  20. package/dataset/firestore_export/all_namespaces/all_kinds/output-0 +0 -0
  21. package/dataset/firestore_export/firestore_export.overall_export_metadata +0 -0
  22. package/extension.yaml +176 -0
  23. package/firebase.json +20 -0
  24. package/functions/.eslintignore +2 -0
  25. package/functions/.eslintrc.js +54 -0
  26. package/functions/__tests__/__mocks__/console.ts +7 -0
  27. package/functions/__tests__/adapter.test.ts +98 -0
  28. package/functions/__tests__/config.test.ts +130 -0
  29. package/functions/__tests__/data/document.ts +11 -0
  30. package/functions/__tests__/data/environment.ts +9 -0
  31. package/functions/__tests__/functions.test.ts +280 -0
  32. package/functions/__tests__/jest.setup.ts +1 -0
  33. package/functions/__tests__/test.types.d.ts +5 -0
  34. package/functions/__tests__/tsconfig.json +5 -0
  35. package/functions/__tests__/util.test.ts +200 -0
  36. package/functions/jest.config.js +12 -0
  37. package/functions/lib/adapter.js +61 -0
  38. package/functions/lib/config.js +13 -0
  39. package/functions/lib/import/config.js +127 -0
  40. package/functions/lib/import/index.js +93 -0
  41. package/functions/lib/index.js +90 -0
  42. package/functions/lib/logs.js +97 -0
  43. package/functions/lib/meilisearch/create-index.js +17 -0
  44. package/functions/lib/meilisearch-index.js +17 -0
  45. package/functions/lib/types.js +2 -0
  46. package/functions/lib/util.js +47 -0
  47. package/functions/lib/version.js +4 -0
  48. package/functions/package.json +53 -0
  49. package/functions/src/adapter.ts +106 -0
  50. package/functions/src/config.ts +34 -0
  51. package/functions/src/import/config.ts +207 -0
  52. package/functions/src/import/index.ts +115 -0
  53. package/functions/src/index.ts +103 -0
  54. package/functions/src/logs.ts +107 -0
  55. package/functions/src/meilisearch/create-index.ts +20 -0
  56. package/functions/src/types.ts +8 -0
  57. package/functions/src/util.ts +63 -0
  58. package/functions/src/version.ts +1 -0
  59. package/functions/tsconfig.eslint.json +13 -0
  60. package/functions/tsconfig.json +23 -0
  61. package/functions/yarn.lock +5306 -0
  62. package/guides/IMPORT_EXISTING_DOCUMENTS.md +74 -0
  63. package/package.json +21 -0
  64. package/script/version.sh +51 -0
  65. package/test-params-example.env +9 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/POSTINSTALL.md ADDED
@@ -0,0 +1,40 @@
1
+ ### See it in action
2
+
3
+ You can test out this extension right away!
4
+
5
+ 1. Go to your [Cloud Firestore dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/firestore/data) in the Firebase console
6
+
7
+ 2. If it doesn't already exist, create the collection you specified during installation: `${param:COLLECTION_PATH}`
8
+
9
+ 3. Create, update, or delete a document in the collection called `${param:COLLECTION_PATH}` that contains any fields with any values that you'd like.
10
+
11
+ 4. You can check the status of tasks in your Meilisearch instance using the following query:
12
+
13
+ ```
14
+ curl \
15
+ -X GET '`${param:MEILISEARCH_HOST}`/tasks'
16
+ ```
17
+ You can read more on [tasks](https://docs.meilisearch.com/reference/api/tasks.html#tasks) in the documentation.
18
+
19
+ ### Using the extension
20
+
21
+ Whenever a document is created, updated, or deleted in the specified collection `${param:COLLECTION_PATH}`, this extension sends that update to your Meilisearch instance.
22
+
23
+ This extension:
24
+ - Indexes a document in Meilisearch and sends all the fields or configured fields defined in the extension
25
+ - Updates a document in your Meilisearch index
26
+ - Deletes a document from your Meilisearch index
27
+
28
+ ### _(Optional)_ Import existing documents
29
+
30
+ This extension does not export your existing document dataset in Meilisearch. It will only export the documents that have been modified or created after installation. To populate your Meilisearch database with all the documents in your Firestore collection, you need to run the import script provided by this extension.
31
+
32
+ The import script reads all existing documents in a Cloud Firestore collection or group collection and indexes them into Meilisearch.
33
+
34
+ **Important:** Run the import script over the entire collection _after_ installing this extension; otherwise, you may lose the current writes in your database during the import.
35
+
36
+ Learn more about using the import script to [backfill your existing collection](https://github.com/meilisearch/firestore-meilisearch/blob/main/guides/IMPORT_EXISTING_DOCUMENTS.md).
37
+
38
+ ### Monitoring
39
+
40
+ As a best practice, you can [monitor the activity](https://firebase.google.com/docs/extensions/manage-installed-extensions#monitor) of your installed extension, including checks on its health, usage, and logs.
package/PREINSTALL.md ADDED
@@ -0,0 +1,42 @@
1
+ Use this extension to synchronize documents from a Cloud Firestore collection to a Meilisearch index. This allows you to use full-text search in your Cloud Firestore documents.
2
+
3
+ This extension listens to each creation, update, or deletion of your documents to keep them in sync with your Meilisearch index. This ensures that the data in Meilisearch mirrors your content in Cloud Firestore. You can then run queries on this mirrored dataset.
4
+
5
+ Note that this extension only listens for changes to _documents_ in a specific collection, but not changes in any _subcollection_. However, you can install additional instances of this extension to listen to other collections in your Firestore database.
6
+
7
+ #### Additional setup
8
+
9
+ Before installing this extension, you'll need to:
10
+
11
+ - [Set up Cloud Firestore in your Firebase project](https://firebase.google.com/docs/firestore/quickstart)
12
+ - Run a Meilisearch instance. There are many easy ways [to download and run a Meilisearch instance](https://docs.meilisearch.com/learn/getting_started/installation.html#download-and-launch)
13
+
14
+ #### Data import format
15
+
16
+ Documents indexed in Meilisearch must have a [unique id](https://docs.meilisearch.com/learn/core_concepts/documents.html#primary-field). The extension will use Firestone's default field: `Document ID` for this purpose. `Document ID` will be renamed to`_firestore_id` to be used as the [document id](https://docs.meilisearch.com/learn/core_concepts/documents.html#document-id). If your documents have another field containing the string `id`, it will not be set as the primary key.
17
+
18
+ **Important:** If your documents contain a field called `_firestore_id`, it will be ignored.
19
+
20
+ [Geosearch](https://docs.meilisearch.com/reference/features/geosearch.html#geosearch) has a specific format in Meilisearch, your documents must have a valid `_geo` field with an object composed of `lat` and `lng`. If a `GeoPoint` from Firestore with the name `_geo` is found, the field `latitude` is renamed to `lat` and `longitude` to `lng`.
21
+ If a `GeoPoint` is found without the name `_geo`, it is added as an array.
22
+
23
+ #### Backfill your Meilisearch data
24
+
25
+ This extension does not export all existing documents into Meilisearch unless they have been modified or created after its installation. You can run the [import script](https://github.com/meilisearch/firestore-meilisearch/) provided by this extension to retrieve your Meilisearch dataset with all the documents present in your Firestore collection
26
+
27
+ #### Billing
28
+
29
+ To install an extension, your project must be on the [Blaze (pay as you go) plan](https://firebase.google.com/pricing)
30
+
31
+ * You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension, even if it is not used.
32
+ * This extension uses other Firebase or Google Cloud services which may have
33
+ associated charges if you exceed the service’s free tier:
34
+ * Cloud Firestore
35
+ * Cloud Functions (Node.js 10+ runtime. [See FAQs](https://firebase.google.com/support/faq#extensions-pricing))
36
+
37
+ When you use Firebase extensions, you're only charged for the underlying
38
+ resources that you use. A paid-tier billing plan is only required if the
39
+ extension uses a service that requires a paid-tier plan, for example calling
40
+ a Google Cloud API or making outbound network requests to non-Google services.
41
+ All Firebase services offer a free tier of usage.
42
+ [Learn more about Firebase billing.](https://firebase.google.com/pricing)
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ <h1 align="center">firestore-meilisearch</h1>
2
+
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/meilisearch/integration-guides/main/assets/logos/meilisearch_firebase.svg" alt="Meilisearch-Firestore" width="200" height="200" />
5
+ </p>
6
+
7
+ <h1 align="center">Meilisearch Firestore</h1>
8
+
9
+ <h4 align="center">
10
+ <a href="https://github.com/meilisearch/meilisearch">Meilisearch</a> |
11
+ <a href="https://docs.meilisearch.com">Documentation</a> |
12
+ <a href="https://slack.meilisearch.com">Slack</a> |
13
+ <a href="https://roadmap.meilisearch.com/tabs/1-under-consideration">Roadmap</a> |
14
+ <a href="https://www.meilisearch.com">Website</a> |
15
+ <a href="https://docs.meilisearch.com/faq">FAQ</a>
16
+ </h4>
17
+
18
+ <p align="center">
19
+ <a href="https://github.com/meilisearch/firestore-meilisearch/actions"><img src="https://github.com/meilisearch/firestore-meilisearch/workflows/Tests/badge.svg" alt="Test"></a>
20
+ <a href="https://github.com/meilisearch/firestore-meilisearch/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
21
+ <a href="https://ms-bors.herokuapp.com/repositories/8"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
22
+ </p>
23
+
24
+ <p align="center">⚡ The Meilisearch API extension written for Firebase</p>
25
+
26
+ # Search in your Firestore content with Meilisearch
27
+
28
+ **Author**: Meilisearch (**[https://meilisearch.com](https://meilisearch.com)**)
29
+
30
+ **Description**: Full-text Search on Firebase with Meilisearch
31
+
32
+ **Details**: Use this extension to synchronize documents from a Cloud Firestore collection to a Meilisearch index. This allows you to use full-text search in your Cloud Firestore documents.
33
+
34
+ This extension listens to each creation, update, or deletion of your documents to keep them in sync with your Meilisearch index. This ensures that the data in Meilisearch mirrors your content in Cloud Firestore. You can then run queries on this mirrored dataset.
35
+
36
+ Note that this extension only listens for changes to _documents_ in a specific collection, but not changes in any _subcollection_. However, you can install additional instances of this extension to listen to other collections in your Firestore database.
37
+
38
+ #### Additional setup
39
+
40
+ Before installing this extension, you'll need to:
41
+
42
+ - [Set up Cloud Firestore in your Firebase project](https://firebase.google.com/docs/firestore/quickstart)
43
+ - Run a Meilisearch instance. There are many easy ways [to download and run a Meilisearch instance](https://docs.meilisearch.com/learn/getting_started/installation.html#download-and-launch)
44
+
45
+ #### Data import format
46
+
47
+ Documents indexed in Meilisearch must have a [unique id](https://docs.meilisearch.com/learn/core_concepts/documents.html#primary-field). The extension will use Firestone's default field: `Document ID` for this purpose. `Document ID` will be renamed to`_firestore_id` to be used as the [document id](https://docs.meilisearch.com/learn/core_concepts/documents.html#document-id). If your documents have another field containing the string `id`, it will not be set as the primary key.
48
+
49
+ **Important:** If your documents contain a field called `_firestore_id`, it will be ignored.
50
+
51
+ [Geosearch](https://docs.meilisearch.com/reference/features/geosearch.html#geosearch) has a specific format in Meilisearch, your documents must have a valid `_geo` field with an object composed of `lat` and `lng`. If a `GeoPoint` from Firestore with the name `_geo` is found, the field `latitude` is renamed to `lat` and `longitude` to `lng`.
52
+ If a `GeoPoint` is found without the name `_geo`, it is added as an array.
53
+
54
+ #### Backfill your Meilisearch data
55
+
56
+ This extension does not export all existing documents into Meilisearch unless they have been modified or created after its installation. You can run the [import script](https://github.com/meilisearch/firestore-meilisearch/) provided by this extension to retrieve your Meilisearch dataset with all the documents present in your Firestore collection
57
+
58
+ #### Billing
59
+
60
+ To install an extension, your project must be on the [Blaze (pay as you go) plan](https://firebase.google.com/pricing)
61
+
62
+ * You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension, even if it is not used.
63
+ * This extension uses other Firebase or Google Cloud services which may have
64
+ associated charges if you exceed the service’s free tier:
65
+ * Cloud Firestore
66
+ * Cloud Functions (Node.js 10+ runtime. [See FAQs](https://firebase.google.com/support/faq#extensions-pricing))
67
+
68
+ When you use Firebase extensions, you're only charged for the underlying
69
+ resources that you use. A paid-tier billing plan is only required if the
70
+ extension uses a service that requires a paid-tier plan, for example calling
71
+ a Google Cloud API or making outbound network requests to non-Google services.
72
+ All Firebase services offer a free tier of usage.
73
+ [Learn more about Firebase billing.](https://firebase.google.com/pricing)
74
+
75
+
76
+
77
+
78
+ **Configuration Parameters:**
79
+
80
+ * Cloud Functions location: Where do you want to deploy the functions created for this extension? If you need help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).
81
+
82
+ * Collection path: What is the path of the collection you would like to export into Meilisearch?
83
+
84
+ * Fields to index in Meilisearch: What fields do you want to index in Meilisearch? Create a comma-separated list of the field names, or leave it blank to include all fields. The id field is always indexed even when omitted from the list.
85
+
86
+ * Meilisearch Index Name: What Meilisearch index do you want to index your data in?
87
+
88
+ * Meilisearch host: What is the URL of the host of your Meilisearch database? Make sure your URL starts with `http://` or `https://`
89
+
90
+ * Meilisearch API key: What is your Meilisearch API key with permission to perform actions on indexes? Both the API keys and the master key are valid choices but we strongly recommend using an API key for security purposes. Check out our guide on [security](https://docs.meilisearch.com/learn/security/master_api_keys.html).
91
+
92
+
93
+
94
+ **Cloud Functions:**
95
+
96
+ * **indexingWorker:** Cloud function triggered by document modification in Firestore to import changes into Meilisearch.
97
+
98
+ ---
99
+
100
+ ## 🧩 Install this extension
101
+
102
+ ### Console
103
+
104
+ [![Install this extension in your Firebase project](https://www.gstatic.com/mobilesdk/210513_mobilesdk/install-extension.png "Install this extension in your Firebase project")][install-link]
105
+
106
+ [install-link]: https://console.firebase.google.com/project/_/extensions/install?ref=publisher_id/extension_name
107
+
108
+ ### Firebase CLI
109
+
110
+ ```bash
111
+ firebase ext:install meilisearch/firestore-meilisearch --project=[your-project-id]
112
+ ```
113
+
114
+ > Learn more about installing extensions in the Firebase Extensions documentation:
115
+ > [console](https://firebase.google.com/docs/extensions/install-extensions?platform=console),
116
+ > [CLI](https://firebase.google.com/docs/extensions/install-extensions?platform=cli)
117
+
118
+ ---
119
+
120
+ ## ⚙️ Development Workflow and Contributing
121
+
122
+ Any new contribution is more than welcome in this project!
123
+
124
+ If you want to know more about the development workflow or wish to contribute, please see our [contributing guidelines](/CONTRIBUTING.md) for detailed instructions!
125
+
126
+ <hr>
127
+
128
+ **Meilisearch** provides and maintains many **SDKs and Integration tools** like this one. We want to provide everyone with an **amazing search experience for any kind of project**. If you wish to contribute, make suggestions, or want to know what's going on right now, visit the [integration-guides](https://github.com/meilisearch/integration-guides) repository.
package/bors.toml ADDED
@@ -0,0 +1,8 @@
1
+ status = [
2
+ 'linter',
3
+ 'integration-tests (14)',
4
+ 'integration-tests (16)',
5
+ 'integration-tests (17)'
6
+ ]
7
+ # 1 hour timeout
8
+ timeout-sec = 3600
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": "9.16.0",
3
+ "firestore": {
4
+ "version": "1.13.1",
5
+ "path": "firestore_export",
6
+ "metadata_file": "firestore_export/firestore_export.overall_export_metadata"
7
+ }
8
+ }
package/extension.yaml ADDED
@@ -0,0 +1,176 @@
1
+ # Copyright 2022 Meilisearch
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Identifier for your extension
16
+ name: firestore-meilisearch
17
+
18
+ # Follow semver versioning
19
+ version: 0.1.0
20
+
21
+ # Version of the Firebase Extensions specification
22
+ specVersion: v1beta
23
+
24
+ # Friendly display name for your extension (~3-5 words)
25
+ displayName: Search in your Firestore content with Meilisearch
26
+
27
+ # Brief description of the task your extension performs (~1 sentence)
28
+ description: >-
29
+ Full-text Search on Firebase with Meilisearch
30
+
31
+ license: Apache-2.0 # https://spdx.org/licenses/
32
+
33
+ # Public URL for the source code of your extension
34
+ sourceUrl: https://github.com/meilisearch/firestore-meilisearch
35
+
36
+ releaseNotesUrl: https://github.com/meilisearch/firestore-meilisearch/releases
37
+
38
+ author:
39
+ authorName: Meilisearch
40
+ email: bonjour@meilisearch.com
41
+ url: https://meilisearch.com
42
+
43
+ # Specify whether a paid-tier billing plan is required to use your extension.
44
+ # Learn more in the docs: https://firebase.google.com/docs/extensions/alpha/ref-extension-yaml#billing-required-field
45
+ billingRequired: true
46
+
47
+ # In an `apis` field, list any Google APIs (like Cloud Translation, BigQuery, etc.)
48
+ # required for your extension to operate.
49
+ # Learn more in the docs: https://firebase.google.com/docs/extensions/alpha/ref-extension-yaml#apis-field
50
+
51
+ # In a `roles` field, list any IAM access roles required for your extension to operate.
52
+ # Learn more in the docs: https://firebase.google.com/docs/extensions/alpha/ref-extension-yaml#roles-field
53
+
54
+ # In the `resources` field, list each of your extension's functions, including the trigger for each function.
55
+ # Learn more in the docs: https://firebase.google.com/docs/extensions/alpha/ref-extension-yaml#resources-field
56
+ resources:
57
+ - name: indexingWorker
58
+ type: firebaseextensions.v1beta.function
59
+ description: >-
60
+ Cloud function triggered by document modification in Firestore to import changes into Meilisearch.
61
+ properties:
62
+ # LOCATION is a user-configured parameter value specified by the user
63
+ # during installation.
64
+ location: ${LOCATION}
65
+ runtime: nodejs14
66
+ eventTrigger:
67
+ eventType: providers/cloud.firestore/eventTypes/document.write
68
+ resource: projects/${PROJECT_ID}/databases/(default)/documents/${COLLECTION_PATH}/{documentID}
69
+
70
+ # In the `params` field, set up your extension's user-configured parameters.
71
+ # Learn more in the docs: https://firebase.google.com/docs/extensions/alpha/ref-extension-yaml#params-field
72
+ params:
73
+ - param: LOCATION
74
+ label: Cloud Functions location
75
+ description: >-
76
+ Where do you want to deploy the functions created for this extension?
77
+ If you need help selecting a location, refer to the [location selection
78
+ guide](https://firebase.google.com/docs/functions/locations).
79
+ type: select
80
+ options:
81
+ - label: Iowa (us-central1)
82
+ value: us-central1
83
+ - label: South Carolina (us-east1)
84
+ value: us-east1
85
+ - label: Northern Virginia (us-east4)
86
+ value: us-east4
87
+ - label: Los Angeles (us-west2)
88
+ value: us-west2
89
+ - label: Salt Lake City (us-west3)
90
+ value: us-west3
91
+ - label: Las Vegas (us-west4)
92
+ value: us-west4
93
+ - label: Warsaw (europe-central2)
94
+ value: europe-central2
95
+ - label: Belgium (europe-west1)
96
+ value: europe-west1
97
+ - label: London (europe-west2)
98
+ value: europe-west2
99
+ - label: Frankfurt (europe-west3)
100
+ value: europe-west3
101
+ - label: Zurich (europe-west6)
102
+ value: europe-west6
103
+ - label: Hong Kong (asia-east2)
104
+ value: asia-east2
105
+ - label: Tokyo (asia-northeast1)
106
+ value: asia-northeast1
107
+ - label: Osaka (asia-northeast2)
108
+ value: asia-northeast2
109
+ - label: Seoul (asia-northeast3)
110
+ value: asia-northeast3
111
+ - label: Mumbai (asia-south1)
112
+ value: asia-south1
113
+ - label: Jakarta (asia-southeast2)
114
+ value: asia-southeast2
115
+ - label: Montreal (northamerica-northeast1)
116
+ value: northamerica-northeast1
117
+ - label: Sao Paulo (southamerica-east1)
118
+ value: southamerica-east1
119
+ - label: Sydney (australia-southeast1)
120
+ value: australia-southeast1
121
+ required: true
122
+ immutable: true
123
+
124
+ - param: COLLECTION_PATH
125
+ label: Collection path
126
+ description: >-
127
+ What is the path of the collection you would like to export into Meilisearch?
128
+ example: movies
129
+ type: string
130
+ validationRegex: "^[^/]+(/[^/]+/[^/]+)*$"
131
+ validationErrorMessage: Must be a valid Cloud Firestore Collection.
132
+ required: true
133
+
134
+ - param: MEILISEARCH_FIELDS_TO_INDEX
135
+ label: Fields to index in Meilisearch
136
+ description: >-
137
+ What fields do you want to index in Meilisearch?
138
+ Create a comma-separated list of the field names, or leave it blank to include all fields.
139
+ The id field is always indexed even when omitted from the list.
140
+ default: ''
141
+ example: title,overview,release_date
142
+ validationRegex: "^[^,]?[a-zA-Z-_0-9,]*[^,]$"
143
+ validationErrorMessage:
144
+ Fields must be given through a comma-separated list.
145
+ required: false
146
+
147
+ - param: MEILISEARCH_INDEX_NAME
148
+ label: Meilisearch Index Name
149
+ description: >-
150
+ What Meilisearch index do you want to index your data in?
151
+ type: string
152
+ example: movies
153
+ validationRegex: "^[0-9A-Za-z_-]+$"
154
+ validationErrorMessage: Must be a valid Index format.
155
+ Index uid can be of type integer or string only composed of alphanumeric characters, hyphens (-) and underscores (_).
156
+ Check out our guide on [index creation](https://docs.meilisearch.com/learn/core_concepts/indexes.html#index-creation).
157
+ required: true
158
+
159
+ - param: MEILISEARCH_HOST
160
+ label: Meilisearch host
161
+ description: >-
162
+ What is the URL of the host of your Meilisearch database?
163
+ Make sure your URL starts with `http://` or `https://`
164
+ type: string
165
+ example: 'http://127.0.0.1:7700'
166
+ required: true
167
+
168
+ - param: MEILISEARCH_API_KEY
169
+ label: Meilisearch API key
170
+ description: >-
171
+ What is your Meilisearch API key with permission to perform actions on indexes?
172
+ Both the API keys and the master key are valid choices but we strongly recommend using an API key for security purposes.
173
+ Check out our guide on [security](https://docs.meilisearch.com/learn/security/master_api_keys.html).
174
+ type: string
175
+ example: 37778d5a6f5c39660c66c0f882dabedd55840f3a
176
+ required: false
package/firebase.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "functions": {
3
+ "predeploy": [
4
+ "npm --prefix \"$RESOURCE_DIR\" run lint",
5
+ "npm --prefix \"$RESOURCE_DIR\" run build"
6
+ ],
7
+ "source": "functions"
8
+ },
9
+ "emulators": {
10
+ "functions": {
11
+ "port": 5001
12
+ },
13
+ "firestore": {
14
+ "port": 8080
15
+ },
16
+ "ui": {
17
+ "enabled": true
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,2 @@
1
+ node_modules
2
+ coverage