Text search env variables

This commit is contained in:
francesco
2020-04-29 00:37:24 +02:00
parent a19451fb31
commit 520f4804df
8 changed files with 164 additions and 10 deletions

2
example/.env.template Normal file
View File

@@ -0,0 +1,2 @@
REACT_APP_ALGOLIA_APP_ID=
REACT_APP_SEARCH_KEY=

View File

@@ -3,7 +3,18 @@
It is linked to the firecms package in the parent directory for development
purposes.
In a regular project you would link the dependencies regularly using `npm`
In a regular project you would link the dependencies regularly using the `npm`
repository.
To run this project locally you can set your Firebase configuration in the file
`firebase_config.ts` under `src`
You can run `yarn install` and then `yarn start` to test this package.
### Algolia search
The example backend included in this package indexes various collections to
Algolia, using Cloud functions. If you deploy it your data will be indexed.
Then you can add your appId and searchKey to the .env file in the root of this
example project.

View File

@@ -7,10 +7,10 @@
"@material-ui/icons": "link:../node_modules/@material-ui/icons",
"@material-ui/pickers": "link:../node_modules/firebase",
"firebase": "link:../node_modules/firebase",
"firecms": "link:..",
"react": "link:../node_modules/react",
"react-dom": "link:../node_modules/react-dom",
"react-scripts": "link:../node_modules/react-scripts",
"firecms": "link:.."
"react-scripts": "link:../node_modules/react-scripts"
},
"scripts": {
"start": "node ../node_modules/react-scripts/bin/react-scripts.js start",

View File

@@ -1,7 +1,7 @@
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import logo from './images/test_shop_logo.png';
import logo from "./images/test_shop_logo.png";
import * as serviceWorker from "./serviceWorker";
@@ -271,7 +271,16 @@ const usersSchema: EntitySchema = {
}
};
const usersSearchDelegate = new AlgoliaTextSearchDelegate("Y6FR1MDSVW", "f084e6dcc154c04295c8124dbb797ff1", "users");
let usersSearchDelegate: AlgoliaTextSearchDelegate | undefined = undefined;
if (process.env.REACT_APP_ALGOLIA_APP_ID && process.env.REACT_APP_ALGOLIA_SEARCH_KEY) {
usersSearchDelegate = new AlgoliaTextSearchDelegate(
process.env.REACT_APP_ALGOLIA_APP_ID,
process.env.REACT_APP_ALGOLIA_SEARCH_KEY,
"users");
} else {
console.error("ALGOLIA_APP_ID or SEARCH_KEY env variables not specified");
console.error("Text search not enabled");
}
ReactDOM.render(
<CMSApp

View File

@@ -2,6 +2,110 @@
# yarn lockfile v1
"@algolia/cache-browser-local-storage@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.2.0.tgz#45cc4be4c8fcd69cb98ebaa2e78a459a1cf6ba64"
integrity sha512-uji5zxBxwNu8qKtyqghg9lUsN0OOZ58NfRKk0Il4IZCcCo78E0KfT3Uxr7XiYCJMRnqIsvbKWf0xA67tYNBSbA==
dependencies:
"@algolia/cache-common" "4.2.0"
"@algolia/cache-common@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/cache-common/-/cache-common-4.2.0.tgz#ada18e559f205a63eaf60c21a035b3d41f0f8d7d"
integrity sha512-ATBQCBBLt4hPNKIKn06y5zqZPWQmI+PBF0287rFVj8BGmEr82BzoKMa5XIkvgpjtxwx6c5nSKxZaYkEFqtrxtQ==
"@algolia/cache-in-memory@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/cache-in-memory/-/cache-in-memory-4.2.0.tgz#82f07cc99aee9e20a96bdd69c635bdd2dc4288f1"
integrity sha512-NsVOR6ixK6jvurLW+1+h80/9N18QjU/AXdAZJoVeu4JXb2NPuej4Ld1zXFYvz/ypCFQE+dU8haaQnJIuTbD4vg==
dependencies:
"@algolia/cache-common" "4.2.0"
"@algolia/client-account@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/client-account/-/client-account-4.2.0.tgz#7abf3dd8922fde1735b1e0d19e8b0bdbf64a1435"
integrity sha512-xz5OXU9DQ9pegABAgmTPV23f9tXmbUPO3w5J/b2QcP6jzfNnNfW3CkTwywgNLr16jIKLxmmClN5yqyJp6XmHBA==
dependencies:
"@algolia/client-common" "4.2.0"
"@algolia/client-search" "4.2.0"
"@algolia/transporter" "4.2.0"
"@algolia/client-analytics@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/client-analytics/-/client-analytics-4.2.0.tgz#11e9331fed5bbaa6668d71c890dff60c4af1c741"
integrity sha512-UNuZQOYuKPYl5fCgm1HZzoZ6Ewxtqrc4Cv5Dhdy5VatIV6lYEWOtdn+g+5qvWFGb6fv6688dg5EVJnXZNvVVZQ==
dependencies:
"@algolia/client-common" "4.2.0"
"@algolia/client-search" "4.2.0"
"@algolia/requester-common" "4.2.0"
"@algolia/transporter" "4.2.0"
"@algolia/client-common@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-4.2.0.tgz#bf8a550dc51927bb103de9aab7e6ac4d90a9cf0d"
integrity sha512-KxZTWXf9FSl188iTAz9rhTMeBtbF/uaJcxw99jbWHxyK9KR87obZzTlTFYnIWLEBaTG1MmlgPSsDogAE4CHLOQ==
dependencies:
"@algolia/requester-common" "4.2.0"
"@algolia/transporter" "4.2.0"
"@algolia/client-recommendation@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/client-recommendation/-/client-recommendation-4.2.0.tgz#bd49b5b9601fe4220ba6db0fc397d816584ee4ec"
integrity sha512-5QwvUJ5hpZVDz99o+EPgMg+z7maLWOZGUrUt5z8s+esl+taTb2h1PtyLpikAvC2d/BjYCEKyObTiRDYdzhqcoA==
dependencies:
"@algolia/client-common" "4.2.0"
"@algolia/requester-common" "4.2.0"
"@algolia/transporter" "4.2.0"
"@algolia/client-search@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/client-search/-/client-search-4.2.0.tgz#4917499cac66a5cca7f2ca9d1334bffc96a79b17"
integrity sha512-2SAz1/undr+RM7FNj3G0taWFG+8QEMQcYHxUhoOJKMIY9sPQN7UNCJRHYsulM+/g45oF67tXX09NSt14ewen0Q==
dependencies:
"@algolia/client-common" "4.2.0"
"@algolia/requester-common" "4.2.0"
"@algolia/transporter" "4.2.0"
"@algolia/logger-common@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/logger-common/-/logger-common-4.2.0.tgz#dd373b267594656d72a1563f6621ab7f727c4373"
integrity sha512-VQcJE5lr78oc+lbcGfPonCDTRwLNSxwtPrUP6Tj+CoDedsVHZhODAlHzLHhxc4vuyrU7xomvKJLqTUgfDNxzXQ==
"@algolia/logger-console@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/logger-console/-/logger-console-4.2.0.tgz#10e18ab75f60fd0f2e2b16cb9a1b0bcc947087f2"
integrity sha512-/1GE43jY0xKfJUi5ZGtEqq+oTyOzs+EgGKj7/zEHIpUc5NyxokIPWTqt3q6pzGSWFEkNbaA1gAVgXM1zCMVWYw==
dependencies:
"@algolia/logger-common" "4.2.0"
"@algolia/requester-browser-xhr@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.2.0.tgz#c2a7982bef940e1749f2ba2aa04e3f8a971b6a78"
integrity sha512-+PZKOe+UBdZYQg/h/8AbKQ2Ha4uDeoLnpZFv00IMr/elym0m2hl76xAeIBiIqGYsLCmGybGBFUF9n1imsKJUJQ==
dependencies:
"@algolia/requester-common" "4.2.0"
"@algolia/requester-common@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/requester-common/-/requester-common-4.2.0.tgz#df67a940516d5a313bbf79bcbceddadfff9f8ce2"
integrity sha512-SSKPRM/7UP54/dxyK6EYt4p6nTeJxYb1P6xVh/Ic6noBTCfqg5vBEKDa1DZD5MBtCvABoODd97UOfAo3ECG/jg==
"@algolia/requester-node-http@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-4.2.0.tgz#e26efd3d630b7c988bcc9cda3a8ee68ab4a168dd"
integrity sha512-mRQgSM8qrMfjXaBnMjTmymR0NKwbr82Qwh1a5TgYyzMOBuRO5nRikawvTVgpNaEnQS0uesIiwd2ohOJ2gNu6oA==
dependencies:
"@algolia/requester-common" "4.2.0"
"@algolia/transporter@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@algolia/transporter/-/transporter-4.2.0.tgz#9e6bea3304f1e6f4a64a3d7c1f9de047ba89056f"
integrity sha512-7CiwMYsEhrHySA8q70euIYOyhGtz/wz+MEC3nwGONBC82nGI6ntVqTFhCkpLIJqqbGbNlFgnCpwnLmSqLhRP3A==
dependencies:
"@algolia/cache-common" "4.2.0"
"@algolia/logger-common" "4.2.0"
"@algolia/requester-common" "4.2.0"
"@babel/code-frame@7.8.3", "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e"
@@ -2242,6 +2346,26 @@ ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.0, ajv@^6.5.5:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
algoliasearch@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.2.0.tgz#dd81a1a0c57eb9f74af6db70b0c11f256692d1e6"
integrity sha512-CgbyDBGMSzNISBFezPt68xAseknork+wNe/Oour1Hluk4OwbtobysRawFf93ZbLSQw/KbeGlVmVAvujeVIVdnQ==
dependencies:
"@algolia/cache-browser-local-storage" "4.2.0"
"@algolia/cache-common" "4.2.0"
"@algolia/cache-in-memory" "4.2.0"
"@algolia/client-account" "4.2.0"
"@algolia/client-analytics" "4.2.0"
"@algolia/client-common" "4.2.0"
"@algolia/client-recommendation" "4.2.0"
"@algolia/client-search" "4.2.0"
"@algolia/logger-common" "4.2.0"
"@algolia/logger-console" "4.2.0"
"@algolia/requester-browser-xhr" "4.2.0"
"@algolia/requester-common" "4.2.0"
"@algolia/requester-node-http" "4.2.0"
"@algolia/transporter" "4.2.0"
alphanum-sort@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3"
@@ -4202,7 +4326,7 @@ dotenv-expand@5.1.0:
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0"
integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==
dotenv@8.2.0:
dotenv@8.2.0, dotenv@^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==
@@ -10828,6 +10952,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
typeface-roboto@^0.0.75:
version "0.0.75"
resolved "https://registry.yarnpkg.com/typeface-roboto/-/typeface-roboto-0.0.75.tgz#98d5ba35ec234bbc7172374c8297277099cc712b"
integrity sha512-VrR/IiH00Z1tFP4vDGfwZ1esNqTiDMchBEXYY9kilT6wRGgFoCAlgkEUMHb1E3mB0FsfZhv756IF0+R+SFPfdg==
unicode-canonical-property-names-ecmascript@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818"

View File

@@ -1,6 +1,6 @@
{
"name": "@camberi/firecms",
"version": "0.1.3",
"version": "0.2.0",
"description": "Awesome Firestore based CMS",
"author": "camberi",
"license": "GPL-3.0",

View File

@@ -1,6 +1,4 @@
import { SearchIndex } from "algoliasearch";
const algoliasearch = require("algoliasearch");
import algoliasearch, { SearchIndex } from "algoliasearch";
export interface TextSearchDelegate {
performTextSearch(query: string): Promise<readonly string[]>;

View File

@@ -12596,6 +12596,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
typeface-roboto@^0.0.75:
version "0.0.75"
resolved "https://registry.yarnpkg.com/typeface-roboto/-/typeface-roboto-0.0.75.tgz#98d5ba35ec234bbc7172374c8297277099cc712b"
integrity sha512-VrR/IiH00Z1tFP4vDGfwZ1esNqTiDMchBEXYY9kilT6wRGgFoCAlgkEUMHb1E3mB0FsfZhv756IF0+R+SFPfdg==
typescript@^3.8.3:
version "3.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"