@dxos/functions-runtime-cloudflare 0.8.4-main.9be5663bfe → 0.8.4-main.bc2380dfbc
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/index.mjs +66 -144
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +66 -144
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/functions-client.d.ts +0 -5
- package/dist/types/src/functions-client.d.ts.map +1 -1
- package/dist/types/src/internal/data-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/query-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/queue-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/service-container.d.ts +1 -1
- package/dist/types/src/internal/service-container.d.ts.map +1 -1
- package/dist/types/src/internal/utils.d.ts.map +1 -1
- package/dist/types/src/queues-api.d.ts +7 -3
- package/dist/types/src/queues-api.d.ts.map +1 -1
- package/dist/types/src/space-proxy.d.ts.map +1 -1
- package/dist/types/src/wrap-handler-for-cloudflare.d.ts +6 -0
- package/dist/types/src/wrap-handler-for-cloudflare.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
- package/src/functions-client.ts +0 -6
- package/src/internal/data-service-impl.ts +6 -1
- package/src/internal/service-container.ts +5 -2
- package/src/logger.ts +10 -8
- package/src/queues-api.ts +23 -4
- package/src/wrap-handler-for-cloudflare.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/functions-runtime-cloudflare",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.bc2380dfbc",
|
|
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": "
|
|
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/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/debug": "0.8.4-main.
|
|
34
|
-
"@dxos/echo": "0.8.4-main.
|
|
35
|
-
"@dxos/echo
|
|
36
|
-
"@dxos/errors": "0.8.4-main.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/protocols": "0.8.4-main.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
31
|
+
"@dxos/codec-protobuf": "0.8.4-main.bc2380dfbc",
|
|
32
|
+
"@dxos/context": "0.8.4-main.bc2380dfbc",
|
|
33
|
+
"@dxos/debug": "0.8.4-main.bc2380dfbc",
|
|
34
|
+
"@dxos/echo-db": "0.8.4-main.bc2380dfbc",
|
|
35
|
+
"@dxos/echo": "0.8.4-main.bc2380dfbc",
|
|
36
|
+
"@dxos/errors": "0.8.4-main.bc2380dfbc",
|
|
37
|
+
"@dxos/invariant": "0.8.4-main.bc2380dfbc",
|
|
38
|
+
"@dxos/log": "0.8.4-main.bc2380dfbc",
|
|
39
|
+
"@dxos/echo-protocol": "0.8.4-main.bc2380dfbc",
|
|
40
|
+
"@dxos/protocols": "0.8.4-main.bc2380dfbc",
|
|
41
|
+
"@dxos/keys": "0.8.4-main.bc2380dfbc",
|
|
42
|
+
"@dxos/util": "0.8.4-main.bc2380dfbc"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@cloudflare/workers-types": "^4.20260302.0",
|
|
46
|
-
"@dxos/types": "0.8.4-main.
|
|
46
|
+
"@dxos/types": "0.8.4-main.bc2380dfbc"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
package/src/functions-client.ts
CHANGED
|
@@ -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.
|
|
139
|
+
log.verbose('updateIndexes called, but it is a no-op in EDGE env.');
|
|
135
140
|
// No-op.
|
|
136
141
|
}
|
|
137
142
|
|
|
@@ -6,7 +6,7 @@ import { type AnyEntity } from '@dxos/echo/internal';
|
|
|
6
6
|
import { type DXN, 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
|
|
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';
|
|
@@ -58,6 +58,7 @@ export class ServiceContainer {
|
|
|
58
58
|
if (!parts) {
|
|
59
59
|
throw new Error('Invalid queue DXN');
|
|
60
60
|
}
|
|
61
|
+
|
|
61
62
|
const { subspaceTag, spaceId, queueId } = parts;
|
|
62
63
|
const result = await this._queueService.queryQueue(this._executionContext, {
|
|
63
64
|
query: {
|
|
@@ -66,6 +67,7 @@ export class ServiceContainer {
|
|
|
66
67
|
queueIds: [queueId],
|
|
67
68
|
},
|
|
68
69
|
});
|
|
70
|
+
|
|
69
71
|
return {
|
|
70
72
|
objects: structuredClone(result.objects),
|
|
71
73
|
nextCursor: result.nextCursor ?? null,
|
|
@@ -78,12 +80,13 @@ export class ServiceContainer {
|
|
|
78
80
|
if (!parts) {
|
|
79
81
|
throw new Error('Invalid queue DXN');
|
|
80
82
|
}
|
|
83
|
+
|
|
81
84
|
const { subspaceTag, spaceId, queueId } = parts;
|
|
82
85
|
await this._queueService.insertIntoQueue(this._executionContext, {
|
|
83
86
|
subspaceTag,
|
|
84
87
|
spaceId,
|
|
85
88
|
queueId,
|
|
86
|
-
objects: objects
|
|
89
|
+
objects: objects.map((obj) => JSON.stringify(obj)),
|
|
87
90
|
});
|
|
88
91
|
}
|
|
89
92
|
}
|
package/src/logger.ts
CHANGED
|
@@ -16,27 +16,29 @@ const functionLogProcessor: LogProcessor = (config, entry) => {
|
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
const context = entry.computedContext;
|
|
20
|
+
const error = entry.computedError;
|
|
21
|
+
const extras = [Object.keys(context).length > 0 ? context : undefined, error].filter((value) => value !== undefined);
|
|
22
|
+
|
|
19
23
|
switch (entry.level) {
|
|
20
24
|
case LogLevel.DEBUG:
|
|
21
|
-
console.debug(entry.message, entry.context);
|
|
22
|
-
break;
|
|
23
25
|
case LogLevel.TRACE:
|
|
24
|
-
console.debug(entry.message,
|
|
26
|
+
console.debug(entry.message, ...extras);
|
|
25
27
|
break;
|
|
26
28
|
case LogLevel.VERBOSE:
|
|
27
|
-
console.log(entry.message,
|
|
29
|
+
console.log(entry.message, ...extras);
|
|
28
30
|
break;
|
|
29
31
|
case LogLevel.INFO:
|
|
30
|
-
console.info(entry.message,
|
|
32
|
+
console.info(entry.message, ...extras);
|
|
31
33
|
break;
|
|
32
34
|
case LogLevel.WARN:
|
|
33
|
-
console.warn(entry.message,
|
|
35
|
+
console.warn(entry.message, ...extras);
|
|
34
36
|
break;
|
|
35
37
|
case LogLevel.ERROR:
|
|
36
|
-
console.error(entry.message,
|
|
38
|
+
console.error(entry.message, ...extras);
|
|
37
39
|
break;
|
|
38
40
|
default:
|
|
39
|
-
console.log(entry.message,
|
|
41
|
+
console.log(entry.message, ...extras);
|
|
40
42
|
break;
|
|
41
43
|
}
|
|
42
44
|
};
|
package/src/queues-api.ts
CHANGED
|
@@ -4,17 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import { type AnyEntity } from '@dxos/echo/internal';
|
|
6
6
|
import type { DXN, SpaceId } from '@dxos/keys';
|
|
7
|
-
import {
|
|
7
|
+
import { log } from '@dxos/log';
|
|
8
8
|
|
|
9
9
|
import type { ServiceContainer } from './internal';
|
|
10
10
|
|
|
11
|
+
export interface QueuesQueryResult {
|
|
12
|
+
objects: AnyEntity[];
|
|
13
|
+
nextCursor: string | null;
|
|
14
|
+
prevCursor: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
// TODO(dmaretskyi): Temporary API to get the queues working.
|
|
12
18
|
// TODO(dmaretskyi): To be replaced with integrating queues into echo.
|
|
13
19
|
/**
|
|
14
20
|
* @deprecated
|
|
15
21
|
*/
|
|
16
22
|
export interface QueuesAPI {
|
|
17
|
-
queryQueue(queue: DXN, options?: {}): Promise<
|
|
23
|
+
queryQueue(queue: DXN, options?: {}): Promise<QueuesQueryResult>;
|
|
18
24
|
insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void>;
|
|
19
25
|
}
|
|
20
26
|
|
|
@@ -27,8 +33,21 @@ export class QueuesAPIImpl implements QueuesAPI {
|
|
|
27
33
|
private readonly _spaceId: SpaceId,
|
|
28
34
|
) {}
|
|
29
35
|
|
|
30
|
-
queryQueue(queue: DXN, options?: {}): Promise<
|
|
31
|
-
|
|
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
|
+
};
|
|
32
51
|
}
|
|
33
52
|
|
|
34
53
|
insertIntoQueue(queue: DXN, objects: AnyEntity[]): Promise<void> {
|