@dxos/functions-runtime-cloudflare 0.8.4-main.e00bdcdb52 → 0.8.4-main.effb148878

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.e00bdcdb52",
3
+ "version": "0.8.4-main.effb148878",
4
4
  "description": "Functions runtime for Cloudflare.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -8,7 +8,7 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/dxos/dxos"
10
10
  },
11
- "license": "MIT",
11
+ "license": "FSL-1.1-Apache-2.0",
12
12
  "author": "info@dxos.org",
13
13
  "sideEffects": false,
14
14
  "type": "module",
@@ -28,22 +28,22 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "effect": "3.20.0",
31
- "@dxos/codec-protobuf": "0.8.4-main.e00bdcdb52",
32
- "@dxos/context": "0.8.4-main.e00bdcdb52",
33
- "@dxos/echo": "0.8.4-main.e00bdcdb52",
34
- "@dxos/errors": "0.8.4-main.e00bdcdb52",
35
- "@dxos/echo-db": "0.8.4-main.e00bdcdb52",
36
- "@dxos/debug": "0.8.4-main.e00bdcdb52",
37
- "@dxos/echo-protocol": "0.8.4-main.e00bdcdb52",
38
- "@dxos/invariant": "0.8.4-main.e00bdcdb52",
39
- "@dxos/log": "0.8.4-main.e00bdcdb52",
40
- "@dxos/keys": "0.8.4-main.e00bdcdb52",
41
- "@dxos/protocols": "0.8.4-main.e00bdcdb52",
42
- "@dxos/util": "0.8.4-main.e00bdcdb52"
31
+ "@dxos/context": "0.8.4-main.effb148878",
32
+ "@dxos/echo": "0.8.4-main.effb148878",
33
+ "@dxos/debug": "0.8.4-main.effb148878",
34
+ "@dxos/codec-protobuf": "0.8.4-main.effb148878",
35
+ "@dxos/echo-db": "0.8.4-main.effb148878",
36
+ "@dxos/errors": "0.8.4-main.effb148878",
37
+ "@dxos/invariant": "0.8.4-main.effb148878",
38
+ "@dxos/keys": "0.8.4-main.effb148878",
39
+ "@dxos/echo-protocol": "0.8.4-main.effb148878",
40
+ "@dxos/log": "0.8.4-main.effb148878",
41
+ "@dxos/protocols": "0.8.4-main.effb148878",
42
+ "@dxos/util": "0.8.4-main.effb148878"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@cloudflare/workers-types": "^4.20260302.0",
46
- "@dxos/types": "0.8.4-main.e00bdcdb52"
46
+ "@dxos/types": "0.8.4-main.effb148878"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
@@ -80,9 +80,3 @@ export const createClientFromEnv = async (env: any): Promise<FunctionsClient> =>
80
80
  await client.open();
81
81
  return client;
82
82
  };
83
-
84
- /**
85
- - Provides data access capabilities for user functions.
86
- - No real-time replication or reactive queries -- function receives a snapshot.
87
- - Function event contains the metadata but doesn't need to include the data.
88
- */
@@ -97,6 +97,11 @@ export class DataServiceImpl implements DataServiceProto {
97
97
  // TODO(dmaretskyi): Batch.
98
98
  try {
99
99
  for (const update of updates ?? []) {
100
+ // Mutation-less updates (e.g. `requesting: true` transition signals from the worker) carry no
101
+ // bytes to apply; this runtime only forwards real document writes.
102
+ if (!update.mutation) {
103
+ continue;
104
+ }
100
105
  await this._dataService.changeDocument(this._executionContext, sub.spaceId, update.documentId, update.mutation);
101
106
  }
102
107
  } catch (error) {
@@ -131,7 +136,7 @@ export class DataServiceImpl implements DataServiceProto {
131
136
  }
132
137
 
133
138
  async updateIndexes(): Promise<void> {
134
- log.error('updateIndexes is not available in EDGE env.');
139
+ log.verbose('updateIndexes called, but it is a no-op in EDGE env.');
135
140
  // No-op.
136
141
  }
137
142
 
@@ -63,4 +63,8 @@ export class QueueServiceImpl implements FeedProtocol.QueueService {
63
63
  async syncQueue(_: FeedProtocol.SyncQueueRequest): Promise<void> {
64
64
  // No-op in Cloudflare runtime.
65
65
  }
66
+
67
+ async getSyncState(_: FeedProtocol.GetSyncStateRequest): Promise<FeedProtocol.GetSyncStateResponse> {
68
+ return { namespaces: [] };
69
+ }
66
70
  }
@@ -3,10 +3,10 @@
3
3
  //
4
4
 
5
5
  import { type AnyEntity } from '@dxos/echo/internal';
6
- import { type DXN, type SpaceId } from '@dxos/keys';
6
+ import { EchoURI, type SpaceId } from '@dxos/keys';
7
7
  import { type EdgeFunctionEnv, type FeedProtocol } from '@dxos/protocols';
8
8
  import { type QueryService as QueryServiceProto } from '@dxos/protocols/proto/dxos/echo/query';
9
- import type { DataService as DataServiceProto } from '@dxos/protocols/proto/dxos/echo/service';
9
+ import { type DataService as DataServiceProto } from '@dxos/protocols/proto/dxos/echo/service';
10
10
 
11
11
  import { DataServiceImpl } from './data-service-impl';
12
12
  import { QueryServiceImpl } from './query-service-impl';
@@ -53,19 +53,19 @@ export class ServiceContainer {
53
53
  };
54
54
  }
55
55
 
56
- async queryQueue(queue: DXN): Promise<FeedProtocol.QueryResult> {
57
- const parts = queue.asQueueDXN();
58
- if (!parts) {
59
- throw new Error('Invalid queue DXN');
56
+ async queryQueue(queue: EchoURI.EchoURI): Promise<FeedProtocol.QueryResult> {
57
+ const spaceId = EchoURI.getSpaceId(queue);
58
+ const queueId = EchoURI.getObjectId(queue);
59
+ if (!spaceId || !queueId) {
60
+ throw new Error('Invalid queue EchoURI');
60
61
  }
61
- const { subspaceTag, spaceId, queueId } = parts;
62
62
  const result = await this._queueService.queryQueue(this._executionContext, {
63
63
  query: {
64
64
  spaceId,
65
- queuesNamespace: subspaceTag,
66
65
  queueIds: [queueId],
67
66
  },
68
67
  });
68
+
69
69
  return {
70
70
  objects: structuredClone(result.objects),
71
71
  nextCursor: result.nextCursor ?? null,
@@ -73,14 +73,15 @@ export class ServiceContainer {
73
73
  };
74
74
  }
75
75
 
76
- async insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {
77
- const parts = queue.asQueueDXN();
78
- if (!parts) {
79
- throw new Error('Invalid queue DXN');
76
+ async insertIntoQueue(queue: EchoURI.EchoURI, objects: AnyEntity[]): Promise<void> {
77
+ const spaceId = EchoURI.getSpaceId(queue);
78
+ const queueId = EchoURI.getObjectId(queue);
79
+ if (!spaceId || !queueId) {
80
+ throw new Error('Invalid queue EchoURI');
80
81
  }
81
- const { subspaceTag, spaceId, queueId } = parts;
82
+ // TODO(dmaretskyi): EchoURI does not encode the subspaceTag defaulting to 'data'.
82
83
  await this._queueService.insertIntoQueue(this._executionContext, {
83
- subspaceTag,
84
+ subspaceTag: 'data',
84
85
  spaceId,
85
86
  queueId,
86
87
  objects: objects.map((obj) => JSON.stringify(obj)),
package/src/queues-api.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  //
4
4
 
5
5
  import { type AnyEntity } from '@dxos/echo/internal';
6
- import type { DXN, SpaceId } from '@dxos/keys';
7
- import { log } from '@dxos/log';
6
+ import { type EchoURI, type SpaceId } from '@dxos/keys';
7
+ import { type FeedProtocol } from '@dxos/protocols';
8
8
 
9
9
  import type { ServiceContainer } from './internal';
10
10
 
@@ -20,8 +20,8 @@ export interface QueuesQueryResult {
20
20
  * @deprecated
21
21
  */
22
22
  export interface QueuesAPI {
23
- queryQueue(queue: DXN, options?: {}): Promise<QueuesQueryResult>;
24
- insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void>;
23
+ queryQueue(queue: EchoURI.EchoURI, options?: {}): Promise<FeedProtocol.QueryResult>;
24
+ insertIntoQueue(queue: EchoURI.EchoURI, objects: AnyEntity[]): Promise<void>;
25
25
  }
26
26
 
27
27
  /**
@@ -33,24 +33,11 @@ export class QueuesAPIImpl implements QueuesAPI {
33
33
  private readonly _spaceId: SpaceId,
34
34
  ) {}
35
35
 
36
- async queryQueue(queue: DXN, options?: {}): Promise<QueuesQueryResult> {
37
- const result = await this._serviceContainer.queryQueue(queue);
38
- const objects = (result.objects ?? []).flatMap((encoded): AnyEntity[] => {
39
- try {
40
- return [JSON.parse(encoded) as AnyEntity];
41
- } catch (err) {
42
- log.verbose('queue object JSON parse failed; object ignored', { encoded, error: err });
43
- return [];
44
- }
45
- });
46
- return {
47
- objects,
48
- nextCursor: result.nextCursor ?? null,
49
- prevCursor: result.prevCursor ?? null,
50
- };
36
+ queryQueue(queue: EchoURI.EchoURI, options?: {}): Promise<FeedProtocol.QueryResult> {
37
+ return this._serviceContainer.queryQueue(queue);
51
38
  }
52
39
 
53
- insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {
40
+ insertIntoQueue(queue: EchoURI.EchoURI, objects: AnyEntity[]): Promise<void> {
54
41
  // TODO(dmaretskyi): Ugly.
55
42
  return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
56
43
  }