@roc-db/in-memory 0.2.0-pre.98 → 0.2.0-pre.99

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
@@ -55,11 +55,7 @@ var findAddedAndRemovedEntries = (oldArr, newArr) => {
55
55
  const added = oldArr?.filter(([k1, v1]) => !newArr.some(([k2, v2]) => k1 === k2 && v1 === v2));
56
56
  return [added, removed];
57
57
  };
58
- var commit = (txn, mutation, {
59
- created,
60
- updated,
61
- deleted
62
- }) => {
58
+ var commit = (txn, mutation, { created, updated, deleted }) => {
63
59
  const { mutations } = txn.engineOpts;
64
60
  const currentMutation = mutations.get(txn.mutation.ref);
65
61
  if (currentMutation) {
@@ -157,7 +153,7 @@ var commit = (txn, mutation, {
157
153
  // src/functions/findDebounceMutation.ts
158
154
  var findDebounceMutation = (request, engine, now, mutationName, identityRef) => {
159
155
  const debounceTime = request.operation.debounce;
160
- const thresholdTime = new Date(now - debounceTime * 1000).toISOString();
156
+ const thresholdTime = new Date(now.getTime() - debounceTime * 1000).toISOString();
161
157
  const payloadRef = request.payload?.ref;
162
158
  const res = engine.mutations.values().find((mutation) => {
163
159
  if (mutation.operation.name === mutationName && mutation.timestamp > thresholdTime && mutation.payload?.ref === payloadRef && mutation.identityRef === identityRef) {
@@ -190,7 +186,7 @@ var pageEntities = (txn, args) => {
190
186
  continue;
191
187
  } else {
192
188
  if (childrenOf && childrenOf.length > 0) {
193
- if (!childrenOf.some((childRef) => doc.__.parentRefs.includes(childRef))) {
189
+ if (!childrenOf.some((childRef) => doc.__?.parentRefs?.includes(childRef))) {
194
190
  continue;
195
191
  }
196
192
  }
@@ -207,11 +203,7 @@ var pageEntitiesByIndex = (txn, entity, field, value) => {
207
203
  return refs.map((ref) => txn.engineOpts.entities.get(ref));
208
204
  };
209
205
  // src/functions/pageMutations.ts
210
- var pageMutations = (txn, {
211
- size = 30,
212
- skip = 0,
213
- changeSetRef
214
- } = {}) => {
206
+ var pageMutations = (txn, { size = 30, skip = 0, changeSetRef } = {}) => {
215
207
  const res = [];
216
208
  const iterator = txn.engineOpts.mutations.values().drop(skip);
217
209
  let next = iterator.next();
@@ -1,9 +1,5 @@
1
- import { Snowflake, type Adapter, type Operation, type Session } from "roc-db";
2
- import type { z } from "zod";
3
- type Entity = z.ZodObject<{
4
- entity: z.ZodLiteral<string>;
5
- }>;
6
- export declare const createInMemoryAdapter: <const Name extends string, const Operations extends readonly Operation[], const Entities extends readonly Entity[]>({ operations, entities, snowflake, optimistic, session, engine, }: {
1
+ import { Snowflake, type Adapter, type Entity, type Operation, type Session } from "roc-db";
2
+ export declare const createInMemoryAdapter: <const Name extends string, const Operations extends readonly Operation[], const Entities extends readonly Entity<any>[]>({ operations, entities, snowflake, optimistic, session, engine, }: {
7
3
  operations: Operations;
8
4
  entities: Entities;
9
5
  snowflake?: Snowflake;
@@ -16,4 +12,3 @@ export declare const createInMemoryAdapter: <const Name extends string, const Op
16
12
  entitiesIndex: Map<string, any>;
17
13
  };
18
14
  }) => Adapter;
19
- export {};
@@ -1,2 +1,3 @@
1
- import type { Ref } from "roc-db";
2
- export declare const batchReadEntities: (txn: any, refs: Ref[]) => any[];
1
+ import type { Ref, Transaction } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const batchReadEntities: (txn: Transaction<InMemoryEngine>, refs: Ref[]) => any[];
@@ -1,6 +1,3 @@
1
- import { type Entity, type Mutation, type Ref, type WriteTransaction } from "roc-db";
2
- export declare const commit: (txn: WriteTransaction, mutation: Mutation, { created, updated, deleted, }: {
3
- created: Entity[];
4
- updated: Entity[];
5
- deleted: Ref[];
6
- }) => Mutation;
1
+ import { type CommitFunction } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const commit: CommitFunction<InMemoryEngine>;
@@ -1,3 +1,3 @@
1
- import type { WriteRequest } from "roc-db";
1
+ import type { FindDebounceMutationFunction } from "roc-db";
2
2
  import type { InMemoryEngine } from "../types/InMemoryEngine";
3
- export declare const findDebounceMutation: (request: WriteRequest, engine: InMemoryEngine, now: number, mutationName: string, identityRef: string) => import("roc-db").Mutation | undefined;
3
+ export declare const findDebounceMutation: FindDebounceMutationFunction<InMemoryEngine>;
@@ -1 +1,3 @@
1
- export declare const getChangeSetMutations: (txn: any, changeSetRef: any) => any[];
1
+ import type { GetChangeSetMutationsFunction } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const getChangeSetMutations: GetChangeSetMutationsFunction<InMemoryEngine>;
@@ -1 +1,3 @@
1
- export declare const pageEntities: (txn: any, args: any) => any[];
1
+ import type { PageEntitiesFunction } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const pageEntities: PageEntitiesFunction<InMemoryEngine>;
@@ -1 +1,3 @@
1
- export declare const pageEntitiesByIndex: (txn: any, entity: any, field: any, value: any) => any;
1
+ import type { PageEntitiesByIndexFunction } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const pageEntitiesByIndex: PageEntitiesByIndexFunction<InMemoryEngine>;
@@ -1,7 +1,3 @@
1
- import type { ReadTransaction } from "roc-db";
1
+ import type { PageMutationsFunction } from "roc-db";
2
2
  import type { InMemoryEngine } from "../types/InMemoryEngine";
3
- export declare const pageMutations: (txn: ReadTransaction<any, InMemoryEngine, any, any>, { size, skip, changeSetRef, }?: {
4
- size?: number;
5
- skip?: number;
6
- changeSetRef?: string;
7
- }) => any[];
3
+ export declare const pageMutations: PageMutationsFunction<InMemoryEngine>;
@@ -1,2 +1,3 @@
1
- import type { Ref, Transaction } from "roc-db";
2
- export declare const readEntity: (txn: Transaction, ref: Ref) => any;
1
+ import type { ReadEntityFunctiun } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const readEntity: ReadEntityFunctiun<InMemoryEngine>;
@@ -1 +1,3 @@
1
- export declare const readMutation: (engineOpts: any, ref: any) => any;
1
+ import type { ReadMutationFunction } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const readMutation: ReadMutationFunction<InMemoryEngine>;
@@ -1 +1,3 @@
1
- export declare const refByUniqueField: (txn: WriteTransaction, entity: string, field: string, fieldIndex: number, value: any) => any;
1
+ import type { RefByUniqueFieldFunction } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const refByUniqueField: RefByUniqueFieldFunction<InMemoryEngine>;
@@ -1,2 +1,3 @@
1
- import type { InMemoryWriteTransaction } from "../types/InMemoryWriteTransaction";
2
- export declare const saveMutation: (txn: InMemoryWriteTransaction, finalizedMutation: any) => any;
1
+ import type { SaveMutationFunction } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const saveMutation: SaveMutationFunction<InMemoryEngine>;
@@ -1,5 +1,7 @@
1
- import type { Entity, Ref, Mutation } from "roc-db";
1
+ import type { EntityDocument, Mutation, Ref } from "roc-db";
2
2
  export type InMemoryEngine = {
3
- entities: Map<Ref, Entity>;
3
+ entities: Map<Ref, EntityDocument>;
4
4
  mutations: Map<Ref, Mutation>;
5
+ entitiesUnique: Map<string, Ref>;
6
+ entitiesIndex: Map<string, Ref[]>;
5
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roc-db/in-memory",
3
- "version": "0.2.0-pre.98",
3
+ "version": "0.2.0-pre.99",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "sideEffects": false,
15
15
  "peerDependencies": {
16
- "roc-db": "0.2.0-pre.98",
16
+ "roc-db": ">=0.2.0-pre.98 <1.0.0",
17
17
  "zod": ">=4.0.0"
18
18
  },
19
19
  "keywords": [],
@@ -22,5 +22,9 @@
22
22
  "type": "git",
23
23
  "url": "git+https://github.com/eigilsagafos/roc-db.git"
24
24
  },
25
- "license": "MIT"
25
+ "license": "MIT",
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "registry": "https://registry.npmjs.org/"
29
+ }
26
30
  }
@@ -1,3 +0,0 @@
1
- import type { WriteTransaction } from "roc-db";
2
- import type { InMemoryEngine } from "./InMemoryEngine";
3
- export type InMemoryWriteTransaction = WriteTransaction<any, InMemoryEngine, any, any>;