firestore-meilisearch 0.3.0 → 0.3.1

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.
package/README.md CHANGED
@@ -36,16 +36,16 @@ This extension listens to each creation, update, or deletion of your documents t
36
36
 
37
37
  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.
38
38
 
39
- ## âš¡ Supercharge your Meilisearch experience
40
-
41
- Say goodbye to server deployment and manual updates with [Meilisearch Cloud](https://www.meilisearch.com/cloud?utm_campaign=oss&utm_source=github&utm_medium=firestore-meilisearch). Get started with a 14-day free trial! No credit card required.
39
+ ## 🚀 Getting started
42
40
 
43
41
  #### Additional setup
44
42
 
45
43
  Before installing this extension, you'll need to:
46
44
 
47
45
  - [Set up Cloud Firestore in your Firebase project](https://firebase.google.com/docs/firestore/quickstart)
48
- - Run a Meilisearch instance. [Learn more about Meilisearch cloud](https://www.meilisearch.com/pricing). Alternatively there are many other easy ways [to download and run a Meilisearch instance](https://docs.meilisearch.com/learn/getting_started/installation.html#download-and-launch)
46
+ - Run a Meilisearch instance:
47
+ - ⚡ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no maintenance, no commitment, cancel anytime. [Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss&utm_source=github&utm_medium=firestore-meilisearch).
48
+ - 🪨 Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss&utm_source=github&utm_medium=firestore-meilisearch) our fast, open-source search engine on your own infrastructure.
49
49
 
50
50
  #### Data import format
51
51
 
@@ -76,9 +76,6 @@ a Google Cloud API or making outbound network requests to non-Google services.
76
76
  All Firebase services offer a free tier of usage.
77
77
  [Learn more about Firebase billing.](https://firebase.google.com/pricing)
78
78
 
79
-
80
-
81
-
82
79
  **Configuration Parameters:**
83
80
 
84
81
  * 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).
@@ -1,3 +1,4 @@
1
+ import { describe, test, expect } from '@jest/globals'
1
2
  import * as firebaseFunctionsTestInit from 'firebase-functions-test'
2
3
  import { mockConsoleInfo } from './__mocks__/console'
3
4
  import * as firestore from 'firebase-admin/firestore'
@@ -1,3 +1,11 @@
1
+ import {
2
+ describe,
3
+ test,
4
+ expect,
5
+ beforeEach,
6
+ afterEach,
7
+ jest,
8
+ } from '@jest/globals'
1
9
  import { readFileSync } from 'fs'
2
10
  import { resolve as pathResolve } from 'path'
3
11
  import * as yaml from 'js-yaml'
@@ -1,3 +1,11 @@
1
+ import {
2
+ describe,
3
+ test,
4
+ expect,
5
+ beforeEach,
6
+ afterEach,
7
+ jest,
8
+ } from '@jest/globals'
1
9
  import * as firebaseFunctionsTestInit from 'firebase-functions-test'
2
10
  import mockedEnv from 'mocked-env'
3
11
  import { mocked } from 'jest-mock'
@@ -49,6 +57,7 @@ describe('extension', () => {
49
57
  test('functions are exported', () => {
50
58
  const exportedFunctions = jest.requireActual('../src')
51
59
 
60
+ // @ts-ignore: We're asserting the export is a function
52
61
  expect(exportedFunctions.indexingWorker).toBeInstanceOf(Function)
53
62
  })
54
63
 
@@ -1,5 +1,15 @@
1
1
  {
2
2
  "extends": "../tsconfig.json",
3
- "files": ["test.types.d.ts"],
4
- "include": ["**/*"]
3
+ "compilerOptions": {
4
+ "types": [
5
+ "jest",
6
+ "node"
7
+ ]
8
+ },
9
+ "files": [
10
+ "test.types.d.ts"
11
+ ],
12
+ "include": [
13
+ "**/*"
14
+ ]
5
15
  }
@@ -1,3 +1,11 @@
1
+ import {
2
+ describe,
3
+ test,
4
+ expect,
5
+ beforeEach,
6
+ afterEach,
7
+ jest,
8
+ } from '@jest/globals'
1
9
  import * as firebaseFunctionsTestInit from 'firebase-functions-test'
2
10
  import mockedEnv from 'mocked-env'
3
11
  import { ChangeType, getChangedDocumentId, getChangeType } from '../src/util'
@@ -151,19 +159,19 @@ describe('getFieldsToIndex', () => {
151
159
  test('return empty list', () => {
152
160
  adapter = require('../src/meilisearch-adapter')
153
161
  mockParseFieldsToIndex = adapter.parseFieldsToIndex()
154
- expect(mockParseFieldsToIndex).toMatchObject([])
162
+ expect(mockParseFieldsToIndex).toEqual([])
155
163
  })
156
164
 
157
165
  test('return list with one field', () => {
158
166
  adapter = require('../src/meilisearch-adapter')
159
167
  mockParseFieldsToIndex = adapter.parseFieldsToIndex('field')
160
- expect(mockParseFieldsToIndex).toMatchObject(['field'])
168
+ expect(mockParseFieldsToIndex).toEqual(['field'])
161
169
  })
162
170
 
163
171
  test('return list with multiple fields', () => {
164
172
  adapter = require('../src/meilisearch-adapter')
165
173
  mockParseFieldsToIndex = adapter.parseFieldsToIndex('field1,field2,field3')
166
- expect(mockParseFieldsToIndex).toMatchObject(['field1', 'field2', 'field3'])
174
+ expect(mockParseFieldsToIndex).toEqual(['field1', 'field2', 'field3'])
167
175
  })
168
176
 
169
177
  test('return list with multiple fields and spaces', () => {
@@ -171,7 +179,7 @@ describe('getFieldsToIndex', () => {
171
179
  mockParseFieldsToIndex = adapter.parseFieldsToIndex(
172
180
  'field1, field2, field3'
173
181
  )
174
- expect(mockParseFieldsToIndex).toMatchObject(['field1', 'field2', 'field3'])
182
+ expect(mockParseFieldsToIndex).toEqual(['field1', 'field2', 'field3'])
175
183
  })
176
184
 
177
185
  test('return list of fiels with underscore', () => {
@@ -179,10 +187,6 @@ describe('getFieldsToIndex', () => {
179
187
  mockParseFieldsToIndex = adapter.parseFieldsToIndex(
180
188
  'field_1,field_2,field_3'
181
189
  )
182
- expect(mockParseFieldsToIndex).toMatchObject([
183
- 'field_1',
184
- 'field_2',
185
- 'field_3',
186
- ])
190
+ expect(mockParseFieldsToIndex).toEqual(['field_1', 'field_2', 'field_3'])
187
191
  })
188
192
  })
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- const admin = require("firebase-admin");
19
+ const firebase_admin_1 = require("firebase-admin");
20
20
  const config_1 = require("./config");
21
21
  const logs = require("../logs");
22
22
  const meilisearch_adapter_1 = require("../meilisearch-adapter");
@@ -25,11 +25,11 @@ const run = async () => {
25
25
  // Retrieve all arguments from the commande line.
26
26
  const config = await (0, config_1.parseConfig)();
27
27
  // Initialize Firebase using the Google Credentials in the GOOGLE_APPLICATION_CREDENTIALS environment variable.
28
- admin.initializeApp({
29
- credential: admin.credential.applicationDefault(),
28
+ (0, firebase_admin_1.initializeApp)({
29
+ credential: firebase_admin_1.credential.applicationDefault(),
30
30
  databaseURL: `https://${config.projectId}.firebaseio.com`,
31
31
  });
32
- const database = admin.firestore();
32
+ const database = (0, firebase_admin_1.firestore)();
33
33
  // Initialize Meilisearch index.
34
34
  const index = (0, create_index_1.initMeilisearchIndex)(config.meilisearch);
35
35
  await retrieveCollectionFromFirestore(database, config, index);
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = '0.3.0';
4
+ exports.version = '0.3.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firestore-meilisearch",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "scripts": {
5
5
  "lint": "eslint .",
6
6
  "lint:fix": "eslint . --fix",
@@ -25,10 +25,12 @@
25
25
  "firebase-admin": "^11.5.0",
26
26
  "firebase-functions": "^4.2.1",
27
27
  "inquirer": "^8.2.2",
28
- "meilisearch": "^0.30.0"
28
+ "meilisearch": "^0.30.0",
29
+ "typescript": "^4.4.3"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@babel/preset-typescript": "^7.15.0",
33
+ "@jest/globals": "^29.7.0",
32
34
  "@types/jest": "^27.0.2",
33
35
  "@typescript-eslint/eslint-plugin": "^4.32.0",
34
36
  "@typescript-eslint/parser": "^4.32.0",
@@ -46,8 +48,7 @@
46
48
  "mocked-env": "^1.3.5",
47
49
  "prettier": "^2.4.1",
48
50
  "ts-jest": "^29.0.5",
49
- "ts-node": "^10.2.1",
50
- "typescript": "^4.4.3"
51
+ "ts-node": "^10.2.1"
51
52
  },
52
53
  "bin": "lib/import/index.js"
53
54
  }
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import * as admin from 'firebase-admin'
19
+ import { initializeApp, credential, firestore } from 'firebase-admin'
20
20
  import { DocumentSnapshot } from 'firebase-functions/lib/v1/providers/firestore'
21
21
  import { CLIConfig, parseConfig } from './config'
22
22
  import * as logs from '../logs'
@@ -29,12 +29,12 @@ const run = async () => {
29
29
  const config: CLIConfig = await parseConfig()
30
30
 
31
31
  // Initialize Firebase using the Google Credentials in the GOOGLE_APPLICATION_CREDENTIALS environment variable.
32
- admin.initializeApp({
33
- credential: admin.credential.applicationDefault(),
32
+ initializeApp({
33
+ credential: credential.applicationDefault(),
34
34
  databaseURL: `https://${config.projectId}.firebaseio.com`,
35
35
  })
36
36
 
37
- const database = admin.firestore()
37
+ const database = firestore()
38
38
 
39
39
  // Initialize Meilisearch index.
40
40
  const index = initMeilisearchIndex(config.meilisearch)
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '0.3.0'
1
+ export const version = '0.3.1'
package/tsconfig.json CHANGED
@@ -9,7 +9,6 @@
9
9
  "strict": true,
10
10
  "target": "es2018",
11
11
  "types": [
12
- "jest",
13
12
  "node",
14
13
  ]
15
14
  },
@@ -19,5 +18,6 @@
19
18
  ],
20
19
  "exclude": [
21
20
  "node_modules",
21
+ "**/__tests__/**"
22
22
  ]
23
23
  }