@revojs/cloudflare 0.2.6 → 0.2.8
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 +5 -1
- package/dist/index.js +4 -1
- package/dist/module/index.js +37 -7
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +2 -0
- package/dist/types/index.d.ts +14 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { DurableObjectNamespace } from "@cloudflare/workers-types";
|
|
1
|
+
import type { DurableObjectNamespace, Workflow } from "@cloudflare/workers-types";
|
|
2
2
|
import { type Scope } from "revojs";
|
|
3
3
|
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
4
|
export type DurableObjects = {
|
|
5
5
|
[ClassName in keyof typeof import("#durable-objects") as ScreamingSnake<ClassName>]: DurableObjectNamespace<InstanceType<(typeof import("#durable-objects"))[ClassName]>>;
|
|
6
6
|
};
|
|
7
|
+
export type Workflows = {
|
|
8
|
+
[ClassName in keyof typeof import("#workflows") as ScreamingSnake<ClassName>]: Workflow;
|
|
9
|
+
};
|
|
7
10
|
export declare function useDurableObjects(scope: Scope): DurableObjects;
|
|
11
|
+
export declare function useWorkflows(scope: Scope): Workflows;
|
package/dist/index.js
CHANGED
|
@@ -3,5 +3,8 @@ import { useVariables } from "revojs";
|
|
|
3
3
|
function useDurableObjects(scope) {
|
|
4
4
|
return useVariables(scope);
|
|
5
5
|
}
|
|
6
|
+
function useWorkflows(scope) {
|
|
7
|
+
return useVariables(scope);
|
|
8
|
+
}
|
|
6
9
|
//#endregion
|
|
7
|
-
export { useDurableObjects };
|
|
10
|
+
export { useDurableObjects, useWorkflows };
|
package/dist/module/index.js
CHANGED
|
@@ -24,15 +24,32 @@ var module_default = defineModule({
|
|
|
24
24
|
from: ["./durable-objects"],
|
|
25
25
|
format: "named"
|
|
26
26
|
};
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const workflows = {
|
|
28
|
+
match: [
|
|
29
|
+
"**/*.js",
|
|
30
|
+
"**/*.ts",
|
|
31
|
+
"!*.d.ts"
|
|
32
|
+
],
|
|
33
|
+
from: ["./workflows"],
|
|
34
|
+
format: "named"
|
|
35
|
+
};
|
|
36
|
+
const durableObjectKeys = new Array();
|
|
37
|
+
for (const files of resolveSource(durableObjects).values()) for (const key of files.keys()) durableObjectKeys.push(key);
|
|
38
|
+
const workflowKeys = new Array();
|
|
39
|
+
for (const files of resolveSource(workflows).values()) for (const key of files.keys()) workflowKeys.push(key);
|
|
40
|
+
const durableObjectNames = toExportNames(durableObjectKeys);
|
|
41
|
+
const workflowNames = toExportNames(workflowKeys);
|
|
42
|
+
const durableObjectBindings = durableObjectNames.map((className) => ({
|
|
31
43
|
name: className.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase(),
|
|
32
44
|
class_name: className
|
|
33
45
|
}));
|
|
46
|
+
const workflowBindings = workflowNames.map((className) => ({
|
|
47
|
+
binding: className.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase(),
|
|
48
|
+
name: className.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(),
|
|
49
|
+
class_name: className
|
|
50
|
+
}));
|
|
34
51
|
const exportsMap = {};
|
|
35
|
-
for (const className of
|
|
52
|
+
for (const className of durableObjectNames) exportsMap[className] = {
|
|
36
53
|
type: "durable-object",
|
|
37
54
|
storage: "sqlite"
|
|
38
55
|
};
|
|
@@ -42,13 +59,26 @@ var module_default = defineModule({
|
|
|
42
59
|
config: {
|
|
43
60
|
main: fromModule("../server/index.js"),
|
|
44
61
|
assets: { run_worker_first: ["/"] },
|
|
45
|
-
durable_objects: { bindings },
|
|
62
|
+
durable_objects: { bindings: durableObjectBindings },
|
|
63
|
+
workflows: workflowBindings,
|
|
46
64
|
exports: exportsMap,
|
|
47
65
|
triggers: { crons: [...crons] }
|
|
48
66
|
}
|
|
49
67
|
});
|
|
50
68
|
return {
|
|
51
|
-
sources: {
|
|
69
|
+
sources: {
|
|
70
|
+
"durable-objects": durableObjects,
|
|
71
|
+
entrypoints: {
|
|
72
|
+
match: [
|
|
73
|
+
"**/*.js",
|
|
74
|
+
"**/*.ts",
|
|
75
|
+
"!*.d.ts"
|
|
76
|
+
],
|
|
77
|
+
from: ["./entrypoints"],
|
|
78
|
+
format: "named"
|
|
79
|
+
},
|
|
80
|
+
workflows
|
|
81
|
+
},
|
|
52
82
|
vite: {
|
|
53
83
|
server: { watch: { ignored: ["**/.wrangler/**"] } },
|
|
54
84
|
plugins: [cloudflare(options)]
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ScheduledEvent } from "@cloudflare/workers-types";
|
|
2
2
|
export * from "#durable-objects";
|
|
3
|
+
export * from "#entrypoints";
|
|
4
|
+
export * from "#workflows";
|
|
3
5
|
declare const _default: {
|
|
4
6
|
fetch(request: Request, variables: Cloudflare.Env): Promise<Response | undefined>;
|
|
5
7
|
scheduled(event: ScheduledEvent, variables: Cloudflare.Env): Promise<void>;
|
package/dist/server/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import { VARIABLE_CONTEXT, createScope } from "revojs";
|
|
|
2
2
|
import "@cloudflare/workers-types";
|
|
3
3
|
import { SCHEDULE_CONTEXT, SERVER_CONTEXT, isResponse, isWebSocket, sendResponse } from "@revojs/server";
|
|
4
4
|
export * from "#durable-objects";
|
|
5
|
+
export * from "#entrypoints";
|
|
6
|
+
export * from "#workflows";
|
|
5
7
|
//#region src/server/index.ts
|
|
6
8
|
var server_default = {
|
|
7
9
|
async fetch(request, variables) {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,3 +4,17 @@ declare module "#durable-objects" {
|
|
|
4
4
|
const durableObject: typeof DurableObject;
|
|
5
5
|
export { durableObject };
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
declare module "#workflows" {
|
|
9
|
+
import type { WorkflowEntrypoint } from "cloudflare:workers";
|
|
10
|
+
|
|
11
|
+
const workflow: typeof WorkflowEntrypoint;
|
|
12
|
+
export { workflow };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module "#entrypoints" {
|
|
16
|
+
import type { WorkerEntrypoint } from "cloudflare:workers";
|
|
17
|
+
|
|
18
|
+
const entrypoint: typeof WorkerEntrypoint;
|
|
19
|
+
export { entrypoint };
|
|
20
|
+
}
|