@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 +4 -12
- package/dist/types/createInMemoryAdapter.d.ts +2 -7
- package/dist/types/functions/batchReadEntities.d.ts +3 -2
- package/dist/types/functions/commit.d.ts +3 -6
- package/dist/types/functions/findDebounceMutation.d.ts +2 -2
- package/dist/types/functions/getChangeSetMutations.d.ts +3 -1
- package/dist/types/functions/pageEntities.d.ts +3 -1
- package/dist/types/functions/pageEntitiesByIndex.d.ts +3 -1
- package/dist/types/functions/pageMutations.d.ts +2 -6
- package/dist/types/functions/readEntity.d.ts +3 -2
- package/dist/types/functions/readMutation.d.ts +3 -1
- package/dist/types/functions/refByUniqueField.d.ts +3 -1
- package/dist/types/functions/saveMutation.d.ts +3 -2
- package/dist/types/types/InMemoryEngine.d.ts +4 -2
- package/package.json +7 -3
- package/dist/types/types/InMemoryWriteTransaction.d.ts +0 -3
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.__
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
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 {
|
|
1
|
+
import type { FindDebounceMutationFunction } from "roc-db";
|
|
2
2
|
import type { InMemoryEngine } from "../types/InMemoryEngine";
|
|
3
|
-
export declare const findDebounceMutation:
|
|
3
|
+
export declare const findDebounceMutation: FindDebounceMutationFunction<InMemoryEngine>;
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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 {
|
|
1
|
+
import type { PageMutationsFunction } from "roc-db";
|
|
2
2
|
import type { InMemoryEngine } from "../types/InMemoryEngine";
|
|
3
|
-
export declare const pageMutations:
|
|
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 {
|
|
2
|
-
|
|
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
|
-
|
|
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 {
|
|
2
|
-
|
|
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 {
|
|
1
|
+
import type { EntityDocument, Mutation, Ref } from "roc-db";
|
|
2
2
|
export type InMemoryEngine = {
|
|
3
|
-
entities: Map<Ref,
|
|
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.
|
|
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
|
}
|