clean up & upgrade dependencies
2
.env.example
Normal file
@@ -0,0 +1,2 @@
|
||||
REACT_APP_FIREBASE_PROJECT_ID=
|
||||
REACT_APP_FIREBASE_PROJECT_WEB_API_KEY=
|
||||
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -23,6 +23,9 @@ A clear and concise description of what you expected to happen.
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Rowy Run version**
|
||||
If applicable, share the Rowy Run version from your project settings.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
|
||||
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 🤔 Support & questions
|
||||
url: https://discord.com/invite/fjBugmvzZP
|
||||
about: Chat with us for live support on discord.
|
||||
- name: 🙌 Want to join our team?
|
||||
url: https://www.rowy.io/jobs
|
||||
about: Get in touch to contribute & work with Rowy
|
||||
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for Firetable
|
||||
about: Suggest an idea for Rowy
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
32
.github/workflows/deploy-preview.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: Deploy to Preview Channel
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
# Optionally configure to run only for specific files. For example:
|
||||
# paths:
|
||||
# - "website/**"
|
||||
env:
|
||||
REACT_APP_FIREBASE_PROJECT_ID: rowyio
|
||||
REACT_APP_FIREBASE_PROJECT_WEB_API_KEY:
|
||||
"${{ secrets.FIREBASE_WEB_API_KEY_ROWYIO }}"
|
||||
CI: ""
|
||||
jobs:
|
||||
build_and_preview:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: borales/actions-yarn@v2.3.0
|
||||
with:
|
||||
cmd: install # will run `yarn install` command
|
||||
- uses: borales/actions-yarn@v2.3.0
|
||||
with:
|
||||
cmd: build # will run `yarn build` command
|
||||
env:
|
||||
CI: ""
|
||||
- uses: FirebaseExtended/action-hosting-deploy@v0
|
||||
with:
|
||||
repoToken: "${{ secrets.GITHUB_TOKEN }}"
|
||||
firebaseServiceAccount:
|
||||
"${{ secrets.FIREBASE_SERVICE_ACCOUNT_ROWYIO }}"
|
||||
expires: 14d
|
||||
projectId: rowyio
|
||||
4
.github/workflows/tweet_release.yml
vendored
@@ -31,7 +31,7 @@ on:
|
||||
with:
|
||||
message:
|
||||
"Testing github action for tweeting new releases and updates to
|
||||
Firetable project"
|
||||
Rowy project"
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
@@ -52,4 +52,4 @@ jobs:
|
||||
with:
|
||||
message:
|
||||
"Testing github action for tweeting new releases and updates to
|
||||
Firetable project"
|
||||
Rowy project"
|
||||
|
||||
34
.gitignore
vendored
@@ -2,26 +2,17 @@
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
www/node_modules
|
||||
|
||||
|
||||
Firetable/node_modules
|
||||
cloud_functions/functions/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
www/build
|
||||
/build
|
||||
cloud_functions/functions/lib
|
||||
|
||||
|
||||
# cloud function config
|
||||
cloud_functions/functions/src/functionConfig.ts
|
||||
|
||||
cloud_functions/functions/firebase-credentials.json
|
||||
# firebase
|
||||
*.firebaserc
|
||||
*-firebase.json
|
||||
.firebase/
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
@@ -34,16 +25,7 @@ yarn-debug.log*
|
||||
yarn-error.log*
|
||||
firebase-debug.log*
|
||||
|
||||
*.firebaserc
|
||||
.eslintcache
|
||||
.npm
|
||||
|
||||
|
||||
# Accidental package installs to root directories
|
||||
/yarn.lock
|
||||
/package.json
|
||||
package-lock.json
|
||||
node_modules/
|
||||
|
||||
cloud_functions/functions/src/functionConfig.json
|
||||
*.iml
|
||||
.idea
|
||||
*-firebase.json
|
||||
.vercel
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "Firetable",
|
||||
"name": "Rowy",
|
||||
"platforms": ["Node", "Admin", "Web"],
|
||||
"content": "README.md",
|
||||
"related": ["firebase/firebase-js-sdk"],
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
{
|
||||
"trailingComma": "es5",
|
||||
"proseWrap": "always"
|
||||
}
|
||||
|
||||
132
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,132 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at hello@rowy.io.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
|
||||
at [https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
42
CONTRIBUTING.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# Contributing
|
||||
|
||||
We welcome any feedback and contributions from the community. Please read the following guidelines to contribute to Rowy.
|
||||
|
||||
## Code of conduct
|
||||
|
||||
We want to have a welcoming and inclusive environment, towards this please read and follow our [our code of conduct](https://github.com/rowyio/rowy/blob/main/CODE_OF_CONDUCT.md).
|
||||
|
||||
## Getting started
|
||||
|
||||
Read the documentation on getting started [here](http://docs.rowy.io/). To get familiar with the project, [good first issues](https://github.com/rowyio/rowy/projects/3) is a good place to start.
|
||||
|
||||
## Working on existing issues
|
||||
|
||||
If you are working on an [issue](https://github.com/rowyio/rowy/issues), share that you are working on it by commenting on the issue and posting a message on #contributions channel in Rowy's [Discord](https://discord.com/invite/fjBugmvzZP).
|
||||
This allows others in the community and the maintainers a chance to provide feedback and guidance before you spend time working on it.
|
||||
|
||||
## File a feature request
|
||||
|
||||
If you have some interesting idea that will be a good addition to Rowy, then create a new issue using [Feature Request Template](https://github.com/rowyio/rowy/issues/new?assignees=&labels=&template=feature_request.md)
|
||||
to share your idea. If you are working on this to contribute to the project, then let others in the community and project maintainers know by posting on #contributions channel in Rowy's [Discord](https://discord.com/invite/fjBugmvzZP).
|
||||
This allows others in the community and the maintainers a chance to provide feedback and guidance before you spend time working on it.
|
||||
|
||||
## Report an issue
|
||||
|
||||
You can report all issues through using [Report A Bug](https://github.com/rowyio/rowy/issues/new?assignees=&labels=&template=bug_report.md) template. Please provide as much information as possible so that it can be resolved.
|
||||
|
||||
## Review
|
||||
|
||||
All submissions, including code and copy changes, will require review by project maintainers.
|
||||
|
||||
## Create a pull request
|
||||
|
||||
When making any pull requests to the repository, please follow these instructions:
|
||||
|
||||
- Submit your PR to the develop branch
|
||||
- Add as much information as possible in your PR's description including link to any related issues.
|
||||
- Ensure all your commits have clear commit message along with comments in the code as required
|
||||
|
||||
## License
|
||||
|
||||
By contributing to Rowy, you agree that your contributions will be licensed with the same license that is specified in the repository you are contributing to.
|
||||
201
LICENSE
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2019 Antler Innovation Pte Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
208
README.md
@@ -1,170 +1,122 @@
|
||||
<p align="center">
|
||||
<img src="src/assets/logo-sticker.svg" alt="Rowy" height="69" />
|
||||
</p>
|
||||
|
||||
<h1 align="center">
|
||||
Firetable
|
||||
✨ Data x Code ✨ <br/>
|
||||
</h1>
|
||||
|
||||
<h3 align="center">
|
||||
Firetable is an open-source platform to unlock the full potential of Google Firestore
|
||||
Modern Backend Stack
|
||||
</h3>
|
||||
|
||||
<p align="center">
|
||||
With Firetable, non-technical team members can access Firestore data with a permission controlled intuitive UI while developers can build fast on the GCP stack (manage their data models, create and deploy cloud functions, connect to third party apps via webhooks and APIs...and more!) 🚀
|
||||
Forget CLIs, configs, and DevOps. Focus on building your apps with a platform designed for developer productivity. Your production database (Firestore) in an Airtable-like UI with full coding extensibility via Cloud Functions visually in the browser.
|
||||
</p>
|
||||
|
||||
<!-- [](https://firetable.io) -->
|
||||
<div align="center">
|
||||
|
||||
<h3 align="center">
|
||||
<a href="https://firetable.io">Website</a>
|
||||
<span> · </span>
|
||||
<a href="https://discord.gg/B8yAD5PDX4">Discord</a>
|
||||
<span> · </span>
|
||||
<a href="https://twitter.com/firetableio">Twitter</a>
|
||||
|
||||
</h3>
|
||||
[](https://discord.gg/fjBugmvzZP)
|
||||
|
||||
<p align="center">
|
||||
|
||||
<a aria-label="License" href="https://github.com/FiretableProject/firetable/blob/master/LICENSE">
|
||||
<img src="https://badgen.net/github/license/FiretableProject/firetable" />
|
||||
</a>
|
||||
|
||||
<a aria-label="Commits" href="https://github.com/FiretableProject/firetable/commits/develop">
|
||||
<img src="https://badgen.net/github/last-commit/FiretableProject/firetable/develop" />
|
||||
</a>
|
||||
|
||||
<a aria-label="Firetable CLI" href="https://npmjs.com/package/firetable">
|
||||
<img src="https://badgen.net/npm/v/firetable" />
|
||||
</a>
|
||||
|
||||
<a href="http://www.rowy.io"><b>Website</b></a> •
|
||||
<a href="http://docs.rowy.io"><b>Documentation</b></a> •
|
||||
<a href="https://discord.gg/fjBugmvzZP"><b>Discord</b></a> •
|
||||
<a href="https://twitter.com/rowyio"><b>Twitter</b></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://try.firetable.io" >
|
||||
<img align="center" alt="Firetable demo GIF" src="https://firetable.io/demo.gif" width="100%">
|
||||
</a>
|
||||
</p>
|
||||
<br/>
|
||||
<h3 align="center">
|
||||
<a href="https://try.firetable.io">Live Demo</a>
|
||||
<span> · </span>
|
||||
<a href="https://github.com/FiretableProject/firetable/wiki/Getting-Started">Get started</a>
|
||||
<span> · </span>
|
||||
<a href="https://github.com/FiretableProject/firetable/issues/new?assignees=&labels=&template=feature_request.md&title=">Feature request</a>
|
||||
<span> · </span>
|
||||
<a href="https://github.com/FiretableProject/firetable/issues/new?assignees=&labels=&template=bug_report.md&title=">Report a bug</a>
|
||||
<span> · </span>
|
||||
<a href="https://discord.gg/B8yAD5PDX4">Discussions</a>
|
||||
</a>
|
||||
</h3>
|
||||
<br/>
|
||||
[](https://github.com/rowyio/rowy/blob/main/LICENSE)
|
||||
[](https://github.com/rowyio/rowy/commits/rc)
|
||||
[](https://github.com/rowyio/rowy/stargazers/)
|
||||
|
||||
# Features
|
||||
</div>
|
||||
<img width="100%" src="https://user-images.githubusercontent.com/307298/157184506-f94f3f5b-e6d3-49df-9a2c-f665511883f2.png" />
|
||||
|
||||
- **Intuitive spreadsheet like interface for Firestore.** With Firetable UI you
|
||||
can view and directly edit the data in Firestore but not just that, you can
|
||||
completely manage your existing data model or create from scratch.
|
||||
## Live Demo
|
||||
💥 Check out the [live demo](https://demo.rowy.io/) of Rowy 💥
|
||||
|
||||
- CRUD operations on your data - Add, edit, and delete rows
|
||||
- Create table collections, add column fields
|
||||
- Sort and filter data
|
||||
- Resize and rename columns
|
||||
## Quick Deploy
|
||||
|
||||
- **Rich set of data fields.**
|
||||
[29+ field types](https://github.com/FiretableProject/firetable/wiki/Field-Types)
|
||||
supported and growing
|
||||
Set up Rowy on your Google Cloud Platform project with this easy deploy button.
|
||||
|
||||
- Basic types: Short Text, Long Text, Email, Phone, URL…
|
||||
- Custom UI pickers: Date, Checkbox, Single Select, Multi Select…
|
||||
- Uploaders: Image, File
|
||||
- Rich Editors: JSON, Code, Rich Text (HTML)
|
||||
[](https://deploy.rowy.app/)
|
||||
|
||||
- **Permission controlled views.** You can customize who sees what data and what
|
||||
action they can take with powerful set of access controls based on custom user
|
||||
roles.
|
||||
[Read more](https://github.com/FiretableProject/firetable/wiki/Role-Based-Security-Rules)
|
||||
- **Bulk data actions.** You can import and export your Firestore data from/to
|
||||
CSV files.
|
||||
https://deploy.rowy.app/
|
||||
|
||||
- **Supercharge your database with your own scripts.**
|
||||
## Documentation
|
||||
|
||||
- Action field: trigger any Cloud Function
|
||||
- Derivative field: populate cell with value derived from the rest of the
|
||||
row’s values
|
||||
- Aggregate field: populate cell with value aggregated from the row’s
|
||||
sub-table
|
||||
You can find the full documentation with how-to guides and templates
|
||||
[here](http://docs.rowy.io/).
|
||||
|
||||
- **Integrations with external services.**
|
||||
- Connect Table uses Algolia to get a snapshot of another table’s row values
|
||||
- Connect Service uses any HTTP endpoint to get a cell value
|
||||
## Features
|
||||
|
||||
## Firetable makes it easy to use key Firebase products
|
||||
https://user-images.githubusercontent.com/307298/157185793-f67511cd-7b7b-4229-9589-d7defbf7a63f.mp4
|
||||
|
||||
<p align="center">
|
||||
<a href="https://firebase.google.com/products/firestore">
|
||||
<img src="https://github.com/FiretableProject/firetable/wiki/images/firebase/firestore.png" alt="Cloud Firestore" width="19%" />
|
||||
</a>
|
||||
<a href="https://firebase.google.com/products/auth">
|
||||
<img src="https://github.com/FiretableProject/firetable/wiki/images/firebase/authentication.png" alt="Firebase Authentication" width="19%" />
|
||||
</a>
|
||||
<a href="https://firebase.google.com/products/functions">
|
||||
<img src="https://github.com/FiretableProject/firetable/wiki/images/firebase/functions.png" alt="Firebase Functions" width="19%" />
|
||||
</a>
|
||||
<a href="https://firebase.google.com/products/hosting">
|
||||
<img src="https://github.com/FiretableProject/firetable/wiki/images/firebase/hosting.png" alt="Firebase Hosting" width="19%" />
|
||||
</a>
|
||||
<a href="https://firebase.google.com/products/storage">
|
||||
<img src="https://github.com/FiretableProject/firetable/wiki/images/firebase/storage.png" alt="Firebase Storage" width="19%" />
|
||||
</a>
|
||||
</p>
|
||||
<!-- <img width="85%" src="https://firebasestorage.googleapis.com/v0/b/rowyio.appspot.com/o/publicDemo%2FRowy%20Website%20Video%20GIF%20Small.gif?alt=media&token=3f699a8f-c1f2-4046-8ed5-e4ff66947cd8" />
|
||||
-->
|
||||
### Powerful spreadsheet interface for Firestore
|
||||
|
||||
# Getting started
|
||||
- CRUD operations
|
||||
- Sort and filter by row values
|
||||
- Lock, Freeze, Resize, Hide and Rename columns
|
||||
- Multiple views for the same collection
|
||||
- Bulk import or export data - csv, json
|
||||
|
||||
To set up Firetable, you must be comfortable with working with the command line.
|
||||
### Automate with cloud functions and ready made extensions
|
||||
|
||||
You must have at least a basic understanding of how to use npm and install npm
|
||||
packages globally.
|
||||
- Effortlessly build cloud functions on field level triggers right in the browser
|
||||
- Use any NPM modules or APIs
|
||||
- Connect to your favourite tool with pre-built extensions or create your own
|
||||
- SendGrid, Algolia, Twilio, Bigquery and more
|
||||
|
||||
We’ve created the Firetable CLI to automate the steps required to set up
|
||||
Firetable.
|
||||
### Rich and flexible data fields
|
||||
|
||||
### [**Read the getting started guide →**](https://github.com/FiretableProject/firetable/wiki/Getting-Started)
|
||||
- [30+ fields supported](https://docs.rowy.io/field-types/supported-fields)
|
||||
- Basic types: Short Text, Long Text, Email, Phone, URL…
|
||||
- Custom UI pickers: Date, Checkbox, Single Select, Multi Select…
|
||||
- Uploaders: Image, File
|
||||
- Rich Editors: JSON, Code, Rich Text (HTML)
|
||||
- Data validation, default values, required fields
|
||||
- Action field: Clickable trigger for any Cloud Function
|
||||
- Aggregate field: Populate cell with value aggregated from the row’s sub-table
|
||||
- Connect Table: Get snapshot of data from another data table using Algolia
|
||||
- Connect Service: Get data from any HTTP endpoint
|
||||
|
||||
# Documentation
|
||||
### Collaborate with your team
|
||||
|
||||
We’re still working on improving our documentation and writing more
|
||||
beginner-friendly guides.
|
||||
- Granular table-level and field-level permission control
|
||||
with custom user roles
|
||||
- Built in user management
|
||||
- Customizable views for different user roles
|
||||
|
||||
[**Documentation on GitHub Wiki →**](https://github.com/FiretableProject/firetable/wiki)
|
||||
## Install
|
||||
|
||||
# Issues
|
||||
Set up Rowy on your Google Cloud project with this one-click deploy button. Your data and cloud functions stay on your own Firestore/GCP.
|
||||
|
||||
[](https://github.com/antlervc/firetable/issues)
|
||||
[](https://deploy.rowy.app/)
|
||||
|
||||
[Create issues and bug reports here.](https://github.com/antlervc/firetable/issues)
|
||||
Make sure to provide console log outputs and screenshots!
|
||||
The one-click deploy makes the process of setting up easy with a step by step
|
||||
guide and ensures your project is setup correctly.
|
||||
|
||||
# Roadmap and feature requests
|
||||
It deploys [Rowy Run](https://github.com/rowyio/rowyrun), an open-source Cloud
|
||||
Run instance that operates exclusively on your GCP project. So we never have
|
||||
access to your service account or any of your data.
|
||||
|
||||
- [Roadmap](https://github.com/FiretableProject/firetable/wiki/Roadmap)
|
||||
- [View our ideas and feature requests](https://github.com/FiretableProject/firetable/projects/1)
|
||||
Alternatively, you can manually install by
|
||||
[following this guide](https://docs.rowy.io/setup/install).
|
||||
|
||||
---
|
||||
## Roadmap
|
||||
|
||||
<!-- # Join Our Community
|
||||
[View our roadmap](https://demo.rowy.io/table/roadmap) on Rowy - Upvote, downvote, share your thoughts!
|
||||
|
||||
<a href="https://discord.gg/B8yAD5PDX4">
|
||||
<img
|
||||
src="https://invidget.switchblade.xyz/B8yAD5PDX4"
|
||||
alt="Join Firetable Open Source Project"
|
||||
>
|
||||
</a>
|
||||
<br> -->
|
||||
If you'd like to propose a feature, submit an issue [here](https://github.com/rowyio/rowy/issues/new?assignees=&labels=&template=feature_request.md&title=).
|
||||
|
||||
# Contributing 🙌
|
||||
## Support the project
|
||||
|
||||
We welcome any contributions from the open source community.
|
||||
- Join a community of developers on [Discord](https://discord.gg/fjBugmvzZP) and share your ideas/feedback 💬
|
||||
- Follow us on [Twitter](https://twitter.com/rowyio) and help [spread the word](https://twitter.com/intent/tweet?text=Check%20out%20@rowyio%20-%20It%27s%20like%20an%20open-source%20Airtable%20for%20your%20database,%20but%20with%20a%20built-in%20code%20editor%20for%20cloud%20functions%20to%20run%20on%20data%20CRUD!%0a%0aEsp%20if%20building%20on%20@googlecloud%20and%20@Firebase%20stack,%20it%20is%20the%20fastest%20way%20to%20build%20your%20product.%20Live%20demo:%20https://demo.rowy.io) 🙏
|
||||
- Give us a star to this Github repo ⭐️
|
||||
- Submit a PR. Take a look at our [contribution guide](https://github.com/rowyio/rowy/blob/main/CONTRIBUTING.md) and get started with [good first issues](https://github.com/rowyio/rowy/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).
|
||||
|
||||
- **[Good First Issues](https://github.com/FiretableProject/firetable/projects/3)**
|
||||
project is a good place to start for contributing to Firetable.
|
||||
- For new feature or enhancement, please create an issue first or send us a
|
||||
message on **[Discord](https://discord.gg/B8yAD5PDX4)** so that we can discuss
|
||||
and guide you as needed ahead of you starting the work.
|
||||
## Help
|
||||
|
||||
- Live chat support on [Discord](https://discord.gg/fjBugmvzZP)
|
||||
- [Email](mailto:hello@rowy.io)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"functions": {
|
||||
"predeploy": [
|
||||
"npm --prefix \"$RESOURCE_DIR\" run lint",
|
||||
"npm --prefix \"$RESOURCE_DIR\" run build"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
lib/
|
||||
147392
cloud_functions/functions/.yarn/releases/yarn-1.22.5.cjs
vendored
@@ -1,56 +0,0 @@
|
||||
{
|
||||
"name": "functions",
|
||||
"scripts": {
|
||||
"updateStatus": "ts-node updateDeployStatus.ts",
|
||||
"generateConfig": "ts-node src/generateConfig.ts",
|
||||
"lint": "tslint --project tsconfig.json",
|
||||
"build": "tsc",
|
||||
"serve": "npm run build && firebase serve --only functions",
|
||||
"shell": "npm run build && firebase functions:shell",
|
||||
"start": "npm run shell",
|
||||
"deployFT": "echo 'n\n' | firebase deploy --interactive",
|
||||
"logs": "firebase functions:log"
|
||||
},
|
||||
"engines": {
|
||||
"node": "14"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@google-cloud/cloudbuild": "^2.0.6",
|
||||
"@google-cloud/firestore": "^4.9.7",
|
||||
"@google-cloud/pubsub": "^2.5.0",
|
||||
"@google-cloud/storage": "^5.1.2",
|
||||
"@sendgrid/mail": "^7.4.2",
|
||||
"@slack/web-api": "^6.0.0",
|
||||
"algoliasearch": "^4.8.6",
|
||||
"firebase-admin": "^9.4.2",
|
||||
"firebase-functions": "^3.13.1",
|
||||
"imagemin": "^7.0.1",
|
||||
"imagemin-mozjpeg": "^9.0.0",
|
||||
"imagemin-pngquant": "^9.0.2",
|
||||
"lodash": "^4.17.21",
|
||||
"sharp": "^0.25.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/algoliasearch": "^3.34.10",
|
||||
"@types/imagemin": "^7.0.0",
|
||||
"@types/imagemin-mozjpeg": "^8.0.0",
|
||||
"@types/imagemin-pngquant": "^7.0.0",
|
||||
"@types/json2csv": "^5.0.1",
|
||||
"@types/lodash": "^4.14.158",
|
||||
"@types/sharp": "^0.25.1",
|
||||
"firebase-tools": "^9.2.2",
|
||||
"husky": "^4.2.5",
|
||||
"prettier": "^2.1.1",
|
||||
"pretty-quick": "^3.0.0",
|
||||
"ts-node": "^8.6.2",
|
||||
"tslint": "^6.1.0",
|
||||
"typescript": "^3.2.2"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged"
|
||||
}
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
import * as _ from "lodash";
|
||||
import { db, auth } from "../config";
|
||||
import * as admin from "firebase-admin";
|
||||
import utilFns from "../utils";
|
||||
type ActionData = {
|
||||
ref: {
|
||||
id: string;
|
||||
path: string;
|
||||
parentId: string;
|
||||
tablePath: string;
|
||||
};
|
||||
schemaDocPath?: string;
|
||||
column: any;
|
||||
action: "run" | "redo" | "undo";
|
||||
actionParams: any;
|
||||
};
|
||||
// import {
|
||||
// makeId,
|
||||
// hasGoogleMailServer,
|
||||
// hasMissingFields,
|
||||
// } from "../utils";
|
||||
|
||||
import { hasAnyRole } from "../utils/auth";
|
||||
|
||||
const missingFieldsReducer = (data: any) => (acc: string[], curr: string) => {
|
||||
if (data[curr] === undefined) {
|
||||
return [...acc, curr];
|
||||
} else return acc;
|
||||
};
|
||||
|
||||
const generateSchemaDocPath = (tablePath) => {
|
||||
const pathComponents = tablePath.split("/");
|
||||
return `_FIRETABLE_/settings/${
|
||||
pathComponents[1] === "table" ? "schema" : "groupSchema"
|
||||
}/${pathComponents[2]}`;
|
||||
};
|
||||
const serverTimestamp = admin.firestore.FieldValue.serverTimestamp;
|
||||
|
||||
export const actionScript = functions.https.onCall(
|
||||
async (data: ActionData, context: functions.https.CallableContext) => {
|
||||
try {
|
||||
if (!context) {
|
||||
throw Error(`You are unauthenticated`);
|
||||
}
|
||||
|
||||
const { ref, actionParams, column, action, schemaDocPath } = data;
|
||||
const _schemaDocPath =
|
||||
schemaDocPath ?? generateSchemaDocPath(ref.tablePath);
|
||||
const [schemaDoc, rowQuery] = await Promise.all([
|
||||
db.doc(_schemaDocPath).get(),
|
||||
db.doc(ref.path).get(),
|
||||
]);
|
||||
const row = rowQuery.data();
|
||||
const schemaDocData = schemaDoc.data();
|
||||
if (!schemaDocData) {
|
||||
return {
|
||||
success: false,
|
||||
message: "no schema found",
|
||||
};
|
||||
}
|
||||
const config = schemaDocData.columns[column.key].config;
|
||||
const { script, requiredRoles, requiredFields, undo, redo } = config;
|
||||
if (!requiredRoles || requiredRoles.length === 0) {
|
||||
throw Error(`You need to specify at least one role to run this script`);
|
||||
}
|
||||
if (!hasAnyRole(requiredRoles, context)) {
|
||||
throw Error(`You don't have the required roles permissions`);
|
||||
}
|
||||
|
||||
const missingRequiredFields = requiredFields
|
||||
? requiredFields.reduce(missingFieldsReducer(row), [])
|
||||
: [];
|
||||
if (missingRequiredFields.length > 0) {
|
||||
throw new Error(
|
||||
`Missing required fields:${missingRequiredFields.join(", ")}`
|
||||
);
|
||||
}
|
||||
//
|
||||
// get auth
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
undo,
|
||||
redo,
|
||||
row,
|
||||
ref,
|
||||
actionParams,
|
||||
column,
|
||||
schemaDocData,
|
||||
script,
|
||||
requiredRoles,
|
||||
requiredFields,
|
||||
})
|
||||
);
|
||||
|
||||
const result: {
|
||||
message: string;
|
||||
status: string;
|
||||
success: boolean;
|
||||
} = await eval(
|
||||
`async({row,db, ref,auth,utilFns,actionParams,context})=>{${
|
||||
action === "undo" ? config["undo.script"] : script
|
||||
}}`
|
||||
)({ row, db, auth, utilFns, ref, actionParams, context });
|
||||
if (result.success)
|
||||
return {
|
||||
success: result.success,
|
||||
message: result.message,
|
||||
cellValue: {
|
||||
redo: config["redo.enabled"],
|
||||
status: result.status,
|
||||
completedAt: serverTimestamp(),
|
||||
meta: { ranBy: context.auth!.token.email },
|
||||
undo: action !== "undo" && config["undo.enabled"],
|
||||
},
|
||||
undo: config["undo.enabled"],
|
||||
redo: config["redo.enabled"],
|
||||
};
|
||||
else
|
||||
return {
|
||||
success: false,
|
||||
message: result.message,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error,
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -1,81 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
import * as admin from "firebase-admin";
|
||||
|
||||
import { db } from "../config";
|
||||
import config, { collectionPath, functionName } from "../functionConfig";
|
||||
// generated using generateConfig.ts
|
||||
|
||||
const incrementor = (v: number) => admin.firestore.FieldValue.increment(v);
|
||||
const functionConfig: any = config;
|
||||
|
||||
const subDocTrigger = async (
|
||||
change: functions.Change<functions.firestore.DocumentSnapshot>,
|
||||
context: functions.EventContext
|
||||
) => {
|
||||
const beforeData = change.before?.data();
|
||||
const afterData = change.after?.data();
|
||||
const triggerType =
|
||||
Boolean(beforeData) && Boolean(afterData)
|
||||
? "update"
|
||||
: Boolean(afterData)
|
||||
? "create"
|
||||
: "delete";
|
||||
const parentDocRef = change.after
|
||||
? change.after.ref.parent.parent
|
||||
: change.before.ref.parent.parent;
|
||||
const parentDoc = await parentDocRef?.get();
|
||||
const parentDocData = parentDoc?.data();
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
parentDocRef,
|
||||
parentDocData,
|
||||
beforeData,
|
||||
afterData,
|
||||
triggerType,
|
||||
})
|
||||
);
|
||||
//return false;
|
||||
const aggregateData = await functionConfig.reduce(
|
||||
async (accAggregate: any, currAggregate) => {
|
||||
// check relavent sub-table
|
||||
if (currAggregate.subtables.includes(context.params.subCollectionId)) {
|
||||
const newValue = await currAggregate.eval(db)({
|
||||
beforeData,
|
||||
afterData,
|
||||
incrementor,
|
||||
triggerType,
|
||||
});
|
||||
if (newValue !== undefined) {
|
||||
return {
|
||||
...(await accAggregate),
|
||||
...Object.keys(newValue).reduce((acc, curr) => {
|
||||
return {
|
||||
...acc,
|
||||
[`${currAggregate.fieldName}.${curr}`]: newValue[curr],
|
||||
};
|
||||
}, {}),
|
||||
};
|
||||
} else return await accAggregate;
|
||||
} else return await accAggregate;
|
||||
},
|
||||
{}
|
||||
);
|
||||
const update = Object.keys(aggregateData).reduce((acc: any, curr: string) => {
|
||||
if (aggregateData[curr] !== undefined) {
|
||||
return { ...acc, [curr]: aggregateData[curr] };
|
||||
} else {
|
||||
return acc;
|
||||
}
|
||||
}, {});
|
||||
console.log({ update, aggregateData });
|
||||
if (parentDocRef && Object.keys(update).length !== 0) {
|
||||
return parentDocRef.update(update);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
export const FT_aggregates = {
|
||||
[functionName]: functions.firestore
|
||||
.document(`${collectionPath}/{parentId}/{subCollectionId}/{docId}`)
|
||||
.onWrite(subDocTrigger),
|
||||
};
|
||||
@@ -1,218 +0,0 @@
|
||||
import algoliasearch from "algoliasearch";
|
||||
import * as functions from "firebase-functions";
|
||||
import * as _ from "lodash";
|
||||
import { env } from "../config";
|
||||
import fnConfig from "../functionConfig"; // generated using generateConfig.ts
|
||||
const functionConfig: any = fnConfig;
|
||||
|
||||
const APP_ID = env.algolia ? env.algolia.app : "NEEDS_CONFIG";
|
||||
const ADMIN_KEY = env.algolia ? env.algolia.key : "NEEDS_CONFIG";
|
||||
|
||||
const client = algoliasearch(APP_ID, ADMIN_KEY);
|
||||
|
||||
const missingFieldsReducer = (data: any) => (acc: string[], curr: string) => {
|
||||
if (data[curr] === undefined) {
|
||||
return [...acc, curr];
|
||||
} else return acc;
|
||||
};
|
||||
|
||||
const filterSnapshot = (
|
||||
field: { docPath: string; snapshot: any },
|
||||
preservedKeys: string[]
|
||||
) => {
|
||||
return {
|
||||
docPath: field.docPath,
|
||||
...preservedKeys.reduce((acc: any, currentKey: string) => {
|
||||
const value = _.get(field.snapshot, currentKey);
|
||||
if (value) {
|
||||
return { ...acc, snapshot: { [currentKey]: value, ...acc.snapshot } };
|
||||
} else return acc;
|
||||
}, {}),
|
||||
};
|
||||
};
|
||||
|
||||
// returns object of fieldsToSync
|
||||
const algoliaReducer = (docData: FirebaseFirestore.DocumentData) => (
|
||||
acc: any,
|
||||
curr: string | { fieldName: string; snapshotFields: string[] }
|
||||
) => {
|
||||
if (typeof curr === "string") {
|
||||
if (docData[curr] && typeof docData[curr].toDate === "function") {
|
||||
return {
|
||||
...acc,
|
||||
[curr]: docData[curr].toDate().getTime() / 1000,
|
||||
};
|
||||
} else if (docData[curr] !== undefined || docData[curr] !== null) {
|
||||
return { ...acc, [curr]: docData[curr] };
|
||||
} else {
|
||||
return acc;
|
||||
}
|
||||
} else {
|
||||
if (docData[curr.fieldName] && curr.snapshotFields) {
|
||||
return {
|
||||
...acc,
|
||||
[curr.fieldName]: docData[curr.fieldName].map((snapshot) =>
|
||||
filterSnapshot(snapshot, curr.snapshotFields)
|
||||
),
|
||||
};
|
||||
} else {
|
||||
return acc;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const addToAlgolia = (
|
||||
config: any,
|
||||
fieldsToSync: string[],
|
||||
requiredFields: string[],
|
||||
indexName?: string
|
||||
) => (
|
||||
snapshot: FirebaseFirestore.DocumentSnapshot,
|
||||
context: functions.EventContext
|
||||
) => {
|
||||
if (config.subTable && config.subTable !== context.params.subCollectionId)
|
||||
return false;
|
||||
const _index = indexName
|
||||
? indexName
|
||||
: `${config.name}${config.subTable ? `_${config.subTable}` : ""}`;
|
||||
const objectID = snapshot.id;
|
||||
const docData = snapshot.data();
|
||||
if (!docData) return false; // returns if theres no data in the doc
|
||||
const missingRequiredFields = requiredFields.reduce(
|
||||
missingFieldsReducer(docData),
|
||||
[]
|
||||
);
|
||||
if (missingRequiredFields.length > 0) {
|
||||
throw new Error(
|
||||
`Missing required fields:${missingRequiredFields.join(", ")}`
|
||||
);
|
||||
}
|
||||
const algoliaData = fieldsToSync.reduce(algoliaReducer(docData), {});
|
||||
if (Object.keys(algoliaData).length === 0) return false; // returns if theres nothing to sync
|
||||
const index = client.initIndex(_index); // initialize algolia index
|
||||
return index.saveObject({ ...algoliaData, objectID }); // add new algolia entry
|
||||
};
|
||||
|
||||
const updateAlgolia = (
|
||||
config: any,
|
||||
fieldsToSync: string[],
|
||||
requiredFields: string[],
|
||||
indexName?: string
|
||||
) => async (
|
||||
snapshot: functions.Change<FirebaseFirestore.DocumentSnapshot>,
|
||||
context: functions.EventContext
|
||||
) => {
|
||||
const objectID = snapshot.after.id;
|
||||
try {
|
||||
if (config.subTable && config.subTable !== context.params.subCollectionId)
|
||||
return false;
|
||||
const _index = indexName
|
||||
? indexName
|
||||
: `${config.name}${config.subTable ? `_${config.subTable}` : ""}`;
|
||||
|
||||
const docData = snapshot.after.data();
|
||||
if (!docData) return false; // returns if theres no data in the doc
|
||||
|
||||
const missingRequiredFields = requiredFields.reduce(
|
||||
missingFieldsReducer(docData),
|
||||
[]
|
||||
);
|
||||
if (missingRequiredFields.length > 0) {
|
||||
throw new Error(
|
||||
`Missing required fields:${missingRequiredFields.join(", ")}`
|
||||
);
|
||||
}
|
||||
const algoliaData = fieldsToSync.reduce(algoliaReducer(docData), {});
|
||||
if (Object.keys(algoliaData).length === 0) return false; // returns if theres nothing to sync
|
||||
const index = client.initIndex(_index); // initialize algolia index
|
||||
const algoliaTask = await index.saveObject({ ...algoliaData, objectID }); // add update algolia entry
|
||||
|
||||
return algoliaTask;
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify({ error, objectID }));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const deleteFromAlgolia = (config: any, indexName?: string) => (
|
||||
snapshot: FirebaseFirestore.DocumentSnapshot,
|
||||
context: functions.EventContext
|
||||
) => {
|
||||
if (config.subTable && config.subTable !== context.params.subCollectionId)
|
||||
return false;
|
||||
const _index = indexName
|
||||
? indexName
|
||||
: `${config.name}${config.subTable ? `_${config.subTable}` : ""}`;
|
||||
const objectID = snapshot.id;
|
||||
const index = client.initIndex(_index); // initialize algolia index
|
||||
return index.deleteObject(objectID); // delete algolia entry
|
||||
};
|
||||
|
||||
const documentPathGenerator = (config) =>
|
||||
`${
|
||||
config.subTable
|
||||
? `${config.name}/{parentId}/{subCollectionId}/{docId}`
|
||||
: `${config.name}/{docId}`
|
||||
}`;
|
||||
/**
|
||||
* returns 3 different trigger functions (onCreate,onUpdate,onDelete) in an object
|
||||
* @param config configuration object
|
||||
*/
|
||||
const algoliaFnsGenerator = (config) => ({
|
||||
onCreate: functions.firestore
|
||||
.document(documentPathGenerator(config))
|
||||
.onCreate(
|
||||
config.indices
|
||||
? (snapshot, context) =>
|
||||
Promise.all(
|
||||
config.indices.map((index) =>
|
||||
addToAlgolia(
|
||||
config,
|
||||
index.fieldsToSync,
|
||||
config.requiredFields ?? [],
|
||||
index.name
|
||||
)(snapshot, context)
|
||||
)
|
||||
)
|
||||
: addToAlgolia(config, config.fieldsToSync, config.requiredFields ?? [])
|
||||
),
|
||||
onUpdate: functions.firestore
|
||||
.document(documentPathGenerator(config))
|
||||
.onUpdate(
|
||||
config.indices
|
||||
? (snapshot, context) =>
|
||||
Promise.all(
|
||||
config.indices.map((index) =>
|
||||
updateAlgolia(
|
||||
config,
|
||||
index.fieldsToSync,
|
||||
config.requiredFields ?? [],
|
||||
index.name
|
||||
)(snapshot, context)
|
||||
)
|
||||
)
|
||||
: updateAlgolia(
|
||||
config,
|
||||
config.fieldsToSync,
|
||||
config.requiredFields ?? []
|
||||
)
|
||||
),
|
||||
onDelete: functions.firestore
|
||||
.document(documentPathGenerator(config))
|
||||
.onDelete(
|
||||
config.indices
|
||||
? (snapshot, context) =>
|
||||
Promise.all(
|
||||
config.indices.map((index) =>
|
||||
deleteFromAlgolia(config, index.name)(snapshot, context)
|
||||
)
|
||||
)
|
||||
: deleteFromAlgolia(config)
|
||||
),
|
||||
});
|
||||
|
||||
export const FT_algolia = {
|
||||
[`${functionConfig.name}${
|
||||
functionConfig.subTable ? `${functionConfig.subTable}` : ""
|
||||
}`]: { ...algoliaFnsGenerator(functionConfig) },
|
||||
};
|
||||
@@ -1,51 +0,0 @@
|
||||
import algoliasearch from "algoliasearch";
|
||||
import * as functions from "firebase-functions";
|
||||
import { env } from "./config";
|
||||
|
||||
const algoliaClient = algoliasearch(env.algolia.app, env.algolia.key);
|
||||
|
||||
export const getAlgoliaSearchKey = functions.https.onCall(async (
|
||||
data: { index: string },
|
||||
context: functions.https.CallableContext
|
||||
) => {
|
||||
const requestedIndex = data.index
|
||||
try {
|
||||
if (!context.auth || !context.auth.token) throw new Error("Unauthenticated")
|
||||
|
||||
const allIndicesRoles = ['ADMIN',"TEAM"] // you can add more roles here that need access to all algolia indices
|
||||
|
||||
const rolesIndicesAccess = {
|
||||
"ROLE":["index_1","index_2"]
|
||||
}
|
||||
const userRoles = context.auth.token.roles
|
||||
if (userRoles.some(role=> allIndicesRoles.includes(role)||rolesIndicesAccess[role].includes(requestedIndex))){
|
||||
const validUntil = Math.floor(Date.now() / 1000) + 3600;
|
||||
const key = algoliaClient.generateSecuredApiKey(
|
||||
env.algolia.search,
|
||||
{
|
||||
filters:"",
|
||||
validUntil,
|
||||
restrictIndices: [requestedIndex],
|
||||
userToken: context.auth.uid,
|
||||
}
|
||||
);
|
||||
return {
|
||||
data: key,
|
||||
success: true,
|
||||
};
|
||||
}else{
|
||||
return {
|
||||
message: 'Missing Required roles for this index',
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error,
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
import * as firestore from "@google-cloud/firestore";
|
||||
import { hasAnyRole } from "./utils/auth";
|
||||
|
||||
const client = new firestore.v1.FirestoreAdminClient();
|
||||
|
||||
// Replace BUCKET_NAME
|
||||
const bucket = "gs://BUCKET_NAME";
|
||||
/*
|
||||
const restoreFirestoreBackup = (collectionIds: string[] = []) => {
|
||||
const projectId = process.env.GCP_PROJECT || process.env.GCLOUD_PROJECT;
|
||||
const databaseName = client.databasePath(projectId, "(default)");
|
||||
const date = new Date();
|
||||
|
||||
const backupFolder = `${date.getFullYear()}-${
|
||||
date.getMonth() + 1
|
||||
}-${date.getDate()}`;
|
||||
const inputUriPrefix = bucket + "/" + backupFolder;
|
||||
console.log(inputUriPrefix);
|
||||
return client
|
||||
.importDocuments({
|
||||
name: databaseName,
|
||||
inputUriPrefix,
|
||||
// Leave collectionIds empty to export all collections
|
||||
// or set to a list of collection IDs to export,
|
||||
// collectionIds: ['users', 'posts']
|
||||
collectionIds,
|
||||
})
|
||||
.then((responses) => {
|
||||
const response = responses[0];
|
||||
console.log(`Operation Name: ${response["name"]}`);
|
||||
return response;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
throw new Error("import operation failed");
|
||||
});
|
||||
};
|
||||
|
||||
export const scheduledFirestoreImport = functions.pubsub
|
||||
.schedule("every 24 hours")
|
||||
.onRun((context) => {
|
||||
console.log(context);
|
||||
return restoreFirestoreBackup();
|
||||
});
|
||||
*/
|
||||
|
||||
const firestoreBackup = (collectionIds: string[] = []) => {
|
||||
const projectId = process.env.GCP_PROJECT || process.env.GCLOUD_PROJECT;
|
||||
const databaseName = client.databasePath(projectId ?? "", "(default)");
|
||||
const date = new Date();
|
||||
|
||||
const backupFolder = `${date.getUTCFullYear()}-${
|
||||
date.getUTCMonth() + 1
|
||||
}-${date.getUTCDate()}-${date.getUTCHours()}`;
|
||||
|
||||
return client
|
||||
.exportDocuments({
|
||||
name: databaseName,
|
||||
outputUriPrefix: bucket + "/" + backupFolder,
|
||||
// Leave collectionIds empty to export all collections
|
||||
// or set to a list of collection IDs to export,
|
||||
// collectionIds: ['users', 'posts']
|
||||
collectionIds,
|
||||
})
|
||||
.then((responses) => {
|
||||
const response = responses[0];
|
||||
console.log(`Operation Name: ${response["name"]}`);
|
||||
return response;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
throw new Error("Export operation failed");
|
||||
});
|
||||
};
|
||||
export const scheduledFirestoreBackup = functions.pubsub
|
||||
.schedule("every 12 hours")
|
||||
.onRun((context) => {
|
||||
console.log(context);
|
||||
return firestoreBackup();
|
||||
});
|
||||
|
||||
export const callableFirestoreBackup = functions.https.onCall(
|
||||
async (data, context) => {
|
||||
console.log(data);
|
||||
const authorized = hasAnyRole(["ADMIN"], context);
|
||||
if (!context.auth || !authorized) {
|
||||
console.warn(`unauthorized user${context}`);
|
||||
return {
|
||||
success: false,
|
||||
message: "you don't have permissions to send this email",
|
||||
};
|
||||
} else {
|
||||
await firestoreBackup();
|
||||
return {
|
||||
success: true,
|
||||
message: "backup ran",
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -1,96 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
import { hasAnyRole } from "../utils/auth";
|
||||
import { serverTimestamp } from "../utils";
|
||||
import { db } from "../config";
|
||||
const { CloudBuildClient } = require("@google-cloud/cloudbuild");
|
||||
const cb = new CloudBuildClient();
|
||||
|
||||
export const triggerCloudBuild = functions.https.onCall(
|
||||
async (
|
||||
data: {
|
||||
ref: {
|
||||
id: string;
|
||||
path: string;
|
||||
parentId: string;
|
||||
};
|
||||
action: "run" | "redo" | "undo";
|
||||
},
|
||||
context: functions.https.CallableContext
|
||||
) => {
|
||||
const {
|
||||
ref, // action
|
||||
} = data;
|
||||
|
||||
const authorized = hasAnyRole(["ADMIN"], context);
|
||||
if (!context.auth || !authorized) {
|
||||
console.warn(`unauthorized user${context}`);
|
||||
return {
|
||||
success: false,
|
||||
message: "you don't have permission to trigger a build",
|
||||
};
|
||||
}
|
||||
const doc = await db.doc(ref.path).get();
|
||||
const row = doc.data();
|
||||
if (!row) throw Error("No row data");
|
||||
const { triggerId, branch, projectId, groupName, functionConfig } = row;
|
||||
// Starts a build against the branch provided.
|
||||
const [resp] = await cb.runBuildTrigger({
|
||||
projectId, //project hosting cloud build
|
||||
triggerId,
|
||||
source: {
|
||||
branchName: branch,
|
||||
substitutions: {
|
||||
_PROJECT_ID: projectId,
|
||||
_FUNCTIONS_GROUP: groupName,
|
||||
_FUNCTION_CONFIG: functionConfig,
|
||||
_REQUEST_DOC_PATH: ref.path,
|
||||
},
|
||||
},
|
||||
});
|
||||
const buildId = resp.metadata.build.id;
|
||||
const logUrl = resp.metadata.build.logUrl;
|
||||
console.log({ buildId, logUrl });
|
||||
await db
|
||||
.doc(ref.path)
|
||||
.update({ buildId, logUrl, buildDuration: { start: serverTimestamp() } });
|
||||
if (buildId && logUrl) {
|
||||
return {
|
||||
message: "cloud functions are snow flakes",
|
||||
cellValue: {
|
||||
redo: true,
|
||||
status: `Triggered`,
|
||||
completedAt: serverTimestamp(),
|
||||
meta: { ranBy: context.auth.token.email },
|
||||
undo: false,
|
||||
},
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
export const cloudBuildUpdates = functions.pubsub
|
||||
.topic("cloud-builds")
|
||||
.onPublish(async (message, context) => {
|
||||
console.log(JSON.stringify(message));
|
||||
const { buildId, status } = message.attributes;
|
||||
console.log(JSON.stringify({ buildId, status }));
|
||||
//message
|
||||
//status: "SUCCESS"
|
||||
//buildId: "1a6d7819-aa35-486c-a29c-fb67eb39430f"
|
||||
|
||||
const query = await db
|
||||
.collection("cloudFunctions")
|
||||
.where("buildId", "==", buildId)
|
||||
.get();
|
||||
|
||||
if (query.docs.length !== 0) {
|
||||
const update = { status };
|
||||
if (status === "SUCCESS" || status === "FAILURE") {
|
||||
update["buildDuration.end"] = serverTimestamp();
|
||||
}
|
||||
await query.docs[0].ref.update(update);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@@ -1,33 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
import * as _ from "lodash";
|
||||
import { hasAnyRole } from "./utils/auth";
|
||||
import { auth } from "./config";
|
||||
|
||||
// Impersonator Auth callable takes email and returns JWT of user on firebaseAuth
|
||||
// requires a user admin role
|
||||
|
||||
export const ImpersonatorAuth = functions.https.onCall(
|
||||
async (data, context) => {
|
||||
try {
|
||||
if (hasAnyRole(["ADMIN"], context)) {
|
||||
const user = await auth.getUserByEmail(data.email);
|
||||
const jwt = await auth.createCustomToken(user.uid);
|
||||
return {
|
||||
success: true,
|
||||
jwt,
|
||||
message: "successfully generated token",
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
success: false,
|
||||
message: "admin role is required",
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
message: JSON.stringify(error),
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -1,158 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
|
||||
import { db } from "../config";
|
||||
|
||||
import * as _ from "lodash";
|
||||
import { replacer } from "../utils";
|
||||
import config from "../functionConfig"; // generated using generateConfig.ts
|
||||
const functionConfig: any = config;
|
||||
// returns object of fieldsToSync
|
||||
const docReducer = (docData: FirebaseFirestore.DocumentData) => (
|
||||
acc: any,
|
||||
curr: string
|
||||
) => {
|
||||
if (docData[curr] !== undefined && docData[curr] !== null)
|
||||
return { ...acc, [curr]: docData[curr] };
|
||||
else return acc;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param targetCollection
|
||||
* @param fieldsToSync
|
||||
*/
|
||||
const cloneDoc = (targetCollection: string, fieldsToSync: string[]) => (
|
||||
snapshot: FirebaseFirestore.DocumentSnapshot
|
||||
) => {
|
||||
const docId = snapshot.id;
|
||||
const docData = snapshot.data();
|
||||
if (!docData) return false; // returns if theres no data in the doc
|
||||
const syncData = fieldsToSync.reduce(docReducer(docData), {});
|
||||
if (Object.keys(syncData).length === 0) return false; // returns if theres nothing to sync
|
||||
console.log(`creating new doc or forcing update ${docId}`);
|
||||
const collectionPath = targetCollection.replace(
|
||||
/\{\{(.*?)\}\}/g,
|
||||
replacer(docData)
|
||||
);
|
||||
if (collectionPath.includes("//")) {
|
||||
console.log(`${collectionPath} is an invalid collection path`);
|
||||
return false;
|
||||
}
|
||||
db.collection(collectionPath)
|
||||
.doc(docId)
|
||||
.set({ ...syncData, syncedAt: new Date() }, { merge: true })
|
||||
.catch((error) => console.error(error));
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param targetCollection
|
||||
* @param fieldsToSync
|
||||
*/
|
||||
const syncDoc = (targetCollection: string, fieldsToSync: string[]) => async (
|
||||
snapshot: FirebaseFirestore.DocumentSnapshot
|
||||
) => {
|
||||
const docId = snapshot.id;
|
||||
const docData = snapshot.data();
|
||||
if (!docData) return false; // returns if theres no data in the doc
|
||||
const syncData = fieldsToSync.reduce(docReducer(docData), {});
|
||||
|
||||
const collectionPath = targetCollection.replace(
|
||||
/\{\{(.*?)\}\}/g,
|
||||
replacer(docData)
|
||||
);
|
||||
|
||||
if (collectionPath.includes("//")) {
|
||||
console.log(`${collectionPath} is an invalid collection path`);
|
||||
return false;
|
||||
}
|
||||
if (Object.keys(syncData).length === 0) return false; // returns if theres nothing to sync
|
||||
const targetDoc = await db.collection(collectionPath).doc(docId).get();
|
||||
if (!targetDoc.exists) return false;
|
||||
db.collection(collectionPath)
|
||||
.doc(docId)
|
||||
.update({ ...syncData, syncedAt: new Date() })
|
||||
.catch((error) => console.error(error));
|
||||
return true;
|
||||
};
|
||||
|
||||
const deleteDoc = (targetCollection: string) => async (
|
||||
snapshot: FirebaseFirestore.DocumentSnapshot,
|
||||
context: functions.EventContext
|
||||
) => {
|
||||
const { docId } = context.params;
|
||||
return db.collection(targetCollection).doc(docId).delete();
|
||||
};
|
||||
|
||||
/**
|
||||
* onUpdate change to snapshot adapter
|
||||
* @param targetCollection
|
||||
* @param fieldsToSync
|
||||
*/
|
||||
const syncDocOnUpdate = (
|
||||
targetCollection: string,
|
||||
fieldsToSync: string[],
|
||||
forcedUpdate: boolean
|
||||
) => (snapshot: functions.Change<FirebaseFirestore.DocumentSnapshot>) => {
|
||||
const afterData = snapshot.after.data();
|
||||
const beforeData = snapshot.before.data();
|
||||
const hasChanged = !_.isEqual(afterData, beforeData);
|
||||
if (hasChanged) {
|
||||
if (forcedUpdate === true) {
|
||||
return cloneDoc(targetCollection, fieldsToSync)(snapshot.after);
|
||||
} else {
|
||||
return syncDoc(targetCollection, fieldsToSync)(snapshot.after);
|
||||
}
|
||||
} else {
|
||||
console.warn("no change detected");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* returns 2 different trigger functions (onCreate,onUpdate) in an object
|
||||
* @param collectionConfig configuration object
|
||||
* onCreate
|
||||
* onUpdate
|
||||
* onDelete
|
||||
* source
|
||||
* target
|
||||
* fieldsToSync
|
||||
*
|
||||
*/
|
||||
const collectionSyncFnsGenerator = (collectionConfig) =>
|
||||
Object.entries({
|
||||
onCreate: collectionConfig.onCreate
|
||||
? functions.firestore
|
||||
.document(`${collectionConfig.source}/{docId}`)
|
||||
.onCreate(
|
||||
cloneDoc(collectionConfig.target, collectionConfig.fieldsToSync)
|
||||
)
|
||||
: null,
|
||||
onUpdate: collectionConfig.onUpdate
|
||||
? functions.firestore
|
||||
.document(`${collectionConfig.source}/{docId}`)
|
||||
.onUpdate(
|
||||
syncDocOnUpdate(
|
||||
collectionConfig.target,
|
||||
collectionConfig.fieldsToSync,
|
||||
collectionConfig.forcedUpdate
|
||||
)
|
||||
)
|
||||
: null,
|
||||
onDelete: collectionConfig.onDelete
|
||||
? functions.firestore
|
||||
.document(`${collectionConfig.source}/{docId}`)
|
||||
.onDelete(deleteDoc(collectionConfig.target))
|
||||
: null,
|
||||
}).reduce((a, [k, v]) => (v === null ? a : { ...a, [k]: v }), {});
|
||||
|
||||
//export default collectionSyncFnsGenerator;
|
||||
export const FT_sync = {
|
||||
[`${`${`${functionConfig.source}`
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")}`}2${`${`${functionConfig.target}`
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")}`}`]: collectionSyncFnsGenerator(functionConfig),
|
||||
};
|
||||
@@ -1,113 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
// tslint:disable-next-line: no-import-side-effect
|
||||
import "../config";
|
||||
import * as admin from "firebase-admin";
|
||||
import * as path from "path";
|
||||
import * as os from "os";
|
||||
import * as fs from "fs";
|
||||
import * as sharp from "sharp";
|
||||
import * as imagemin from "imagemin";
|
||||
import * as imageminMozjpeg from "imagemin-mozjpeg";
|
||||
import imageminPngquant from "imagemin-pngquant";
|
||||
import config_ from "../functionConfig";
|
||||
const SUPPORTED_TYPES = ["image/jpeg", "image/png"];
|
||||
const DEFAULT_SIZES = ["400x400", "200x200", "100x100"];
|
||||
const config: any = config_;
|
||||
const sizes =
|
||||
config && Array.isArray(config.sizes) && typeof config.sizes[0] === "string"
|
||||
? config.sizes
|
||||
: DEFAULT_SIZES;
|
||||
const excludePaths =
|
||||
config &&
|
||||
Array.isArray(config.excludes) &&
|
||||
typeof config.excludes[0] === "string"
|
||||
? config.excludes
|
||||
: [];
|
||||
export const FT_compressedThumbnail = functions.storage
|
||||
.object()
|
||||
.onFinalize(async (object) => {
|
||||
// Log file name, size, and content type for monitoring
|
||||
console.log(object.name, object.size, object.contentType);
|
||||
// Exit if this is triggered on a file that is not an image.
|
||||
if (!object.contentType || !SUPPORTED_TYPES.includes(object.contentType)) {
|
||||
console.log("Unsupported type", object.contentType);
|
||||
return null;
|
||||
}
|
||||
// Exit if this is already a compressed thumbnail.
|
||||
if (object.metadata?.resizedImage) {
|
||||
console.log("This is already a compressed thumbnail", object.name);
|
||||
return null;
|
||||
}
|
||||
// Get Firebase Storage download token
|
||||
const token = object.metadata?.firebaseStorageDownloadTokens;
|
||||
|
||||
const filePath: string = object.name!;
|
||||
|
||||
// Check if file should be excluded based off path
|
||||
for (const excludePath of excludePaths)
|
||||
if (filePath.startsWith(excludePath)) {
|
||||
console.log("File excluded from path", excludePath);
|
||||
return null;
|
||||
}
|
||||
const baseFileName = path.basename(filePath, path.extname(filePath));
|
||||
const tempLocalFile = path.join(
|
||||
os.tmpdir(),
|
||||
baseFileName + path.extname(filePath)
|
||||
);
|
||||
// Download file from bucket.
|
||||
const bucket = admin.storage().bucket(object.bucket);
|
||||
await bucket.file(filePath).download({ destination: tempLocalFile });
|
||||
for (const size of sizes) {
|
||||
try {
|
||||
const thumbFilePath = path.normalize(
|
||||
path.format({
|
||||
dir: path.dirname(filePath),
|
||||
name: baseFileName + "__" + size,
|
||||
ext: path.extname(filePath),
|
||||
})
|
||||
);
|
||||
const tempLocalThumbFile = path.join(
|
||||
os.tmpdir(),
|
||||
path.basename(thumbFilePath)
|
||||
);
|
||||
// Resize image to thumbnail size
|
||||
const resized = await sharp(tempLocalFile)
|
||||
.rotate()
|
||||
.resize(
|
||||
parseInt(size.split("x")[0], 10),
|
||||
parseInt(size.split("x")[1], 10),
|
||||
{
|
||||
fit: "inside",
|
||||
withoutEnlargement: true,
|
||||
}
|
||||
)
|
||||
.toBuffer();
|
||||
// Compress the image
|
||||
const compressed = await imagemin.buffer(resized, {
|
||||
plugins: [
|
||||
imageminMozjpeg({ quality: 75 }),
|
||||
imageminPngquant({ quality: [0.6, 0.8] }),
|
||||
],
|
||||
});
|
||||
fs.writeFileSync(tempLocalThumbFile, compressed);
|
||||
// Upload the image
|
||||
await bucket.upload(tempLocalThumbFile, {
|
||||
destination: thumbFilePath,
|
||||
contentType: object.contentType,
|
||||
metadata: {
|
||||
metadata: {
|
||||
firebaseStorageDownloadTokens: token,
|
||||
resizedImage: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(size, "thumbnail uploaded to Storage at", thumbFilePath);
|
||||
// Once the image has been converted delete the local files to free up disk space.
|
||||
fs.unlinkSync(tempLocalThumbFile);
|
||||
} catch (e) {
|
||||
console.error(`Failed to generate thumbnail size: ${size}`, e);
|
||||
}
|
||||
}
|
||||
fs.unlinkSync(tempLocalFile);
|
||||
return filePath;
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
// Initialize Firebase Admin
|
||||
import * as functions from "firebase-functions";
|
||||
import * as admin from "firebase-admin";
|
||||
admin.initializeApp();
|
||||
|
||||
// Initialize Cloud Firestore Database
|
||||
export const db = admin.firestore();
|
||||
// Initialize Auth
|
||||
export const auth = admin.auth();
|
||||
|
||||
const settings = { timestampsInSnapshots: true };
|
||||
db.settings(settings);
|
||||
export const env = functions.config();
|
||||
@@ -1,4 +0,0 @@
|
||||
enum Collections {
|
||||
fireMail = "firemail",
|
||||
emailOTP = "emailOTP",
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
|
||||
import { db } from "../config";
|
||||
import config, { collectionPath, functionName } from "../functionConfig";
|
||||
// generated using generateConfig.ts
|
||||
const functionConfig: any = config;
|
||||
|
||||
const shouldEvaluateReducer = (listeners, before, after) =>
|
||||
listeners.reduce((acc: Boolean, currField: string) => {
|
||||
if (acc) return true;
|
||||
else
|
||||
return (
|
||||
JSON.stringify(before[currField]) !== JSON.stringify(after[currField])
|
||||
);
|
||||
}, false);
|
||||
|
||||
export const derivativeOnChange = async (
|
||||
ref: FirebaseFirestore.DocumentReference<FirebaseFirestore.DocumentData>,
|
||||
beforeData: FirebaseFirestore.DocumentData,
|
||||
afterData: FirebaseFirestore.DocumentData
|
||||
) => {
|
||||
const update = await functionConfig.reduce(
|
||||
async (accUpdates: any, currDerivative) => {
|
||||
const shouldEval = shouldEvaluateReducer(
|
||||
currDerivative.listenerFields,
|
||||
beforeData,
|
||||
afterData
|
||||
);
|
||||
if (shouldEval) {
|
||||
const newValue = await currDerivative.eval(db)({
|
||||
row: afterData,
|
||||
ref,
|
||||
});
|
||||
if (newValue !== undefined) {
|
||||
return {
|
||||
...(await accUpdates),
|
||||
[currDerivative.fieldName]: newValue,
|
||||
};
|
||||
}
|
||||
}
|
||||
return await accUpdates;
|
||||
},
|
||||
{}
|
||||
);
|
||||
if (Object.keys(update).length !== 0) {
|
||||
return ref.update(update);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
export const derivativeOnCreate = async (
|
||||
snapshot: functions.firestore.DocumentSnapshot
|
||||
) => {
|
||||
const docData = snapshot.data();
|
||||
|
||||
if (!docData) return false;
|
||||
return derivativeOnChange(snapshot.ref, {}, docData);
|
||||
};
|
||||
|
||||
export const derivativeOnUpdate = async (
|
||||
Change: functions.Change<FirebaseFirestore.DocumentSnapshot>
|
||||
) => {
|
||||
const beforeData = Change.before.data();
|
||||
const afterData = Change.after.data();
|
||||
if (!beforeData || !afterData) return false;
|
||||
return derivativeOnChange(Change.after.ref, beforeData, afterData);
|
||||
};
|
||||
|
||||
export const FT_derivatives = {
|
||||
[functionName]: {
|
||||
u: functions.firestore
|
||||
.document(`${collectionPath}/{docId}`)
|
||||
.onUpdate(derivativeOnUpdate),
|
||||
c: functions.firestore
|
||||
.document(`${collectionPath}/{docId}`)
|
||||
.onCreate(derivativeOnCreate),
|
||||
},
|
||||
};
|
||||
@@ -1,144 +0,0 @@
|
||||
import { firestore } from "firebase-functions";
|
||||
|
||||
import { sendEmail } from "../utils/email";
|
||||
import { hasRequiredFields } from "../utils";
|
||||
import { db } from "../config";
|
||||
import _config from "../functionConfig"; // generated using generateConfig.ts
|
||||
const functionConfig: any = _config;
|
||||
type EmailOnTriggerConfig = {
|
||||
collectionPath: string;
|
||||
templateId: string;
|
||||
categories: string[];
|
||||
onCreate: Boolean;
|
||||
from: Function;
|
||||
to: Function;
|
||||
attachments?: Function;
|
||||
bcc?: Function;
|
||||
cc?: Function;
|
||||
requiredFields: string[];
|
||||
shouldSend: (
|
||||
snapshot:
|
||||
| firestore.DocumentSnapshot
|
||||
| {
|
||||
before: firestore.DocumentSnapshot;
|
||||
after: firestore.DocumentSnapshot;
|
||||
}
|
||||
) => Boolean;
|
||||
onUpdate: Boolean;
|
||||
};
|
||||
const emailOnCreate = (config: EmailOnTriggerConfig) =>
|
||||
firestore
|
||||
.document(`${config.collectionPath}/{docId}`)
|
||||
.onCreate(async (snapshot) => {
|
||||
try {
|
||||
const snapshotData = snapshot.data();
|
||||
if (!snapshotData) throw Error("no snapshot data");
|
||||
|
||||
const shouldSend = config.shouldSend(snapshot);
|
||||
const hasAllRequiredFields = hasRequiredFields(
|
||||
config.requiredFields,
|
||||
snapshotData
|
||||
);
|
||||
const from = await config.from(snapshotData, db);
|
||||
const to = await config.to(snapshotData, db);
|
||||
|
||||
const optionalFields = await ["attachments", "cc", "bcc"].reduce(
|
||||
async (accOptions, currOption) => {
|
||||
if (config[currOption]) {
|
||||
return {
|
||||
...(await accOptions),
|
||||
[currOption]: await config[currOption](snapshotData, db),
|
||||
};
|
||||
} else return await accOptions;
|
||||
},
|
||||
{}
|
||||
);
|
||||
console.log(JSON.stringify({ optionalFields }));
|
||||
if (shouldSend && hasAllRequiredFields) {
|
||||
const msg = {
|
||||
from,
|
||||
personalizations: [
|
||||
{
|
||||
to,
|
||||
cc: optionalFields["cc"],
|
||||
bcc: optionalFields["bcc"],
|
||||
dynamic_template_data: {
|
||||
...snapshotData,
|
||||
},
|
||||
},
|
||||
],
|
||||
template_id: config.templateId,
|
||||
categories: config.categories,
|
||||
attachments: optionalFields["attachments"],
|
||||
};
|
||||
console.log({ msg });
|
||||
const resp = await sendEmail(msg);
|
||||
console.log({ resp });
|
||||
return resp;
|
||||
} else {
|
||||
console.log("requirements were not met");
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Failed", JSON.stringify(error));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
const emailOnUpdate = (config: EmailOnTriggerConfig) =>
|
||||
firestore
|
||||
.document(`${config.collectionPath}/{docId}`)
|
||||
.onUpdate(async (change) => {
|
||||
try {
|
||||
const beforeData = change.before.data();
|
||||
const afterData = change.after.data();
|
||||
if (!beforeData || !afterData) throw Error("no data found in snapshot");
|
||||
const shouldSend = config.shouldSend(change);
|
||||
const hasAllRequiredFields = hasRequiredFields(
|
||||
config.requiredFields,
|
||||
afterData
|
||||
);
|
||||
const dynamic_template_data = config.requiredFields.reduce(
|
||||
(acc: any, curr: string) => {
|
||||
return { ...acc, [curr]: afterData[curr] };
|
||||
},
|
||||
{}
|
||||
);
|
||||
if (shouldSend && hasAllRequiredFields) {
|
||||
const from = await config.from(afterData, db);
|
||||
const to = await config.to(afterData, db);
|
||||
const msg = {
|
||||
from,
|
||||
personalizations: [
|
||||
{
|
||||
to,
|
||||
dynamic_template_data,
|
||||
},
|
||||
],
|
||||
template_id: config.templateId,
|
||||
categories: config.categories,
|
||||
};
|
||||
await sendEmail(msg);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
console.log("requirements were not met");
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
const emailOnTriggerFns = (config: EmailOnTriggerConfig) =>
|
||||
Object.entries({
|
||||
onCreate: config.onCreate ? emailOnCreate(config) : null,
|
||||
onUpdate: config.onUpdate ? emailOnUpdate(config) : null,
|
||||
}).reduce((a, [k, v]) => (v === null ? a : { ...a, [k]: v }), {});
|
||||
|
||||
export const FT_email = {
|
||||
[`${`${functionConfig.collectionPath}`
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")}`]: emailOnTriggerFns(functionConfig),
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
export const collectionPath = ''
|
||||
export const functionName = ''
|
||||
export default {}
|
||||
@@ -1,98 +0,0 @@
|
||||
const fs = require("fs");
|
||||
// Initialize Firebase Admin
|
||||
import * as admin from "firebase-admin";
|
||||
// Initialize Firebase Admin
|
||||
//const serverTimestamp = admin.firestore.FieldValue.serverTimestamp;
|
||||
//const serviceAccount = require('../firebase-credentials.json')
|
||||
//admin.initializeApp({credential: admin.credential.cert(serviceAccount)});
|
||||
admin.initializeApp();
|
||||
const db = admin.firestore();
|
||||
const main = async (functionType: string, configString: string) => {
|
||||
let configData;
|
||||
switch (functionType) {
|
||||
case "FT_derivatives":
|
||||
const isCollectionGroup = configString.includes("/");
|
||||
const isSubtable = configString.includes("/subTables/");
|
||||
const collectionPath = `${configString}`;
|
||||
const schemaPath =
|
||||
isCollectionGroup && !isSubtable
|
||||
? `/_FIRETABLE_/settings/groupSchema/${configString.split("/").pop()}`
|
||||
: `_FIRETABLE_/settings/schema/${collectionPath}`;
|
||||
const schemaDoc = await db.doc(schemaPath).get();
|
||||
const schemaData = schemaDoc.data();
|
||||
if (!schemaData) return;
|
||||
const derivativeColumns = Object.values(schemaData.columns).filter(
|
||||
(col: any) => col.type === "DERIVATIVE"
|
||||
);
|
||||
const config = derivativeColumns.reduce((acc, currColumn: any) => {
|
||||
return `${acc}{
|
||||
fieldName:'${currColumn.key}',eval:(db)=> async ({row,ref}) =>{${
|
||||
currColumn.config.script
|
||||
}},listenerFields:[${(currColumn.config.listenerFields ?? [])
|
||||
.map((f) => `"${f}"`)
|
||||
.join(",")}]},`;
|
||||
}, ``);
|
||||
|
||||
configData = `export default [${config}]\nexport const collectionPath ="${
|
||||
isSubtable
|
||||
? ((path) => {
|
||||
const pathTables = path.split("/subTables/");
|
||||
const subcollection = pathTables.pop();
|
||||
return `${pathTables
|
||||
.map((t) => `${t}/{${t.replace(/-/g, "_")}DocId}`)
|
||||
.join("/")}/${subcollection}`;
|
||||
})(collectionPath)
|
||||
: collectionPath
|
||||
}"`;
|
||||
break;
|
||||
|
||||
case "FT_spark":
|
||||
const sparkSchemaDoc = await db
|
||||
.doc(`_FIRETABLE_/settings/schema/${configString}`)
|
||||
.get();
|
||||
const sparkSchemaData = sparkSchemaDoc.data();
|
||||
|
||||
configData = `export default [${sparkSchemaData?.sparks.join(
|
||||
",\n"
|
||||
)}]\n export const collectionPath='${configString}';`;
|
||||
case "FT_aggregates":
|
||||
const _schemaDoc = await db
|
||||
.doc(`_FIRETABLE_/settings/schema/${configString}`)
|
||||
.get();
|
||||
const _schemaData = _schemaDoc.data();
|
||||
if (!_schemaData) return;
|
||||
const aggregateColumns = Object.values(_schemaData.columns).filter(
|
||||
(col: any) => col.type === "AGGREGATE"
|
||||
);
|
||||
const _config = aggregateColumns.reduce((acc, currColumn: any) => {
|
||||
return `${acc}{
|
||||
fieldName:'${
|
||||
currColumn.key
|
||||
}',eval:(db)=> async ({aggregateState,incrementor,triggerType,change,afterData,beforeData}) =>{${
|
||||
currColumn.config.script
|
||||
}},subtables:[${currColumn.config.subtables
|
||||
.map((t) => `"${t}"`)
|
||||
.join(",")}]},`;
|
||||
}, ``);
|
||||
|
||||
configData = `export default [${_config}]\nexport const collectionPath ="${configString}"`;
|
||||
break;
|
||||
case "FT_subTableStats":
|
||||
configData = `export const collectionPath ="${configString}"\nexport default []`;
|
||||
break;
|
||||
default:
|
||||
configData = `export default ${configString}\n export const collectionPath=''`;
|
||||
break;
|
||||
}
|
||||
configData =
|
||||
configData +
|
||||
'\nexport const functionName = collectionPath.replace("-", "_").replace(/\\//g, "_").replace(/_{.*?}_/g, "_")';
|
||||
console.log({ configData });
|
||||
fs.writeFileSync("./src/functionConfig.ts", configData);
|
||||
return;
|
||||
};
|
||||
|
||||
main(process.argv[2], process.argv[3])
|
||||
.catch((err) => console.log(err))
|
||||
.then(() => console.log("this will succeed"))
|
||||
.catch(() => "obligatory catch");
|
||||
@@ -1,40 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
import * as _ from "lodash";
|
||||
import { db } from "../config";
|
||||
|
||||
import config from "../functionConfig"; // generated using generateConfig.ts
|
||||
const functionConfig: any = config;
|
||||
|
||||
const historySnapshot = (trackedFields: string[]) => async (
|
||||
change: functions.Change<FirebaseFirestore.DocumentSnapshot>
|
||||
) => {
|
||||
const before = change.before.data();
|
||||
const after = change.after.data();
|
||||
const docPath = change.after.ref.path;
|
||||
if (!before || !after) return false;
|
||||
const trackedChanges: any = {};
|
||||
trackedFields.forEach((field) => {
|
||||
if (!_.isEqual(before[field], after[field]))
|
||||
trackedChanges[field] = after[field];
|
||||
});
|
||||
if (!_.isEmpty(trackedChanges)) {
|
||||
await db
|
||||
.doc(docPath)
|
||||
.collection("historySnapshots")
|
||||
.add({ ...before, archivedAt: new Date() });
|
||||
return true;
|
||||
} else return false;
|
||||
};
|
||||
|
||||
const historySnapshotFnsGenerator = (collection) =>
|
||||
functions.firestore
|
||||
.document(`${collection.name}/{docId}`)
|
||||
.onUpdate(historySnapshot(collection.trackedFields));
|
||||
|
||||
//export default historySnapshotFnsGenerator;
|
||||
|
||||
export const FT_history = {
|
||||
[functionConfig.name
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")]: historySnapshotFnsGenerator(functionConfig),
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
// export { triggerCloudBuild, cloudBuildUpdates } from "./buildTriggers"; // a callable used for triggering cloudbuild to build and deploy configurable cloud functions
|
||||
// export {
|
||||
// scheduledFirestoreBackup, // callableFirestoreBackup
|
||||
// } from "./backup";
|
||||
// import * as callableFns from "./callable";
|
||||
|
||||
// export const callable = callableFns;
|
||||
|
||||
// // all the cloud functions bellow are deployed using the triggerCloudBuild callable function
|
||||
// // these functions are designed to be built and deployed based on the configuration passed through the callable
|
||||
|
||||
// export { FT_aggregates } from "./aggregates";
|
||||
// export { FT_subTableStats } from "./subTableStats";
|
||||
|
||||
// export { actionScript } from "./actionScript";
|
||||
|
||||
// export { webhook } from "./webhooks";
|
||||
|
||||
// export { FT_snapshotSync } from "./snapshotSync";
|
||||
|
||||
// export { FT_compressedThumbnail } from "./compressedThumbnail";
|
||||
|
||||
export {getAlgoliaSearchKey} from './algoliaSearchKey'
|
||||
|
||||
//deprecated, updated implementation moved to FT_build folder and used within sparks table functions
|
||||
// export { FT_derivatives } from "./derivatives";
|
||||
// export { FT_algolia } from "./algolia";
|
||||
// export { FT_email } from "./emailOnTrigger";
|
||||
// export { FT_slack } from "./slackOnTrigger";
|
||||
// export { FT_sync } from "./collectionSync";
|
||||
// export { FT_spark } from "./sparks";
|
||||
// export { FT_history } from "./history";
|
||||
// export { slackBotMessageOnCreate } from "./slackOnTrigger/trigger";
|
||||
@@ -1,111 +0,0 @@
|
||||
import { firestore } from "firebase-functions";
|
||||
import { hasRequiredFields, serverTimestamp, asyncForEach } from "../utils";
|
||||
import _config from "../functionConfig"; // generated using generateConfig.ts
|
||||
import { db } from "../config";
|
||||
const functionConfig: any = _config;
|
||||
type SlackOnTriggerConfig = {
|
||||
collectionPath: string;
|
||||
onCreate: Boolean;
|
||||
onUpdate: Boolean;
|
||||
onDelete: Boolean;
|
||||
requiredFields: string[];
|
||||
messageDocGenerator: (
|
||||
snapshot:
|
||||
| firestore.DocumentSnapshot
|
||||
| {
|
||||
before: firestore.DocumentSnapshot;
|
||||
after: firestore.DocumentSnapshot;
|
||||
}
|
||||
// db: FirebaseFirestore.Firestore
|
||||
) => Boolean | any;
|
||||
};
|
||||
const slackOnCreate = (config: SlackOnTriggerConfig) =>
|
||||
firestore
|
||||
.document(`${config.collectionPath}/{docId}`)
|
||||
.onCreate(async (snapshot) => {
|
||||
try {
|
||||
const snapshotData = snapshot.data();
|
||||
if (!snapshotData) throw Error("no snapshot data");
|
||||
const hasAllRequiredFields = hasRequiredFields(
|
||||
config.requiredFields,
|
||||
snapshotData
|
||||
);
|
||||
if (hasAllRequiredFields) {
|
||||
const messageDoc = await config.messageDocGenerator(snapshot);
|
||||
if (messageDoc && typeof messageDoc === "object") {
|
||||
await db
|
||||
.collection("slackBotMessages")
|
||||
.add({ createdAt: serverTimestamp(), ...messageDoc });
|
||||
return true;
|
||||
} else {
|
||||
console.log("message is not sent");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
console.log("requirements were not met");
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(JSON.stringify(error.response.body));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
const slackOnUpdate = (config: SlackOnTriggerConfig) =>
|
||||
firestore
|
||||
.document(`${config.collectionPath}/{docId}`)
|
||||
.onUpdate(async (change) => {
|
||||
try {
|
||||
const beforeData = change.before.data();
|
||||
const afterData = change.after.data();
|
||||
if (!beforeData || !afterData) throw Error("no data found in snapshot");
|
||||
const hasAllRequiredFields = hasRequiredFields(
|
||||
config.requiredFields,
|
||||
afterData
|
||||
);
|
||||
if (hasAllRequiredFields) {
|
||||
const messageDoc = await config.messageDocGenerator(change);
|
||||
console.log({ messageDoc });
|
||||
if (
|
||||
(messageDoc && typeof messageDoc === "object") ||
|
||||
Array.isArray(messageDoc)
|
||||
) {
|
||||
console.log("creating slack message doc");
|
||||
if (Array.isArray(messageDoc)) {
|
||||
await asyncForEach(messageDoc, async (message) => {
|
||||
await db
|
||||
.collection("slackBotMessages")
|
||||
.add({ createdAt: serverTimestamp(), ...message });
|
||||
});
|
||||
} else {
|
||||
await db
|
||||
.collection("slackBotMessages")
|
||||
.add({ createdAt: serverTimestamp(), ...messageDoc });
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
console.log("message is not sent");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
console.log("requirements were not met");
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
const slackOnTriggerFns = (config: SlackOnTriggerConfig) =>
|
||||
Object.entries({
|
||||
onCreate: config.onCreate ? slackOnCreate(config) : null,
|
||||
onUpdate: config.onUpdate ? slackOnUpdate(config) : null,
|
||||
}).reduce((a, [k, v]) => (v === null ? a : { ...a, [k]: v }), {});
|
||||
|
||||
export const FT_slack = {
|
||||
[`${`${functionConfig.collectionPath}`
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")}`]: slackOnTriggerFns(functionConfig),
|
||||
};
|
||||
@@ -1,103 +0,0 @@
|
||||
import { firestore } from "firebase-functions";
|
||||
|
||||
import { env } from "../config";
|
||||
import { WebClient } from "@slack/web-api";
|
||||
import { asyncForEach, serverTimestamp } from "../utils";
|
||||
// Initialize
|
||||
const web = new WebClient(env.slackbot ? env.slackbot.token : "NEEDS_CONFIG");
|
||||
|
||||
const messageByChannel = async ({
|
||||
text,
|
||||
channel,
|
||||
blocks,
|
||||
attachments,
|
||||
}: {
|
||||
channel: string;
|
||||
text: string;
|
||||
blocks: any[];
|
||||
attachments: any[];
|
||||
}) =>
|
||||
await web.chat.postMessage({
|
||||
link_names: true,
|
||||
text,
|
||||
channel,
|
||||
blocks,
|
||||
attachments,
|
||||
});
|
||||
const messageByEmail = async ({
|
||||
email,
|
||||
text,
|
||||
blocks,
|
||||
attachments,
|
||||
}: {
|
||||
email: string;
|
||||
text: string;
|
||||
blocks: any[];
|
||||
attachments: any[];
|
||||
}) => {
|
||||
try {
|
||||
const user = await web.users.lookupByEmail({ email });
|
||||
if (user.ok) {
|
||||
const channel = (user as any).user.id as string;
|
||||
return await messageByChannel({
|
||||
text,
|
||||
blocks,
|
||||
attachments,
|
||||
channel,
|
||||
});
|
||||
} else {
|
||||
return await false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`${error} maybe${email} is not on slack`);
|
||||
console.log(`${error}`);
|
||||
return await false;
|
||||
}
|
||||
};
|
||||
|
||||
export const slackBotMessageOnCreate = firestore
|
||||
.document(`slackBotMessages/{docId}`)
|
||||
.onCreate(async (snapshot) => {
|
||||
const docData = snapshot.data();
|
||||
if (!docData) {
|
||||
return snapshot.ref.update({
|
||||
delivered: false,
|
||||
error: "undefined doc",
|
||||
});
|
||||
}
|
||||
try {
|
||||
const channels = docData.channel ? [docData.channel] : docData.channels;
|
||||
const emails = docData.email ? [docData.email] : docData.emails;
|
||||
if (channels) {
|
||||
await asyncForEach(channels, async (channel: string) => {
|
||||
await messageByChannel({
|
||||
text: docData.text,
|
||||
blocks: docData.blocks,
|
||||
attachments: docData.attachments,
|
||||
channel,
|
||||
});
|
||||
});
|
||||
} else if (emails) {
|
||||
await asyncForEach(emails, async (email: string) => {
|
||||
await messageByEmail({
|
||||
text: docData.text,
|
||||
blocks: docData.blocks ?? [],
|
||||
attachments: docData.attachments ?? [],
|
||||
email,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return snapshot.ref.update({
|
||||
delivered: true,
|
||||
updatedAt: serverTimestamp(),
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return snapshot.ref.update({
|
||||
delivered: false,
|
||||
updatedAt: serverTimestamp(),
|
||||
error: JSON.stringify(error),
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,205 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
|
||||
import { db } from "../config";
|
||||
|
||||
import * as _ from "lodash";
|
||||
import { replacer, identifyTriggerType } from "../utils";
|
||||
|
||||
import Config from "../functionConfig"; // generated using generateConfig.ts
|
||||
const functionConfig: any = Config;
|
||||
|
||||
enum TargetTypes {
|
||||
subCollection = "subCollection",
|
||||
document = "document",
|
||||
}
|
||||
/**
|
||||
* returns object with only keys included in fieldsToSync
|
||||
* @param docData
|
||||
*/
|
||||
const docReducer = (docData: FirebaseFirestore.DocumentData) => (
|
||||
acc: any,
|
||||
curr: string
|
||||
) => {
|
||||
if (docData[curr] !== undefined && docData[curr] !== null) {
|
||||
return { ...acc, [curr]: docData[curr] };
|
||||
} else return acc;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param targetPath
|
||||
* @param fieldsToSync
|
||||
*/
|
||||
const syncSubCollection = async (
|
||||
targetPath: string,
|
||||
snapshotField: string,
|
||||
syncData: any,
|
||||
snapshot: FirebaseFirestore.DocumentSnapshot<FirebaseFirestore.DocumentData>
|
||||
) => {
|
||||
const targetDocs = await db.collection(targetPath).get();
|
||||
if (targetDocs.empty) return false;
|
||||
for (const doc of targetDocs.docs) {
|
||||
await doc.ref.update({
|
||||
[snapshotField]: {
|
||||
docPath: snapshot.ref.path,
|
||||
snapshot: syncData,
|
||||
},
|
||||
});
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const syncDocSnapshot = async (
|
||||
targetPath,
|
||||
isArray,
|
||||
snapshotField,
|
||||
newSnapshotData,
|
||||
snapshot
|
||||
) => {
|
||||
console.log({
|
||||
targetPath,
|
||||
isArray,
|
||||
snapshotField,
|
||||
});
|
||||
const targetRef = db.doc(targetPath);
|
||||
const targetSnapshot = await targetRef.get();
|
||||
const targetData = targetSnapshot.data();
|
||||
if (!targetData) {
|
||||
console.warn("target does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isArray) {
|
||||
const oldSnapshotsArray = targetData[snapshotField];
|
||||
if (!oldSnapshotsArray) {
|
||||
return targetRef.update({
|
||||
[snapshotField]: [
|
||||
{ docPath: snapshot.ref.path, snapshot: newSnapshotData },
|
||||
],
|
||||
});
|
||||
} else {
|
||||
const snapshotDocPath = snapshot.ref.path;
|
||||
const oldSnapshot = _.find(oldSnapshotsArray, {
|
||||
docPath: snapshotDocPath,
|
||||
});
|
||||
if (oldSnapshot) {
|
||||
return targetRef.update({
|
||||
[snapshotField]: oldSnapshotsArray.map(
|
||||
(item: { docPath: string; snapshot: any }) => {
|
||||
if (item.docPath === snapshotDocPath) {
|
||||
return {
|
||||
...oldSnapshot,
|
||||
docPath: snapshotDocPath,
|
||||
snapshot: newSnapshotData,
|
||||
};
|
||||
} else return item;
|
||||
}
|
||||
),
|
||||
});
|
||||
} else {
|
||||
return targetRef.update({
|
||||
[snapshotField]: [
|
||||
...oldSnapshotsArray,
|
||||
{ docPath: snapshotDocPath, snapshot: newSnapshotData },
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return targetRef.update({
|
||||
[snapshotField]: {
|
||||
...targetData[snapshotField],
|
||||
snapshot: newSnapshotData,
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* onUpdate change to snapshot adapter
|
||||
* @param targetCollection
|
||||
* @param fieldsToSync
|
||||
*/
|
||||
const syncDocOnWrite = (config: {
|
||||
target: string;
|
||||
snapshotField: string;
|
||||
targetType: TargetTypes;
|
||||
fieldsToSync: string[];
|
||||
isArray: boolean;
|
||||
}) => (snapshot: functions.Change<FirebaseFirestore.DocumentSnapshot>) => {
|
||||
const { fieldsToSync, target, snapshotField, targetType, isArray } = config;
|
||||
|
||||
const afterDocData = snapshot.after.data();
|
||||
const beforeDocData = snapshot.before.data();
|
||||
|
||||
const triggerType = identifyTriggerType(beforeDocData, afterDocData);
|
||||
|
||||
const afterData = fieldsToSync.reduce(docReducer(afterDocData ?? {}), {});
|
||||
const beforeData = fieldsToSync.reduce(docReducer(beforeDocData ?? {}), {});
|
||||
const hasChanged = !_.isEqual(afterData, beforeData);
|
||||
console.log("nothing important changed");
|
||||
if (Object.keys(afterData).length === 0) return false; // returns if theres nothing to sync
|
||||
|
||||
const targetPath = target.replace(
|
||||
/\{\{(.*?)\}\}/g,
|
||||
replacer({ ...snapshot.after.data(), id: snapshot.after.id })
|
||||
);
|
||||
console.log({ targetPath });
|
||||
if (targetPath === "") {
|
||||
console.log("unspecified target");
|
||||
return false;
|
||||
}
|
||||
console.log({ hasChanged, targetType });
|
||||
if (hasChanged) {
|
||||
switch (targetType) {
|
||||
case TargetTypes.subCollection:
|
||||
return triggerType === "update"
|
||||
? syncSubCollection(
|
||||
targetPath,
|
||||
snapshotField,
|
||||
{ ...afterData, objectID: snapshot.after.ref.id },
|
||||
snapshot.after
|
||||
)
|
||||
: false;
|
||||
|
||||
case TargetTypes.document:
|
||||
return triggerType !== "delete"
|
||||
? syncDocSnapshot(
|
||||
targetPath,
|
||||
isArray,
|
||||
snapshotField,
|
||||
{ ...afterData, objectID: snapshot.after.ref.id },
|
||||
snapshot.after
|
||||
)
|
||||
: false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
console.warn("no change detected");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* returns 2 different trigger functions (onCreate,onUpdate) in an object
|
||||
* @param config configuration object
|
||||
*/
|
||||
const snapshotSyncFnsGenerator = (config) =>
|
||||
functions.firestore
|
||||
.document(`${config.source}/{docId}`)
|
||||
.onWrite(syncDocOnWrite(config));
|
||||
|
||||
//export default snapshotSyncFnsGenerator;
|
||||
|
||||
export const FT_snapshotSync = functionConfig.fnName
|
||||
? { [functionConfig.fnName]: snapshotSyncFnsGenerator(functionConfig) }
|
||||
: {
|
||||
[`${`${`${functionConfig.source}`
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")}`}2${`${`${functionConfig.target}`
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")}`}`]: snapshotSyncFnsGenerator(
|
||||
functionConfig
|
||||
),
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
import * as admin from "firebase-admin";
|
||||
|
||||
import { collectionPath } from "./functionConfig"; // generated using generateConfig.ts
|
||||
const increment = admin.firestore.FieldValue.increment(1);
|
||||
const decrement = admin.firestore.FieldValue.increment(-1);
|
||||
const docCreated = (
|
||||
snapshot: functions.firestore.DocumentSnapshot,
|
||||
context: functions.EventContext
|
||||
) => {
|
||||
const { subCollectionId } = context.params;
|
||||
return snapshot.ref.parent.parent?.update({
|
||||
[`${subCollectionId}.count`]: increment,
|
||||
});
|
||||
};
|
||||
|
||||
const docDelete = (
|
||||
snapshot: functions.firestore.DocumentSnapshot,
|
||||
context: functions.EventContext
|
||||
) => {
|
||||
const { subCollectionId } = context.params;
|
||||
return snapshot.ref.parent.parent?.update({
|
||||
[subCollectionId]: decrement,
|
||||
});
|
||||
};
|
||||
const subTableFnsGenerator = {
|
||||
onCreate: functions.firestore
|
||||
.document(`${collectionPath}/{parentId}/{subCollectionId}/{docId}`)
|
||||
.onCreate(docCreated),
|
||||
onDelete: functions.firestore
|
||||
.document(`${collectionPath}/{parentId}/{subCollectionId}/{docId}`)
|
||||
.onDelete(docDelete),
|
||||
};
|
||||
|
||||
export const FT_subTableStats = {
|
||||
[collectionPath]: { ...subTableFnsGenerator },
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
|
||||
export const hasAnyRole = (
|
||||
authorizedRoles: string[],
|
||||
context: functions.https.CallableContext
|
||||
) => {
|
||||
if (!context.auth || !context.auth.token.roles) return false;
|
||||
const userRoles = context.auth.token.roles as string[];
|
||||
const authorization = authorizedRoles.reduce(
|
||||
(authorized: boolean, role: string) => {
|
||||
if (userRoles.includes(role)) return true;
|
||||
else return authorized;
|
||||
},
|
||||
false
|
||||
);
|
||||
return authorization;
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
const sgMail = require("@sendgrid/mail");
|
||||
import { env } from "../config";
|
||||
sgMail.setSubstitutionWrappers("{{", "}}");
|
||||
if (env.send_grid) sgMail.setApiKey(env.send_grid.key);
|
||||
|
||||
export const sendEmail = (msg: any) => sgMail.send(msg);
|
||||
@@ -1,41 +0,0 @@
|
||||
import * as admin from "firebase-admin";
|
||||
import * as _ from "lodash";
|
||||
export const serverTimestamp = admin.firestore.FieldValue.serverTimestamp;
|
||||
import { sendEmail } from "./email";
|
||||
import { hasAnyRole } from "./auth";
|
||||
|
||||
const characters =
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
export function generateId(length) {
|
||||
let result = "";
|
||||
const charactersLength = characters.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export default { generateId, sendEmail, serverTimestamp, hasAnyRole };
|
||||
export const replacer = (data: any) => (m: string, key: string) => {
|
||||
const objKey = key.split(":")[0];
|
||||
const defaultValue = key.split(":")[1] || "";
|
||||
return _.get(data, objKey, defaultValue);
|
||||
};
|
||||
|
||||
export const hasRequiredFields = (requiredFields: string[], data: any) =>
|
||||
requiredFields.reduce((acc: boolean, currField: string) => {
|
||||
if (data[currField] === undefined || data[currField] === null) return false;
|
||||
else return acc;
|
||||
}, true);
|
||||
export async function asyncForEach(array: any[], callback: Function) {
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
await callback(array[index], index, array);
|
||||
}
|
||||
}
|
||||
|
||||
export const identifyTriggerType = (beforeData, afterData) =>
|
||||
Boolean(beforeData) && Boolean(afterData)
|
||||
? "update"
|
||||
: Boolean(afterData)
|
||||
? "create"
|
||||
: "delete";
|
||||
@@ -1,84 +0,0 @@
|
||||
import { db } from "../config";
|
||||
import * as functions from "firebase-functions";
|
||||
// const fetch = require("node-fetch");
|
||||
|
||||
//import * as crypto from "crypto";
|
||||
|
||||
//const TYPEFORM_SECRET = "testsecret123";
|
||||
//const verifySignature = function (secret, receivedSignature, payload) {
|
||||
// const hash = crypto
|
||||
// .createHmac("sha256", secret)
|
||||
// .update(payload)
|
||||
// .digest("base64");
|
||||
// console.log(receivedSignature, `sha256=${hash}`);
|
||||
// return receivedSignature === `sha256=${hash}`;
|
||||
// };
|
||||
|
||||
//const file = bucket.file('path/to/image.jpg');
|
||||
|
||||
const typeformParser = (body) => ({
|
||||
_ft_createdAt: body.form_response.submitted_at,
|
||||
...body.form_response.hidden,
|
||||
...body.form_response.answers.reduce((accRow, currAnswer) => {
|
||||
switch (currAnswer.type) {
|
||||
case "date":
|
||||
return {
|
||||
...accRow,
|
||||
[currAnswer.field.ref]: new Date(currAnswer[currAnswer.type]),
|
||||
};
|
||||
case "choice":
|
||||
return {
|
||||
...accRow,
|
||||
[currAnswer.field.ref]: currAnswer[currAnswer.type].label,
|
||||
};
|
||||
case "choices":
|
||||
return {
|
||||
...accRow,
|
||||
[currAnswer.field.ref]: currAnswer[currAnswer.type].labels,
|
||||
};
|
||||
case "file_url":
|
||||
default:
|
||||
return {
|
||||
...accRow,
|
||||
[currAnswer.field.ref]: currAnswer[currAnswer.type],
|
||||
};
|
||||
}
|
||||
}, {}),
|
||||
});
|
||||
|
||||
export const webhook = functions.https.onRequest(async (req, res) => {
|
||||
const { body, url, query } = req;
|
||||
console.log(JSON.stringify({ body, url, query }));
|
||||
const schemaDocPath = `_FIRETABLE_/settings/schema/${decodeURIComponent(
|
||||
query.tablePath as string
|
||||
)}`;
|
||||
const schemaDoc = await db.doc(schemaDocPath).get();
|
||||
const schemaDocData = schemaDoc.data();
|
||||
if (!schemaDocData) {
|
||||
res.sendStatus(404);
|
||||
}
|
||||
if (!schemaDocData?.webhooks.enabled) {
|
||||
res.sendStatus(401);
|
||||
}
|
||||
|
||||
if (query.type === "CUSTOM") {
|
||||
console.log({ schemaDocData });
|
||||
} else if (query.type === "TYPE_FORM") {
|
||||
// const receivedSignature = req.header("Typeform-Signature");
|
||||
const secret = schemaDocData?.webhooks.secret;
|
||||
// const isValidSignature = verifySignature(
|
||||
// TYPEFORM_SECRET,
|
||||
// receivedSignature,
|
||||
// req.body.toString()
|
||||
// );
|
||||
if (req.query.secret === secret) {
|
||||
const newRow = typeformParser(req.body);
|
||||
await db
|
||||
.collection(decodeURIComponent(req.query.tablePath as string))
|
||||
.add(newRow);
|
||||
} else {
|
||||
res.sendStatus(403);
|
||||
}
|
||||
}
|
||||
res.sendStatus(200);
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": true,
|
||||
"outDir": "lib",
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"resolveJsonModule": true,
|
||||
"target": "es2017"
|
||||
},
|
||||
"compileOnSave": true,
|
||||
"include": ["src", "generateConfig.ts"]
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
{
|
||||
"rules": {
|
||||
// -- Strict errors --
|
||||
// These lint rules are likely always a good idea.
|
||||
|
||||
// Force function overloads to be declared together. This ensures readers understand APIs.
|
||||
"adjacent-overload-signatures": true,
|
||||
|
||||
// Do not allow the subtle/obscure comma operator.
|
||||
"ban-comma-operator": true,
|
||||
|
||||
// Do not allow internal modules or namespaces . These are deprecated in favor of ES6 modules.
|
||||
"no-namespace": true,
|
||||
|
||||
// Do not allow parameters to be reassigned. To avoid bugs, developers should instead assign new values to new vars.
|
||||
"no-parameter-reassignment": true,
|
||||
|
||||
// Force the use of ES6-style imports instead of /// <reference path=> imports.
|
||||
"no-reference": true,
|
||||
|
||||
// Do not allow type assertions that do nothing. This is a big warning that the developer may not understand the
|
||||
// code currently being edited (they may be incorrectly handling a different type case that does not exist).
|
||||
"no-unnecessary-type-assertion": true,
|
||||
|
||||
// Disallow nonsensical label usage.
|
||||
"label-position": true,
|
||||
|
||||
// Disallows the (often typo) syntax if (var1 = var2). Replace with if (var2) { var1 = var2 }.
|
||||
"no-conditional-assignment": true,
|
||||
|
||||
// Disallows constructors for primitive types (e.g. new Number('123'), though Number('123') is still allowed).
|
||||
"no-construct": true,
|
||||
|
||||
// Do not allow super() to be called twice in a constructor.
|
||||
"no-duplicate-super": true,
|
||||
|
||||
// Do not allow the same case to appear more than once in a switch block.
|
||||
"no-duplicate-switch-case": true,
|
||||
|
||||
// Do not allow a variable to be declared more than once in the same block. Consider function parameters in this
|
||||
// rule.
|
||||
"no-duplicate-variable": [true, "check-parameters"],
|
||||
|
||||
// Disallows a variable definition in an inner scope from shadowing a variable in an outer scope. Developers should
|
||||
// instead use a separate variable name.
|
||||
"no-shadowed-variable": true,
|
||||
|
||||
// Empty blocks are almost never needed. Allow the one general exception: empty catch blocks.
|
||||
"no-empty": [true, "allow-empty-catch"],
|
||||
|
||||
// Functions must either be handled directly (e.g. with a catch() handler) or returned to another function.
|
||||
// This is a major source of errors in Cloud Functions and the team strongly recommends leaving this rule on.
|
||||
"no-floating-promises": true,
|
||||
|
||||
// Do not allow any imports for modules that are not in package.json. These will almost certainly fail when
|
||||
// deployed.
|
||||
"no-implicit-dependencies": true,
|
||||
|
||||
// The 'this' keyword can only be used inside of classes.
|
||||
"no-invalid-this": true,
|
||||
|
||||
// Do not allow strings to be thrown because they will not include stack traces. Throw Errors instead.
|
||||
"no-string-throw": true,
|
||||
|
||||
// Disallow control flow statements, such as return, continue, break, and throw in finally blocks.
|
||||
"no-unsafe-finally": true,
|
||||
|
||||
// Do not allow variables to be used before they are declared.
|
||||
"no-use-before-declare": true,
|
||||
|
||||
// Expressions must always return a value. Avoids common errors like const myValue = functionReturningVoid();
|
||||
"no-void-expression": [true, "ignore-arrow-function-shorthand"],
|
||||
|
||||
// Disallow duplicate imports in the same file.
|
||||
"no-duplicate-imports": true,
|
||||
|
||||
// -- Strong Warnings --
|
||||
// These rules should almost never be needed, but may be included due to legacy code.
|
||||
// They are left as a warning to avoid frustration with blocked deploys when the developer
|
||||
// understand the warning and wants to deploy anyway.
|
||||
|
||||
// Warn when an empty interface is defined. These are generally not useful.
|
||||
"no-empty-interface": { "severity": "warning" },
|
||||
|
||||
// Warn when an import will have side effects.
|
||||
"no-import-side-effect": { "severity": "warning" },
|
||||
|
||||
// Warn when variables are defined with var. Var has subtle meaning that can lead to bugs. Strongly prefer const for
|
||||
// most values and let for values that will change.
|
||||
"no-var-keyword": { "severity": "warning" },
|
||||
|
||||
// Prefer === and !== over == and !=. The latter operators support overloads that are often accidental.
|
||||
"triple-equals": { "severity": "warning" },
|
||||
|
||||
// Warn when using deprecated APIs.
|
||||
"deprecation": { "severity": "warning" },
|
||||
|
||||
// -- Light Warnings --
|
||||
// These rules are intended to help developers use better style. Simpler code has fewer bugs. These would be "info"
|
||||
// if TSLint supported such a level.
|
||||
|
||||
// prefer for( ... of ... ) to an index loop when the index is only used to fetch an object from an array.
|
||||
// (Even better: check out utils like .map if transforming an array!)
|
||||
"prefer-for-of": { "severity": "warning" },
|
||||
|
||||
// Warns if function overloads could be unified into a single function with optional or rest parameters.
|
||||
"unified-signatures": { "severity": "warning" },
|
||||
|
||||
// Prefer const for values that will not change. This better documents code.
|
||||
"prefer-const": { "severity": "warning" },
|
||||
|
||||
// Multi-line object literals and function calls should have a trailing comma. This helps avoid merge conflicts.
|
||||
"trailing-comma": { "severity": "warning" }
|
||||
},
|
||||
"linterOptions": {
|
||||
"exclude": ["./generator/templates/**"]
|
||||
},
|
||||
"defaultSeverity": "error"
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// Initialize Firebase Admin
|
||||
import * as admin from "firebase-admin";
|
||||
// Initialize Firebase Admin
|
||||
const serverTimestamp = admin.firestore.FieldValue.serverTimestamp;
|
||||
admin.initializeApp();
|
||||
const db = admin.firestore();
|
||||
|
||||
const main = async (deployRequestPath: string, currentBuild) => {
|
||||
await db.doc(deployRequestPath).update({
|
||||
deployedAt: serverTimestamp(),
|
||||
currentBuild: currentBuild ?? "",
|
||||
});
|
||||
return true;
|
||||
};
|
||||
|
||||
main(process.argv[2], process.argv[3])
|
||||
.catch((err) => console.log(err))
|
||||
.then(() => console.log("this will succeed"))
|
||||
.catch(() => "obligatory catch");
|
||||
@@ -2,7 +2,6 @@ steps:
|
||||
- name: node:10.17.0
|
||||
entrypoint: yarn
|
||||
args: ["install"]
|
||||
dir: "www"
|
||||
- name: node:10.17.0
|
||||
entrypoint: yarn
|
||||
args:
|
||||
@@ -11,11 +10,9 @@ steps:
|
||||
- "${_FIREBASE_WEB_API_KEY}"
|
||||
- "${_ALGOLIA_APP_ID}"
|
||||
- "${_ALGOLIA_APP_KEY}"
|
||||
dir: "www"
|
||||
- name: node:10.17.0
|
||||
entrypoint: yarn
|
||||
args: ["build"]
|
||||
dir: "www"
|
||||
- name: node:10.17.0
|
||||
entrypoint: yarn
|
||||
args:
|
||||
@@ -23,7 +20,6 @@ steps:
|
||||
- "${_HOSTING_TARGET}"
|
||||
- --project
|
||||
- "${_PROJECT_ID}"
|
||||
dir: "www"
|
||||
- name: node:10.17.0
|
||||
entrypoint: yarn
|
||||
args:
|
||||
@@ -35,7 +31,6 @@ steps:
|
||||
- "${_FIREBASE_TOKEN}"
|
||||
- --only
|
||||
- hosting
|
||||
dir: "www"
|
||||
substitutions:
|
||||
_PROJECT_ID: "project-id" # default value
|
||||
options:
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
steps:
|
||||
# - name: "gcr.io/kaniko-project/executor:latest"
|
||||
# args:
|
||||
# - --destination=gcr.io/$PROJECT_ID/image
|
||||
# - --cache=true
|
||||
# - --cache-ttl=24h
|
||||
- name: node:10.15.1
|
||||
entrypoint: yarn
|
||||
args: ["install"]
|
||||
dir: "cloud_functions/functions"
|
||||
- name: node:10.15.1
|
||||
entrypoint: yarn
|
||||
args:
|
||||
- "generateConfig"
|
||||
- "${_FUNCTIONS_GROUP}"
|
||||
- "${_FUNCTION_CONFIG}"
|
||||
dir: "cloud_functions/functions"
|
||||
- name: node:10.15.1
|
||||
entrypoint: yarn
|
||||
args:
|
||||
- "deployFT"
|
||||
- "--project"
|
||||
- "${_PROJECT_ID}"
|
||||
- "--token"
|
||||
- "${_FIREBASE_TOKEN}"
|
||||
- "--only"
|
||||
- "functions:${_FUNCTIONS_GROUP}"
|
||||
dir: "cloud_functions/functions"
|
||||
# - name: gcr.io/cloud-builders/gcloud
|
||||
# args:
|
||||
# - functions
|
||||
# - deploy
|
||||
# - "${_FUNCTIONS_GROUP}"
|
||||
# dir: "cloud_functions/functions"
|
||||
- name: node:10.15.1
|
||||
entrypoint: yarn
|
||||
args:
|
||||
- "updateStatus"
|
||||
- "${_REQUEST_DOC_PATH}"
|
||||
- "${_FUNCTION_CONFIG}"
|
||||
dir: "cloud_functions/functions"
|
||||
|
||||
substitutions:
|
||||
_PROJECT_ID: "project-id" # default value
|
||||
_FUNCTIONS_GROUP: "exportTable" # default value
|
||||
options:
|
||||
machineType: "N1_HIGHCPU_8"
|
||||
@@ -1,7 +1,16 @@
|
||||
const CracoAlias = require("craco-alias");
|
||||
const CracoSwcPlugin = require("craco-swc");
|
||||
|
||||
module.exports = {
|
||||
plugins: [
|
||||
{
|
||||
plugin: CracoAlias,
|
||||
options: {
|
||||
source: "tsconfig",
|
||||
baseUrl: "./src",
|
||||
tsConfigPath: "./tsconfig.extend.json",
|
||||
},
|
||||
},
|
||||
{
|
||||
plugin: CracoSwcPlugin,
|
||||
options: {
|
||||
1
e2e/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
firebase-credentials.json
|
||||
20
e2e/auth.ts
@@ -1,20 +0,0 @@
|
||||
import { auth } from "./credentials";
|
||||
|
||||
export const authenticateUser = async (page, email = "shams@antler.co") => {
|
||||
const user = await auth.getUserByEmail(email);
|
||||
const jwt = await auth.createCustomToken(user.uid);
|
||||
// Go to http://localhost:3000/jwtAuth
|
||||
await page.goto("http://localhost:3000/jwtAuth");
|
||||
|
||||
// Click input[name="JWT"]
|
||||
await page.click('input[name="JWT"]');
|
||||
|
||||
// Fill input[name="JWT"]
|
||||
await page.fill('input[name="JWT"]', jwt);
|
||||
|
||||
// Click text="Sign in"
|
||||
return await Promise.all([
|
||||
page.waitForNavigation(/*{ url: 'http://localhost:3000/' }*/),
|
||||
page.click('text="Sign in"'),
|
||||
]);
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
// Initialize Firebase Admin
|
||||
import * as admin from "firebase-admin";
|
||||
// Initialize Firebase Admin
|
||||
const serverTimestamp = admin.firestore.FieldValue.serverTimestamp;
|
||||
const serviceAccount = require("./firebase-credentials.json");
|
||||
|
||||
admin.initializeApp({
|
||||
credential: admin.credential.cert(serviceAccount),
|
||||
databaseURL: `https://${serviceAccount.project_id}.firebaseio.com`,
|
||||
});
|
||||
export const db = admin.firestore();
|
||||
export const auth = admin.auth();
|
||||
123
e2e/index.ts
@@ -1,123 +0,0 @@
|
||||
import { chromium } from "playwright";
|
||||
import { authenticateUser } from "./auth";
|
||||
(async () => {
|
||||
const browser = await chromium.launch({
|
||||
headless: false,
|
||||
});
|
||||
const context = await browser.newContext();
|
||||
|
||||
// Open new page
|
||||
const page = await context.newPage();
|
||||
|
||||
await authenticateUser(page);
|
||||
|
||||
await page.goto("http://localhost:3000/table/test");
|
||||
// Click text="Add Column"
|
||||
await page.click(
|
||||
"//div[starts-with(normalize-space(.), 'EdwardKnightEd has had a multi decade career in European banking and capital mar') and normalize-space(@role)='row']/div[2][normalize-space(@role)='gridcell']/div/div/div/div[normalize-space(@role)='button']"
|
||||
);
|
||||
|
||||
// Click //li[normalize-space(.)='LON3' and normalize-space(@role)='option']/*[local-name()="svg"]
|
||||
await page.click(
|
||||
"//li[normalize-space(.)='LON3' and normalize-space(@role)='option']/*[local-name()=\"svg\"]"
|
||||
);
|
||||
|
||||
// Click //div[normalize-space(.)='Beijing' and normalize-space(@role)='button']
|
||||
await page.click(
|
||||
"//div[normalize-space(.)='Beijing' and normalize-space(@role)='button']"
|
||||
);
|
||||
|
||||
// Click //li[normalize-space(.)='India' and normalize-space(@role)='option']/*[local-name()="svg"]
|
||||
await page.click(
|
||||
"//li[normalize-space(.)='India' and normalize-space(@role)='option']/*[local-name()=\"svg\"]"
|
||||
);
|
||||
|
||||
// Click //li[normalize-space(.)='Oslo' and normalize-space(@role)='option']
|
||||
await page.click(
|
||||
"//li[normalize-space(.)='Oslo' and normalize-space(@role)='option']"
|
||||
);
|
||||
|
||||
// Click text="Add Row"
|
||||
await page.click('text="Add Row"');
|
||||
|
||||
// Click //button[normalize-space(.)='Hide']
|
||||
await page.click("//button[normalize-space(.)='Hide']");
|
||||
|
||||
// Click li[role="option"] >> text="Department"
|
||||
await page.click('li[role="option"] >> text="Department"');
|
||||
|
||||
// Click li[role="option"] >> text="Location"
|
||||
await page.click('li[role="option"] >> text="Location"');
|
||||
|
||||
// Click li[role="option"] >> text="Designation"
|
||||
await page.click('li[role="option"] >> text="Designation"');
|
||||
|
||||
// Click li[role="option"] >> text="Employment Type"
|
||||
await page.click('li[role="option"] >> text="Employment Type"');
|
||||
|
||||
// Click text="Done"
|
||||
await page.click('text="Done"');
|
||||
|
||||
// Click .MuiGrid-root.MuiGrid-item .MuiGrid-root .MuiButtonBase-root .MuiButton-label .MuiButton-startIcon .MuiSvgIcon-root path
|
||||
await page.click(
|
||||
".MuiGrid-root.MuiGrid-item .MuiGrid-root .MuiButtonBase-root .MuiButton-label .MuiButton-startIcon .MuiSvgIcon-root path"
|
||||
);
|
||||
|
||||
// Click //div[normalize-space(.)='Select Column']
|
||||
await page.click("//div[normalize-space(.)='Select Column']");
|
||||
|
||||
// Click //li[normalize-space(.)='Last Name' and normalize-space(@role)='option']
|
||||
await page.click(
|
||||
"//li[normalize-space(.)='Last Name' and normalize-space(@role)='option']"
|
||||
);
|
||||
|
||||
// Click div[role="presentation"] div[role="button"]
|
||||
await page.click('div[role="presentation"] div[role="button"]');
|
||||
|
||||
// Click //li[normalize-space(.)='Employment Type' and normalize-space(@role)='option']
|
||||
await page.click(
|
||||
"//li[normalize-space(.)='Employment Type' and normalize-space(@role)='option']"
|
||||
);
|
||||
|
||||
// Click //div[normalize-space(.)='Select Condition' and normalize-space(@role)='button']
|
||||
await page.click(
|
||||
"//div[normalize-space(.)='Select Condition' and normalize-space(@role)='button']"
|
||||
);
|
||||
|
||||
// Click //li[normalize-space(.)='Equals' and normalize-space(@role)='option']
|
||||
await page.click(
|
||||
"//li[normalize-space(.)='Equals' and normalize-space(@role)='option']"
|
||||
);
|
||||
|
||||
// Click //div[normalize-space(.)='Equals' and normalize-space(@role)='button']
|
||||
await page.click(
|
||||
"//div[normalize-space(.)='Equals' and normalize-space(@role)='button']"
|
||||
);
|
||||
|
||||
// Click //div[normalize-space(.)='Select ConditionEqualsmatches any of' and normalize-space(@role)='presentation']/div[1]
|
||||
await page.click(
|
||||
"//div[normalize-space(.)='Select ConditionEqualsmatches any of' and normalize-space(@role)='presentation']/div[1]"
|
||||
);
|
||||
|
||||
// Click //div[normalize-space(.)='' and normalize-space(@role)='button']
|
||||
await page.click(
|
||||
"//div[normalize-space(.)='' and normalize-space(@role)='button']"
|
||||
);
|
||||
|
||||
// Click //li[normalize-space(.)='Part Time' and normalize-space(@role)='option']/*[local-name()="svg"]
|
||||
await page.click(
|
||||
"//li[normalize-space(.)='Part Time' and normalize-space(@role)='option']/*[local-name()=\"svg\"]"
|
||||
);
|
||||
|
||||
// Click text="Apply"
|
||||
await page.click('text="Apply"');
|
||||
|
||||
// Click //div[normalize-space(.)='employmentType == Part Time' and normalize-space(@role)='button']/*[local-name()="svg"]
|
||||
await page.click(
|
||||
"//div[normalize-space(.)='employmentType == Part Time' and normalize-space(@role)='button']/*[local-name()=\"svg\"]"
|
||||
);
|
||||
|
||||
// ---------------------
|
||||
await context.close();
|
||||
await browser.close();
|
||||
})();
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.14.33",
|
||||
"playwright": "^1.9.2",
|
||||
"playwright-cli": "^0.180.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase-admin": "^9.5.0"
|
||||
}
|
||||
}
|
||||
1196
e2e/yarn.lock
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"hosting": {
|
||||
"target": "firetable",
|
||||
"public": "build",
|
||||
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
|
||||
"rewrites": [
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"functions": {
|
||||
"predeploy": [
|
||||
"npm --prefix \"$RESOURCE_DIR\" run lint",
|
||||
"npm --prefix \"$RESOURCE_DIR\" run build"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
es6: true,
|
||||
node: true,
|
||||
},
|
||||
extends: ["plugin:import/errors", "plugin:import/warnings"],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "tsconfig.json",
|
||||
sourceType: "module",
|
||||
},
|
||||
plugins: ["@typescript-eslint", "import"],
|
||||
rules: {
|
||||
"@typescript-eslint/adjacent-overload-signatures": "error",
|
||||
"@typescript-eslint/no-empty-function": "error",
|
||||
"@typescript-eslint/no-empty-interface": "warn",
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"@typescript-eslint/no-namespace": "error",
|
||||
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
||||
"@typescript-eslint/prefer-for-of": "warn",
|
||||
"@typescript-eslint/triple-slash-reference": "error",
|
||||
"@typescript-eslint/unified-signatures": "warn",
|
||||
"comma-dangle": "warn",
|
||||
"constructor-super": "error",
|
||||
eqeqeq: ["warn", "always"],
|
||||
"import/no-deprecated": "warn",
|
||||
"import/no-extraneous-dependencies": "error",
|
||||
"import/no-unassigned-import": "warn",
|
||||
"no-cond-assign": "error",
|
||||
"no-duplicate-case": "error",
|
||||
"no-duplicate-imports": "error",
|
||||
"no-empty": [
|
||||
"error",
|
||||
{
|
||||
allowEmptyCatch: true,
|
||||
},
|
||||
],
|
||||
"no-invalid-this": "error",
|
||||
"no-new-wrappers": "error",
|
||||
"no-param-reassign": "error",
|
||||
"no-redeclare": "error",
|
||||
"no-sequences": "error",
|
||||
"no-shadow": [
|
||||
"error",
|
||||
{
|
||||
hoist: "all",
|
||||
},
|
||||
],
|
||||
"no-throw-literal": "error",
|
||||
"no-unsafe-finally": "error",
|
||||
"no-unused-labels": "error",
|
||||
"no-var": "warn",
|
||||
"no-void": "error",
|
||||
"prefer-const": "warn",
|
||||
},
|
||||
settings: {
|
||||
jsdoc: {
|
||||
tagNamePreference: {
|
||||
returns: "return",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
12
ft_actions/functions/.gitignore
vendored
@@ -1,12 +0,0 @@
|
||||
# Compiled JavaScript files
|
||||
**/*.js
|
||||
**/*.js.map
|
||||
|
||||
# Except the ESLint config file
|
||||
!.eslintrc.js
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Node.js dependency directory
|
||||
node_modules/
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"name": "functions",
|
||||
"scripts": {
|
||||
"lint": "tslint --project tsconfig.json",
|
||||
"build": "tsc",
|
||||
"serve": "npm run build && firebase serve --only functions",
|
||||
"shell": "npm run build && firebase functions:shell",
|
||||
"start": "npm run shell",
|
||||
"deployFT": "echo 'n\n' | firebase deploy --interactive",
|
||||
"logs": "firebase functions:log"
|
||||
},
|
||||
"engines": {
|
||||
"node": "14"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"firebase-admin": "^9.11.0",
|
||||
"firebase-functions": "^3.14.1",
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"firebase-tools": "^8.7.0",
|
||||
"husky": "^4.2.5",
|
||||
"prettier": "^2.1.1",
|
||||
"pretty-quick": "^3.0.0",
|
||||
"ts-node": "^8.6.2",
|
||||
"tslint": "^6.1.0",
|
||||
"typescript": "^3.2.2"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged"
|
||||
}
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Initialize Firebase Admin
|
||||
import * as functions from "firebase-functions";
|
||||
import * as admin from "firebase-admin";
|
||||
admin.initializeApp();
|
||||
|
||||
// Initialize Cloud Firestore Database
|
||||
export const db = admin.firestore();
|
||||
// Initialize Auth
|
||||
export const auth = admin.auth();
|
||||
|
||||
const settings = { timestampsInSnapshots: true, ignoreUndefinedProperties: true};
|
||||
db.settings(settings);
|
||||
export const env = functions.config();
|
||||
@@ -1,113 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
import * as _ from "lodash";
|
||||
import { db, auth } from "./firebaseConfig";
|
||||
import * as admin from "firebase-admin";
|
||||
import utilFns from "./utils";
|
||||
type ActionData = {
|
||||
ref: {
|
||||
id: string;
|
||||
path: string;
|
||||
parentId: string;
|
||||
tablePath: string;
|
||||
};
|
||||
schemaDocPath?: string;
|
||||
column: any;
|
||||
action: "run" | "redo" | "undo";
|
||||
actionParams: any;
|
||||
};
|
||||
|
||||
const missingFieldsReducer = (data: any) => (acc: string[], curr: string) => {
|
||||
if (data[curr] === undefined) {
|
||||
return [...acc, curr];
|
||||
} else return acc;
|
||||
};
|
||||
|
||||
const generateSchemaDocPath = (tablePath) => {
|
||||
const pathComponents = tablePath.split("/");
|
||||
return `_FIRETABLE_/settings/${
|
||||
pathComponents[1] === "table" ? "schema" : "groupSchema"
|
||||
}/${pathComponents[2]}`;
|
||||
};
|
||||
const serverTimestamp = admin.firestore.FieldValue.serverTimestamp;
|
||||
|
||||
export const actionScript = functions.https.onCall(
|
||||
async (data: ActionData, context: functions.https.CallableContext) => {
|
||||
try {
|
||||
if (!context) {
|
||||
throw Error(`You are unauthenticated`);
|
||||
}
|
||||
|
||||
const { ref, actionParams, column, action, schemaDocPath } = data;
|
||||
const _schemaDocPath =
|
||||
schemaDocPath ?? generateSchemaDocPath(ref.tablePath);
|
||||
const [schemaDoc, rowQuery] = await Promise.all([
|
||||
db.doc(_schemaDocPath).get(),
|
||||
db.doc(ref.path).get(),
|
||||
]);
|
||||
const row = rowQuery.data();
|
||||
const schemaDocData = schemaDoc.data();
|
||||
if (!schemaDocData) {
|
||||
return {
|
||||
success: false,
|
||||
message: "no schema found",
|
||||
};
|
||||
}
|
||||
const config = schemaDocData.columns[column.key].config;
|
||||
const { script, requiredRoles, requiredFields } = config;
|
||||
if (!requiredRoles || requiredRoles.length === 0) {
|
||||
throw Error(`You need to specify at least one role to run this script`);
|
||||
}
|
||||
if (!utilFns.hasAnyRole(requiredRoles, context)) {
|
||||
throw Error(`You don't have the required roles permissions`);
|
||||
}
|
||||
|
||||
const missingRequiredFields = requiredFields
|
||||
? requiredFields.reduce(missingFieldsReducer(row), [])
|
||||
: [];
|
||||
if (missingRequiredFields.length > 0) {
|
||||
throw new Error(
|
||||
`Missing required fields:${missingRequiredFields.join(", ")}`
|
||||
);
|
||||
}
|
||||
const result: {
|
||||
message: string;
|
||||
status: string;
|
||||
success: boolean;
|
||||
} = await eval(
|
||||
`async({row,db, ref,auth,utilFns,actionParams,context})=>{${
|
||||
action === "undo" ? config["undo.script"] : script
|
||||
}}`
|
||||
)({ row, db, auth, utilFns, ref, actionParams, context });
|
||||
if (result.success){
|
||||
const cellValue = {
|
||||
redo: config["redo.enabled"],
|
||||
status: result.status,
|
||||
completedAt: serverTimestamp(),
|
||||
ranBy: context.auth!.token.email,
|
||||
undo: config["undo.enabled"],
|
||||
}
|
||||
const userDoc = await db.collection("_FT_USERS").doc(context.auth!.uid).get()
|
||||
const user = userDoc?.get('user')
|
||||
await db.doc(ref.path).update({[column.key]:cellValue, _ft_updatedBy:user? {
|
||||
...user,
|
||||
...context.auth!,
|
||||
timestamp: new Date(),
|
||||
}:null })
|
||||
return {
|
||||
...result,
|
||||
cellValue,
|
||||
}
|
||||
}
|
||||
else return {
|
||||
success: false,
|
||||
message: result.message,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error,
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -1,17 +0,0 @@
|
||||
import * as functions from "firebase-functions";
|
||||
|
||||
export const hasAnyRole = (
|
||||
authorizedRoles: string[],
|
||||
context: functions.https.CallableContext
|
||||
) => {
|
||||
if (!context.auth || !context.auth.token.roles) return false;
|
||||
const userRoles = context.auth.token.roles as string[];
|
||||
const authorization = authorizedRoles.reduce(
|
||||
(authorized: boolean, role: string) => {
|
||||
if (userRoles.includes(role)) return true;
|
||||
else return authorized;
|
||||
},
|
||||
false
|
||||
);
|
||||
return authorization;
|
||||
};
|
||||
@@ -1,40 +0,0 @@
|
||||
import * as admin from "firebase-admin";
|
||||
export const serverTimestamp = admin.firestore.FieldValue.serverTimestamp;
|
||||
import { hasAnyRole } from "./auth";
|
||||
|
||||
const characters =
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
export function generateId(length: number): string {
|
||||
let result = "";
|
||||
const charactersLength = characters.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const hasRequiredFields = (requiredFields: string[], data: any) =>
|
||||
requiredFields.reduce((acc: boolean, currField: string) => {
|
||||
if (data[currField] === undefined || data[currField] === null) return false;
|
||||
else return acc;
|
||||
}, true);
|
||||
async function asyncForEach(array: any[], callback: Function) {
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
await callback(array[index], index, array);
|
||||
}
|
||||
}
|
||||
const identifyTriggerType = (beforeData: any, afterData: any) =>
|
||||
Boolean(beforeData) && Boolean(afterData)
|
||||
? "update"
|
||||
: Boolean(afterData)
|
||||
? "create"
|
||||
: "delete";
|
||||
|
||||
export default {
|
||||
hasRequiredFields,
|
||||
generateId,
|
||||
serverTimestamp,
|
||||
hasAnyRole,
|
||||
asyncForEach,
|
||||
identifyTriggerType,
|
||||
};
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": true,
|
||||
"outDir": "lib",
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"target": "ESNext"
|
||||
},
|
||||
"compileOnSave": true,
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
{
|
||||
"rules": {
|
||||
// -- Strict errors --
|
||||
// These lint rules are likely always a good idea.
|
||||
|
||||
// Force function overloads to be declared together. This ensures readers understand APIs.
|
||||
"adjacent-overload-signatures": true,
|
||||
|
||||
// Do not allow the subtle/obscure comma operator.
|
||||
"ban-comma-operator": true,
|
||||
|
||||
// Do not allow internal modules or namespaces . These are deprecated in favor of ES6 modules.
|
||||
"no-namespace": true,
|
||||
|
||||
// Do not allow parameters to be reassigned. To avoid bugs, developers should instead assign new values to new vars.
|
||||
"no-parameter-reassignment": true,
|
||||
|
||||
// Force the use of ES6-style imports instead of /// <reference path=> imports.
|
||||
"no-reference": true,
|
||||
|
||||
// Do not allow type assertions that do nothing. This is a big warning that the developer may not understand the
|
||||
// code currently being edited (they may be incorrectly handling a different type case that does not exist).
|
||||
"no-unnecessary-type-assertion": true,
|
||||
|
||||
// Disallow nonsensical label usage.
|
||||
"label-position": true,
|
||||
|
||||
// Disallows the (often typo) syntax if (var1 = var2). Replace with if (var2) { var1 = var2 }.
|
||||
"no-conditional-assignment": true,
|
||||
|
||||
// Disallows constructors for primitive types (e.g. new Number('123'), though Number('123') is still allowed).
|
||||
"no-construct": true,
|
||||
|
||||
// Do not allow super() to be called twice in a constructor.
|
||||
"no-duplicate-super": true,
|
||||
|
||||
// Do not allow the same case to appear more than once in a switch block.
|
||||
"no-duplicate-switch-case": true,
|
||||
|
||||
// Do not allow a variable to be declared more than once in the same block. Consider function parameters in this
|
||||
// rule.
|
||||
"no-duplicate-variable": [true, "check-parameters"],
|
||||
|
||||
// Disallows a variable definition in an inner scope from shadowing a variable in an outer scope. Developers should
|
||||
// instead use a separate variable name.
|
||||
"no-shadowed-variable": true,
|
||||
|
||||
// Empty blocks are almost never needed. Allow the one general exception: empty catch blocks.
|
||||
"no-empty": [true, "allow-empty-catch"],
|
||||
|
||||
// Functions must either be handled directly (e.g. with a catch() handler) or returned to another function.
|
||||
// This is a major source of errors in Cloud Functions and the team strongly recommends leaving this rule on.
|
||||
"no-floating-promises": true,
|
||||
|
||||
// Do not allow any imports for modules that are not in package.json. These will almost certainly fail when
|
||||
// deployed.
|
||||
"no-implicit-dependencies": true,
|
||||
|
||||
// The 'this' keyword can only be used inside of classes.
|
||||
"no-invalid-this": true,
|
||||
|
||||
// Do not allow strings to be thrown because they will not include stack traces. Throw Errors instead.
|
||||
"no-string-throw": true,
|
||||
|
||||
// Disallow control flow statements, such as return, continue, break, and throw in finally blocks.
|
||||
"no-unsafe-finally": true,
|
||||
|
||||
// Do not allow variables to be used before they are declared.
|
||||
"no-use-before-declare": true,
|
||||
|
||||
// Expressions must always return a value. Avoids common errors like const myValue = functionReturningVoid();
|
||||
"no-void-expression": [true, "ignore-arrow-function-shorthand"],
|
||||
|
||||
// Disallow duplicate imports in the same file.
|
||||
"no-duplicate-imports": true,
|
||||
|
||||
// -- Strong Warnings --
|
||||
// These rules should almost never be needed, but may be included due to legacy code.
|
||||
// They are left as a warning to avoid frustration with blocked deploys when the developer
|
||||
// understand the warning and wants to deploy anyway.
|
||||
|
||||
// Warn when an empty interface is defined. These are generally not useful.
|
||||
"no-empty-interface": { "severity": "warning" },
|
||||
|
||||
// Warn when an import will have side effects.
|
||||
"no-import-side-effect": { "severity": "warning" },
|
||||
|
||||
// Warn when variables are defined with var. Var has subtle meaning that can lead to bugs. Strongly prefer const for
|
||||
// most values and let for values that will change.
|
||||
"no-var-keyword": { "severity": "warning" },
|
||||
|
||||
// Prefer === and !== over == and !=. The latter operators support overloads that are often accidental.
|
||||
"triple-equals": { "severity": "warning" },
|
||||
|
||||
// Warn when using deprecated APIs.
|
||||
"deprecation": { "severity": "warning" },
|
||||
|
||||
// -- Light Warnings --
|
||||
// These rules are intended to help developers use better style. Simpler code has fewer bugs. These would be "info"
|
||||
// if TSLint supported such a level.
|
||||
|
||||
// prefer for( ... of ... ) to an index loop when the index is only used to fetch an object from an array.
|
||||
// (Even better: check out utils like .map if transforming an array!)
|
||||
"prefer-for-of": { "severity": "warning" },
|
||||
|
||||
// Warns if function overloads could be unified into a single function with optional or rest parameters.
|
||||
"unified-signatures": { "severity": "warning" },
|
||||
|
||||
// Prefer const for values that will not change. This better documents code.
|
||||
"prefer-const": { "severity": "warning" },
|
||||
|
||||
// Multi-line object literals and function calls should have a trailing comma. This helps avoid merge conflicts.
|
||||
"trailing-comma": { "severity": "warning" }
|
||||
},
|
||||
"linterOptions": {
|
||||
"exclude": ["./generator/templates/**"]
|
||||
},
|
||||
"defaultSeverity": "error"
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
export const dependencies = {
|
||||
// --- Add your dependencies
|
||||
// algoliasearch: "^4.8.3",
|
||||
};
|
||||
// Define your spark
|
||||
const sparkName = async (data, sparkContext) => {
|
||||
// Your spark inputs
|
||||
const { row, targetPath, fieldsToSync } = data;
|
||||
const { triggerType, change } = sparkContext;
|
||||
|
||||
// ---------------------------------------------
|
||||
// --- Utilise your dependencies ---
|
||||
// const algoliasearch = require("algoliasearch");
|
||||
|
||||
// ---------------------------------------------
|
||||
// --- Get the secret from Secrets Manager
|
||||
// Example: Algolia Secret
|
||||
// const { getSecret } = require("../utils");
|
||||
// const { appId, adminKey } = await getSecret("algolia");
|
||||
|
||||
// ---------------------------------------------
|
||||
// --- Connect to any third party extensions ---
|
||||
// Example Algolia
|
||||
// const client = algoliasearch(appId, adminKey);
|
||||
// const _index = client.initIndex(index);
|
||||
|
||||
// ---------------------------------------------
|
||||
// --- Handle required trigger actions ---
|
||||
switch (triggerType) {
|
||||
case "create":
|
||||
// create trigger actions
|
||||
break;
|
||||
|
||||
case "update":
|
||||
// update trigger actions
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
// delete trigger actions
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
export default sparkName;
|
||||
BIN
icon.png
|
Before Width: | Height: | Size: 956 B After Width: | Height: | Size: 1.1 KiB |
83
package.json
Normal file
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"name": "rowy",
|
||||
"version": "3.0.0-alpha.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@craco/craco": "^6.4.3",
|
||||
"@emotion/react": "^11.9.0",
|
||||
"@emotion/styled": "^11.8.1",
|
||||
"@mdi/js": "^6.6.96",
|
||||
"@mui/icons-material": "^5.6.0",
|
||||
"@mui/lab": "^5.0.0-alpha.76",
|
||||
"@mui/material": "^5.6.0",
|
||||
"@mui/styles": "^5.6.0",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/react": "^13.0.0",
|
||||
"@testing-library/user-event": "^14.0.4",
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/node": "^17.0.23",
|
||||
"@types/react": "^18.0.0",
|
||||
"@types/react-dom": "^18.0.0",
|
||||
"craco-swc": "^0.5.1",
|
||||
"date-fns": "^2.28.0",
|
||||
"dompurify": "^2.3.6",
|
||||
"firebase": "^9.6.10",
|
||||
"firebaseui": "^6.0.1",
|
||||
"jotai": "^1.6.2",
|
||||
"lodash": "^4.17.21",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"react-firebaseui": "^6.0.0",
|
||||
"react-router-dom": "^6.3.0",
|
||||
"react-scripts": "^5.0.0",
|
||||
"reactfire": "^4.2.1",
|
||||
"typescript": "^4.6.3",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cross-env PORT=7699 craco start",
|
||||
"build": "craco build",
|
||||
"test": "craco test",
|
||||
"eject": "craco eject",
|
||||
"prepare": "cd .. && husky install www/.husky"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest",
|
||||
"prettier"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/dompurify": "^2.3.3",
|
||||
"@types/lodash": "^4.14.181",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"@typescript-eslint/parser": "^5.18.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.12.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-config-react-app": "^7.0.0",
|
||||
"husky": ">=7.0.4",
|
||||
"lint-staged": ">=12.3.7",
|
||||
"prettier": "^2.6.2"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,ts,tsx}": "eslint --cache --fix",
|
||||
"*.{js,ts,tsx,css,md}": "prettier --write"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
8
tsconfig.extend.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@root/*": ["../*"],
|
||||
"@src/*": ["./*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"target": "es2021",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
@@ -13,11 +13,12 @@
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"newLine": "lf",
|
||||
"noEmit": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"jsx": "react-jsx",
|
||||
"baseUrl": "src"
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
BIN
www-v1/.env.enc
@@ -1,5 +0,0 @@
|
||||
REACT_APP_ALGOLIA_APP_ID=
|
||||
REACT_APP_ALGOLIA_SEARCH_API_KEY=
|
||||
|
||||
REACT_APP_FIREBASE_PROJECT_ID=
|
||||
REACT_APP_FIREBASE_PROJECT_WEB_API_KEY=
|
||||
68
www-v1/.gitignore
vendored
@@ -1,68 +0,0 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
firebase-debug.log*
|
||||
|
||||
# Firebase cache
|
||||
.firebase/
|
||||
|
||||
# Firebase config
|
||||
|
||||
# Uncomment this if you'd like others to create their own Firebase project.
|
||||
# For a team working on the same Firebase project(s), it is recommended to leave
|
||||
# it commented so all members can deploy to the same project(s) in .firebaserc.
|
||||
# .firebaserc
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
firebase-debug.log
|
||||
|
||||
build
|
||||
@@ -1,5 +0,0 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
yarn-path ".yarn/releases/yarn-1.22.5.cjs"
|
||||
@@ -1,121 +0,0 @@
|
||||
{
|
||||
"name": "Firetable",
|
||||
"version": "2.0.0",
|
||||
"homepage": "https://firetable.io/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/FiretableProject/firetable.git"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@antlerengineering/form-builder": "^3.0.0-2",
|
||||
"@antlerengineering/multiselect": "^1.0.0-0",
|
||||
"@craco/craco": "^6.2.0",
|
||||
"@date-io/date-fns": "1.x",
|
||||
"@emotion/react": "^11.4.0",
|
||||
"@emotion/styled": "^11.3.0",
|
||||
"@material-ui/core": "^5.0.0-beta.4",
|
||||
"@material-ui/icons": "^5.0.0-beta.4",
|
||||
"@material-ui/lab": "^5.0.0-alpha.43",
|
||||
"@material-ui/styles": "^5.0.0-beta.4",
|
||||
"@mdi/js": "^5.8.55",
|
||||
"@monaco-editor/react": "^4.1.0",
|
||||
"@tinymce/tinymce-react": "^3.4.0",
|
||||
"algoliasearch": "^4.8.6",
|
||||
"ansi-to-react": "^6.1.5",
|
||||
"chroma-js": "^2.1.2",
|
||||
"colord": "^2.7.0",
|
||||
"craco-swc": "^0.1.3",
|
||||
"csv-parse": "^4.15.3",
|
||||
"date-fns": "^2.19.0",
|
||||
"dompurify": "^2.2.6",
|
||||
"file-saver": "^2.0.5",
|
||||
"firebase": "8.6.8",
|
||||
"hotkeys-js": "^3.7.2",
|
||||
"json-format": "^1.0.1",
|
||||
"json2csv": "^5.0.6",
|
||||
"jszip": "^3.6.0",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.29.1",
|
||||
"query-string": "^6.8.3",
|
||||
"react": "^17.0.2",
|
||||
"react-beautiful-dnd": "^13.0.0",
|
||||
"react-color": "^2.17.3",
|
||||
"react-data-grid": "7.0.0-canary.30",
|
||||
"react-div-100vh": "^0.3.8",
|
||||
"react-dnd": "^11.1.3",
|
||||
"react-dnd-html5-backend": "^11.1.3",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-dropzone": "^10.1.8",
|
||||
"react-firebaseui": "^5.0.2",
|
||||
"react-hook-form": "^6",
|
||||
"react-image": "^4.0.3",
|
||||
"react-joyride": "^2.3.0",
|
||||
"react-json-view": "^1.19.1",
|
||||
"react-router-dom": "^5.0.1",
|
||||
"react-scripts": "^4.0.3",
|
||||
"react-scroll-sync": "^0.8.0",
|
||||
"react-usestateref": "^1.0.5",
|
||||
"serve": "^11.3.2",
|
||||
"tinymce": "^5.2.0",
|
||||
"typescript": "^4.3.5",
|
||||
"use-algolia": "^1.4.1",
|
||||
"use-debounce": "^3.3.0",
|
||||
"use-persisted-state": "^0.3.3",
|
||||
"yarn": "^1.22.10",
|
||||
"yup": "^0.32.9"
|
||||
},
|
||||
"scripts": {
|
||||
"serve": "serve -s build",
|
||||
"start": "craco start",
|
||||
"build": "craco build",
|
||||
"test": "craco test --env=jsdom",
|
||||
"eject": "craco eject",
|
||||
"env": "node createDotEnv",
|
||||
"target": "firebase target:apply hosting firetable",
|
||||
"deploy": "firebase deploy"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chroma-js": "^2.1.3",
|
||||
"@types/dompurify": "^2.2.1",
|
||||
"@types/file-saver": "^2.0.1",
|
||||
"@types/lodash": "^4.14.168",
|
||||
"@types/node": "^14.14.6",
|
||||
"@types/react": "^17.0.11",
|
||||
"@types/react-beautiful-dnd": "^13.0.0",
|
||||
"@types/react-color": "^3.0.1",
|
||||
"@types/react-div-100vh": "^0.3.0",
|
||||
"@types/react-dom": "^17.0.8",
|
||||
"@types/react-router-dom": "^5.1.7",
|
||||
"@types/use-persisted-state": "^0.3.0",
|
||||
"firebase-tools": "^8.12.1",
|
||||
"husky": "^4.2.5",
|
||||
"monaco-editor": "^0.21.2",
|
||||
"playwright": "^1.5.2",
|
||||
"prettier": "^2.2.1",
|
||||
"pretty-quick": "^3.0.0"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
# Rewrite a path
|
||||
/* /index.html 200
|
||||