@concavejs/runtime-cf 0.0.1-alpha.4 → 0.0.1-alpha.5

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.
@@ -0,0 +1,29 @@
1
+ import type { DocStore } from "@concavejs/core/docstore";
2
+ import type { BlobStore } from "@concavejs/core/abstractions";
3
+ import type { UdfExec } from "@concavejs/core/udf";
4
+ import { ConcaveDOBase, type ConcaveDOAdapterContext } from "@concavejs/runtime-cf-base";
5
+ export interface ConcaveDOFactoryContext<Env = any> extends ConcaveDOAdapterContext<Env> {
6
+ }
7
+ export interface ConcaveDOExecutorFactoryContext<Env = any> extends ConcaveDOFactoryContext<Env> {
8
+ docstore: DocStore;
9
+ blobstore?: BlobStore;
10
+ }
11
+ export interface ConcaveDOFactoryOptions<Env = any> {
12
+ /**
13
+ * Build a DocStore from Durable Object context.
14
+ */
15
+ docstore: (context: ConcaveDOFactoryContext<Env>) => DocStore;
16
+ /**
17
+ * Build a BlobStore from Durable Object context.
18
+ */
19
+ blobstore?: (context: ConcaveDOFactoryContext<Env>) => BlobStore | undefined;
20
+ /**
21
+ * Build a UDF executor from resolved runtime services.
22
+ */
23
+ udfExecutor: (context: ConcaveDOExecutorFactoryContext<Env>) => UdfExec;
24
+ }
25
+ export type ConcaveDOClass<Env = any> = new (state: DurableObjectState, env: Env) => ConcaveDOBase;
26
+ /**
27
+ * Create a Concave Durable Object class with env-aware adapter factories.
28
+ */
29
+ export declare function createConcaveDO<Env = any>(options: ConcaveDOFactoryOptions<Env>): ConcaveDOClass<Env>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Cloudflare Durable Object adapter for the platform-agnostic sync protocol
3
+ *
4
+ * This is a thin wrapper that:
5
+ * 1. Extends DurableObject
6
+ * 2. Handles WebSocket lifecycle events
7
+ * 3. Delegates to SyncProtocolHandler for all business logic
8
+ * 4. Provides UDF execution via ConcaveDO
9
+ */
10
+ import { DurableObject } from "cloudflare:workers";
11
+ /**
12
+ * Cloudflare Durable Object implementation of sync node
13
+ *
14
+ * This is a thin wrapper around SyncProtocolHandler that:
15
+ * - Handles WebSocket lifecycle
16
+ * - Manages session IDs
17
+ * - Provides UDF execution via ConcaveDO
18
+ */
19
+ export declare class SyncDO extends DurableObject {
20
+ private readonly state;
21
+ readonly env: Env;
22
+ private protocolHandler;
23
+ private wsToSessionId;
24
+ private readonly instanceName;
25
+ constructor(state: DurableObjectState, env: Env);
26
+ private initializeProtocolHandler;
27
+ fetch(request: Request): Promise<Response>;
28
+ webSocketMessage(ws: WebSocket, message: string | ArrayBuffer): Promise<void>;
29
+ webSocketClose(ws: WebSocket, _code: number, _reason: string, _wasClean: boolean): Promise<void>;
30
+ webSocketError(ws: WebSocket, error: any): Promise<void>;
31
+ private sendMessage;
32
+ }
33
+ interface Env {
34
+ CONCAVE_DO: DurableObjectNamespace;
35
+ }
36
+ interface DurableObjectNamespace {
37
+ idFromName(name: string): DurableObjectId;
38
+ get(id: DurableObjectId): DurableObjectStub;
39
+ }
40
+ interface DurableObjectId {
41
+ toString(): string;
42
+ }
43
+ interface DurableObjectStub {
44
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
45
+ }
46
+ export {};
@@ -0,0 +1,26 @@
1
+ import { type ConcaveWorkerOptions } from "@concavejs/runtime-cf-base";
2
+ import { type ConcaveDOFactoryOptions } from "./durable-objects/create-concave-do";
3
+ import { SyncDO } from "./durable-objects/sync-do";
4
+ export interface ConcaveCfRuntimeOptions<Env = any> {
5
+ /**
6
+ * HTTP/Sync worker routing configuration.
7
+ */
8
+ worker: ConcaveWorkerOptions;
9
+ /**
10
+ * Durable Object runtime services configuration.
11
+ */
12
+ durableObject: ConcaveDOFactoryOptions<Env>;
13
+ }
14
+ /**
15
+ * Configure Cloudflare Concave runtime once and export the resulting bindings.
16
+ *
17
+ * This keeps docstore/blobstore/UDF wiring in one place and flows it down
18
+ * into the durable object execution boundary.
19
+ */
20
+ export declare function defineConcaveRuntime<Env = any>(options: ConcaveCfRuntimeOptions<Env>): {
21
+ worker: {
22
+ fetch(request: Request, env: any, ctx: import("@cloudflare/workers-types").ExecutionContext): Promise<Response>;
23
+ };
24
+ ConcaveDO: import("./durable-objects/create-concave-do").ConcaveDOClass<Env>;
25
+ SyncDO: typeof SyncDO;
26
+ };
@@ -0,0 +1,2 @@
1
+ export * from "@concavejs/runtime-cf-base";
2
+ export { defineConcaveRuntime, type ConcaveCfRuntimeOptions } from "./factory";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Internal exports re-exported from core
3
+ */
4
+ export * from "@concavejs/core/system/internal";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@concavejs/runtime-cf",
3
- "version": "0.0.1-alpha.4",
3
+ "version": "0.0.1-alpha.5",
4
4
  "license": "FSL-1.1-Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,12 +24,12 @@
24
24
  "test": "bun test --run --passWithNoTests || true"
25
25
  },
26
26
  "dependencies": {
27
- "@concavejs/core": "0.0.1-alpha.4",
28
- "@concavejs/runtime-base": "0.0.1-alpha.4",
29
- "@concavejs/runtime-cf-base": "0.0.1-alpha.4",
30
- "@concavejs/docstore-cf-do": "0.0.1-alpha.4",
31
- "@concavejs/docstore-cf-d1": "0.0.1-alpha.4",
32
- "@concavejs/blobstore-cf-r2": "0.0.1-alpha.4",
27
+ "@concavejs/core": "0.0.1-alpha.5",
28
+ "@concavejs/runtime-base": "0.0.1-alpha.5",
29
+ "@concavejs/runtime-cf-base": "0.0.1-alpha.5",
30
+ "@concavejs/docstore-cf-do": "0.0.1-alpha.5",
31
+ "@concavejs/docstore-cf-d1": "0.0.1-alpha.5",
32
+ "@concavejs/blobstore-cf-r2": "0.0.1-alpha.5",
33
33
  "convex": "^1.27.3"
34
34
  },
35
35
  "devDependencies": {