@dxos/functions-runtime-cloudflare 0.8.4-main.74a063c4e0 → 0.8.4-main.765dc60934
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 +67 -139
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +67 -139
- 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 +8 -2
- 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,10 +157,8 @@ var DataServiceImpl = class {
|
|
|
180
157
|
hasError: false
|
|
181
158
|
};
|
|
182
159
|
try {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
initialValue
|
|
186
|
-
}), false);
|
|
160
|
+
invariant(SpaceId.isValid(spaceId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 153, S: this, A: ["SpaceId.isValid(spaceId)", ""] });
|
|
161
|
+
const response = _ts_add_disposable_resource(env, await this._dataService.createDocument(this._executionContext, spaceId, initialValue), false);
|
|
187
162
|
return {
|
|
188
163
|
documentId: response.documentId
|
|
189
164
|
};
|
|
@@ -203,6 +178,9 @@ var DataServiceImpl = class {
|
|
|
203
178
|
}));
|
|
204
179
|
try {
|
|
205
180
|
for (const update of updates ?? []) {
|
|
181
|
+
if (!update.mutation) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
206
184
|
await this._dataService.changeDocument(this._executionContext, sub.spaceId, update.documentId, update.mutation);
|
|
207
185
|
}
|
|
208
186
|
} catch (error) {
|
|
@@ -233,12 +211,7 @@ var DataServiceImpl = class {
|
|
|
233
211
|
});
|
|
234
212
|
}
|
|
235
213
|
async updateIndexes() {
|
|
236
|
-
log.
|
|
237
|
-
F: __dxlog_file,
|
|
238
|
-
L: 133,
|
|
239
|
-
S: this,
|
|
240
|
-
C: (f, a) => f(...a)
|
|
241
|
-
});
|
|
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 });
|
|
242
215
|
}
|
|
243
216
|
async waitUntilHeadsReplicated({ heads: _heads }) {
|
|
244
217
|
throw new NotImplementedError({
|
|
@@ -251,6 +224,7 @@ var DataServiceImpl = class {
|
|
|
251
224
|
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
252
225
|
import { NotImplementedError as NotImplementedError2, RuntimeServiceError as RuntimeServiceError2 } from "@dxos/errors";
|
|
253
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";
|
|
254
228
|
function _ts_add_disposable_resource2(env, value, async) {
|
|
255
229
|
if (value !== null && value !== void 0) {
|
|
256
230
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -316,7 +290,6 @@ function _ts_dispose_resources2(env) {
|
|
|
316
290
|
return next();
|
|
317
291
|
})(env);
|
|
318
292
|
}
|
|
319
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions-runtime-cloudflare/src/internal/query-service-impl.ts";
|
|
320
293
|
var QueryServiceImpl = class {
|
|
321
294
|
_executionContext;
|
|
322
295
|
_dataService;
|
|
@@ -328,12 +301,7 @@ var QueryServiceImpl = class {
|
|
|
328
301
|
execQuery(request) {
|
|
329
302
|
log2.info("execQuery", {
|
|
330
303
|
request
|
|
331
|
-
}, {
|
|
332
|
-
F: __dxlog_file2,
|
|
333
|
-
L: 20,
|
|
334
|
-
S: this,
|
|
335
|
-
C: (f, a) => f(...a)
|
|
336
|
-
});
|
|
304
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 81, S: this });
|
|
337
305
|
return Stream2.fromPromise((async () => {
|
|
338
306
|
try {
|
|
339
307
|
const env = {
|
|
@@ -345,21 +313,11 @@ var QueryServiceImpl = class {
|
|
|
345
313
|
this._queryCount++;
|
|
346
314
|
log2.info("begin query", {
|
|
347
315
|
request
|
|
348
|
-
}, {
|
|
349
|
-
F: __dxlog_file2,
|
|
350
|
-
L: 26,
|
|
351
|
-
S: this,
|
|
352
|
-
C: (f, a) => f(...a)
|
|
353
|
-
});
|
|
316
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 93, S: this });
|
|
354
317
|
const queryResponse = _ts_add_disposable_resource2(env, await this._dataService.execQuery(this._executionContext, request), false);
|
|
355
318
|
log2.info("query response", {
|
|
356
319
|
resultCount: queryResponse.results?.length
|
|
357
|
-
}, {
|
|
358
|
-
F: __dxlog_file2,
|
|
359
|
-
L: 28,
|
|
360
|
-
S: this,
|
|
361
|
-
C: (f, a) => f(...a)
|
|
362
|
-
});
|
|
320
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 97, S: this });
|
|
363
321
|
return structuredClone(queryResponse);
|
|
364
322
|
} catch (e) {
|
|
365
323
|
env.error = e;
|
|
@@ -370,12 +328,7 @@ var QueryServiceImpl = class {
|
|
|
370
328
|
} catch (error) {
|
|
371
329
|
log2.error("query failed", {
|
|
372
330
|
err: error
|
|
373
|
-
}, {
|
|
374
|
-
F: __dxlog_file2,
|
|
375
|
-
L: 31,
|
|
376
|
-
S: this,
|
|
377
|
-
C: (f, a) => f(...a)
|
|
378
|
-
});
|
|
331
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 108, S: this });
|
|
379
332
|
throw new RuntimeServiceError2({
|
|
380
333
|
message: `Query execution failed (queryCount=${this._queryCount})`,
|
|
381
334
|
context: {
|
|
@@ -703,7 +656,7 @@ var ServiceContainer = class {
|
|
|
703
656
|
subspaceTag,
|
|
704
657
|
spaceId,
|
|
705
658
|
queueId,
|
|
706
|
-
objects
|
|
659
|
+
objects: objects.map((obj) => JSON.stringify(obj))
|
|
707
660
|
});
|
|
708
661
|
}
|
|
709
662
|
};
|
|
@@ -714,6 +667,8 @@ import { invariant as invariant2 } from "@dxos/invariant";
|
|
|
714
667
|
import { PublicKey } from "@dxos/keys";
|
|
715
668
|
|
|
716
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";
|
|
717
672
|
var QueuesAPIImpl = class {
|
|
718
673
|
_serviceContainer;
|
|
719
674
|
_spaceId;
|
|
@@ -721,8 +676,26 @@ var QueuesAPIImpl = class {
|
|
|
721
676
|
this._serviceContainer = _serviceContainer;
|
|
722
677
|
this._spaceId = _spaceId;
|
|
723
678
|
}
|
|
724
|
-
queryQueue(queue, options) {
|
|
725
|
-
|
|
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
|
+
};
|
|
726
699
|
}
|
|
727
700
|
insertIntoQueue(queue, objects) {
|
|
728
701
|
return this._serviceContainer.insertIntoQueue(queue, JSON.parse(JSON.stringify(objects)));
|
|
@@ -730,7 +703,7 @@ var QueuesAPIImpl = class {
|
|
|
730
703
|
};
|
|
731
704
|
|
|
732
705
|
// src/space-proxy.ts
|
|
733
|
-
var
|
|
706
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/space-proxy.ts";
|
|
734
707
|
var SpaceProxy = class extends Resource {
|
|
735
708
|
_serviceContainer;
|
|
736
709
|
_echoClient;
|
|
@@ -745,30 +718,14 @@ var SpaceProxy = class extends Resource {
|
|
|
745
718
|
return this._id;
|
|
746
719
|
}
|
|
747
720
|
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
|
-
});
|
|
721
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 24, S: this, A: ["this._db", ""] });
|
|
757
722
|
return this._db;
|
|
758
723
|
}
|
|
759
724
|
/**
|
|
760
725
|
* @deprecated Use db API.
|
|
761
726
|
*/
|
|
762
727
|
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
|
-
});
|
|
728
|
+
invariant2(this._db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 30, S: this, A: ["this._db", ""] });
|
|
772
729
|
return this._db.coreDatabase;
|
|
773
730
|
}
|
|
774
731
|
get queues() {
|
|
@@ -792,7 +749,7 @@ var SpaceProxy = class extends Resource {
|
|
|
792
749
|
};
|
|
793
750
|
|
|
794
751
|
// src/functions-client.ts
|
|
795
|
-
var
|
|
752
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/functions-client.ts";
|
|
796
753
|
var FunctionsClient = class extends Resource2 {
|
|
797
754
|
_serviceContainer;
|
|
798
755
|
_echoClient;
|
|
@@ -800,24 +757,8 @@ var FunctionsClient = class extends Resource2 {
|
|
|
800
757
|
_spaces = /* @__PURE__ */ new Map();
|
|
801
758
|
constructor(services) {
|
|
802
759
|
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
|
-
});
|
|
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'"] });
|
|
821
762
|
this._serviceContainer = new ServiceContainer(this._executionContext, services.dataService, services.queueService, services.functionsAiService);
|
|
822
763
|
this._echoClient = new EchoClient({});
|
|
823
764
|
}
|
|
@@ -869,9 +810,9 @@ var FunctionRouteValue = /* @__PURE__ */ (function(FunctionRouteValue2) {
|
|
|
869
810
|
// src/wrap-handler-for-cloudflare.ts
|
|
870
811
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
871
812
|
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
872
|
-
import { log as
|
|
813
|
+
import { log as log4 } from "@dxos/log";
|
|
873
814
|
import { EdgeResponse } from "@dxos/protocols";
|
|
874
|
-
var
|
|
815
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/compute/functions-runtime-cloudflare/src/wrap-handler-for-cloudflare.ts";
|
|
875
816
|
var wrapHandlerForCloudflare = (func) => {
|
|
876
817
|
return async (request, env) => {
|
|
877
818
|
if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
|
|
@@ -893,15 +834,10 @@ var wrapHandlerForCloudflare = (func) => {
|
|
|
893
834
|
});
|
|
894
835
|
return EdgeResponse.success(await invokeFunction(func, context, request));
|
|
895
836
|
} catch (error) {
|
|
896
|
-
|
|
837
|
+
log4.error("error invoking function", {
|
|
897
838
|
error,
|
|
898
839
|
stack: error.stack
|
|
899
|
-
}, {
|
|
900
|
-
F: __dxlog_file5,
|
|
901
|
-
L: 44,
|
|
902
|
-
S: void 0,
|
|
903
|
-
C: (f, a) => f(...a)
|
|
904
|
-
});
|
|
840
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 37, S: void 0 });
|
|
905
841
|
return EdgeResponse.failure({
|
|
906
842
|
message: error?.message ?? "Internal error",
|
|
907
843
|
error
|
|
@@ -934,12 +870,7 @@ var decodeRequest = async (request) => {
|
|
|
934
870
|
}
|
|
935
871
|
};
|
|
936
872
|
} catch (err) {
|
|
937
|
-
|
|
938
|
-
F: __dxlog_file5,
|
|
939
|
-
L: 79,
|
|
940
|
-
S: void 0,
|
|
941
|
-
C: (f, a) => f(...a)
|
|
942
|
-
});
|
|
873
|
+
log4.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 76, S: void 0 });
|
|
943
874
|
return {
|
|
944
875
|
data: {
|
|
945
876
|
bodyText,
|
|
@@ -972,15 +903,7 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
972
903
|
throw new Error(`Space not found: ${contextSpaceId}`);
|
|
973
904
|
}
|
|
974
905
|
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
|
-
});
|
|
906
|
+
invariant4(!meta.rootDocumentId.startsWith("automerge:"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 109, S: void 0, A: ["!meta.rootDocumentId.startsWith('automerge:')", ""] });
|
|
984
907
|
rootUrl = `automerge:${meta.rootDocumentId}`;
|
|
985
908
|
}
|
|
986
909
|
return {
|
|
@@ -997,36 +920,40 @@ var createFunctionContext = async ({ serviceContainer, contextSpaceId }) => {
|
|
|
997
920
|
};
|
|
998
921
|
|
|
999
922
|
// src/logger.ts
|
|
1000
|
-
import { LogLevel, log as
|
|
923
|
+
import { LogLevel, log as log5, shouldLog } from "@dxos/log";
|
|
1001
924
|
var setupFunctionsLogger = () => {
|
|
1002
|
-
|
|
1003
|
-
|
|
925
|
+
log5.runtimeConfig.processors.length = 0;
|
|
926
|
+
log5.runtimeConfig.processors.push(functionLogProcessor);
|
|
1004
927
|
};
|
|
1005
928
|
var functionLogProcessor = (config, entry) => {
|
|
1006
929
|
if (!shouldLog(entry, config.filters)) {
|
|
1007
930
|
return;
|
|
1008
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);
|
|
1009
938
|
switch (entry.level) {
|
|
1010
939
|
case LogLevel.DEBUG:
|
|
1011
|
-
console.debug(entry.message, entry.context);
|
|
1012
|
-
break;
|
|
1013
940
|
case LogLevel.TRACE:
|
|
1014
|
-
console.debug(entry.message,
|
|
941
|
+
console.debug(entry.message, ...extras);
|
|
1015
942
|
break;
|
|
1016
943
|
case LogLevel.VERBOSE:
|
|
1017
|
-
console.log(entry.message,
|
|
944
|
+
console.log(entry.message, ...extras);
|
|
1018
945
|
break;
|
|
1019
946
|
case LogLevel.INFO:
|
|
1020
|
-
console.info(entry.message,
|
|
947
|
+
console.info(entry.message, ...extras);
|
|
1021
948
|
break;
|
|
1022
949
|
case LogLevel.WARN:
|
|
1023
|
-
console.warn(entry.message,
|
|
950
|
+
console.warn(entry.message, ...extras);
|
|
1024
951
|
break;
|
|
1025
952
|
case LogLevel.ERROR:
|
|
1026
|
-
console.error(entry.message,
|
|
953
|
+
console.error(entry.message, ...extras);
|
|
1027
954
|
break;
|
|
1028
955
|
default:
|
|
1029
|
-
console.log(entry.message,
|
|
956
|
+
console.log(entry.message, ...extras);
|
|
1030
957
|
break;
|
|
1031
958
|
}
|
|
1032
959
|
};
|
|
@@ -1036,6 +963,7 @@ export {
|
|
|
1036
963
|
FunctionsClient,
|
|
1037
964
|
ServiceContainer,
|
|
1038
965
|
createClientFromEnv,
|
|
966
|
+
createFunctionContext,
|
|
1039
967
|
setupFunctionsLogger,
|
|
1040
968
|
wrapHandlerForCloudflare
|
|
1041
969
|
};
|