@roc-db/in-memory 0.2.0-pre.96 → 0.2.0-pre.98
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
|
@@ -76,6 +76,9 @@ var commit = (txn, mutation, {
|
|
|
76
76
|
if (txn.request.changeSetRef)
|
|
77
77
|
return mutation;
|
|
78
78
|
for (const doc of created) {
|
|
79
|
+
if (txn.adapter.models?.[doc.entity]?.singleton && txn.engineOpts.entities.has(doc.ref)) {
|
|
80
|
+
throw createUniqueConstraintConflictError(doc.entity);
|
|
81
|
+
}
|
|
79
82
|
if (doc.__.unique?.length) {
|
|
80
83
|
doc.__.unique.forEach(([key, value]) => {
|
|
81
84
|
const uniqueKey = `${doc.entity}:${key}:${JSON.stringify(value)}`;
|
|
@@ -152,11 +155,12 @@ var commit = (txn, mutation, {
|
|
|
152
155
|
return mutation;
|
|
153
156
|
};
|
|
154
157
|
// src/functions/findDebounceMutation.ts
|
|
155
|
-
var findDebounceMutation = (request, engine, now, mutationName) => {
|
|
158
|
+
var findDebounceMutation = (request, engine, now, mutationName, identityRef) => {
|
|
156
159
|
const debounceTime = request.operation.debounce;
|
|
157
160
|
const thresholdTime = new Date(now - debounceTime * 1000).toISOString();
|
|
161
|
+
const payloadRef = request.payload?.ref;
|
|
158
162
|
const res = engine.mutations.values().find((mutation) => {
|
|
159
|
-
if (mutation.operation.name === mutationName && mutation.timestamp > thresholdTime && mutation.payload
|
|
163
|
+
if (mutation.operation.name === mutationName && mutation.timestamp > thresholdTime && mutation.payload?.ref === payloadRef && mutation.identityRef === identityRef) {
|
|
160
164
|
return true;
|
|
161
165
|
}
|
|
162
166
|
});
|
|
@@ -241,7 +245,8 @@ var createInMemoryAdapter = ({
|
|
|
241
245
|
entities,
|
|
242
246
|
snowflake = new Snowflake(1, 1),
|
|
243
247
|
optimistic = true,
|
|
244
|
-
session
|
|
248
|
+
session,
|
|
249
|
+
engine
|
|
245
250
|
}) => {
|
|
246
251
|
return createAdapter({
|
|
247
252
|
name: "in-memory",
|
|
@@ -251,7 +256,7 @@ var createInMemoryAdapter = ({
|
|
|
251
256
|
snowflake,
|
|
252
257
|
optimistic,
|
|
253
258
|
session
|
|
254
|
-
}, {
|
|
259
|
+
}, engine ?? {
|
|
255
260
|
entities: new Map,
|
|
256
261
|
mutations: new Map,
|
|
257
262
|
entitiesUnique: new Map,
|
|
@@ -3,11 +3,17 @@ 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, optimistic, session, }: {
|
|
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, }: {
|
|
7
7
|
operations: Operations;
|
|
8
8
|
entities: Entities;
|
|
9
9
|
snowflake?: Snowflake;
|
|
10
10
|
optimistic?: boolean;
|
|
11
11
|
session: Session;
|
|
12
|
+
engine?: {
|
|
13
|
+
entities: Map<string, any>;
|
|
14
|
+
mutations: Map<string, any>;
|
|
15
|
+
entitiesUnique: Map<string, any>;
|
|
16
|
+
entitiesIndex: Map<string, any>;
|
|
17
|
+
};
|
|
12
18
|
}) => Adapter;
|
|
13
19
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { WriteRequest } from "roc-db";
|
|
2
2
|
import type { InMemoryEngine } from "../types/InMemoryEngine";
|
|
3
|
-
export declare const findDebounceMutation: (request: WriteRequest, engine: InMemoryEngine, now: number, mutationName: string) => import("roc-db").Mutation | undefined;
|
|
3
|
+
export declare const findDebounceMutation: (request: WriteRequest, engine: InMemoryEngine, now: number, mutationName: string, identityRef: string) => import("roc-db").Mutation | undefined;
|
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.98",
|
|
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.
|
|
16
|
+
"roc-db": "0.2.0-pre.98",
|
|
17
17
|
"zod": ">=4.0.0"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [],
|