@dxos/functions-runtime-cloudflare 0.8.4-main.1068cf700f → 0.8.4-main.2244d791bb

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/functions-runtime-cloudflare",
3
- "version": "0.8.4-main.1068cf700f",
3
+ "version": "0.8.4-main.2244d791bb",
4
4
  "description": "Functions runtime for Cloudflare.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -28,22 +28,22 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "effect": "3.19.16",
31
- "@dxos/context": "0.8.4-main.1068cf700f",
32
- "@dxos/debug": "0.8.4-main.1068cf700f",
33
- "@dxos/echo-db": "0.8.4-main.1068cf700f",
34
- "@dxos/echo": "0.8.4-main.1068cf700f",
35
- "@dxos/codec-protobuf": "0.8.4-main.1068cf700f",
36
- "@dxos/errors": "0.8.4-main.1068cf700f",
37
- "@dxos/echo-protocol": "0.8.4-main.1068cf700f",
38
- "@dxos/invariant": "0.8.4-main.1068cf700f",
39
- "@dxos/keys": "0.8.4-main.1068cf700f",
40
- "@dxos/protocols": "0.8.4-main.1068cf700f",
41
- "@dxos/log": "0.8.4-main.1068cf700f",
42
- "@dxos/util": "0.8.4-main.1068cf700f"
31
+ "@dxos/codec-protobuf": "0.8.4-main.2244d791bb",
32
+ "@dxos/context": "0.8.4-main.2244d791bb",
33
+ "@dxos/debug": "0.8.4-main.2244d791bb",
34
+ "@dxos/echo": "0.8.4-main.2244d791bb",
35
+ "@dxos/echo-db": "0.8.4-main.2244d791bb",
36
+ "@dxos/errors": "0.8.4-main.2244d791bb",
37
+ "@dxos/invariant": "0.8.4-main.2244d791bb",
38
+ "@dxos/keys": "0.8.4-main.2244d791bb",
39
+ "@dxos/log": "0.8.4-main.2244d791bb",
40
+ "@dxos/echo-protocol": "0.8.4-main.2244d791bb",
41
+ "@dxos/protocols": "0.8.4-main.2244d791bb",
42
+ "@dxos/util": "0.8.4-main.2244d791bb"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@cloudflare/workers-types": "^4.20251210.0",
46
- "@dxos/types": "0.8.4-main.1068cf700f"
46
+ "@dxos/types": "0.8.4-main.2244d791bb"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
@@ -2,8 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { NotImplementedError, RuntimeServiceError } from '@dxos/errors';
6
- import { invariant } from '@dxos/invariant';
5
+ import { RuntimeServiceError } from '@dxos/errors';
7
6
  import { type EdgeFunctionEnv, type FeedProtocol } from '@dxos/protocols';
8
7
 
9
8
  export class QueueServiceImpl implements FeedProtocol.QueueService {
@@ -11,39 +10,35 @@ export class QueueServiceImpl implements FeedProtocol.QueueService {
11
10
  protected _ctx: EdgeFunctionEnv.ExecutionContext,
12
11
  private readonly _queueService: EdgeFunctionEnv.QueueService,
13
12
  ) {}
13
+
14
14
  async queryQueue(request: FeedProtocol.QueryQueueRequest): Promise<FeedProtocol.QueryResult> {
15
- const { query } = request;
16
- const { queueIds, ...filter } = query!;
17
- const spaceId = query!.spaceId;
18
- const queueId = queueIds?.[0];
19
- invariant(request.query.queuesNamespace);
20
15
  try {
21
- using result = await this._queueService.query(
22
- this._ctx,
23
- `dxn:queue:${request.query.queuesNamespace}:${spaceId}:${queueId}`,
24
- filter,
25
- );
16
+ using result = await this._queueService.queryQueue(this._ctx, request);
17
+ // Copy to avoid hanging RPC stub (Workers RPC lifecycle).
26
18
  return {
27
- // Copy returned object to avoid hanging RPC stub
28
- // See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
29
19
  objects: structuredClone(result.objects),
30
20
  nextCursor: result.nextCursor,
31
21
  prevCursor: result.prevCursor,
32
22
  };
33
23
  } catch (error) {
24
+ const { query } = request;
34
25
  throw RuntimeServiceError.wrap({
35
26
  message: 'Queue query failed.',
36
- context: { subspaceTag: request.query.queuesNamespace, spaceId, queueId },
27
+ context: {
28
+ subspaceTag: query?.queuesNamespace,
29
+ spaceId: query?.spaceId,
30
+ queueId: query?.queueIds?.[0],
31
+ },
37
32
  ifTypeDiffers: true,
38
33
  })(error);
39
34
  }
40
35
  }
41
36
 
42
37
  async insertIntoQueue(request: FeedProtocol.InsertIntoQueueRequest): Promise<void> {
43
- const { subspaceTag, spaceId, queueId, objects } = request;
44
38
  try {
45
- await this._queueService.append(this._ctx, `dxn:queue:${subspaceTag}:${spaceId}:${queueId}`, objects ?? []);
39
+ using _ = await this._queueService.insertIntoQueue(this._ctx, request);
46
40
  } catch (error) {
41
+ const { subspaceTag, spaceId, queueId } = request;
47
42
  throw RuntimeServiceError.wrap({
48
43
  message: 'Queue append failed.',
49
44
  context: { subspaceTag, spaceId, queueId },
@@ -52,11 +47,20 @@ export class QueueServiceImpl implements FeedProtocol.QueueService {
52
47
  }
53
48
  }
54
49
 
55
- deleteFromQueue(request: FeedProtocol.DeleteFromQueueRequest): Promise<void> {
56
- const { subspaceTag, spaceId, queueId } = request;
57
- throw new NotImplementedError({
58
- message: 'Deleting from queue is not supported.',
59
- context: { subspaceTag, spaceId, queueId },
60
- });
50
+ async deleteFromQueue(request: FeedProtocol.DeleteFromQueueRequest): Promise<void> {
51
+ try {
52
+ using _ = await this._queueService.deleteFromQueue(this._ctx, request);
53
+ } catch (error) {
54
+ const { subspaceTag, spaceId, queueId } = request;
55
+ throw RuntimeServiceError.wrap({
56
+ message: 'Queue delete failed.',
57
+ context: { subspaceTag, spaceId, queueId },
58
+ ifTypeDiffers: true,
59
+ })(error);
60
+ }
61
+ }
62
+
63
+ async syncQueue(_: FeedProtocol.SyncQueueRequest): Promise<void> {
64
+ // No-op in Cloudflare runtime.
61
65
  }
62
66
  }
@@ -54,10 +54,18 @@ export class ServiceContainer {
54
54
  }
55
55
 
56
56
  async queryQueue(queue: DXN): Promise<FeedProtocol.QueryResult> {
57
- const { spaceId } = queue.asQueueDXN() ?? {};
58
- using result = (await this._queueService.query({}, queue.toString(), { spaceId: spaceId! })) as any;
59
- // Copy returned object to avoid hanging RPC stub
60
- // See https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/
57
+ const parts = queue.asQueueDXN();
58
+ if (!parts) {
59
+ throw new Error('Invalid queue DXN');
60
+ }
61
+ const { subspaceTag, spaceId, queueId } = parts;
62
+ const result = await this._queueService.queryQueue(this._executionContext, {
63
+ query: {
64
+ spaceId,
65
+ queuesNamespace: subspaceTag,
66
+ queueIds: [queueId],
67
+ },
68
+ });
61
69
  return {
62
70
  objects: structuredClone(result.objects),
63
71
  nextCursor: result.nextCursor ?? null,
@@ -66,6 +74,16 @@ export class ServiceContainer {
66
74
  }
67
75
 
68
76
  async insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {
69
- await this._queueService.append({}, queue.toString(), objects);
77
+ const parts = queue.asQueueDXN();
78
+ if (!parts) {
79
+ throw new Error('Invalid queue DXN');
80
+ }
81
+ const { subspaceTag, spaceId, queueId } = parts;
82
+ await this._queueService.insertIntoQueue(this._executionContext, {
83
+ subspaceTag,
84
+ spaceId,
85
+ queueId,
86
+ objects: objects as FeedProtocol.InsertIntoQueueRequest['objects'],
87
+ });
70
88
  }
71
89
  }