@roc-db/in-memory 0.2.0-pre.2 → 0.2.0-pre.20

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";
@@ -195,14 +212,16 @@ var updateEntity = (txn, ref, { data = {}, children = {}, parents = {}, ancestor
195
212
  var createInMemoryAdapter = ({
196
213
  operations,
197
214
  entities,
198
- snowflake = new Snowflake(1, 1)
215
+ snowflake = new Snowflake(1, 1),
216
+ session
199
217
  }) => {
200
218
  return createAdapter({
201
219
  name: "in-memory",
202
220
  operations,
203
221
  entities,
204
222
  functions: exports_functions,
205
- snowflake
223
+ snowflake,
224
+ session
206
225
  }, {
207
226
  entities: new Map,
208
227
  mutations: new Map
@@ -3,7 +3,7 @@ import type { z } from "zod";
3
3
  type Entity = z.ZodObject<{
4
4
  entity: z.ZodLiteral<string>;
5
5
  }>;
6
- export declare const createInMemoryAdapter: <const Name extends string, const Operations extends readonly Operation[], const Entities extends readonly Entity[]>({ operations, entities, snowflake, }: {
6
+ export declare const createInMemoryAdapter: <const Name extends string, const Operations extends readonly Operation[], const Entities extends readonly Entity[]>({ operations, entities, snowflake, session, }: {
7
7
  operations: Operations;
8
8
  entities: Entities;
9
9
  snowflake?: Snowflake;
@@ -1 +1 @@
1
- export declare const begin: (request: any, engineOpts: any) => any;
1
+ export declare const begin: (request: any, engineOpts: any, callback: any) => any;
@@ -1,6 +1,7 @@
1
1
  import type { ReadTransaction } from "roc-db";
2
2
  import type { InMemoryEngine } from "../types/InMemoryEngine";
3
- export declare const pageMutations: (txn: ReadTransaction<any, InMemoryEngine, any, any>, { size, skip }?: {
3
+ export declare const pageMutations: (txn: ReadTransaction<any, InMemoryEngine, any, any>, { size, skip, changeSetRef, }?: {
4
4
  size?: number;
5
5
  skip?: number;
6
+ changeSetRef?: string;
6
7
  }) => import("roc-db").Mutation[];
package/package.json CHANGED
@@ -1,27 +1,20 @@
1
1
  {
2
2
  "name": "@roc-db/in-memory",
3
- "version": "0.2.0-pre.2",
3
+ "version": "0.2.0-pre.20",
4
4
  "type": "module",
5
5
  "exports": {
6
- ".": "./src/index.ts"
6
+ ".": {
7
+ "import": "./dist/index.js",
8
+ "types": "./dist/types/index.d.ts"
9
+ }
7
10
  },
8
11
  "files": [
9
12
  "dist"
10
13
  ],
11
14
  "sideEffects": false,
12
- "scripts": {
13
- "build": "NODE_ENV=production bun run scripts/build.ts",
14
- "build:types": "rm -rf dist/types && bun run tsc --noCheck",
15
- "test": "bun test"
16
- },
17
- "devDependencies": {
18
- "@roc-db/test-utils": "0.2.0-pre.2",
19
- "roc-db": "0.2.0-pre.2",
20
- "zod": "3.24.2"
21
- },
22
15
  "peerDependencies": {
23
- "roc-db": "0.2.0-pre.2",
24
- "zod": "3.24.2"
16
+ "roc-db": "0.2.0-pre.20",
17
+ "zod": "^3.0.0"
25
18
  },
26
19
  "keywords": [],
27
20
  "author": "Eigil Sagafos",