@concavejs/core 0.0.1-alpha.5 → 0.0.1-alpha.7
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/dist/auth/jwt.d.ts +5 -0
- package/dist/auth/jwt.js +37 -5
- package/dist/http/api-router.d.ts +3 -1
- package/dist/http/api-router.js +62 -15
- package/dist/http/http-handler.js +53 -4
- package/dist/interfaces/execution-context.d.ts +2 -1
- package/dist/kernel/blob-store-gateway.js +7 -7
- package/dist/kernel/context-storage.js +6 -0
- package/dist/kernel/syscalls/action-syscalls.js +4 -6
- package/dist/kernel/syscalls/database-syscalls.js +1 -1
- package/dist/kernel/syscalls/js-router.d.ts +2 -2
- package/dist/kernel/syscalls/kernel-syscalls.d.ts +1 -1
- package/dist/kernel/syscalls/query-syscalls.js +2 -2
- package/dist/kernel/syscalls/router.d.ts +3 -2
- package/dist/kernel/syscalls/utils.d.ts +3 -3
- package/dist/kernel/syscalls/utils.js +3 -2
- package/dist/queryengine/developer-id.d.ts +8 -0
- package/dist/queryengine/developer-id.js +23 -2
- package/dist/router/router.d.ts +8 -3
- package/dist/runtime/runtime-context.d.ts +1 -1
- package/dist/scheduler/cron-executor.d.ts +6 -2
- package/dist/scheduler/cron-executor.js +54 -26
- package/dist/scheduler/scheduled-function-executor.d.ts +6 -2
- package/dist/scheduler/scheduled-function-executor.js +58 -36
- package/dist/sync/protocol-handler.d.ts +25 -0
- package/dist/sync/protocol-handler.js +111 -1
- package/dist/transactor/occ-transaction.js +3 -3
- package/dist/udf/execution-adapter.d.ts +1 -1
- package/dist/udf/execution-adapter.js +2 -2
- package/dist/udf/executor/inline.d.ts +1 -1
- package/dist/udf/executor/inline.js +3 -3
- package/dist/udf/executor/interface.d.ts +5 -2
- package/dist/udf/runtime/udf-setup.d.ts +4 -4
- package/dist/udf/runtime/udf-setup.js +11 -9
- package/dist/utils/long.d.ts +1 -1
- package/package.json +1 -1
|
@@ -68,9 +68,9 @@ function patchGlobals() {
|
|
|
68
68
|
globalThis.Date.now = udfDateNow;
|
|
69
69
|
globalThis.fetch = udfFetch;
|
|
70
70
|
globalThis.Math.random = udfMathRandom;
|
|
71
|
-
globalThis.setInterval = udfSetInterval;
|
|
72
|
-
globalThis.setTimeout = udfSetTimeout;
|
|
73
71
|
const globalAny = globalThis;
|
|
72
|
+
globalAny.setInterval = udfSetInterval;
|
|
73
|
+
globalAny.setTimeout = udfSetTimeout;
|
|
74
74
|
globalAny.crypto.randomUUID = udfCryptoRandomUUID;
|
|
75
75
|
globalAny.crypto.getRandomValues = udfCryptoGetRandomValues;
|
|
76
76
|
globalAny.console = udfConsole;
|
|
@@ -116,7 +116,7 @@ class ForbiddenInQueriesOrMutations extends Error {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
async function runUdfAndGetLogs(docstore, fn, ops, auth, // Still accept for backwards compatibility, but prefer ambient context
|
|
119
|
-
udfType, storage, deterministicSeed, mutationTransaction, udfExecutor, componentPath) {
|
|
119
|
+
udfType, storage, deterministicSeed, mutationTransaction, udfExecutor, componentPath, snapshotOverride) {
|
|
120
120
|
// Get auth from ambient context (set by execution adapter) or fallback to explicit param
|
|
121
121
|
const ambientIdentity = getAuthContext();
|
|
122
122
|
let effectiveAuth;
|
|
@@ -133,7 +133,7 @@ udfType, storage, deterministicSeed, mutationTransaction, udfExecutor, component
|
|
|
133
133
|
const inheritedSnapshot = snapshotContext.getStore() ?? null;
|
|
134
134
|
const existingIdGenerator = idGeneratorContext.getStore() ?? undefined;
|
|
135
135
|
const idGenerator = existingIdGenerator ?? (deterministicSeed ? createDeterministicIdGenerator(deterministicSeed) : undefined);
|
|
136
|
-
const convex = new UdfKernel(docstore, effectiveAuth, storage, inheritedSnapshot, mutationTransaction, udfExecutor, componentPath, idGenerator);
|
|
136
|
+
const convex = new UdfKernel(docstore, effectiveAuth, storage, snapshotOverride ?? inheritedSnapshot, mutationTransaction, udfExecutor, componentPath, idGenerator);
|
|
137
137
|
convex.clearAccessLogs();
|
|
138
138
|
const logLines = [];
|
|
139
139
|
const logger = (level) => {
|
|
@@ -196,7 +196,7 @@ udfType, storage, deterministicSeed, mutationTransaction, udfExecutor, component
|
|
|
196
196
|
// Globals are unpatched in runWithUdfRuntime
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
export function runUdfQuery(docstore, fn, auth, storage, requestId, udfExecutor, componentPath) {
|
|
199
|
+
export function runUdfQuery(docstore, fn, auth, storage, requestId, udfExecutor, componentPath, snapshotOverride) {
|
|
200
200
|
const tnow = Date.now();
|
|
201
201
|
const seed = resolveSeed("query", requestId, tnow);
|
|
202
202
|
const rng = udfRng(seed);
|
|
@@ -210,7 +210,7 @@ export function runUdfQuery(docstore, fn, auth, storage, requestId, udfExecutor,
|
|
|
210
210
|
fetch: forbiddenAsyncOp("fetch"),
|
|
211
211
|
setInterval: forbiddenAsyncOp("setInterval"),
|
|
212
212
|
setTimeout: forbiddenAsyncOp("setTimeout"),
|
|
213
|
-
}, auth, "query", storage, seed, undefined, udfExecutor, componentPath);
|
|
213
|
+
}, auth, "query", storage, seed, undefined, udfExecutor, componentPath, snapshotOverride);
|
|
214
214
|
}
|
|
215
215
|
export function runUdfMutation(docstore, fn, auth, storage, requestId, udfExecutor, componentPath) {
|
|
216
216
|
const tnow = Date.now();
|
|
@@ -274,9 +274,11 @@ export function runUdfMutation(docstore, fn, auth, storage, requestId, udfExecut
|
|
|
274
274
|
// execute within the same transaction scope
|
|
275
275
|
const existingIdGenerator = idGeneratorContext.getStore();
|
|
276
276
|
const idGenerator = existingIdGenerator ?? createDeterministicIdGenerator(seed);
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
// ContextStorage.run returns R (UdfResult here) but in practice the async
|
|
278
|
+
// callback produces a Promise<UdfResult>. We need to attach a .catch for
|
|
279
|
+
// savepoint rollback, so cast to the runtime-accurate Promise type.
|
|
280
|
+
const nestedResult = transactionContext.run(parentTransaction, () => idGeneratorContext.run(idGenerator, () => runUdfAndGetLogs(docstore, fn, ops, auth, "mutation", storage, seed, parentTransaction, udfExecutor, componentPath)));
|
|
281
|
+
return nestedResult.catch((error) => {
|
|
280
282
|
parentTransaction.restoreSavepoint(savepoint);
|
|
281
283
|
throw error;
|
|
282
284
|
});
|
package/dist/utils/long.d.ts
CHANGED