From 35e0b5e1f63ee4dde11d28dbf00a86912247022e Mon Sep 17 00:00:00 2001 From: Jason Bosco Date: Tue, 6 Feb 2024 18:12:08 -0600 Subject: [PATCH] Shorten function names to fix issue with local emulator --- CHANGELOG.md | 4 ++++ README.md | 6 +++--- extension.yaml | 6 +++--- .../{backfillToTypesenseFromFirestore.js => backfill.js} | 0 functions/src/index.js | 4 ++-- ...{indexToTypesenseOnFirestoreWrite.js => indexOnWrite.js} | 0 package.json | 4 ++-- ...illToTypesenseFromFirestore.spec.js => backfill.spec.js} | 2 +- ...pesenseOnFirestoreWrite.spec.js => indexOnWrite.spec.js} | 2 +- ...tening.spec.js => indexOnWriteWithoutFlattening.spec.js} | 2 +- 10 files changed, 17 insertions(+), 13 deletions(-) rename functions/src/{backfillToTypesenseFromFirestore.js => backfill.js} (100%) rename functions/src/{indexToTypesenseOnFirestoreWrite.js => indexOnWrite.js} (100%) rename test/{backfillToTypesenseFromFirestore.spec.js => backfill.spec.js} (99%) rename test/{indexToTypesenseOnFirestoreWrite.spec.js => indexOnWrite.spec.js} (99%) rename test/{indexToTypesenseOnFirestoreWriteWithoutFlattening.spec.js => indexOnWriteWithoutFlattening.spec.js} (98%) diff --git a/CHANGELOG.md b/CHANGELOG.md index e869932..cfb55ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Version 1.4.0 + +- Shorten function names to fix issue with local emulator + ## Version 1.3.0 - Use `action=upsert` for back-filling data diff --git a/README.md b/README.md index 4a6a0f2..850f0e7 100644 --- a/README.md +++ b/README.md @@ -90,9 +90,9 @@ This will trigger the backfill background Cloud function, which will read data f ## ☁ī¸ Cloud Functions -* **indexToTypesenseOnFirestoreWrite:** A function that indexes data into Typesense when it's triggered by Firestore changes. +* **indexOnWrite:** A function that indexes data into Typesense when it's triggered by Firestore changes. -* **backfillToTypesenseFromFirestore:** A function that backfills data from a Firestore collection into Typesense, triggered when a Firestore document with the path `typesense_sync/backfill` has the contents of `trigger: true`. +* **backfill:** A function that backfills data from a Firestore collection into Typesense, triggered when a Firestore document with the path `typesense_sync/backfill` has the contents of `trigger: true`. ## 🔑 Access Required @@ -154,4 +154,4 @@ firebase ext:info ./ --markdown > README.md ## ℹī¸ Support -Please open a Github issue or join our [Slack community](https://join.slack.com/t/typesense-community/shared_invite/zt-mx4nbsbn-AuOL89O7iBtvkz136egSJg). +Please open a GitHub issue or join our [Slack community](https://join.slack.com/t/typesense-community/shared_invite/zt-mx4nbsbn-AuOL89O7iBtvkz136egSJg). diff --git a/extension.yaml b/extension.yaml index ca136d1..983d3a5 100644 --- a/extension.yaml +++ b/extension.yaml @@ -1,5 +1,5 @@ name: firestore-typesense-search -version: 1.3.0 +version: 1.4.0 specVersion: v1beta # Firebase Extensions specification version (do not edit) displayName: Search Firestore with Typesense @@ -17,7 +17,7 @@ releaseNotesUrl: https://github.com/typesense/firestore-typesense-search/release billingRequired: true resources: - - name: indexToTypesenseOnFirestoreWrite + - name: indexOnWrite description: A function that indexes data into Typesense when it's triggered by Firestore changes type: firebaseextensions.v1beta.function properties: @@ -29,7 +29,7 @@ resources: eventType: providers/cloud.firestore/eventTypes/document.write resource: projects/${param:PROJECT_ID}/databases/(default)/documents/${param:FIRESTORE_COLLECTION_PATH}/{documentID} - - name: backfillToTypesenseFromFirestore + - name: backfill description: >- A function that backfills data from a Firestore collection into Typesense, triggered when a Firestore document with the path `typesense_sync/backfill` has the contents of `trigger: true`. diff --git a/functions/src/backfillToTypesenseFromFirestore.js b/functions/src/backfill.js similarity index 100% rename from functions/src/backfillToTypesenseFromFirestore.js rename to functions/src/backfill.js diff --git a/functions/src/index.js b/functions/src/index.js index 1314dbe..46063be 100644 --- a/functions/src/index.js +++ b/functions/src/index.js @@ -1,2 +1,2 @@ -exports.indexToTypesenseOnFirestoreWrite = require("./indexToTypesenseOnFirestoreWrite.js"); -exports.backfillToTypesenseFromFirestore = require("./backfillToTypesenseFromFirestore.js"); +exports.indexOnWrite = require("./indexOnWrite.js"); +exports.backfill = require("./backfill.js"); diff --git a/functions/src/indexToTypesenseOnFirestoreWrite.js b/functions/src/indexOnWrite.js similarity index 100% rename from functions/src/indexToTypesenseOnFirestoreWrite.js rename to functions/src/indexOnWrite.js diff --git a/package.json b/package.json index e75055f..eb0a49b 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "emulator": "DOTENV_CONFIG=extensions/test-params-flatten-nested-false.local.env firebase emulators:start --import=emulator_data", "export": "firebase emulators:export emulator_data", "test": "npm run test-part-1 && npm run test-part-2", - "test-part-1": "cp -f extensions/test-params-flatten-nested-true.local.env extensions/firestore-typesense-search.env.local && NODE_OPTIONS=--experimental-vm-modules DOTENV_CONFIG=extensions/test-params-flatten-nested-true.local.env firebase emulators:exec --only functions,firestore,extensions 'jest --testPathIgnorePatterns=test/indexToTypesenseOnFirestoreWriteWithoutFlattening.spec.js'", - "test-part-2": "cp -f extensions/test-params-flatten-nested-false.local.env extensions/firestore-typesense-search.env.local && NODE_OPTIONS=--experimental-vm-modules DOTENV_CONFIG=extensions/test-params-flatten-nested-false.local.env firebase emulators:exec --only functions,firestore,extensions 'jest --testPathPattern=test/indexToTypesenseOnFirestoreWriteWithoutFlattening.spec.js'", + "test-part-1": "cp -f extensions/test-params-flatten-nested-true.local.env extensions/firestore-typesense-search.env.local && NODE_OPTIONS=--experimental-vm-modules DOTENV_CONFIG=extensions/test-params-flatten-nested-true.local.env firebase emulators:exec --only functions,firestore,extensions 'jest --testPathIgnorePatterns=test/indexOnWriteWithoutFlattening.spec.js'", + "test-part-2": "cp -f extensions/test-params-flatten-nested-false.local.env extensions/firestore-typesense-search.env.local && NODE_OPTIONS=--experimental-vm-modules DOTENV_CONFIG=extensions/test-params-flatten-nested-false.local.env firebase emulators:exec --only functions,firestore,extensions 'jest --testPathPattern=test/indexOnWriteWithoutFlattening.spec.js'", "typesenseServer": "mkdir -p $(pwd)/typesense-server-data && docker run -i -p 8108:8108 -v$(pwd)/typesense-server-data/:/data typesense/typesense:0.25.1 --data-dir /data --api-key=xyz --listen-port 8108 --enable-cors", "lint": "eslint . --fix" }, diff --git a/test/backfillToTypesenseFromFirestore.spec.js b/test/backfill.spec.js similarity index 99% rename from test/backfillToTypesenseFromFirestore.spec.js rename to test/backfill.spec.js index d92aa16..dbae4ee 100644 --- a/test/backfillToTypesenseFromFirestore.spec.js +++ b/test/backfill.spec.js @@ -9,7 +9,7 @@ const app = firebase.initializeApp({ }); const firestore = app.firestore(); -describe("backfillToTypesenseFromFirestore", () => { +describe("backfill", () => { beforeEach(async () => { // Clear the database between tests await firestore.recursiveDelete(firestore.collection(config.firestoreCollectionPath)); diff --git a/test/indexToTypesenseOnFirestoreWrite.spec.js b/test/indexOnWrite.spec.js similarity index 99% rename from test/indexToTypesenseOnFirestoreWrite.spec.js rename to test/indexOnWrite.spec.js index 8a0f4b1..a363a49 100644 --- a/test/indexToTypesenseOnFirestoreWrite.spec.js +++ b/test/indexOnWrite.spec.js @@ -9,7 +9,7 @@ const app = firebase.initializeApp({ }); const firestore = app.firestore(); -describe("indexToTypesenseOnFirestoreWrite", () => { +describe("indexOnWrite", () => { beforeEach(async () => { // delete the Firestore collection await firestore.recursiveDelete(firestore.collection(config.firestoreCollectionPath)); diff --git a/test/indexToTypesenseOnFirestoreWriteWithoutFlattening.spec.js b/test/indexOnWriteWithoutFlattening.spec.js similarity index 98% rename from test/indexToTypesenseOnFirestoreWriteWithoutFlattening.spec.js rename to test/indexOnWriteWithoutFlattening.spec.js index fbdde57..85b692d 100644 --- a/test/indexToTypesenseOnFirestoreWriteWithoutFlattening.spec.js +++ b/test/indexOnWriteWithoutFlattening.spec.js @@ -9,7 +9,7 @@ const app = firebase.initializeApp({ }); const firestore = app.firestore(); -describe("indexToTypesenseOnFirestoreWriteWithoutFlattening", () => { +describe("indexOnWriteWithoutFlattening", () => { beforeEach(async () => { // delete the Firestore collection await firestore.recursiveDelete(firestore.collection(config.firestoreCollectionPath));