@dxos/functions-runtime-cloudflare 0.8.4-main.d05539e30a → 0.8.4-main.d9fc60f731

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.d05539e30a",
3
+ "version": "0.8.4-main.d9fc60f731",
4
4
  "description": "Functions runtime for Cloudflare.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -27,23 +27,23 @@
27
27
  "src"
28
28
  ],
29
29
  "dependencies": {
30
- "effect": "3.20.0",
31
- "@dxos/codec-protobuf": "0.8.4-main.d05539e30a",
32
- "@dxos/echo": "0.8.4-main.d05539e30a",
33
- "@dxos/debug": "0.8.4-main.d05539e30a",
34
- "@dxos/context": "0.8.4-main.d05539e30a",
35
- "@dxos/echo-protocol": "0.8.4-main.d05539e30a",
36
- "@dxos/errors": "0.8.4-main.d05539e30a",
37
- "@dxos/invariant": "0.8.4-main.d05539e30a",
38
- "@dxos/log": "0.8.4-main.d05539e30a",
39
- "@dxos/echo-db": "0.8.4-main.d05539e30a",
40
- "@dxos/protocols": "0.8.4-main.d05539e30a",
41
- "@dxos/util": "0.8.4-main.d05539e30a",
42
- "@dxos/keys": "0.8.4-main.d05539e30a"
30
+ "effect": "3.21.2",
31
+ "@dxos/codec-protobuf": "0.8.4-main.d9fc60f731",
32
+ "@dxos/context": "0.8.4-main.d9fc60f731",
33
+ "@dxos/debug": "0.8.4-main.d9fc60f731",
34
+ "@dxos/echo": "0.8.4-main.d9fc60f731",
35
+ "@dxos/echo-db": "0.8.4-main.d9fc60f731",
36
+ "@dxos/echo-protocol": "0.8.4-main.d9fc60f731",
37
+ "@dxos/errors": "0.8.4-main.d9fc60f731",
38
+ "@dxos/invariant": "0.8.4-main.d9fc60f731",
39
+ "@dxos/keys": "0.8.4-main.d9fc60f731",
40
+ "@dxos/log": "0.8.4-main.d9fc60f731",
41
+ "@dxos/protocols": "0.8.4-main.d9fc60f731",
42
+ "@dxos/util": "0.8.4-main.d9fc60f731"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@cloudflare/workers-types": "^4.20260302.0",
46
- "@dxos/types": "0.8.4-main.d05539e30a"
46
+ "@dxos/types": "0.8.4-main.d9fc60f731"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
@@ -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,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { type AnyEntity } from '@dxos/echo/internal';
6
- import { type DXN, type SpaceId } from '@dxos/keys';
6
+ import { EID, 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
9
  import { type DataService as DataServiceProto } from '@dxos/protocols/proto/dxos/echo/service';
@@ -53,17 +53,15 @@ 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: EID.EID): Promise<FeedProtocol.QueryResult> {
57
+ const spaceId = EID.getSpaceId(queue);
58
+ const queueId = EID.getEntityId(queue);
59
+ if (!spaceId || !queueId) {
60
+ throw new Error('Invalid queue EID');
60
61
  }
61
-
62
- const { subspaceTag, spaceId, queueId } = parts;
63
62
  const result = await this._queueService.queryQueue(this._executionContext, {
64
63
  query: {
65
64
  spaceId,
66
- queuesNamespace: subspaceTag,
67
65
  queueIds: [queueId],
68
66
  },
69
67
  });
@@ -75,15 +73,15 @@ export class ServiceContainer {
75
73
  };
76
74
  }
77
75
 
78
- async insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {
79
- const parts = queue.asQueueDXN();
80
- if (!parts) {
81
- throw new Error('Invalid queue DXN');
76
+ async insertIntoQueue(queue: EID.EID, objects: AnyEntity[]): Promise<void> {
77
+ const spaceId = EID.getSpaceId(queue);
78
+ const queueId = EID.getEntityId(queue);
79
+ if (!spaceId || !queueId) {
80
+ throw new Error('Invalid queue EID');
82
81
  }
83
-
84
- const { subspaceTag, spaceId, queueId } = parts;
82
+ // TODO(dmaretskyi): EID does not encode the subspaceTag — defaulting to 'data'.
85
83
  await this._queueService.insertIntoQueue(this._executionContext, {
86
- subspaceTag,
84
+ subspaceTag: 'data',
87
85
  spaceId,
88
86
  queueId,
89
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 EID, 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: EID.EID, options?: {}): Promise<FeedProtocol.QueryResult>;
24
+ insertIntoQueue(queue: EID.EID, 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: EID.EID, 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: EID.EID, objects: AnyEntity[]): Promise<void> {
54
41
  // TODO(dmaretskyi): Ugly.
55
42
  return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
56
43
  }