@roc-db/in-memory 0.2.0-pre.100 → 0.2.0-pre.101

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.js CHANGED
@@ -26,7 +26,7 @@ __export(exports_functions, {
26
26
  pageEntitiesByIndex: () => pageEntitiesByIndex,
27
27
  pageEntities: () => pageEntities,
28
28
  getChangeSetMutations: () => getChangeSetMutations,
29
- findDebounceMutation: () => findDebounceMutation,
29
+ findRecentMutations: () => findRecentMutations,
30
30
  commit: () => commit,
31
31
  batchReadEntities: () => batchReadEntities
32
32
  });
@@ -150,18 +150,8 @@ var commit = (txn, mutation, { created, updated, deleted }) => {
150
150
  }
151
151
  return mutation;
152
152
  };
153
- // src/functions/findDebounceMutation.ts
154
- var findDebounceMutation = (request, engine, now, mutationName, identityRef) => {
155
- const debounceTime = request.operation.debounce;
156
- const thresholdTime = new Date(now.getTime() - debounceTime * 1000).toISOString();
157
- const payloadRef = request.payload?.ref;
158
- const res = engine.mutations.values().find((mutation) => {
159
- if (mutation.operation.name === mutationName && mutation.timestamp > thresholdTime && mutation.payload?.ref === payloadRef && (mutation.changeSetRef ?? null) === (request.changeSetRef ?? null) && mutation.identityRef === identityRef) {
160
- return true;
161
- }
162
- });
163
- return res;
164
- };
153
+ // src/functions/findRecentMutations.ts
154
+ var findRecentMutations = (engine, { changeSetRef, identityRef, since }) => engine.mutations.values().filter((mutation) => (mutation.timestamp > since || !!mutation.persistedAt && mutation.persistedAt > since) && ((mutation.changeSetRef ?? null) === changeSetRef || mutation.identityRef === identityRef)).toArray();
165
155
  // src/functions/getChangeSetMutations.ts
166
156
  var getChangeSetMutations = (txn, changeSetRef) => {
167
157
  if (!changeSetRef)
@@ -0,0 +1,3 @@
1
+ import type { FindRecentMutationsFunction } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const findRecentMutations: FindRecentMutationsFunction<InMemoryEngine>;
@@ -1,6 +1,6 @@
1
1
  export { batchReadEntities } from "./batchReadEntities";
2
2
  export { commit } from "./commit";
3
- export { findDebounceMutation } from "./findDebounceMutation";
3
+ export { findRecentMutations } from "./findRecentMutations";
4
4
  export { getChangeSetMutations } from "./getChangeSetMutations";
5
5
  export { pageEntities } from "./pageEntities";
6
6
  export { pageEntitiesByIndex } from "./pageEntitiesByIndex";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roc-db/in-memory",
3
- "version": "0.2.0-pre.100",
3
+ "version": "0.2.0-pre.101",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,3 +0,0 @@
1
- import type { FindDebounceMutationFunction } from "roc-db";
2
- import type { InMemoryEngine } from "../types/InMemoryEngine";
3
- export declare const findDebounceMutation: FindDebounceMutationFunction<InMemoryEngine>;