@roc-db/in-memory 0.2.0-pre.6 → 0.2.0-pre.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/index.js CHANGED
@@ -29,14 +29,14 @@ __export(exports_functions, {
29
29
  });
30
30
 
31
31
  // src/functions/begin.ts
32
- var begin = (request, engineOpts) => {
33
- return {
32
+ var begin = (request, engineOpts, callback) => {
33
+ return callback({
34
34
  ...engineOpts,
35
35
  changeSet: request.changeSetRef ? {
36
36
  entities: new Map([]),
37
37
  mutations: new Map([])
38
38
  } : null
39
- };
39
+ });
40
40
  };
41
41
  // src/functions/createEntity.ts
42
42
  import { entityFromRef } from "roc-db";
@@ -115,8 +115,25 @@ var findDebounceMutation = (request, engine, now) => {
115
115
  return res;
116
116
  };
117
117
  // src/functions/pageMutations.ts
118
- var pageMutations = (txn, { size = 30, skip = 0 } = {}) => {
119
- return txn.engineOpts.mutations.values().drop(skip).take(size).toArray();
118
+ var pageMutations = (txn, {
119
+ size = 30,
120
+ skip = 0,
121
+ changeSetRef
122
+ } = {}) => {
123
+ const res = [];
124
+ const iterator = txn.engineOpts.mutations.values().drop(skip);
125
+ let next = iterator.next();
126
+ while (!next.done && res.length < size) {
127
+ if (changeSetRef) {
128
+ if (next.value.changeSetRef === changeSetRef) {
129
+ res.push(next.value);
130
+ }
131
+ } else {
132
+ res.push(next.value);
133
+ }
134
+ next = iterator.next();
135
+ }
136
+ return res;
120
137
  };
121
138
  // src/functions/patchEntity.ts
122
139
  import { deepPatch, NotFoundError } from "roc-db";
@@ -0,0 +1,11 @@
1
+ import { Snowflake, type Adapter, type Operation } 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, }: {
7
+ operations: Operations;
8
+ entities: Entities;
9
+ snowflake?: Snowflake;
10
+ }) => Adapter;
11
+ export {};
@@ -0,0 +1 @@
1
+ export declare const begin: (request: any, engineOpts: any, callback: any) => any;
@@ -0,0 +1,24 @@
1
+ import { type Ref } from "roc-db";
2
+ import type { InMemoryWriteTransaction } from "../types/InMemoryWriteTransaction";
3
+ export declare const createEntity: (txn: InMemoryWriteTransaction, ref: Ref, { data, indexedData, children, parents, ancestors, }: {
4
+ data?: {} | undefined;
5
+ indexedData?: {} | undefined;
6
+ children?: {} | undefined;
7
+ parents?: {} | undefined;
8
+ ancestors?: {} | undefined;
9
+ }) => {
10
+ ref: `${string}/${string}`;
11
+ entity: string;
12
+ created: {
13
+ timestamp: any;
14
+ mutationRef: any;
15
+ };
16
+ updated: {
17
+ timestamp: any;
18
+ mutationRef: any;
19
+ };
20
+ data: {};
21
+ children: {};
22
+ parents: {};
23
+ ancestors: {};
24
+ };
@@ -0,0 +1 @@
1
+ export declare const deleteEntity: (txn: any, ref: any) => boolean;
@@ -0,0 +1,3 @@
1
+ import type { WriteOperation } from "roc-db";
2
+ import type { InMemoryEngine } from "../types/InMemoryEngine";
3
+ export declare const findDebounceMutation: (request: WriteOperation, engine: InMemoryEngine, now: any) => import("roc-db").Mutation | undefined;
@@ -0,0 +1 @@
1
+ export declare const getChangeSetMutations: (txn: any, changeSetRef: any) => any[];
@@ -0,0 +1,11 @@
1
+ export { begin } from "./begin";
2
+ export { createEntity } from "./createEntity";
3
+ export { deleteEntity } from "./deleteEntity";
4
+ export { getChangeSetMutations } from "./getChangeSetMutations";
5
+ export { findDebounceMutation } from "./findDebounceMutation";
6
+ export { pageMutations } from "./pageMutations";
7
+ export { patchEntity } from "./patchEntity";
8
+ export { readEntity } from "./readEntity";
9
+ export { readMutation } from "./readMutation";
10
+ export { saveMutation } from "./saveMutation";
11
+ export { updateEntity } from "./updateEntity";
@@ -0,0 +1,7 @@
1
+ import type { ReadTransaction } from "roc-db";
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
+ }) => import("roc-db").Mutation[];
@@ -0,0 +1,6 @@
1
+ export declare const patchEntity: (txn: any, ref: any, { data, children, parents, ancestors }: {
2
+ data?: {} | undefined;
3
+ children?: {} | undefined;
4
+ parents?: {} | undefined;
5
+ ancestors?: {} | undefined;
6
+ }) => any;
@@ -0,0 +1 @@
1
+ export declare const readEntity: (txn: any, ref: any) => any;
@@ -0,0 +1 @@
1
+ export declare const readMutation: (engineOpts: any, ref: any) => any;
@@ -0,0 +1,2 @@
1
+ import type { InMemoryWriteTransaction } from "../types/InMemoryWriteTransaction";
2
+ export declare const saveMutation: (txn: InMemoryWriteTransaction, finalizedMutation: any) => any;
@@ -0,0 +1,6 @@
1
+ export declare const updateEntity: (txn: any, ref: any, { data, children, parents, ancestors }: {
2
+ data?: {} | undefined;
3
+ children?: {} | undefined;
4
+ parents?: {} | undefined;
5
+ ancestors?: {} | undefined;
6
+ }) => any;
@@ -0,0 +1 @@
1
+ export { createInMemoryAdapter } from "./createInMemoryAdapter";
@@ -0,0 +1,5 @@
1
+ import type { Entity, Ref, Mutation } from "roc-db";
2
+ export type InMemoryEngine = {
3
+ entities: Map<Ref, Entity>;
4
+ mutations: Map<Ref, Mutation>;
5
+ };
@@ -0,0 +1,3 @@
1
+ import type { WriteTransaction } from "roc-db";
2
+ import type { InMemoryEngine } from "./InMemoryEngine";
3
+ export type InMemoryWriteTransaction = WriteTransaction<any, InMemoryEngine, any, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roc-db/in-memory",
3
- "version": "0.2.0-pre.6",
3
+ "version": "0.2.0-pre.7",
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.6",
16
+ "roc-db": "0.2.0-pre.7",
17
17
  "zod": "3.24.2"
18
18
  },
19
19
  "keywords": [],