@signaldb/core 2.0.0-beta.0 → 2.0.0-beta.1

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.
Files changed (52) hide show
  1. package/dist/.vite/manifest.json +25 -12
  2. package/dist/AutoFetchDataAdapter.d.ts +0 -1
  3. package/dist/Collection/index.d.ts +2 -0
  4. package/dist/DataAdapter.d.ts +7 -6
  5. package/dist/DefaultDataAdapter.d.ts +1 -0
  6. package/dist/WorkerDataAdapter.d.ts +4 -1
  7. package/dist/WorkerDataAdapterHost.d.ts +9 -6
  8. package/dist/index.cjs12.js +32 -21
  9. package/dist/index.cjs13.js +25 -13
  10. package/dist/index.cjs14.js +31 -37
  11. package/dist/index.cjs15.js +120 -75
  12. package/dist/index.cjs16.js +45 -36
  13. package/dist/index.cjs17.js +1 -1
  14. package/dist/index.cjs2.js +5 -2
  15. package/dist/index.cjs20.js +5 -102
  16. package/dist/index.cjs21.js +93 -118
  17. package/dist/index.cjs22.js +127 -5
  18. package/dist/index.cjs23.js +5 -25
  19. package/dist/index.cjs24.js +25 -5
  20. package/dist/index.cjs26.js +1 -1
  21. package/dist/index.cjs27.js +44 -3
  22. package/dist/index.cjs28.js +6 -5
  23. package/dist/index.cjs29.js +7 -27
  24. package/dist/index.cjs3.js +25 -21
  25. package/dist/index.cjs30.js +3 -40
  26. package/dist/index.cjs31.js +5 -7
  27. package/dist/index.cjs32.js +29 -0
  28. package/dist/index.cjs33.js +42 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index12.mjs +32 -21
  31. package/dist/index13.mjs +25 -13
  32. package/dist/index14.mjs +31 -37
  33. package/dist/index15.mjs +120 -75
  34. package/dist/index16.mjs +45 -36
  35. package/dist/index17.mjs +1 -1
  36. package/dist/index2.mjs +5 -2
  37. package/dist/index20.mjs +5 -102
  38. package/dist/index21.mjs +93 -117
  39. package/dist/index22.mjs +126 -5
  40. package/dist/index23.mjs +5 -25
  41. package/dist/index24.mjs +25 -5
  42. package/dist/index26.mjs +1 -1
  43. package/dist/index27.mjs +44 -3
  44. package/dist/index28.mjs +6 -5
  45. package/dist/index29.mjs +7 -27
  46. package/dist/index3.mjs +25 -21
  47. package/dist/index30.mjs +3 -40
  48. package/dist/index31.mjs +5 -7
  49. package/dist/index32.mjs +30 -0
  50. package/dist/index33.mjs +43 -0
  51. package/dist/utils/batchOnNextTick.d.ts +16 -0
  52. package/package.json +1 -1
package/dist/index30.mjs CHANGED
@@ -1,43 +1,6 @@
1
- const expressionKeys = /* @__PURE__ */ new Set([
2
- "$eq",
3
- "$gt",
4
- "$gte",
5
- "$lt",
6
- "$lte",
7
- "$in",
8
- "$nin",
9
- "$ne",
10
- "$exists",
11
- "$not",
12
- "$expr",
13
- "$jsonSchema",
14
- "$mod",
15
- "$regex",
16
- "$options",
17
- "$text",
18
- "$where",
19
- "$all",
20
- "$elemMatch",
21
- "$size",
22
- "$bitsAllClear",
23
- "$bitsAllSet",
24
- "$bitsAnyClear",
25
- "$bitsAnySet"
26
- ]);
27
- function isFieldExpression(expression) {
28
- if (typeof expression !== "object" || expression == null) {
29
- return false;
30
- }
31
- const keys = Object.keys(expression);
32
- if (keys.length === 0) {
33
- return false;
34
- }
35
- const hasInvalidKeys = keys.some((key) => !expressionKeys.has(key));
36
- if (hasInvalidKeys)
37
- return false;
38
- const hasValidKeys = keys.every((key) => expressionKeys.has(key));
39
- return hasValidKeys;
1
+ function createIndexProvider(definition) {
2
+ return definition;
40
3
  }
41
4
  export {
42
- isFieldExpression as default
5
+ createIndexProvider as default
43
6
  };
package/dist/index31.mjs CHANGED
@@ -1,10 +1,8 @@
1
- function uniqueBy(array, fn) {
2
- const set = /* @__PURE__ */ new Set();
3
- return array.filter((element) => {
4
- const value = typeof fn === "function" ? fn(element) : element[fn];
5
- return !set.has(value) && set.add(value);
6
- });
1
+ function intersection(...arrays) {
2
+ if (arrays.length === 0)
3
+ return [];
4
+ return [...new Set(arrays.reduce((a, b) => a.filter((c) => b.includes(c))))];
7
5
  }
8
6
  export {
9
- uniqueBy as default
7
+ intersection as default
10
8
  };
@@ -0,0 +1,30 @@
1
+ function set(object, path, value, deleteIfUndefined = false) {
2
+ if (object == null)
3
+ return object;
4
+ const segments = path.split(/[.[\]]/g);
5
+ if (segments[0] === "")
6
+ segments.shift();
7
+ if (segments.at(-1) === "")
8
+ segments.pop();
9
+ const apply = (node) => {
10
+ if (segments.length > 1) {
11
+ const key = segments.shift();
12
+ const nextIsNumber = !Number.isNaN(Number.parseInt(segments[0], 10));
13
+ if (node[key] === void 0) {
14
+ node[key] = nextIsNumber ? [] : {};
15
+ }
16
+ apply(node[key]);
17
+ } else {
18
+ if (deleteIfUndefined && value === void 0) {
19
+ delete node[segments[0]];
20
+ return;
21
+ }
22
+ node[segments[0]] = value;
23
+ }
24
+ };
25
+ apply(object);
26
+ return object;
27
+ }
28
+ export {
29
+ set as default
30
+ };
@@ -0,0 +1,43 @@
1
+ const expressionKeys = /* @__PURE__ */ new Set([
2
+ "$eq",
3
+ "$gt",
4
+ "$gte",
5
+ "$lt",
6
+ "$lte",
7
+ "$in",
8
+ "$nin",
9
+ "$ne",
10
+ "$exists",
11
+ "$not",
12
+ "$expr",
13
+ "$jsonSchema",
14
+ "$mod",
15
+ "$regex",
16
+ "$options",
17
+ "$text",
18
+ "$where",
19
+ "$all",
20
+ "$elemMatch",
21
+ "$size",
22
+ "$bitsAllClear",
23
+ "$bitsAllSet",
24
+ "$bitsAnyClear",
25
+ "$bitsAnySet"
26
+ ]);
27
+ function isFieldExpression(expression) {
28
+ if (typeof expression !== "object" || expression == null) {
29
+ return false;
30
+ }
31
+ const keys = Object.keys(expression);
32
+ if (keys.length === 0) {
33
+ return false;
34
+ }
35
+ const hasInvalidKeys = keys.some((key) => !expressionKeys.has(key));
36
+ if (hasInvalidKeys)
37
+ return false;
38
+ const hasValidKeys = keys.every((key) => expressionKeys.has(key));
39
+ return hasValidKeys;
40
+ }
41
+ export {
42
+ isFieldExpression as default
43
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Groups multiple calls by key and flushes them on the next tick (macrotask).
3
+ * @param onFlush - Function that will be called with the key and all queued items when flushing.
4
+ * @returns An object with `enqueue` and `flush` methods.
5
+ * @example
6
+ * const batcher = batchOnNextTick<string>(async (key, items) => {
7
+ * // items is an array of { args, resolve, reject }
8
+ * // do something once with all args...
9
+ * })
10
+ *
11
+ * batcher.enqueue("my-key", [arg1, arg2])
12
+ */
13
+ export default function batchOnNextTick<TKey>(onFlush: (key: TKey, items: any[][]) => Promise<any[]>): {
14
+ enqueue: (key: TKey, args: any[]) => Promise<any>;
15
+ flush: (key: TKey) => Promise<void>;
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaldb/core",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.1",
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",