@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/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
|
|
@@ -15,6 +15,7 @@ import { log } from "@dxos/log";
|
|
|
15
15
|
var copyUint8Array = (value) => new Uint8Array(value);
|
|
16
16
|
|
|
17
17
|
// src/internal/data-service-impl.ts
|
|
18
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
|
|
18
19
|
function _ts_add_disposable_resource(env, value, async) {
|
|
19
20
|
if (value !== null && value !== void 0) {
|
|
20
21
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -80,7 +81,6 @@ function _ts_dispose_resources(env) {
|
|
|
80
81
|
return next();
|
|
81
82
|
})(env);
|
|
82
83
|
}
|
|
83
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/data-service-impl.ts";
|
|
84
84
|
var DataServiceImpl = class {
|
|
85
85
|
_executionContext;
|
|
86
86
|
_dataService;
|
|
@@ -91,15 +91,7 @@ var DataServiceImpl = class {
|
|
|
91
91
|
}
|
|
92
92
|
subscribe({ subscriptionId, spaceId }) {
|
|
93
93
|
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
|
-
});
|
|
94
|
+
invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 86, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
|
|
103
95
|
this.dataSubscriptions.set(subscriptionId, {
|
|
104
96
|
spaceId,
|
|
105
97
|
next
|
|
@@ -119,12 +111,7 @@ var DataServiceImpl = class {
|
|
|
119
111
|
if (addIds) {
|
|
120
112
|
log.info("request documents", {
|
|
121
113
|
count: addIds.length
|
|
122
|
-
}, {
|
|
123
|
-
F: __dxlog_file,
|
|
124
|
-
L: 59,
|
|
125
|
-
S: this,
|
|
126
|
-
C: (f, a) => f(...a)
|
|
127
|
-
});
|
|
114
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 104, S: this });
|
|
128
115
|
for (const documentId of addIds) {
|
|
129
116
|
const env = {
|
|
130
117
|
stack: [],
|
|
@@ -137,21 +124,11 @@ var DataServiceImpl = class {
|
|
|
137
124
|
documentId,
|
|
138
125
|
spaceId: sub.spaceId,
|
|
139
126
|
found: !!document
|
|
140
|
-
}, {
|
|
141
|
-
F: __dxlog_file,
|
|
142
|
-
L: 63,
|
|
143
|
-
S: this,
|
|
144
|
-
C: (f, a) => f(...a)
|
|
145
|
-
});
|
|
127
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 116, S: this });
|
|
146
128
|
if (!document) {
|
|
147
129
|
log.warn("not found", {
|
|
148
130
|
documentId
|
|
149
|
-
}, {
|
|
150
|
-
F: __dxlog_file,
|
|
151
|
-
L: 65,
|
|
152
|
-
S: this,
|
|
153
|
-
C: (f, a) => f(...a)
|
|
154
|
-
});
|
|
131
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 122, S: this });
|
|
155
132
|
continue;
|
|
156
133
|
}
|
|
157
134
|
sub.next({
|
|
@@ -180,15 +157,7 @@ var DataServiceImpl = class {
|
|
|
180
157
|
hasError: false
|
|
181
158
|
};
|
|
182
159
|
try {
|
|
183
|
-
invariant(SpaceId.isValid(spaceId), void 0, {
|
|
184
|
-
F: __dxlog_file,
|
|
185
|
-
L: 83,
|
|
186
|
-
S: this,
|
|
187
|
-
A: [
|
|
188
|
-
"SpaceId.isValid(spaceId)",
|
|
189
|
-
""
|
|
190
|
-
]
|
|
191
|
-
});
|
|
160
|
+
invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 153, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
|
|
192
161
|
const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, spaceId, initialValue), false);
|
|
193
162
|
return {
|
|
194
163
|
documentId: response.documentId
|
|
@@ -209,6 +178,9 @@ var DataServiceImpl = class {
|
|
|
209
178
|
}));
|
|
210
179
|
try {
|
|
211
180
|
for (const update of updates ?? []) {
|
|
181
|
+
if (!update.mutation) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
212
184
|
await this._dataService.changeDocument(this._executionContext, sub.spaceId, update.documentId, update.mutation);
|
|
213
185
|
}
|
|
214
186
|
} catch (error) {
|
|
@@ -239,12 +211,7 @@ var DataServiceImpl = class {
|
|
|
239
211
|
});
|
|
240
212
|
}
|
|
241
213
|
async updateIndexes() {
|
|
242
|
-
log.
|
|
243
|
-
F: __dxlog_file,
|
|
244
|
-
L: 134,
|
|
245
|
-
S: this,
|
|
246
|
-
C: (f, a) => f(...a)
|
|
247
|
-
});
|
|
214
|
+
log.verbose("updateIndexes called, but it is a no-op in EDGE env.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 211, S: this });
|
|
248
215
|
}
|
|
249
216
|
async waitUntilHeadsReplicated({ heads: _heads }) {
|
|
250
217
|
throw new NotImplementedError({
|
|
@@ -257,6 +224,7 @@ var DataServiceImpl = class {
|
|
|
257
224
|
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
258
225
|
import { NotImplementedError as NotImplementedError2, RuntimeServiceError as RuntimeServiceError2 } from "@dxos/errors";
|
|
259
226
|
import { log as log2 } from "@dxos/log";
|
|
227
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
260
228
|
function _ts_add_disposable_resource2(env, value, async) {
|
|
261
229
|
if (value !== null && value !== void 0) {
|
|
262
230
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -322,7 +290,6 @@ function _ts_dispose_resources2(env) {
|
|
|
322
290
|
return next();
|
|
323
291
|
})(env);
|
|
324
292
|
}
|
|
325
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
326
293
|
var QueryServiceImpl = class {
|
|
327
294
|
_executionContext;
|
|
328
295
|
_dataService;
|
|
@@ -334,12 +301,7 @@ var QueryServiceImpl = class {
|
|
|
334
301
|
execQuery(request) {
|
|
335
302
|
log2.info("execQuery", {
|
|
336
303
|
request
|
|
337
|
-
}, {
|
|
338
|
-
F: __dxlog_file2,
|
|
339
|
-
L: 20,
|
|
340
|
-
S: this,
|
|
341
|
-
C: (f, a) => f(...a)
|
|
342
|
-
});
|
|
304
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 81, S: this });
|
|
343
305
|
return Stream2.fromPromise((async () => {
|
|
344
306
|
try {
|
|
345
307
|
const env = {
|
|
@@ -351,21 +313,11 @@ var QueryServiceImpl = class {
|
|
|
351
313
|
this._queryCount++;
|
|
352
314
|
log2.info("begin query", {
|
|
353
315
|
request
|
|
354
|
-
}, {
|
|
355
|
-
F: __dxlog_file2,
|
|
356
|
-
L: 26,
|
|
357
|
-
S: this,
|
|
358
|
-
C: (f, a) => f(...a)
|
|
359
|
-
});
|
|
316
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 93, S: this });
|
|
360
317
|
const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
|
|
361
318
|
log2.info("query response", {
|
|
362
319
|
resultCount: queryResponse.results?.length
|
|
363
|
-
}, {
|
|
364
|
-
F: __dxlog_file2,
|
|
365
|
-
L: 28,
|
|
366
|
-
S: this,
|
|
367
|
-
C: (f, a) => f(...a)
|
|
368
|
-
});
|
|
320
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this });
|
|
369
321
|
return structuredClone(queryResponse);
|
|
370
322
|
} catch (e) {
|
|
371
323
|
env.error = e;
|
|
@@ -376,12 +328,7 @@ var QueryServiceImpl = class {
|
|
|
376
328
|
} catch (error) {
|
|
377
329
|
log2.error("query failed", {
|
|
378
330
|
err: error
|
|
379
|
-
}, {
|
|
380
|
-
F: __dxlog_file2,
|
|
381
|
-
L: 31,
|
|
382
|
-
S: this,
|
|
383
|
-
C: (f, a) => f(...a)
|
|
384
|
-
});
|
|
331
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 108, S: this });
|
|
385
332
|
throw new RuntimeServiceError2({
|
|
386
333
|
message: `Query execution failed (queryCount=${this._queryCount})`,
|
|
387
334
|
context: {
|
|
@@ -709,7 +656,7 @@ var ServiceContainer = class {
|
|
|
709
656
|
subspaceTag,
|
|
710
657
|
spaceId,
|
|
711
658
|
queueId,
|
|
712
|
-
objects
|
|
659
|
+
objects: objects.map((obj) => JSON.stringify(obj))
|
|
713
660
|
});
|
|
714
661
|
}
|
|
715
662
|
};
|
|
@@ -720,6 +667,8 @@ import { invariant as invariant2 } from "@dxos/invariant";
|
|
|
720
667
|
import { PublicKey } from "@dxos/keys";
|
|
721
668
|
|
|
722
669
|
// src/queues-api.ts
|
|
670
|
+
import { log as log3 } from "@dxos/log";
|
|
671
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/queues-api.ts";
|
|
723
672
|
var QueuesAPIImpl = class {
|
|
724
673
|
_serviceContainer;
|
|
725
674
|
_spaceId;
|
|
@@ -727,8 +676,26 @@ var QueuesAPIImpl = class {
|
|
|
727
676
|
this._serviceContainer = _serviceContainer;
|
|
728
677
|
this._spaceId = _spaceId;
|
|
729
678
|
}
|
|
730
|
-
queryQueue(queue, options) {
|
|
731
|
-
|
|
679
|
+
async queryQueue(queue, options) {
|
|
680
|
+
const result = await this._serviceContainer.queryQueue(queue);
|
|
681
|
+
const objects = (result.objects ?? []).flatMap((encoded) => {
|
|
682
|
+
try {
|
|
683
|
+
return [
|
|
684
|
+
JSON.parse(encoded)
|
|
685
|
+
];
|
|
686
|
+
} catch (err) {
|
|
687
|
+
log3.verbose("queue object JSON parse failed; object ignored", {
|
|
688
|
+
encoded,
|
|
689
|
+
error: err
|
|
690
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 22, S: this });
|
|
691
|
+
return [];
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
return {
|
|
695
|
+
objects,
|
|
696
|
+
nextCursor: result.nextCursor ?? null,
|
|
697
|
+
prevCursor: result.prevCursor ?? null
|
|
698
|
+
};
|
|
732
699
|
}
|
|
733
700
|
insertIntoQueue(queue, objects) {
|
|
734
701
|
return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
|
|
@@ -736,7 +703,7 @@ var QueuesAPIImpl = class {
|
|
|
736
703
|
};
|
|
737
704
|
|
|
738
705
|
// src/space-proxy.ts
|
|
739
|
-
var
|
|
706
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/space-proxy.ts";
|
|
740
707
|
var SpaceProxy = class extends Resource {
|
|
741
708
|
_serviceContainer;
|
|
742
709
|
_echoClient;
|
|
@@ -751,30 +718,14 @@ var SpaceProxy = class extends Resource {
|
|
|
751
718
|
return this._id;
|
|
752
719
|
}
|
|
753
720
|
get db() {
|
|
754
|
-
invariant2(this._db, void 0, {
|
|
755
|
-
F: __dxlog_file3,
|
|
756
|
-
L: 35,
|
|
757
|
-
S: this,
|
|
758
|
-
A: [
|
|
759
|
-
"this._db",
|
|
760
|
-
""
|
|
761
|
-
]
|
|
762
|
-
});
|
|
721
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 24, S: this, A: ["this._db", ""] });
|
|
763
722
|
return this._db;
|
|
764
723
|
}
|
|
765
724
|
/**
|
|
766
725
|
* @deprecated Use db API.
|
|
767
726
|
*/
|
|
768
727
|
get crud() {
|
|
769
|
-
invariant2(this._db, void 0, {
|
|
770
|
-
F: __dxlog_file3,
|
|
771
|
-
L: 43,
|
|
772
|
-
S: this,
|
|
773
|
-
A: [
|
|
774
|
-
"this._db",
|
|
775
|
-
""
|
|
776
|
-
]
|
|
777
|
-
});
|
|
728
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 30, S: this, A: ["this._db", ""] });
|
|
778
729
|
return this._db.coreDatabase;
|
|
779
730
|
}
|
|
780
731
|
get queues() {
|
|
@@ -798,7 +749,7 @@ var SpaceProxy = class extends Resource {
|
|
|
798
749
|
};
|
|
799
750
|
|
|
800
751
|
// src/functions-client.ts
|
|
801
|
-
var
|
|
752
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/functions-client.ts";
|
|
802
753
|
var FunctionsClient = class extends Resource2 {
|
|
803
754
|
_serviceContainer;
|
|
804
755
|
_echoClient;
|
|
@@ -806,24 +757,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
806
757
|
_spaces = /* @__PURE__ */ new Map();
|
|
807
758
|
constructor(services) {
|
|
808
759
|
super();
|
|
809
|
-
invariant3(typeof services.dataService !== "undefined", "DataService is required", {
|
|
810
|
-
|
|
811
|
-
L: 33,
|
|
812
|
-
S: this,
|
|
813
|
-
A: [
|
|
814
|
-
"typeof services.dataService !== 'undefined'",
|
|
815
|
-
"'DataService is required'"
|
|
816
|
-
]
|
|
817
|
-
});
|
|
818
|
-
invariant3(typeof services.queueService !== "undefined", "QueueService is required", {
|
|
819
|
-
F: __dxlog_file4,
|
|
820
|
-
L: 34,
|
|
821
|
-
S: this,
|
|
822
|
-
A: [
|
|
823
|
-
"typeof services.queueService !== 'undefined'",
|
|
824
|
-
"'QueueService is required'"
|
|
825
|
-
]
|
|
826
|
-
});
|
|
760
|
+
invariant3(typeof services.dataService !== "undefined", "DataService is required", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 19, S: this, A: ["typeof services.dataService !== 'undefined'", "'DataService is required'"] });
|
|
761
|
+
invariant3(typeof services.queueService !== "undefined", "QueueService is required", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 20, S: this, A: ["typeof services.queueService !== 'undefined'", "'QueueService is required'"] });
|
|
827
762
|
this._serviceContainer = new ServiceContainer(this._executionContext, services.dataService, services.queueService, services.functionsAiService);
|
|
828
763
|
this._echoClient = new EchoClient({});
|
|
829
764
|
}
|
|
@@ -875,9 +810,9 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
|
|
|
875
810
|
// src/wrap-handler-for-cloudflare.ts
|
|
876
811
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
877
812
|
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
878
|
-
import { log as
|
|
813
|
+
import { log as log4 } from "@dxos/log";
|
|
879
814
|
import { EdgeResponse } from "@dxos/protocols";
|
|
880
|
-
var
|
|
815
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
|
|
881
816
|
var wrapHandlerForCloudflare = (func) => {
|
|
882
817
|
return async (request, env) => {
|
|
883
818
|
if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
|
|
@@ -899,15 +834,10 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
899
834
|
});
|
|
900
835
|
return EdgeResponse.success(await invokeFunction(func, context, request));
|
|
901
836
|
} catch (error) {
|
|
902
|
-
|
|
837
|
+
log4.error("error invoking function", {
|
|
903
838
|
error,
|
|
904
839
|
stack: error.stack
|
|
905
|
-
}, {
|
|
906
|
-
F: __dxlog_file5,
|
|
907
|
-
L: 44,
|
|
908
|
-
S: void 0,
|
|
909
|
-
C: (f, a) => f(...a)
|
|
910
|
-
});
|
|
840
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 37, S: void 0 });
|
|
911
841
|
return EdgeResponse.failure({
|
|
912
842
|
message: error?.message ?? "Internal error",
|
|
913
843
|
error
|
|
@@ -940,12 +870,7 @@ var decodeRequest = async (request) => {
|
|
|
940
870
|
}
|
|
941
871
|
};
|
|
942
872
|
} catch (err) {
|
|
943
|
-
|
|
944
|
-
F: __dxlog_file5,
|
|
945
|
-
L: 79,
|
|
946
|
-
S: void 0,
|
|
947
|
-
C: (f, a) => f(...a)
|
|
948
|
-
});
|
|
873
|
+
log4.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 76, S: void 0 });
|
|
949
874
|
return {
|
|
950
875
|
data: {
|
|
951
876
|
bodyText,
|
|
@@ -978,15 +903,7 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
978
903
|
throw new Error(`Space not found: ${contextSpaceId}`);
|
|
979
904
|
}
|
|
980
905
|
spaceKey = meta.spaceKey;
|
|
981
|
-
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, {
|
|
982
|
-
F: __dxlog_file5,
|
|
983
|
-
L: 117,
|
|
984
|
-
S: void 0,
|
|
985
|
-
A: [
|
|
986
|
-
"!meta.rootDocumentId.startsWith('automerge:')",
|
|
987
|
-
""
|
|
988
|
-
]
|
|
989
|
-
});
|
|
906
|
+
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 109, S: void 0, A: ["!meta.rootDocumentId.startsWith('automerge:')", ""] });
|
|
990
907
|
rootUrl = `automerge:${meta.rootDocumentId}`;
|
|
991
908
|
}
|
|
992
909
|
return {
|
|
@@ -1003,36 +920,40 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
1003
920
|
};
|
|
1004
921
|
|
|
1005
922
|
// src/logger.ts
|
|
1006
|
-
import { LogLevel, log as
|
|
923
|
+
import { LogLevel, log as log5, shouldLog } from "@dxos/log";
|
|
1007
924
|
var setupFunctionsLogger = () => {
|
|
1008
|
-
|
|
1009
|
-
|
|
925
|
+
log5.runtimeConfig.processors.length = 0;
|
|
926
|
+
log5.runtimeConfig.processors.push(functionLogProcessor);
|
|
1010
927
|
};
|
|
1011
928
|
var functionLogProcessor = (config, entry) => {
|
|
1012
929
|
if (!shouldLog(entry, config.filters)) {
|
|
1013
930
|
return;
|
|
1014
931
|
}
|
|
932
|
+
const context = entry.computedContext;
|
|
933
|
+
const error = entry.computedError;
|
|
934
|
+
const extras = [
|
|
935
|
+
Object.keys(context).length > 0 ? context : void 0,
|
|
936
|
+
error
|
|
937
|
+
].filter((value) => value !== void 0);
|
|
1015
938
|
switch (entry.level) {
|
|
1016
939
|
case LogLevel.DEBUG:
|
|
1017
|
-
console.debug(entry.message, entry.context);
|
|
1018
|
-
break;
|
|
1019
940
|
case LogLevel.TRACE:
|
|
1020
|
-
console.debug(entry.message,
|
|
941
|
+
console.debug(entry.message, ...extras);
|
|
1021
942
|
break;
|
|
1022
943
|
case LogLevel.VERBOSE:
|
|
1023
|
-
console.log(entry.message,
|
|
944
|
+
console.log(entry.message, ...extras);
|
|
1024
945
|
break;
|
|
1025
946
|
case LogLevel.INFO:
|
|
1026
|
-
console.info(entry.message,
|
|
947
|
+
console.info(entry.message, ...extras);
|
|
1027
948
|
break;
|
|
1028
949
|
case LogLevel.WARN:
|
|
1029
|
-
console.warn(entry.message,
|
|
950
|
+
console.warn(entry.message, ...extras);
|
|
1030
951
|
break;
|
|
1031
952
|
case LogLevel.ERROR:
|
|
1032
|
-
console.error(entry.message,
|
|
953
|
+
console.error(entry.message, ...extras);
|
|
1033
954
|
break;
|
|
1034
955
|
default:
|
|
1035
|
-
console.log(entry.message,
|
|
956
|
+
console.log(entry.message, ...extras);
|
|
1036
957
|
break;
|
|
1037
958
|
}
|
|
1038
959
|
};
|
|
@@ -1042,6 +963,7 @@ export {
|
|
|
1042
963
|
FunctionsClient,
|
|
1043
964
|
ServiceContainer,
|
|
1044
965
|
createClientFromEnv,
|
|
966
|
+
createFunctionContext,
|
|
1045
967
|
setupFunctionsLogger,
|
|
1046
968
|
wrapHandlerForCloudflare
|
|
1047
969
|
};
|