@signaldb/core 2.0.0-beta.7 → 2.0.0-beta.9
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/AsyncDataAdapter.d.ts +3 -5
- package/dist/AutoFetchDataAdapter.d.ts +4 -6
- package/dist/Collection/Cursor.d.ts +3 -3
- package/dist/Collection/index.d.ts +8 -9
- package/dist/Collection/types.d.ts +2 -2
- package/dist/DataAdapter.d.ts +3 -4
- package/dist/DefaultDataAdapter.d.ts +3 -5
- package/dist/WorkerDataAdapter.d.ts +2 -4
- package/dist/WorkerDataAdapterHost.d.ts +5 -5
- package/dist/createIndex.d.ts +2 -2
- package/dist/createIndexProvider.d.ts +2 -2
- package/dist/createReactivityAdapter.d.ts +2 -2
- package/dist/createStorageAdapter.d.ts +1 -1
- package/dist/getIndexInfo.d.ts +3 -4
- package/dist/index25.cjs.js +22 -4
- package/dist/index25.mjs +22 -4
- package/dist/types/IndexProvider.d.ts +2 -2
- package/dist/types/Modifier.d.ts +1 -1
- package/dist/types/ReactivityAdapter.d.ts +1 -1
- package/dist/utils/createSignal.d.ts +2 -2
- package/dist/utils/getMatchingKeys.d.ts +2 -2
- package/dist/utils/isFieldExpression.d.ts +1 -1
- package/dist/utils/match.d.ts +1 -1
- package/dist/utils/modify.d.ts +1 -1
- package/dist/utils/queryId.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type { CollectionBackend } from './DataAdapter';
|
|
5
|
-
import type StorageAdapter from './types/StorageAdapter';
|
|
1
|
+
import { BaseItem, default as Collection } from './Collection';
|
|
2
|
+
import { default as DataAdapter, CollectionBackend } from './DataAdapter';
|
|
3
|
+
import { default as StorageAdapter } from './types/StorageAdapter';
|
|
6
4
|
export interface AsyncDataAdapterOptions {
|
|
7
5
|
/** Factory to obtain a StorageAdapter per collection name */
|
|
8
6
|
storage: (name: string) => StorageAdapter<any, any>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import type StorageAdapter from './types/StorageAdapter';
|
|
6
|
-
import type Selector from './types/Selector';
|
|
1
|
+
import { BaseItem, default as Collection } from './Collection';
|
|
2
|
+
import { default as DataAdapter, CollectionBackend } from './DataAdapter';
|
|
3
|
+
import { default as StorageAdapter } from './types/StorageAdapter';
|
|
4
|
+
import { default as Selector } from './types/Selector';
|
|
7
5
|
/**
|
|
8
6
|
* AutoFetchDataAdapterOptions
|
|
9
7
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { default as ReactivityAdapter } from '../types/ReactivityAdapter';
|
|
2
|
+
import { BaseItem, FindOptions, Transform } from './types';
|
|
3
|
+
import { ObserveCallbacks } from './Observer';
|
|
4
4
|
/**
|
|
5
5
|
* Checks if the current scope is reactive, considering the provided reactivity adapter.
|
|
6
6
|
* @param reactivity - The reactivity adapter or a boolean indicating whether reactivity is enabled.
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import EventEmitter from '../utils/EventEmitter';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import type { AsyncFindOptions, BaseItem, FindOptions, SyncFindOptions, Transform, TransformAll } from './types';
|
|
1
|
+
import { default as ReactivityAdapter } from '../types/ReactivityAdapter';
|
|
2
|
+
import { default as EventEmitter } from '../utils/EventEmitter';
|
|
3
|
+
import { default as Selector } from '../types/Selector';
|
|
4
|
+
import { default as Modifier } from '../types/Modifier';
|
|
5
|
+
import { default as DataAdapter, QueryOptions } from '../DataAdapter';
|
|
6
|
+
import { default as StorageAdapter } from '../types/StorageAdapter';
|
|
7
|
+
import { default as Cursor } from './Cursor';
|
|
8
|
+
import { AsyncFindOptions, BaseItem, FindOptions, SyncFindOptions, Transform, TransformAll } from './types';
|
|
10
9
|
export type { AnyFindOptions, AsyncFindOptions, BaseItem, Transform, TransformAll, SortSpecifier, FieldSpecifier, FindOptions, SyncFindOptions, } from './types';
|
|
11
10
|
export type { CursorOptions } from './Cursor';
|
|
12
11
|
export type { ObserveCallbacks } from './Observer';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { QueryOptions } from '../DataAdapter';
|
|
2
|
+
import { default as ReactivityAdapter } from '../types/ReactivityAdapter';
|
|
3
3
|
export type BaseItem<I = any> = {
|
|
4
4
|
id: I;
|
|
5
5
|
} & Record<string, any>;
|
package/dist/DataAdapter.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type Selector from './types/Selector';
|
|
1
|
+
import { BaseItem, FieldSpecifier, SortSpecifier, default as Collection } from './Collection';
|
|
2
|
+
import { default as Modifier } from './types/Modifier';
|
|
3
|
+
import { default as Selector } from './types/Selector';
|
|
5
4
|
export interface QueryOptions<T extends BaseItem> {
|
|
6
5
|
/** Sort order (default: natural order) */
|
|
7
6
|
sort?: SortSpecifier<T> | undefined;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type { CollectionBackend } from './DataAdapter';
|
|
5
|
-
import type StorageAdapter from './types/StorageAdapter';
|
|
1
|
+
import { BaseItem, default as Collection } from './Collection';
|
|
2
|
+
import { default as DataAdapter, CollectionBackend } from './DataAdapter';
|
|
3
|
+
import { default as StorageAdapter } from './types/StorageAdapter';
|
|
6
4
|
interface DefaultDataAdapterOptions {
|
|
7
5
|
storage?: (name: string) => StorageAdapter<any, any> | undefined;
|
|
8
6
|
onError?: (name: string, error: Error) => void;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import type DataAdapter from './DataAdapter';
|
|
4
|
-
import type { CollectionBackend } from './DataAdapter';
|
|
1
|
+
import { BaseItem, default as Collection } from './Collection';
|
|
2
|
+
import { default as DataAdapter, CollectionBackend } from './DataAdapter';
|
|
5
3
|
interface WorkerDataAdapterOptions {
|
|
6
4
|
id?: string;
|
|
7
5
|
log?: (message: string, ...args: any[]) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { BaseItem } from './Collection';
|
|
2
|
+
import { QueryOptions } from './DataAdapter';
|
|
3
|
+
import { default as Modifier } from './types/Modifier';
|
|
4
|
+
import { default as StorageAdapter } from './types/StorageAdapter';
|
|
5
|
+
import { default as Selector } from './types/Selector';
|
|
6
6
|
interface WorkerContext {
|
|
7
7
|
addEventListener: (type: 'message', listener: (event: MessageEvent) => any) => void;
|
|
8
8
|
postMessage: (message: any) => void;
|
package/dist/createIndex.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BaseItem } from './Collection/types';
|
|
2
2
|
/**
|
|
3
3
|
* creates an index for a specific field
|
|
4
4
|
* @param field name of the field
|
|
5
5
|
* @returns an index provider to pass to the `indices` option of the collection constructor
|
|
6
6
|
*/
|
|
7
|
-
export default function createIndex<T extends BaseItem<I> = BaseItem, I = any>(field: string): import(
|
|
7
|
+
export default function createIndex<T extends BaseItem<I> = BaseItem, I = any>(field: string): import('./types/IndexProvider').default<T, I>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { BaseItem } from './Collection';
|
|
2
|
+
import { default as IndexProvider } from './types/IndexProvider';
|
|
3
3
|
/**
|
|
4
4
|
* Creates an IndexProvider based on the given definition.
|
|
5
5
|
* @param definition - The definition of the IndexProvider.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { default as Dependency } from './types/Dependency';
|
|
2
|
+
import { default as ReactivityAdapter } from './types/ReactivityAdapter';
|
|
3
3
|
/**
|
|
4
4
|
* Creates an ReactivityAdapter based on the given definition.
|
|
5
5
|
* @param definition - The definition of the ReactivityAdapter.
|
package/dist/getIndexInfo.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type { BaseItem } from './Collection/types';
|
|
1
|
+
import { AsynchronousQueryFunction, SynchronousQueryFunction } from './types/IndexProvider';
|
|
2
|
+
import { FlatSelector, default as Selector } from './types/Selector';
|
|
3
|
+
import { BaseItem } from './Collection/types';
|
|
5
4
|
type IndexInfo<T extends BaseItem<I> = BaseItem, I = any> = {
|
|
6
5
|
matched: boolean;
|
|
7
6
|
ids: I[];
|
package/dist/index25.cjs.js
CHANGED
|
@@ -56,11 +56,20 @@ var Collection = class Collection extends require_EventEmitter.default {
|
|
|
56
56
|
const execute = () => Collection.collections.reduce((memo, collection) => () => {
|
|
57
57
|
return collection.batch(memo);
|
|
58
58
|
}, callback)();
|
|
59
|
-
const maybePromise = execute();
|
|
60
59
|
const afterBatch = () => {
|
|
61
60
|
Collection.batchOperationInProgress = false;
|
|
62
61
|
};
|
|
63
|
-
|
|
62
|
+
let maybePromise;
|
|
63
|
+
try {
|
|
64
|
+
maybePromise = execute();
|
|
65
|
+
} catch (error) {
|
|
66
|
+
afterBatch();
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch(), (error) => {
|
|
70
|
+
afterBatch();
|
|
71
|
+
throw error;
|
|
72
|
+
});
|
|
64
73
|
else afterBatch();
|
|
65
74
|
}
|
|
66
75
|
name;
|
|
@@ -318,13 +327,22 @@ var Collection = class Collection extends require_EventEmitter.default {
|
|
|
318
327
|
batch(callback) {
|
|
319
328
|
if (this.batchOperationInProgress) return callback();
|
|
320
329
|
this.batchOperationInProgress = true;
|
|
321
|
-
const maybePromise = callback();
|
|
322
330
|
const afterBatch = () => {
|
|
323
331
|
this.batchOperationInProgress = false;
|
|
324
332
|
this.postBatchCallbacks.forEach((callback_) => callback_());
|
|
325
333
|
this.postBatchCallbacks.clear();
|
|
326
334
|
};
|
|
327
|
-
|
|
335
|
+
let maybePromise;
|
|
336
|
+
try {
|
|
337
|
+
maybePromise = callback();
|
|
338
|
+
} catch (error) {
|
|
339
|
+
afterBatch();
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch(), (error) => {
|
|
343
|
+
afterBatch();
|
|
344
|
+
throw error;
|
|
345
|
+
});
|
|
328
346
|
else afterBatch();
|
|
329
347
|
}
|
|
330
348
|
onPostBatch(callback) {
|
package/dist/index25.mjs
CHANGED
|
@@ -56,11 +56,20 @@ var Collection = class Collection extends EventEmitter {
|
|
|
56
56
|
const execute = () => Collection.collections.reduce((memo, collection) => () => {
|
|
57
57
|
return collection.batch(memo);
|
|
58
58
|
}, callback)();
|
|
59
|
-
const maybePromise = execute();
|
|
60
59
|
const afterBatch = () => {
|
|
61
60
|
Collection.batchOperationInProgress = false;
|
|
62
61
|
};
|
|
63
|
-
|
|
62
|
+
let maybePromise;
|
|
63
|
+
try {
|
|
64
|
+
maybePromise = execute();
|
|
65
|
+
} catch (error) {
|
|
66
|
+
afterBatch();
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch(), (error) => {
|
|
70
|
+
afterBatch();
|
|
71
|
+
throw error;
|
|
72
|
+
});
|
|
64
73
|
else afterBatch();
|
|
65
74
|
}
|
|
66
75
|
name;
|
|
@@ -318,13 +327,22 @@ var Collection = class Collection extends EventEmitter {
|
|
|
318
327
|
batch(callback) {
|
|
319
328
|
if (this.batchOperationInProgress) return callback();
|
|
320
329
|
this.batchOperationInProgress = true;
|
|
321
|
-
const maybePromise = callback();
|
|
322
330
|
const afterBatch = () => {
|
|
323
331
|
this.batchOperationInProgress = false;
|
|
324
332
|
this.postBatchCallbacks.forEach((callback_) => callback_());
|
|
325
333
|
this.postBatchCallbacks.clear();
|
|
326
334
|
};
|
|
327
|
-
|
|
335
|
+
let maybePromise;
|
|
336
|
+
try {
|
|
337
|
+
maybePromise = callback();
|
|
338
|
+
} catch (error) {
|
|
339
|
+
afterBatch();
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch(), (error) => {
|
|
343
|
+
afterBatch();
|
|
344
|
+
throw error;
|
|
345
|
+
});
|
|
328
346
|
else afterBatch();
|
|
329
347
|
}
|
|
330
348
|
onPostBatch(callback) {
|
package/dist/types/Modifier.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DotNotation, GetType } from './Selector';
|
|
2
2
|
type Dictionary<T> = Record<string, T>;
|
|
3
3
|
type PartialMapTo<T, M> = Partial<Record<DotNotation<T>, M>> & Dictionary<M>;
|
|
4
4
|
type OnlyElementsOfArrays<T> = T extends any[] ? Partial<T[0]> : never;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { default as ReactivityAdapter } from '../types/ReactivityAdapter';
|
|
2
|
+
import { default as Signal } from '../types/Signal';
|
|
3
3
|
/**
|
|
4
4
|
* Creates a reactive signal for managing state and triggering dependencies.
|
|
5
5
|
* The signal holds a value and provides methods to get and set the value,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { BaseItem } from '../Collection/types';
|
|
2
|
+
import { FlatSelector } from '../types/Selector';
|
|
3
3
|
type KeyResult = {
|
|
4
4
|
include: (string | null)[] | null;
|
|
5
5
|
exclude: (string | null)[] | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FieldExpression } from '../types/Selector';
|
|
2
2
|
/**
|
|
3
3
|
* Determines whether a given object is a valid field expression.
|
|
4
4
|
* A field expression is an object containing query operators supported by MongoDB-style queries.
|
package/dist/utils/match.d.ts
CHANGED
package/dist/utils/modify.d.ts
CHANGED
package/dist/utils/queryId.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { QueryOptions } from '../DataAdapter';
|
|
2
|
+
import { default as Selector } from '../types/Selector';
|
|
3
3
|
/**
|
|
4
4
|
* Generates a unique identifier for a query based on its selector and options.
|
|
5
5
|
* @param selector - The selector object.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signaldb/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.9",
|
|
4
4
|
"description": "SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON interface to places such as localStorage.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf dist && vite build",
|