mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
restructure cloudfunctions to clean up index
This commit is contained in:
@@ -2,6 +2,8 @@ import * as algoliasearch from "algoliasearch";
|
||||
import * as functions from "firebase-functions";
|
||||
import * as _ from "lodash";
|
||||
import { env } from "../config";
|
||||
import config from "../functionConfig"; // generated using generateConfig.ts
|
||||
const functionConfig: any = config;
|
||||
|
||||
const APP_ID = env.algolia.app;
|
||||
const ADMIN_KEY = env.algolia.key;
|
||||
@@ -181,4 +183,7 @@ const algoliaFnsGenerator = collection => ({
|
||||
// console.log(JSON.stringify(afterData));
|
||||
// }),
|
||||
// });
|
||||
export default algoliaFnsGenerator;
|
||||
//export default algoliaFnsGenerator;
|
||||
export const FT_algolia = {
|
||||
[functionConfig.name]: { ...algoliaFnsGenerator(functionConfig) },
|
||||
};
|
||||
|
||||
@@ -2,6 +2,9 @@ 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>
|
||||
) => {
|
||||
@@ -28,4 +31,10 @@ const historySnapshotFnsGenerator = collection =>
|
||||
.document(`${collection.name}/{docId}`)
|
||||
.onUpdate(historySnapshot(collection.trackedFields));
|
||||
|
||||
export default historySnapshotFnsGenerator;
|
||||
//export default historySnapshotFnsGenerator;
|
||||
|
||||
export const FT_history = {
|
||||
[functionConfig.name
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")]: historySnapshotFnsGenerator(functionConfig),
|
||||
};
|
||||
|
||||
@@ -5,49 +5,8 @@ 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
|
||||
import config from "./functionConfig"; // generated using generateConfig.ts
|
||||
import algoliaFnsGenerator from "./algolia"; // algolia sync functions template
|
||||
import collectionSyncFnsGenerator from "./collectionSync";
|
||||
import snapshotSyncFnsGenerator from "./snapshotSync";
|
||||
import collectionSnapshotFnsGenerator from "./history";
|
||||
import permissionControlFnsGenerator from "./permissions";
|
||||
|
||||
const functionConfig: any = config;
|
||||
|
||||
export const FT_algolia = {
|
||||
[functionConfig.name]: { ...algoliaFnsGenerator(functionConfig) },
|
||||
};
|
||||
|
||||
// {
|
||||
// [functionConfig.name]: { ...algoliaFnsGenerator(functionConfig) },
|
||||
// };
|
||||
|
||||
export const FT_sync = {
|
||||
[`${`${`${functionConfig.source}`
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")}`}2${`${`${functionConfig.target}`
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")}`}`]: collectionSyncFnsGenerator(functionConfig),
|
||||
};
|
||||
|
||||
export const FT_history = {
|
||||
[functionConfig.name
|
||||
.replace(/\//g, "_")
|
||||
.replace(/_{.*?}_/g, "_")]: collectionSnapshotFnsGenerator(functionConfig),
|
||||
};
|
||||
|
||||
export const FT_permissions = {
|
||||
[functionConfig.name]: permissionControlFnsGenerator(functionConfig),
|
||||
};
|
||||
|
||||
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
|
||||
),
|
||||
};
|
||||
export { FT_derivatives } from "./derivatives";
|
||||
export { FT_algolia } from "./algolia";
|
||||
export { FT_sync } from "./collectionSync";
|
||||
export { FT_snapshotSync } from "./snapshotSync";
|
||||
export { FT_history } from "./history";
|
||||
|
||||
@@ -5,6 +5,9 @@ import { db } from "../config";
|
||||
import * as _ from "lodash";
|
||||
import { replacer } from "../utils/email";
|
||||
|
||||
import config from "../functionConfig"; // generated using generateConfig.ts
|
||||
const functionConfig: any = config;
|
||||
|
||||
enum TargetTypes {
|
||||
subCollection = "subCollection",
|
||||
document = "document",
|
||||
@@ -162,4 +165,16 @@ const snapshotSyncFnsGenerator = config =>
|
||||
: null,
|
||||
}).reduce((a, [k, v]) => (v === null ? a : { ...a, [k]: v }), {});
|
||||
|
||||
export default snapshotSyncFnsGenerator;
|
||||
//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
|
||||
),
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@ steps:
|
||||
entrypoint: yarn
|
||||
args:
|
||||
- "generateConfig"
|
||||
- "${_FUNCTIONS_GROUP}"
|
||||
- "${_FUNCTION_CONFIG}"
|
||||
dir: "cloud_functions/functions"
|
||||
- name: node:10.15.1
|
||||
|
||||
Reference in New Issue
Block a user