reddit / devvit

Reddit for Developers
https://developers.reddit.com
BSD 3-Clause "New" or "Revised" License
63 stars 14 forks source link

EventSource enum missing in actual runtime #97

Open PitchforkAssistant opened 3 weeks ago

PitchforkAssistant commented 3 weeks ago

The PostDelete event contains a source property of the type EventSource. It's exported and available to import from @devvit/protos, but the runtime doesn't seem to match that.

The following code is valid, builds, and uploads:

import {EventSource, PostDelete} from "@devvit/protos";
import {TriggerContext} from "@devvit/public-api";

export async function onPostDelete (event: PostDelete, context: TriggerContext) {
    if (event.source !== EventSource.USER) {
        return;
    }
    // handle user deletion...
    console.log(`Processing user deletion of ${event.postId}`);
}

However it fails when actually running on Devvit with the error: TypeError: Cannot read properties of undefined (reading 'USER')

This wasn't always the case and is affecting apps that were previously referencing the enum without issues. I am not sure when it went missing, but it was still there a few months ago.