@absolutejs/sync 1.9.2 → 1.11.0
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/codeMode.d.ts +175 -0
- package/dist/codeMode.js +84 -0
- package/dist/codeMode.js.map +10 -0
- package/dist/engine/devtools.d.ts +9 -0
- package/dist/engine/index.js +50 -1
- package/dist/engine/index.js.map +3 -3
- package/dist/engine/syncEngine.d.ts +22 -0
- package/dist/index.js +50 -1
- package/dist/index.js.map +3 -3
- package/dist/testing.js +50 -1
- package/dist/testing.js.map +3 -3
- package/package.json +6 -1
package/dist/testing.js
CHANGED
|
@@ -1643,6 +1643,55 @@ var createSyncEngine = (options = {}) => {
|
|
|
1643
1643
|
}
|
|
1644
1644
|
throw lastError;
|
|
1645
1645
|
},
|
|
1646
|
+
runMutations: async (specs, ctx) => {
|
|
1647
|
+
if (specs.length === 0)
|
|
1648
|
+
return [];
|
|
1649
|
+
const resolved = specs.map((spec) => {
|
|
1650
|
+
const mutation = mutations.get(spec.name);
|
|
1651
|
+
if (mutation === undefined) {
|
|
1652
|
+
throw new Error(`Unknown mutation "${spec.name}"`);
|
|
1653
|
+
}
|
|
1654
|
+
return { args: spec.args, mutation, name: spec.name };
|
|
1655
|
+
});
|
|
1656
|
+
const runBatch = async (tx) => {
|
|
1657
|
+
const results = [];
|
|
1658
|
+
const accumulated = [];
|
|
1659
|
+
for (const { args, mutation, name } of resolved) {
|
|
1660
|
+
if (mutation.authorize !== undefined) {
|
|
1661
|
+
const allowed = await mutation.authorize(args, ctx);
|
|
1662
|
+
if (!allowed) {
|
|
1663
|
+
throw new UnauthorizedError(`run mutation "${name}"`);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
const sandboxRunner = sandboxRunners.get(name);
|
|
1667
|
+
const invokeHandler = sandboxRunner !== undefined ? sandboxRunner : (a, c, actions2) => Promise.resolve(mutation.handler(a, c, actions2));
|
|
1668
|
+
const { actions, buffered } = makeActions(tx, ctx, true);
|
|
1669
|
+
const result = await invokeHandler(args, ctx, actions);
|
|
1670
|
+
results.push(result);
|
|
1671
|
+
accumulated.push(...buffered);
|
|
1672
|
+
}
|
|
1673
|
+
return { accumulated, results };
|
|
1674
|
+
};
|
|
1675
|
+
try {
|
|
1676
|
+
const { accumulated, results } = runInTransaction !== undefined ? await runInTransaction((tx) => runBatch(tx)) : await runBatch(undefined);
|
|
1677
|
+
await applyChangeBatch(accumulated);
|
|
1678
|
+
emitActivity({
|
|
1679
|
+
type: "mutationBatch",
|
|
1680
|
+
at: Date.now(),
|
|
1681
|
+
names: resolved.map((entry) => entry.name),
|
|
1682
|
+
status: "ok"
|
|
1683
|
+
});
|
|
1684
|
+
return results;
|
|
1685
|
+
} catch (error) {
|
|
1686
|
+
emitActivity({
|
|
1687
|
+
type: "mutationBatch",
|
|
1688
|
+
at: Date.now(),
|
|
1689
|
+
names: resolved.map((entry) => entry.name),
|
|
1690
|
+
status: "error"
|
|
1691
|
+
});
|
|
1692
|
+
throw error;
|
|
1693
|
+
}
|
|
1694
|
+
},
|
|
1646
1695
|
registerSchedule: (schedule) => {
|
|
1647
1696
|
schedules.set(schedule.name, schedule);
|
|
1648
1697
|
},
|
|
@@ -1934,5 +1983,5 @@ export {
|
|
|
1934
1983
|
createTestEngine
|
|
1935
1984
|
};
|
|
1936
1985
|
|
|
1937
|
-
//# debugId=
|
|
1986
|
+
//# debugId=9F4EC6AAC3FF690364756E2164756E21
|
|
1938
1987
|
//# sourceMappingURL=testing.js.map
|