@lunora/testing 1.0.0-alpha.44 → 1.0.0-alpha.46
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/index.d.mts +247 -256
- package/dist/index.d.ts +247 -256
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{lunoraTest-DbzbUAGQ.mjs → lunoraTest-zjGOq924.mjs} +18 -4
- package/package.json +6 -6
|
@@ -2,7 +2,7 @@ import { runShardMigrations, createShardCtxDb } from '@lunora/do';
|
|
|
2
2
|
import { LunoraError } from '@lunora/errors';
|
|
3
3
|
import { DatabaseSync } from 'node:sqlite';
|
|
4
4
|
|
|
5
|
-
const createFakeScheduler = (getDispatch, getMutationContext, getFunctionRegistry, now) => {
|
|
5
|
+
const createFakeScheduler = (getDispatch, getMutationContext, getActionContext, getFunctionRegistry, now) => {
|
|
6
6
|
let nowMs = now;
|
|
7
7
|
let nextId = 1;
|
|
8
8
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -48,8 +48,8 @@ const createFakeScheduler = (getDispatch, getMutationContext, getFunctionRegistr
|
|
|
48
48
|
}
|
|
49
49
|
if (entry.kind === "mutation" || entry.kind === "action") {
|
|
50
50
|
const dispatch = getDispatch();
|
|
51
|
-
const
|
|
52
|
-
await dispatch(entry.kind, entry,
|
|
51
|
+
const context = entry.kind === "action" ? getActionContext() : getMutationContext();
|
|
52
|
+
await dispatch(entry.kind, entry, context, job.args);
|
|
53
53
|
} else {
|
|
54
54
|
console.warn(
|
|
55
55
|
`[fake-scheduler] functionPath "${job.functionPath}" is a ${entry.kind} — only mutations and actions can be scheduled; job ${job.id} dropped`
|
|
@@ -154,9 +154,12 @@ const stubProxy = (surface) => /* @__PURE__ */ new Proxy((..._args) => unavailab
|
|
|
154
154
|
const noopLog = {
|
|
155
155
|
debug: () => void 0,
|
|
156
156
|
error: () => void 0,
|
|
157
|
+
fatal: () => void 0,
|
|
157
158
|
info: () => void 0,
|
|
158
159
|
log: () => void 0,
|
|
159
|
-
|
|
160
|
+
trace: () => void 0,
|
|
161
|
+
warn: () => void 0,
|
|
162
|
+
with: () => noopLog
|
|
160
163
|
};
|
|
161
164
|
const buildSubscribe = (runRegistered, queryContext, mutationListeners) => {
|
|
162
165
|
const factory = (referenceOrInline, args) => {
|
|
@@ -324,6 +327,7 @@ const lunoraTest = (schema, options) => {
|
|
|
324
327
|
};
|
|
325
328
|
let scheduledDispatchRef;
|
|
326
329
|
let mutationContextRef;
|
|
330
|
+
let actionContextRef;
|
|
327
331
|
const harnessNow = options?.now ?? Date.now();
|
|
328
332
|
const { controls: schedulerControls, scheduler: fakeScheduler } = createFakeScheduler(
|
|
329
333
|
() => {
|
|
@@ -344,6 +348,15 @@ const lunoraTest = (schema, options) => {
|
|
|
344
348
|
}
|
|
345
349
|
return mutationContextRef;
|
|
346
350
|
},
|
|
351
|
+
() => {
|
|
352
|
+
if (actionContextRef === void 0) {
|
|
353
|
+
throw new LunoraError(
|
|
354
|
+
"INTERNAL",
|
|
355
|
+
"[fake-scheduler] actionContext not yet available — scheduler.advance called before harness construction completed"
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
return actionContextRef;
|
|
359
|
+
},
|
|
347
360
|
() => functionRegistryMap,
|
|
348
361
|
harnessNow
|
|
349
362
|
);
|
|
@@ -403,6 +416,7 @@ const lunoraTest = (schema, options) => {
|
|
|
403
416
|
vectors: stubProxy("vectors"),
|
|
404
417
|
workflows: stubProxy("workflows")
|
|
405
418
|
};
|
|
419
|
+
actionContextRef ??= actionContext;
|
|
406
420
|
const runRegistered = (expected, reference, context, args, allowInternal) => {
|
|
407
421
|
const kind = registeredFunctionKind(reference);
|
|
408
422
|
if (kind !== expected) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/testing",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.46",
|
|
4
4
|
"description": "Testing toolkit for Lunora: an in-memory harness for queries, mutations, and actions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/agent": "1.0.0-alpha.
|
|
50
|
-
"@lunora/do": "1.0.0-alpha.
|
|
51
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
52
|
-
"@lunora/mail": "1.0.0-alpha.
|
|
53
|
-
"@lunora/server": "1.0.0-alpha.
|
|
49
|
+
"@lunora/agent": "1.0.0-alpha.5",
|
|
50
|
+
"@lunora/do": "1.0.0-alpha.34",
|
|
51
|
+
"@lunora/errors": "1.0.0-alpha.6",
|
|
52
|
+
"@lunora/mail": "1.0.0-alpha.16",
|
|
53
|
+
"@lunora/server": "1.0.0-alpha.28"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": "^22.15.0 || >=24.11.0"
|