Skip to content

Commit 37c9475

Browse files
committed
add jobs
1 parent da3dc3e commit 37c9475

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/Triggers/TriggerStore.js

+29
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,32 @@ export function getValidator(functionName, applicationId) {
177177
export function getJob(jobName, applicationId) {
178178
return get(Category.Jobs, jobName, applicationId);
179179
}
180+
181+
export function getJobs(applicationId) {
182+
var manager = _triggerStore[applicationId];
183+
if (manager && manager.Jobs) {
184+
return manager.Jobs;
185+
}
186+
return undefined;
187+
}
188+
189+
export function getFunctionNames(applicationId) {
190+
const store =
191+
(_triggerStore[applicationId] && _triggerStore[applicationId][Category.Functions]) || {};
192+
const functionNames = [];
193+
const extractFunctionNames = (namespace, store) => {
194+
Object.keys(store).forEach(name => {
195+
const value = store[name];
196+
if (namespace) {
197+
name = `${namespace}.${name}`;
198+
}
199+
if (typeof value === 'function') {
200+
functionNames.push(name);
201+
} else {
202+
extractFunctionNames(name, value);
203+
}
204+
});
205+
};
206+
extractFunctionNames(null, store);
207+
return functionNames;
208+
}

src/triggers.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { _unregisterAll, getTrigger, Types, triggerExists, addTrigger, addFunction, getFunction, getJob, runLiveQueryEventHandlers, addLiveQueryEventHandler, addJob } from "./Triggers/TriggerStore";
1+
import { _unregisterAll, getTrigger, Types, triggerExists, addTrigger, addFunction, getFunction, getJob, getJobs, runLiveQueryEventHandlers, addLiveQueryEventHandler, addJob, removeTrigger, getFunctionNames } from "./Triggers/TriggerStore";
22
import { maybeRunTrigger, getRequestObject, runTrigger } from "./Triggers/Trigger";
33
import { getClassName, inflate, resolveError, toJSONwithObjects } from "./Triggers/Utils";
44
import { maybeRunQueryTrigger,maybeRunAfterFindTrigger } from "./Triggers/QueryTrigger";
@@ -29,5 +29,8 @@ export {
2929
maybeRunGlobalConfigTrigger,
3030
maybeRunAfterFindTrigger,
3131
toJSONwithObjects,
32-
runLiveQueryEventHandlers
32+
runLiveQueryEventHandlers,
33+
removeTrigger,
34+
getJobs,
35+
getFunctionNames
3336
}

0 commit comments

Comments
 (0)