@dxos/functions-runtime-cloudflare 0.8.4-main.d05673bc65 → 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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/index.mjs +58 -143
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +58 -143
- package/dist/lib/node-esm/index.mjs.map +4 -4
- 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 +1 -0
- package/dist/types/src/internal/queue-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/service-container.d.ts +4 -4
- 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 +10 -5
- 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 +16 -16
- package/src/functions-client.ts +0 -6
- package/src/internal/data-service-impl.ts +8 -2
- package/src/internal/queue-service-impl.ts +4 -0
- package/src/internal/service-container.ts +16 -15
- package/src/logger.ts +10 -8
- package/src/queues-api.ts +11 -5
- package/src/space-proxy.ts +1 -1
- package/src/wrap-handler-for-cloudflare.ts +1 -1
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -44,4 +44,4 @@ pnpm i @dxos/functions-runtime-cloudflare
|
|
|
44
44
|
|
|
45
45
|
Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
|
|
46
46
|
|
|
47
|
-
License: [
|
|
47
|
+
License: [FSL-1.1-Apache-2.0](./LICENSE) Copyright 2022 © DXOS
|
|
@@ -3,6 +3,9 @@ import { Resource as Resource2 } from "@dxos/context";
|
|
|
3
3
|
import { EchoClient } from "@dxos/echo-db";
|
|
4
4
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
5
5
|
|
|
6
|
+
// src/internal/service-container.ts
|
|
7
|
+
import { EID } from "@dxos/keys";
|
|
8
|
+
|
|
6
9
|
// src/internal/data-service-impl.ts
|
|
7
10
|
import { Stream } from "@dxos/codec-protobuf/stream";
|
|
8
11
|
import { raise } from "@dxos/debug";
|
|
@@ -15,6 +18,7 @@ import { log } from "@dxos/log";
|
|
|
15
18
|
var copyUint8Array = (value) => new Uint8Array(value);
|
|
16
19
|
|
|
17
20
|
// src/internal/data-service-impl.ts
|
|
21
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
|
|
18
22
|
function _ts_add_disposable_resource(env, value, async) {
|
|
19
23
|
if (value !== null && value !== void 0) {
|
|
20
24
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -80,7 +84,6 @@ function _ts_dispose_resources(env) {
|
|
|
80
84
|
return next();
|
|
81
85
|
})(env);
|
|
82
86
|
}
|
|
83
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
|
|
84
87
|
var DataServiceImpl = class {
|
|
85
88
|
_executionContext;
|
|
86
89
|
_dataService;
|
|
@@ -91,15 +94,7 @@ var DataServiceImpl = class {
|
|
|
91
94
|
}
|
|
92
95
|
subscribe({ subscriptionId, spaceId }) {
|
|
93
96
|
return new Stream(({ next }) => {
|
|
94
|
-
invariant(SpaceId.isValid(spaceId), void 0, {
|
|
95
|
-
F: __dxlog_file,
|
|
96
|
-
L: 39,
|
|
97
|
-
S: this,
|
|
98
|
-
A: [
|
|
99
|
-
"SpaceId.isValid(spaceId)",
|
|
100
|
-
""
|
|
101
|
-
]
|
|
102
|
-
});
|
|
97
|
+
invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 86, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
|
|
103
98
|
this.dataSubscriptions.set(subscriptionId, {
|
|
104
99
|
spaceId,
|
|
105
100
|
next
|
|
@@ -119,12 +114,7 @@ var DataServiceImpl = class {
|
|
|
119
114
|
if (addIds) {
|
|
120
115
|
log.info("request documents", {
|
|
121
116
|
count: addIds.length
|
|
122
|
-
}, {
|
|
123
|
-
F: __dxlog_file,
|
|
124
|
-
L: 59,
|
|
125
|
-
S: this,
|
|
126
|
-
C: (f, a) => f(...a)
|
|
127
|
-
});
|
|
117
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 104, S: this });
|
|
128
118
|
for (const documentId of addIds) {
|
|
129
119
|
const env = {
|
|
130
120
|
stack: [],
|
|
@@ -137,21 +127,11 @@ var DataServiceImpl = class {
|
|
|
137
127
|
documentId,
|
|
138
128
|
spaceId: sub.spaceId,
|
|
139
129
|
found: !!document
|
|
140
|
-
}, {
|
|
141
|
-
F: __dxlog_file,
|
|
142
|
-
L: 63,
|
|
143
|
-
S: this,
|
|
144
|
-
C: (f, a) => f(...a)
|
|
145
|
-
});
|
|
130
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 116, S: this });
|
|
146
131
|
if (!document) {
|
|
147
132
|
log.warn("not found", {
|
|
148
133
|
documentId
|
|
149
|
-
}, {
|
|
150
|
-
F: __dxlog_file,
|
|
151
|
-
L: 65,
|
|
152
|
-
S: this,
|
|
153
|
-
C: (f, a) => f(...a)
|
|
154
|
-
});
|
|
134
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 122, S: this });
|
|
155
135
|
continue;
|
|
156
136
|
}
|
|
157
137
|
sub.next({
|
|
@@ -180,10 +160,8 @@ var DataServiceImpl = class {
|
|
|
180
160
|
hasError: false
|
|
181
161
|
};
|
|
182
162
|
try {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
initialValue
|
|
186
|
-
}), false);
|
|
163
|
+
invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 153, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
|
|
164
|
+
const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, spaceId, initialValue), false);
|
|
187
165
|
return {
|
|
188
166
|
documentId: response.documentId
|
|
189
167
|
};
|
|
@@ -203,6 +181,9 @@ var DataServiceImpl = class {
|
|
|
203
181
|
}));
|
|
204
182
|
try {
|
|
205
183
|
for (const update of updates ?? []) {
|
|
184
|
+
if (!update.mutation) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
206
187
|
await this._dataService.changeDocument(this._executionContext, sub.spaceId, update.documentId, update.mutation);
|
|
207
188
|
}
|
|
208
189
|
} catch (error) {
|
|
@@ -233,12 +214,7 @@ var DataServiceImpl = class {
|
|
|
233
214
|
});
|
|
234
215
|
}
|
|
235
216
|
async updateIndexes() {
|
|
236
|
-
log.
|
|
237
|
-
F: __dxlog_file,
|
|
238
|
-
L: 133,
|
|
239
|
-
S: this,
|
|
240
|
-
C: (f, a) => f(...a)
|
|
241
|
-
});
|
|
217
|
+
log.verbose("updateIndexes called, but it is a no-op in EDGE env.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 211, S: this });
|
|
242
218
|
}
|
|
243
219
|
async waitUntilHeadsReplicated({ heads: _heads }) {
|
|
244
220
|
throw new NotImplementedError({
|
|
@@ -251,6 +227,7 @@ var DataServiceImpl = class {
|
|
|
251
227
|
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
252
228
|
import { NotImplementedError as NotImplementedError2, RuntimeServiceError as RuntimeServiceError2 } from "@dxos/errors";
|
|
253
229
|
import { log as log2 } from "@dxos/log";
|
|
230
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
254
231
|
function _ts_add_disposable_resource2(env, value, async) {
|
|
255
232
|
if (value !== null && value !== void 0) {
|
|
256
233
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -316,7 +293,6 @@ function _ts_dispose_resources2(env) {
|
|
|
316
293
|
return next();
|
|
317
294
|
})(env);
|
|
318
295
|
}
|
|
319
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
320
296
|
var QueryServiceImpl = class {
|
|
321
297
|
_executionContext;
|
|
322
298
|
_dataService;
|
|
@@ -328,12 +304,7 @@ var QueryServiceImpl = class {
|
|
|
328
304
|
execQuery(request) {
|
|
329
305
|
log2.info("execQuery", {
|
|
330
306
|
request
|
|
331
|
-
}, {
|
|
332
|
-
F: __dxlog_file2,
|
|
333
|
-
L: 20,
|
|
334
|
-
S: this,
|
|
335
|
-
C: (f, a) => f(...a)
|
|
336
|
-
});
|
|
307
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 81, S: this });
|
|
337
308
|
return Stream2.fromPromise((async () => {
|
|
338
309
|
try {
|
|
339
310
|
const env = {
|
|
@@ -345,21 +316,11 @@ var QueryServiceImpl = class {
|
|
|
345
316
|
this._queryCount++;
|
|
346
317
|
log2.info("begin query", {
|
|
347
318
|
request
|
|
348
|
-
}, {
|
|
349
|
-
F: __dxlog_file2,
|
|
350
|
-
L: 26,
|
|
351
|
-
S: this,
|
|
352
|
-
C: (f, a) => f(...a)
|
|
353
|
-
});
|
|
319
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 93, S: this });
|
|
354
320
|
const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
|
|
355
321
|
log2.info("query response", {
|
|
356
322
|
resultCount: queryResponse.results?.length
|
|
357
|
-
}, {
|
|
358
|
-
F: __dxlog_file2,
|
|
359
|
-
L: 28,
|
|
360
|
-
S: this,
|
|
361
|
-
C: (f, a) => f(...a)
|
|
362
|
-
});
|
|
323
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this });
|
|
363
324
|
return structuredClone(queryResponse);
|
|
364
325
|
} catch (e) {
|
|
365
326
|
env.error = e;
|
|
@@ -370,12 +331,7 @@ var QueryServiceImpl = class {
|
|
|
370
331
|
} catch (error) {
|
|
371
332
|
log2.error("query failed", {
|
|
372
333
|
err: error
|
|
373
|
-
}, {
|
|
374
|
-
F: __dxlog_file2,
|
|
375
|
-
L: 31,
|
|
376
|
-
S: this,
|
|
377
|
-
C: (f, a) => f(...a)
|
|
378
|
-
});
|
|
334
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 108, S: this });
|
|
379
335
|
throw new RuntimeServiceError2({
|
|
380
336
|
message: `Query execution failed (queryCount=${this._queryCount})`,
|
|
381
337
|
context: {
|
|
@@ -563,6 +519,11 @@ var QueueServiceImpl = class {
|
|
|
563
519
|
}
|
|
564
520
|
async syncQueue(_) {
|
|
565
521
|
}
|
|
522
|
+
async getSyncState(_) {
|
|
523
|
+
return {
|
|
524
|
+
namespaces: []
|
|
525
|
+
};
|
|
526
|
+
}
|
|
566
527
|
};
|
|
567
528
|
|
|
568
529
|
// src/internal/service-container.ts
|
|
@@ -673,15 +634,14 @@ var ServiceContainer = class {
|
|
|
673
634
|
};
|
|
674
635
|
}
|
|
675
636
|
async queryQueue(queue) {
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
637
|
+
const spaceId = EID.getSpaceId(queue);
|
|
638
|
+
const queueId = EID.getEntityId(queue);
|
|
639
|
+
if (!spaceId || !queueId) {
|
|
640
|
+
throw new Error("Invalid queue EID");
|
|
679
641
|
}
|
|
680
|
-
const { subspaceTag, spaceId, queueId } = parts;
|
|
681
642
|
const result = await this._queueService.queryQueue(this._executionContext, {
|
|
682
643
|
query: {
|
|
683
644
|
spaceId,
|
|
684
|
-
queuesNamespace: subspaceTag,
|
|
685
645
|
queueIds: [
|
|
686
646
|
queueId
|
|
687
647
|
]
|
|
@@ -694,16 +654,16 @@ var ServiceContainer = class {
|
|
|
694
654
|
};
|
|
695
655
|
}
|
|
696
656
|
async insertIntoQueue(queue, objects) {
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
657
|
+
const spaceId = EID.getSpaceId(queue);
|
|
658
|
+
const queueId = EID.getEntityId(queue);
|
|
659
|
+
if (!spaceId || !queueId) {
|
|
660
|
+
throw new Error("Invalid queue EID");
|
|
700
661
|
}
|
|
701
|
-
const { subspaceTag, spaceId, queueId } = parts;
|
|
702
662
|
await this._queueService.insertIntoQueue(this._executionContext, {
|
|
703
|
-
subspaceTag,
|
|
663
|
+
subspaceTag: "data",
|
|
704
664
|
spaceId,
|
|
705
665
|
queueId,
|
|
706
|
-
objects
|
|
666
|
+
objects: objects.map((obj) => JSON.stringify(obj))
|
|
707
667
|
});
|
|
708
668
|
}
|
|
709
669
|
};
|
|
@@ -730,7 +690,7 @@ var QueuesAPIImpl = class {
|
|
|
730
690
|
};
|
|
731
691
|
|
|
732
692
|
// src/space-proxy.ts
|
|
733
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/space-proxy.ts";
|
|
693
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/space-proxy.ts";
|
|
734
694
|
var SpaceProxy = class extends Resource {
|
|
735
695
|
_serviceContainer;
|
|
736
696
|
_echoClient;
|
|
@@ -745,30 +705,14 @@ var SpaceProxy = class extends Resource {
|
|
|
745
705
|
return this._id;
|
|
746
706
|
}
|
|
747
707
|
get db() {
|
|
748
|
-
invariant2(this._db, void 0, {
|
|
749
|
-
F: __dxlog_file3,
|
|
750
|
-
L: 35,
|
|
751
|
-
S: this,
|
|
752
|
-
A: [
|
|
753
|
-
"this._db",
|
|
754
|
-
""
|
|
755
|
-
]
|
|
756
|
-
});
|
|
708
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 24, S: this, A: ["this._db", ""] });
|
|
757
709
|
return this._db;
|
|
758
710
|
}
|
|
759
711
|
/**
|
|
760
712
|
* @deprecated Use db API.
|
|
761
713
|
*/
|
|
762
714
|
get crud() {
|
|
763
|
-
invariant2(this._db, void 0, {
|
|
764
|
-
F: __dxlog_file3,
|
|
765
|
-
L: 43,
|
|
766
|
-
S: this,
|
|
767
|
-
A: [
|
|
768
|
-
"this._db",
|
|
769
|
-
""
|
|
770
|
-
]
|
|
771
|
-
});
|
|
715
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 30, S: this, A: ["this._db", ""] });
|
|
772
716
|
return this._db.coreDatabase;
|
|
773
717
|
}
|
|
774
718
|
get queues() {
|
|
@@ -785,14 +729,14 @@ var SpaceProxy = class extends Resource {
|
|
|
785
729
|
reactiveSchemaQuery: false,
|
|
786
730
|
owningObject: this
|
|
787
731
|
});
|
|
788
|
-
await this._db.coreDatabase.open({
|
|
732
|
+
await this._db.coreDatabase.open(this._ctx, {
|
|
789
733
|
rootUrl: meta.rootDocumentId
|
|
790
734
|
});
|
|
791
735
|
}
|
|
792
736
|
};
|
|
793
737
|
|
|
794
738
|
// src/functions-client.ts
|
|
795
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/functions-client.ts";
|
|
739
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/functions-client.ts";
|
|
796
740
|
var FunctionsClient = class extends Resource2 {
|
|
797
741
|
_serviceContainer;
|
|
798
742
|
_echoClient;
|
|
@@ -800,24 +744,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
800
744
|
_spaces = /* @__PURE__ */ new Map();
|
|
801
745
|
constructor(services) {
|
|
802
746
|
super();
|
|
803
|
-
invariant3(typeof services.dataService !== "undefined", "DataService is required", {
|
|
804
|
-
|
|
805
|
-
L: 33,
|
|
806
|
-
S: this,
|
|
807
|
-
A: [
|
|
808
|
-
"typeof services.dataService !== 'undefined'",
|
|
809
|
-
"'DataService is required'"
|
|
810
|
-
]
|
|
811
|
-
});
|
|
812
|
-
invariant3(typeof services.queueService !== "undefined", "QueueService is required", {
|
|
813
|
-
F: __dxlog_file4,
|
|
814
|
-
L: 34,
|
|
815
|
-
S: this,
|
|
816
|
-
A: [
|
|
817
|
-
"typeof services.queueService !== 'undefined'",
|
|
818
|
-
"'QueueService is required'"
|
|
819
|
-
]
|
|
820
|
-
});
|
|
747
|
+
invariant3(typeof services.dataService !== "undefined", "DataService is required", { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 19, S: this, A: ["typeof services.dataService !== 'undefined'", "'DataService is required'"] });
|
|
748
|
+
invariant3(typeof services.queueService !== "undefined", "QueueService is required", { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 20, S: this, A: ["typeof services.queueService !== 'undefined'", "'QueueService is required'"] });
|
|
821
749
|
this._serviceContainer = new ServiceContainer(this._executionContext, services.dataService, services.queueService, services.functionsAiService);
|
|
822
750
|
this._echoClient = new EchoClient({});
|
|
823
751
|
}
|
|
@@ -871,7 +799,7 @@ import { invariant as invariant4 } from "@dxos/invariant";
|
|
|
871
799
|
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
872
800
|
import { log as log3 } from "@dxos/log";
|
|
873
801
|
import { EdgeResponse } from "@dxos/protocols";
|
|
874
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
|
|
802
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
|
|
875
803
|
var wrapHandlerForCloudflare = (func) => {
|
|
876
804
|
return async (request, env) => {
|
|
877
805
|
if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
|
|
@@ -896,12 +824,7 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
896
824
|
log3.error("error invoking function", {
|
|
897
825
|
error,
|
|
898
826
|
stack: error.stack
|
|
899
|
-
}, {
|
|
900
|
-
F: __dxlog_file5,
|
|
901
|
-
L: 44,
|
|
902
|
-
S: void 0,
|
|
903
|
-
C: (f, a) => f(...a)
|
|
904
|
-
});
|
|
827
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 37, S: void 0 });
|
|
905
828
|
return EdgeResponse.failure({
|
|
906
829
|
message: error?.message ?? "Internal error",
|
|
907
830
|
error
|
|
@@ -934,12 +857,7 @@ var decodeRequest = async (request) => {
|
|
|
934
857
|
}
|
|
935
858
|
};
|
|
936
859
|
} catch (err) {
|
|
937
|
-
log3.catch(err, void 0, {
|
|
938
|
-
F: __dxlog_file5,
|
|
939
|
-
L: 79,
|
|
940
|
-
S: void 0,
|
|
941
|
-
C: (f, a) => f(...a)
|
|
942
|
-
});
|
|
860
|
+
log3.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 76, S: void 0 });
|
|
943
861
|
return {
|
|
944
862
|
data: {
|
|
945
863
|
bodyText,
|
|
@@ -972,15 +890,7 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
972
890
|
throw new Error(`Space not found: ${contextSpaceId}`);
|
|
973
891
|
}
|
|
974
892
|
spaceKey = meta.spaceKey;
|
|
975
|
-
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
|
|
976
|
-
F: __dxlog_file5,
|
|
977
|
-
L: 117,
|
|
978
|
-
S: void 0,
|
|
979
|
-
A: [
|
|
980
|
-
"!meta.rootDocumentId.startsWith('automerge:')",
|
|
981
|
-
""
|
|
982
|
-
]
|
|
983
|
-
});
|
|
893
|
+
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 109, S: void 0, A: ["!meta.rootDocumentId.startsWith('automerge:')", ""] });
|
|
984
894
|
rootUrl = `automerge:${meta.rootDocumentId}`;
|
|
985
895
|
}
|
|
986
896
|
return {
|
|
@@ -1006,27 +916,31 @@ var functionLogProcessor = (config, entry) => {
|
|
|
1006
916
|
if (!shouldLog(entry, config.filters)) {
|
|
1007
917
|
return;
|
|
1008
918
|
}
|
|
919
|
+
const context = entry.computedContext;
|
|
920
|
+
const error = entry.computedError;
|
|
921
|
+
const extras = [
|
|
922
|
+
Object.keys(context).length > 0 ? context : void 0,
|
|
923
|
+
error
|
|
924
|
+
].filter((value) => value !== void 0);
|
|
1009
925
|
switch (entry.level) {
|
|
1010
926
|
case LogLevel.DEBUG:
|
|
1011
|
-
console.debug(entry.message, entry.context);
|
|
1012
|
-
break;
|
|
1013
927
|
case LogLevel.TRACE:
|
|
1014
|
-
console.debug(entry.message,
|
|
928
|
+
console.debug(entry.message, ...extras);
|
|
1015
929
|
break;
|
|
1016
930
|
case LogLevel.VERBOSE:
|
|
1017
|
-
console.log(entry.message,
|
|
931
|
+
console.log(entry.message, ...extras);
|
|
1018
932
|
break;
|
|
1019
933
|
case LogLevel.INFO:
|
|
1020
|
-
console.info(entry.message,
|
|
934
|
+
console.info(entry.message, ...extras);
|
|
1021
935
|
break;
|
|
1022
936
|
case LogLevel.WARN:
|
|
1023
|
-
console.warn(entry.message,
|
|
937
|
+
console.warn(entry.message, ...extras);
|
|
1024
938
|
break;
|
|
1025
939
|
case LogLevel.ERROR:
|
|
1026
|
-
console.error(entry.message,
|
|
940
|
+
console.error(entry.message, ...extras);
|
|
1027
941
|
break;
|
|
1028
942
|
default:
|
|
1029
|
-
console.log(entry.message,
|
|
943
|
+
console.log(entry.message, ...extras);
|
|
1030
944
|
break;
|
|
1031
945
|
}
|
|
1032
946
|
};
|
|
@@ -1036,6 +950,7 @@ export {
|
|
|
1036
950
|
FunctionsClient,
|
|
1037
951
|
ServiceContainer,
|
|
1038
952
|
createClientFromEnv,
|
|
953
|
+
createFunctionContext,
|
|
1039
954
|
setupFunctionsLogger,
|
|
1040
955
|
wrapHandlerForCloudflare
|
|
1041
956
|
};
|