Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { Change } = require("firebase-functions");
const newSnap =
proto.data.value &&
(app.firestore() as any).snapshot_(proto.data.value, new Date().toISOString(), "json");
const oldSnap =
proto.data.oldValue &&
(app.firestore() as any).snapshot_(proto.data.oldValue, new Date().toISOString(), "json");
let data;
switch (proto.context.eventType) {
case "providers/cloud.firestore/eventTypes/document.write":
data = Change.fromObjects(oldSnap, newSnap);
break;
case "providers/cloud.firestore/eventTypes/document.delete":
data = Change.fromObjects(oldSnap, newSnap);
break;
default:
data = newSnap && oldSnap ? Change.fromObjects(oldSnap, newSnap) : newSnap;
}
const resourcePath = proto.context.resource.name;
const params = _extractParamsFromPath(trigger.definition.eventTrigger.resource, resourcePath);
const ctx = {
eventId: proto.context.eventId,
timestamp: proto.context.timestamp,
params,
auth: {},
authType: "UNAUTHENTICATED",
};
const proto = JSON.parse(body);
const newSnap =
proto.data.value &&
(app.firestore() as any).snapshot_(proto.data.value, new Date().toISOString(), "json");
const oldSnap =
proto.data.oldValue &&
(app.firestore() as any).snapshot_(proto.data.oldValue, new Date().toISOString(), "json");
let data;
switch (proto.context.eventType) {
case "providers/cloud.firestore/eventTypes/document.write":
data = Change.fromObjects(oldSnap, newSnap);
break;
case "providers/cloud.firestore/eventTypes/document.delete":
data = Change.fromObjects(oldSnap, newSnap);
break;
default:
data = newSnap && oldSnap ? Change.fromObjects(oldSnap, newSnap) : newSnap;
}
const path = proto.context.resource.name;
const params = _extractParamsFromPath(trigger.eventTrigger.resource, path);
const ctx = {
eventId: proto.context.eventId,
timestamp: proto.context.timestamp,
params,
auth: {},
authType: "UNAUTHENTICATED",
};
proto.data.value &&
(app.firestore() as any).snapshot_(proto.data.value, new Date().toISOString(), "json");
const oldSnap =
proto.data.oldValue &&
(app.firestore() as any).snapshot_(proto.data.oldValue, new Date().toISOString(), "json");
let data;
switch (proto.context.eventType) {
case "providers/cloud.firestore/eventTypes/document.write":
data = Change.fromObjects(oldSnap, newSnap);
break;
case "providers/cloud.firestore/eventTypes/document.delete":
data = Change.fromObjects(oldSnap, newSnap);
break;
default:
data = newSnap && oldSnap ? Change.fromObjects(oldSnap, newSnap) : newSnap;
}
const resourcePath = proto.context.resource.name;
const params = _extractParamsFromPath(trigger.definition.eventTrigger.resource, resourcePath);
const ctx = {
eventId: proto.context.eventId,
timestamp: proto.context.timestamp,
params,
auth: {},
authType: "UNAUTHENTICATED",
};
new EmulatorLog("DEBUG", "runtime-status", `Requesting a wrapped function.`).log();
const func = trigger.getWrappedFunction();