@revojs/cloudflare 0.2.37 → 0.2.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -0
- package/dist/index.js +3 -2
- package/dist/package.js +1 -1
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +12 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DurableObjectNamespace, Workflow } from "@cloudflare/workers-types";
|
|
2
2
|
import { type Scope } from "revojs";
|
|
3
|
+
import type { Awaitable } from "revojs/shared";
|
|
3
4
|
export type ScreamingSnake<Value extends string> = Value extends `${infer Head}${infer Next}${infer Tail}` ? `${Uppercase<Head>}${Head extends Lowercase<Head> ? (Next extends Lowercase<Next> ? "" : "_") : ""}${ScreamingSnake<`${Next}${Tail}`>}` : Uppercase<Value>;
|
|
4
5
|
export type DurableObjects = {
|
|
5
6
|
[ClassName in keyof typeof import("#durable-objects") as ScreamingSnake<ClassName>]: DurableObjectNamespace<InstanceType<(typeof import("#durable-objects"))[ClassName]>>;
|
|
@@ -9,3 +10,12 @@ export type Workflows = {
|
|
|
9
10
|
};
|
|
10
11
|
export declare function useDurableObjects(scope: Scope): DurableObjects;
|
|
11
12
|
export declare function useWorkflows(scope: Scope): Workflows;
|
|
13
|
+
export interface ReceivedEmail {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
headers: Headers;
|
|
17
|
+
raw: ReadableStream<Uint8Array>;
|
|
18
|
+
rawSize: number;
|
|
19
|
+
reject: (reason: string) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const EMAIL_RECEIVED_HOOK: import("revojs").Descriptor<import("revojs").Hook<ReceivedEmail, Awaitable<void>>>;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useVariables } from "revojs";
|
|
1
|
+
import { defineHook, useVariables } from "revojs";
|
|
2
2
|
//#region src/index.ts
|
|
3
3
|
function useDurableObjects(scope) {
|
|
4
4
|
return useVariables(scope);
|
|
@@ -6,5 +6,6 @@ function useDurableObjects(scope) {
|
|
|
6
6
|
function useWorkflows(scope) {
|
|
7
7
|
return useVariables(scope);
|
|
8
8
|
}
|
|
9
|
+
var EMAIL_RECEIVED_HOOK = defineHook("EMAIL_RECEIVED_HOOK");
|
|
9
10
|
//#endregion
|
|
10
|
-
export { useDurableObjects, useWorkflows };
|
|
11
|
+
export { EMAIL_RECEIVED_HOOK, useDurableObjects, useWorkflows };
|
package/dist/package.js
CHANGED
package/dist/server/index.d.ts
CHANGED
|
@@ -2,8 +2,17 @@ import { type ScheduledEvent } from "@cloudflare/workers-types";
|
|
|
2
2
|
export * from "#durable-objects";
|
|
3
3
|
export * from "#entrypoints";
|
|
4
4
|
export * from "#workflows";
|
|
5
|
+
interface ForwardableEmailMessage {
|
|
6
|
+
from: string;
|
|
7
|
+
to: string;
|
|
8
|
+
headers: Headers;
|
|
9
|
+
raw: ReadableStream<Uint8Array>;
|
|
10
|
+
rawSize: number;
|
|
11
|
+
setReject: (reason: string) => void;
|
|
12
|
+
}
|
|
5
13
|
declare const _default: {
|
|
6
14
|
fetch(request: Request, variables: Cloudflare.Env): Promise<Response | undefined>;
|
|
7
15
|
scheduled(event: ScheduledEvent, variables: Cloudflare.Env): Promise<void>;
|
|
16
|
+
email(message: ForwardableEmailMessage, variables: Cloudflare.Env): Promise<void>;
|
|
8
17
|
};
|
|
9
18
|
export default _default;
|
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EMAIL_RECEIVED_HOOK } from "../index.js";
|
|
2
|
+
import { VARIABLE_CONTEXT, createScope, dispatchHook } from "revojs";
|
|
2
3
|
import "@cloudflare/workers-types";
|
|
3
4
|
import { SCHEDULE_CONTEXT, createServerScope, invokeWebSocket, isResponse, isWebSocket, sendResponse } from "@revojs/server";
|
|
4
5
|
export * from "#durable-objects";
|
|
@@ -45,6 +46,16 @@ var server_default = {
|
|
|
45
46
|
[VARIABLE_CONTEXT]: variables,
|
|
46
47
|
[SCHEDULE_CONTEXT]: { when: event.cron }
|
|
47
48
|
} }));
|
|
49
|
+
},
|
|
50
|
+
async email(message, variables) {
|
|
51
|
+
await dispatchHook(await createScope({ context: { [VARIABLE_CONTEXT]: variables } }), EMAIL_RECEIVED_HOOK, {
|
|
52
|
+
from: message.from,
|
|
53
|
+
to: message.to,
|
|
54
|
+
headers: message.headers,
|
|
55
|
+
raw: message.raw,
|
|
56
|
+
rawSize: message.rawSize,
|
|
57
|
+
reject: (reason) => message.setReject(reason)
|
|
58
|
+
});
|
|
48
59
|
}
|
|
49
60
|
};
|
|
50
61
|
//#endregion
|