@peers-app/peers-sdk 0.14.0 → 0.15.0

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 (210) hide show
  1. package/dist/context/data-context.d.ts +4 -4
  2. package/dist/context/data-context.js +1 -1
  3. package/dist/context/index.d.ts +3 -3
  4. package/dist/context/index.js +4 -0
  5. package/dist/context/user-context-singleton.js +13 -14
  6. package/dist/context/user-context.d.ts +4 -4
  7. package/dist/context/user-context.js +48 -31
  8. package/dist/data/assistants.d.ts +1 -1
  9. package/dist/data/assistants.js +35 -24
  10. package/dist/data/change-tracking.d.ts +8 -8
  11. package/dist/data/change-tracking.js +45 -39
  12. package/dist/data/channels.js +5 -5
  13. package/dist/data/data-locks.d.ts +2 -2
  14. package/dist/data/data-locks.js +21 -23
  15. package/dist/data/data-locks.test.js +73 -75
  16. package/dist/data/device-sync-info.d.ts +1 -1
  17. package/dist/data/device-sync-info.js +4 -4
  18. package/dist/data/devices.d.ts +1 -1
  19. package/dist/data/devices.js +9 -12
  20. package/dist/data/embeddings.js +14 -11
  21. package/dist/data/files/file-read-stream.d.ts +2 -2
  22. package/dist/data/files/file-read-stream.js +23 -14
  23. package/dist/data/files/file-write-stream.d.ts +2 -2
  24. package/dist/data/files/file-write-stream.js +8 -8
  25. package/dist/data/files/file.types.d.ts +2 -2
  26. package/dist/data/files/file.types.js +17 -11
  27. package/dist/data/files/files.d.ts +6 -6
  28. package/dist/data/files/files.js +17 -19
  29. package/dist/data/files/files.test.js +213 -214
  30. package/dist/data/files/index.d.ts +4 -4
  31. package/dist/data/files/index.js +4 -4
  32. package/dist/data/group-member-roles.js +2 -2
  33. package/dist/data/group-members.d.ts +5 -5
  34. package/dist/data/group-members.js +27 -18
  35. package/dist/data/group-members.test.js +73 -73
  36. package/dist/data/group-permissions.d.ts +3 -3
  37. package/dist/data/group-permissions.js +13 -11
  38. package/dist/data/group-share.d.ts +2 -2
  39. package/dist/data/group-share.js +29 -24
  40. package/dist/data/groups.d.ts +4 -4
  41. package/dist/data/groups.js +27 -19
  42. package/dist/data/groups.test.js +44 -44
  43. package/dist/data/index.d.ts +6 -6
  44. package/dist/data/index.js +6 -6
  45. package/dist/data/knowledge/peer-types.js +9 -9
  46. package/dist/data/messages.d.ts +5 -5
  47. package/dist/data/messages.js +43 -30
  48. package/dist/data/orm/client-proxy.data-source.d.ts +4 -4
  49. package/dist/data/orm/client-proxy.data-source.js +10 -12
  50. package/dist/data/orm/cursor.d.ts +1 -1
  51. package/dist/data/orm/cursor.js +2 -2
  52. package/dist/data/orm/cursor.test.js +92 -93
  53. package/dist/data/orm/data-query.d.ts +3 -3
  54. package/dist/data/orm/data-query.js +24 -18
  55. package/dist/data/orm/data-query.mongo.d.ts +1 -1
  56. package/dist/data/orm/data-query.mongo.js +49 -51
  57. package/dist/data/orm/data-query.mongo.test.js +173 -204
  58. package/dist/data/orm/data-query.sqlite.d.ts +1 -1
  59. package/dist/data/orm/data-query.sqlite.js +84 -73
  60. package/dist/data/orm/data-query.sqlite.test.js +164 -176
  61. package/dist/data/orm/data-query.test.js +216 -224
  62. package/dist/data/orm/decorators.js +3 -3
  63. package/dist/data/orm/dependency-injection.test.js +53 -56
  64. package/dist/data/orm/doc.d.ts +4 -4
  65. package/dist/data/orm/doc.js +17 -21
  66. package/dist/data/orm/event-registry.d.ts +1 -1
  67. package/dist/data/orm/event-registry.test.js +16 -16
  68. package/dist/data/orm/factory.d.ts +2 -2
  69. package/dist/data/orm/factory.js +33 -33
  70. package/dist/data/orm/index.d.ts +10 -10
  71. package/dist/data/orm/index.js +10 -10
  72. package/dist/data/orm/multi-cursors.d.ts +1 -1
  73. package/dist/data/orm/multi-cursors.js +6 -6
  74. package/dist/data/orm/multi-cursors.test.js +152 -144
  75. package/dist/data/orm/sql.data-source.d.ts +7 -7
  76. package/dist/data/orm/sql.data-source.js +88 -93
  77. package/dist/data/orm/sql.data-source.test.js +109 -101
  78. package/dist/data/orm/subscribable.data-source.d.ts +4 -4
  79. package/dist/data/orm/subscribable.data-source.js +5 -5
  80. package/dist/data/orm/table-container-events.test.js +34 -26
  81. package/dist/data/orm/table-container.d.ts +6 -6
  82. package/dist/data/orm/table-container.js +33 -21
  83. package/dist/data/orm/table-container.test.js +64 -53
  84. package/dist/data/orm/table-definitions.system.d.ts +3 -3
  85. package/dist/data/orm/table-definitions.system.js +3 -3
  86. package/dist/data/orm/table-definitions.type.d.ts +5 -5
  87. package/dist/data/orm/table-dependencies.d.ts +2 -2
  88. package/dist/data/orm/table.d.ts +5 -5
  89. package/dist/data/orm/table.event-source.test.js +105 -115
  90. package/dist/data/orm/table.js +35 -34
  91. package/dist/data/orm/types.d.ts +3 -3
  92. package/dist/data/orm/types.js +26 -25
  93. package/dist/data/orm/types.test.js +166 -92
  94. package/dist/data/package-permissions.d.ts +1 -1
  95. package/dist/data/package-permissions.js +2 -2
  96. package/dist/data/package-version-permissions.d.ts +1 -1
  97. package/dist/data/package-version-permissions.js +2 -2
  98. package/dist/data/package-versions.d.ts +9 -9
  99. package/dist/data/package-versions.js +47 -33
  100. package/dist/data/packages.d.ts +2 -2
  101. package/dist/data/packages.js +36 -18
  102. package/dist/data/packages.utils.d.ts +2 -2
  103. package/dist/data/packages.utils.js +4 -4
  104. package/dist/data/persistent-vars.d.ts +15 -15
  105. package/dist/data/persistent-vars.js +165 -154
  106. package/dist/data/table-definitions-table.d.ts +5 -5
  107. package/dist/data/table-definitions-table.js +13 -12
  108. package/dist/data/tool-tests.js +6 -6
  109. package/dist/data/tools.js +29 -19
  110. package/dist/data/user-permissions.d.ts +1 -1
  111. package/dist/data/user-permissions.js +5 -5
  112. package/dist/data/user-permissions.test.js +90 -88
  113. package/dist/data/user-trust-levels.js +10 -10
  114. package/dist/data/users.d.ts +4 -4
  115. package/dist/data/users.js +16 -15
  116. package/dist/data/voice-messages.d.ts +2 -2
  117. package/dist/data/voice-messages.js +13 -13
  118. package/dist/data/welcome-modal.pvar.js +3 -1
  119. package/dist/data/workflow-logs.js +26 -18
  120. package/dist/data/workflow-runs.d.ts +6 -6
  121. package/dist/data/workflow-runs.js +70 -44
  122. package/dist/data/workflows.d.ts +2 -2
  123. package/dist/data/workflows.js +7 -9
  124. package/dist/device/binary-peer-connection-v2.d.ts +7 -7
  125. package/dist/device/binary-peer-connection-v2.js +32 -28
  126. package/dist/device/binary-peer-connection-v2.test.js +80 -67
  127. package/dist/device/binary-peer-connection.d.ts +7 -7
  128. package/dist/device/binary-peer-connection.js +29 -28
  129. package/dist/device/binary-peer-connection.test.js +35 -31
  130. package/dist/device/connection.d.ts +5 -5
  131. package/dist/device/connection.js +59 -48
  132. package/dist/device/connection.test.js +74 -68
  133. package/dist/device/device-election.d.ts +2 -2
  134. package/dist/device/device-election.js +25 -20
  135. package/dist/device/device-election.test.js +35 -36
  136. package/dist/device/device.d.ts +2 -2
  137. package/dist/device/device.js +10 -4
  138. package/dist/device/device.test.js +16 -17
  139. package/dist/device/get-trust-level-fn.d.ts +2 -2
  140. package/dist/device/get-trust-level-fn.js +22 -11
  141. package/dist/device/get-trust-level-fn.test.js +58 -58
  142. package/dist/device/socket-io-binary-peer.d.ts +1 -1
  143. package/dist/device/socket-io-binary-peer.js +16 -13
  144. package/dist/device/socket.type.d.ts +2 -2
  145. package/dist/device/streamed-socket.d.ts +2 -2
  146. package/dist/device/streamed-socket.js +8 -8
  147. package/dist/device/streamed-socket.test.js +40 -40
  148. package/dist/device/tx-encoding.test.js +77 -77
  149. package/dist/events.d.ts +1 -1
  150. package/dist/events.js +5 -2
  151. package/dist/group-invite/group-invite.js +110 -19
  152. package/dist/group-invite/group-invite.pvars.d.ts +2 -2
  153. package/dist/group-invite/group-invite.pvars.js +21 -13
  154. package/dist/group-invite/group-invite.types.d.ts +1 -1
  155. package/dist/group-invite/index.d.ts +3 -3
  156. package/dist/group-invite/index.js +1 -1
  157. package/dist/index.d.ts +25 -24
  158. package/dist/index.js +30 -25
  159. package/dist/keys.d.ts +3 -3
  160. package/dist/keys.js +31 -30
  161. package/dist/keys.test.js +69 -61
  162. package/dist/logging/console-logger.d.ts +1 -1
  163. package/dist/logging/console-logger.js +35 -40
  164. package/dist/logging/console-logger.test.js +115 -115
  165. package/dist/logging/console-logs.table.d.ts +3 -3
  166. package/dist/logging/console-logs.table.js +28 -23
  167. package/dist/mentions.js +16 -12
  168. package/dist/observable.d.ts +2 -2
  169. package/dist/observable.js +15 -9
  170. package/dist/observable.test.js +47 -47
  171. package/dist/package-loader/get-require.js +3 -4
  172. package/dist/package-loader/package-loader.d.ts +2 -2
  173. package/dist/package-loader/package-loader.js +52 -34
  174. package/dist/peers-ui/peers-ui.d.ts +2 -2
  175. package/dist/peers-ui/peers-ui.js +2 -4
  176. package/dist/peers-ui/peers-ui.types.d.ts +3 -3
  177. package/dist/peers-ui/peers-ui.types.js +0 -1
  178. package/dist/rpc-types.d.ts +61 -59
  179. package/dist/rpc-types.js +61 -55
  180. package/dist/serial-json.d.ts +1 -1
  181. package/dist/serial-json.js +50 -43
  182. package/dist/serial-json.test.js +22 -22
  183. package/dist/system-ids.js +8 -8
  184. package/dist/tools/index.d.ts +1 -1
  185. package/dist/tools/tools-factory.d.ts +1 -1
  186. package/dist/tools/tools-factory.js +2 -2
  187. package/dist/types/assistant-runner-args.d.ts +3 -3
  188. package/dist/types/peer-device.d.ts +1 -1
  189. package/dist/types/peers-package.d.ts +3 -3
  190. package/dist/types/workflow-logger.d.ts +1 -1
  191. package/dist/types/workflow-run-context.d.ts +4 -4
  192. package/dist/types/workflow.d.ts +4 -4
  193. package/dist/types/workflow.js +27 -14
  194. package/dist/types/zod-types.d.ts +2 -1
  195. package/dist/types/zod-types.js +9 -3
  196. package/dist/user-connect/connection-code.d.ts +1 -1
  197. package/dist/user-connect/connection-code.js +7 -7
  198. package/dist/user-connect/connection-code.test.js +106 -106
  199. package/dist/user-connect/index.d.ts +3 -3
  200. package/dist/user-connect/index.js +1 -1
  201. package/dist/user-connect/user-connect.pvars.js +13 -11
  202. package/dist/user-connect/user-connect.types.d.ts +3 -3
  203. package/dist/users.query.d.ts +2 -2
  204. package/dist/users.query.js +40 -30
  205. package/dist/utils.d.ts +2 -2
  206. package/dist/utils.js +34 -32
  207. package/dist/utils.test.js +12 -8
  208. package/dist/workflow-log-formatter.d.ts +1 -1
  209. package/dist/workflow-log-formatter.js +17 -18
  210. package/package.json +14 -8
@@ -1,376 +1,364 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const data_query_sqlite_1 = require("./data-query.sqlite");
4
- describe('dataFilterToSqlWhere - Restructured Version', () => {
5
- describe('Main orchestrator function', () => {
6
- it('should handle scalar values', () => {
7
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(null)).toBe('NULL');
8
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(undefined)).toBe('NULL');
9
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(true)).toBe('1');
10
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(false)).toBe('0');
11
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(42)).toBe('42');
12
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)('test')).toBe("'test'");
13
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(new Date('2023-01-01T00:00:00.000Z'))).toBe("'2023-01-01T00:00:00.000Z'");
14
- });
15
- it('should handle empty filter object', () => {
16
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)({})).toBe('(1=1)');
17
- });
18
- it('should delegate to array handler for arrays', () => {
19
- const filter = [{ name: 'John' }, { age: 30 }];
4
+ describe("dataFilterToSqlWhere - Restructured Version", () => {
5
+ describe("Main orchestrator function", () => {
6
+ it("should handle scalar values", () => {
7
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(null)).toBe("NULL");
8
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(undefined)).toBe("NULL");
9
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(true)).toBe("1");
10
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(false)).toBe("0");
11
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(42)).toBe("42");
12
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)("test")).toBe("'test'");
13
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(new Date("2023-01-01T00:00:00.000Z"))).toBe("'2023-01-01T00:00:00.000Z'");
14
+ });
15
+ it("should handle empty filter object", () => {
16
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)({})).toBe("(1=1)");
17
+ });
18
+ it("should delegate to array handler for arrays", () => {
19
+ const filter = [{ name: "John" }, { age: 30 }];
20
20
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(("name" = 'John') OR ("age" = 30))`);
21
21
  });
22
- it('should delegate to object handler for filter objects', () => {
23
- const filter = { name: 'John', age: 30 };
22
+ it("should delegate to object handler for filter objects", () => {
23
+ const filter = { name: "John", age: 30 };
24
24
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = 'John' AND "age" = 30)`);
25
25
  });
26
26
  });
27
- describe('handleOrArray function', () => {
28
- it('should handle empty arrays', () => {
29
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)([])).toBe('(1=1)');
27
+ describe("handleOrArray function", () => {
28
+ it("should handle empty arrays", () => {
29
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)([])).toBe("(1=1)");
30
30
  });
31
- it('should handle single condition arrays', () => {
32
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)([{ name: 'John' }])).toBe(`(("name" = 'John'))`);
31
+ it("should handle single condition arrays", () => {
32
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)([{ name: "John" }])).toBe(`(("name" = 'John'))`);
33
33
  });
34
- it('should handle multiple conditions with OR', () => {
35
- const filter = [{ name: 'John' }, { age: 30 }, { city: 'NYC' }];
34
+ it("should handle multiple conditions with OR", () => {
35
+ const filter = [{ name: "John" }, { age: 30 }, { city: "NYC" }];
36
36
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(("name" = 'John') OR ("age" = 30) OR ("city" = 'NYC'))`);
37
37
  });
38
- it('should handle complex nested conditions', () => {
39
- const filter = [
40
- { name: 'John', age: 30 },
41
- { city: { $in: ['NYC', 'LA'] } }
42
- ];
38
+ it("should handle complex nested conditions", () => {
39
+ const filter = [{ name: "John", age: 30 }, { city: { $in: ["NYC", "LA"] } }];
43
40
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(("name" = 'John' AND "age" = 30) OR ("city" IN ('NYC', 'LA')))`);
44
41
  });
45
42
  });
46
- describe('handleFilterObject function', () => {
47
- it('should handle multiple field conditions with AND', () => {
48
- const filter = { name: 'John', age: 30, active: true };
43
+ describe("handleFilterObject function", () => {
44
+ it("should handle multiple field conditions with AND", () => {
45
+ const filter = { name: "John", age: 30, active: true };
49
46
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = 'John' AND "age" = 30 AND "active" = 1)`);
50
47
  });
51
- it('should handle single field condition', () => {
52
- const filter = { name: 'John' };
48
+ it("should handle single field condition", () => {
49
+ const filter = { name: "John" };
53
50
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = 'John')`);
54
51
  });
55
52
  });
56
- describe('Special operators', () => {
57
- describe('$or operator', () => {
58
- it('should handle $or with multiple conditions', () => {
59
- const filter = { $or: [{ name: 'John' }, { age: 30 }] };
53
+ describe("Special operators", () => {
54
+ describe("$or operator", () => {
55
+ it("should handle $or with multiple conditions", () => {
56
+ const filter = { $or: [{ name: "John" }, { age: 30 }] };
60
57
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`((("name" = 'John') OR ("age" = 30)))`);
61
58
  });
62
- it('should handle empty $or array', () => {
59
+ it("should handle empty $or array", () => {
63
60
  const filter = { $or: [] };
64
61
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`((1=1))`);
65
62
  });
66
- it('should handle $or with empty objects', () => {
63
+ it("should handle $or with empty objects", () => {
67
64
  const filter = { $or: [{}] };
68
65
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(((1=1)))`);
69
66
  });
70
67
  });
71
- describe('$and operator', () => {
72
- it('should handle $and with multiple conditions', () => {
73
- const filter = { $and: [{ name: 'John' }, { age: 30 }] };
68
+ describe("$and operator", () => {
69
+ it("should handle $and with multiple conditions", () => {
70
+ const filter = { $and: [{ name: "John" }, { age: 30 }] };
74
71
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`((("name" = 'John') AND ("age" = 30)))`);
75
72
  });
76
- it('should handle empty $and array', () => {
73
+ it("should handle empty $and array", () => {
77
74
  const filter = { $and: [] };
78
75
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`((1=1))`);
79
76
  });
80
- it('should handle $and with empty objects', () => {
77
+ it("should handle $and with empty objects", () => {
81
78
  const filter = { $and: [{}] };
82
79
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(((1=1)))`);
83
80
  });
84
81
  });
85
- describe('$expr operator', () => {
86
- it('should handle simple expressions', () => {
87
- const filter = { $expr: [{ $substr: ['$id', 1, 1] }, { $eq: 'a' }] };
82
+ describe("$expr operator", () => {
83
+ it("should handle simple expressions", () => {
84
+ const filter = { $expr: [{ $substr: ["$id", 1, 1] }, { $eq: "a" }] };
88
85
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`((substr("id", 1, 1)) = 'a')`);
89
86
  });
90
- it('should handle expressions with column references', () => {
91
- const filter = { $expr: [{ $substr: ['$col1', 2, 4] }, { $gte: '$col2' }] };
87
+ it("should handle expressions with column references", () => {
88
+ const filter = { $expr: [{ $substr: ["$col1", 2, 4] }, { $gte: "$col2" }] };
92
89
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`((substr("col1", 2, 4)) >= "col2")`);
93
90
  });
94
91
  });
95
- describe('$substr operator', () => {
96
- it('should handle substr with column reference', () => {
97
- const filter = { $substr: ['$col1', 2, 4] };
92
+ describe("$substr operator", () => {
93
+ it("should handle substr with column reference", () => {
94
+ const filter = { $substr: ["$col1", 2, 4] };
98
95
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(substr("col1", 2, 4))`);
99
96
  });
100
- it('should handle substr with string literal', () => {
101
- const filter = { $substr: ['test string', 1, 4] };
97
+ it("should handle substr with string literal", () => {
98
+ const filter = { $substr: ["test string", 1, 4] };
102
99
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(substr('test string', 1, 4))`);
103
100
  });
104
- it('should handle substr with escaped quotes', () => {
101
+ it("should handle substr with escaped quotes", () => {
105
102
  const filter = { $substr: ["test's string", 1, 4] };
106
103
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(substr('test''s string', 1, 4))`);
107
104
  });
108
105
  });
109
106
  });
110
- describe('Field operators', () => {
111
- describe('$in operator', () => {
112
- it('should handle string arrays', () => {
113
- const filter = { name: { $in: ['John', 'Jane', 'Bob'] } };
107
+ describe("Field operators", () => {
108
+ describe("$in operator", () => {
109
+ it("should handle string arrays", () => {
110
+ const filter = { name: { $in: ["John", "Jane", "Bob"] } };
114
111
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" IN ('John', 'Jane', 'Bob'))`);
115
112
  });
116
- it('should handle number arrays', () => {
113
+ it("should handle number arrays", () => {
117
114
  const filter = { age: { $in: [20, 30, 40] } };
118
115
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("age" IN (20, 30, 40))`);
119
116
  });
120
- it('should handle mixed type arrays', () => {
121
- const filter = { value: { $in: ['test', 42, null, true] } };
117
+ it("should handle mixed type arrays", () => {
118
+ const filter = { value: { $in: ["test", 42, null, true] } };
122
119
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("value" IN ('test', 42, NULL, 1))`);
123
120
  });
124
- it('should handle empty arrays', () => {
121
+ it("should handle empty arrays", () => {
125
122
  const filter = { name: { $in: [] } };
126
123
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" IN ())`);
127
124
  });
128
- it('should throw error for non-array values', () => {
129
- const filter = { name: { $in: 'John' } };
130
- expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow('$in value must be an array');
125
+ it("should throw error for non-array values", () => {
126
+ const filter = { name: { $in: "John" } };
127
+ expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow("$in value must be an array");
131
128
  });
132
129
  });
133
- describe('$nin operator', () => {
134
- it('should handle string arrays', () => {
135
- const filter = { name: { $nin: ['John', 'Jane'] } };
130
+ describe("$nin operator", () => {
131
+ it("should handle string arrays", () => {
132
+ const filter = { name: { $nin: ["John", "Jane"] } };
136
133
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" NOT IN ('John', 'Jane'))`);
137
134
  });
138
- it('should handle number arrays', () => {
135
+ it("should handle number arrays", () => {
139
136
  const filter = { age: { $nin: [20, 30] } };
140
137
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("age" NOT IN (20, 30))`);
141
138
  });
142
- it('should throw error for non-array values', () => {
143
- const filter = { name: { $nin: 'John' } };
144
- expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow('$nin value must be an array');
139
+ it("should throw error for non-array values", () => {
140
+ const filter = { name: { $nin: "John" } };
141
+ expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow("$nin value must be an array");
145
142
  });
146
143
  });
147
- describe('$matchWords operator', () => {
148
- it('should handle single word', () => {
149
- const filter = { description: { $matchWords: 'test' } };
144
+ describe("$matchWords operator", () => {
145
+ it("should handle single word", () => {
146
+ const filter = { description: { $matchWords: "test" } };
150
147
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("description" LIKE '%test%')`);
151
148
  });
152
- it('should handle multiple words', () => {
153
- const filter = { description: { $matchWords: 'hello world' } };
149
+ it("should handle multiple words", () => {
150
+ const filter = { description: { $matchWords: "hello world" } };
154
151
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("description" LIKE '%hello%' AND "description" LIKE '%world%')`);
155
152
  });
156
- it('should handle words with quotes', () => {
153
+ it("should handle words with quotes", () => {
157
154
  const filter = { description: { $matchWords: "John's world" } };
158
155
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("description" LIKE '%John''s%' AND "description" LIKE '%world%')`);
159
156
  });
160
- it('should handle multiple quotes', () => {
157
+ it("should handle multiple quotes", () => {
161
158
  const filter = { description: { $matchWords: "It's John's" } };
162
159
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("description" LIKE '%It''s%' AND "description" LIKE '%John''s%')`);
163
160
  });
164
- it('should throw error for non-string values', () => {
161
+ it("should throw error for non-string values", () => {
165
162
  const filter = { description: { $matchWords: 123 } };
166
- expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow('$matchWords value must be a string');
163
+ expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow("$matchWords value must be a string");
167
164
  });
168
165
  });
169
- describe('$exists operator', () => {
170
- it('should handle $exists: true', () => {
166
+ describe("$exists operator", () => {
167
+ it("should handle $exists: true", () => {
171
168
  const filter = { name: { $exists: true } };
172
169
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" IS NOT NULL)`);
173
170
  });
174
- it('should handle $exists: false', () => {
171
+ it("should handle $exists: false", () => {
175
172
  const filter = { name: { $exists: false } };
176
173
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" IS NULL)`);
177
174
  });
178
- it('should handle truthy values', () => {
175
+ it("should handle truthy values", () => {
179
176
  const filter = { name: { $exists: 1 } };
180
177
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" IS NOT NULL)`);
181
178
  });
182
- it('should handle falsy values', () => {
179
+ it("should handle falsy values", () => {
183
180
  const filter = { name: { $exists: 0 } };
184
181
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" IS NULL)`);
185
182
  });
186
183
  });
187
- describe('$ne operator', () => {
188
- it('should handle string values', () => {
189
- const filter = { name: { $ne: 'John' } };
184
+ describe("$ne operator", () => {
185
+ it("should handle string values", () => {
186
+ const filter = { name: { $ne: "John" } };
190
187
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(("name" <> 'John' OR "name" IS NULL))`);
191
188
  });
192
- it('should handle number values', () => {
189
+ it("should handle number values", () => {
193
190
  const filter = { age: { $ne: 30 } };
194
191
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(("age" <> 30 OR "age" IS NULL))`);
195
192
  });
196
- it('should handle null values', () => {
193
+ it("should handle null values", () => {
197
194
  const filter = { name: { $ne: null } };
198
195
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(("name" <> NULL OR "name" IS NULL))`);
199
196
  });
200
- it('should escape quotes in strings', () => {
197
+ it("should escape quotes in strings", () => {
201
198
  const filter = { name: { $ne: "O'Hara" } };
202
199
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(("name" <> 'O''Hara' OR "name" IS NULL))`);
203
200
  });
204
201
  });
205
- describe('Comparison operators', () => {
206
- it('should handle $eq operator', () => {
202
+ describe("Comparison operators", () => {
203
+ it("should handle $eq operator", () => {
207
204
  const filter = { age: { $eq: 30 } };
208
205
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("age" = 30)`);
209
206
  });
210
- it('should handle $gt operator', () => {
207
+ it("should handle $gt operator", () => {
211
208
  const filter = { age: { $gt: 30 } };
212
209
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("age" > 30)`);
213
210
  });
214
- it('should handle $gte operator', () => {
211
+ it("should handle $gte operator", () => {
215
212
  const filter = { age: { $gte: 30 } };
216
213
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("age" >= 30)`);
217
214
  });
218
- it('should handle $lt operator', () => {
215
+ it("should handle $lt operator", () => {
219
216
  const filter = { age: { $lt: 30 } };
220
217
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("age" < 30)`);
221
218
  });
222
- it('should handle $lte operator', () => {
219
+ it("should handle $lte operator", () => {
223
220
  const filter = { age: { $lte: 30 } };
224
221
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("age" <= 30)`);
225
222
  });
226
- it('should handle string values with comparison operators', () => {
227
- const filter = { name: { $gt: 'John' } };
223
+ it("should handle string values with comparison operators", () => {
224
+ const filter = { name: { $gt: "John" } };
228
225
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" > 'John')`);
229
226
  });
230
- it('should handle date values', () => {
231
- const date = new Date('2023-01-01T00:00:00.000Z');
227
+ it("should handle date values", () => {
228
+ const date = new Date("2023-01-01T00:00:00.000Z");
232
229
  const filter = { created: { $gte: date } };
233
230
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("created" >= '2023-01-01T00:00:00.000Z')`);
234
231
  });
235
232
  });
236
233
  });
237
- describe('Field conditions', () => {
238
- it('should handle null field values', () => {
234
+ describe("Field conditions", () => {
235
+ it("should handle null field values", () => {
239
236
  const filter = { name: null };
240
237
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" IS NULL)`);
241
238
  });
242
- it('should handle undefined field values', () => {
239
+ it("should handle undefined field values", () => {
243
240
  const filter = { name: undefined };
244
241
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" IS NULL)`);
245
242
  });
246
- it('should handle simple field values', () => {
247
- const filter = { name: 'John', age: 30, active: true };
243
+ it("should handle simple field values", () => {
244
+ const filter = { name: "John", age: 30, active: true };
248
245
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = 'John' AND "age" = 30 AND "active" = 1)`);
249
246
  });
250
- it('should throw error for direct array usage', () => {
251
- const filter = { names: ['John', 'Jane'] };
247
+ it("should throw error for direct array usage", () => {
248
+ const filter = { names: ["John", "Jane"] };
252
249
  expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow(`Invalid filter: Arrays are not allowed as direct field values. Use $in instead: { names: { $in: ['John', 'Jane'] } }`);
253
250
  });
254
- it('should throw error for direct array usage with more items', () => {
255
- const filter = { names: ['John', 'Jane', 'Bob', 'Alice'] };
251
+ it("should throw error for direct array usage with more items", () => {
252
+ const filter = { names: ["John", "Jane", "Bob", "Alice"] };
256
253
  expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow(`Invalid filter: Arrays are not allowed as direct field values. Use $in instead: { names: { $in: ['John', 'Jane', ...] } }`);
257
254
  });
258
255
  });
259
- describe('Field name escaping', () => {
260
- it('should escape field names with double quotes', () => {
261
- const filter = { 'field"name': 'test' };
256
+ describe("Field name escaping", () => {
257
+ it("should escape field names with double quotes", () => {
258
+ const filter = { 'field"name': "test" };
262
259
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("field""name" = 'test')`);
263
260
  });
264
- it('should escape field names with multiple double quotes', () => {
265
- const filter = { 'field"with"quotes': 'test' };
261
+ it("should escape field names with multiple double quotes", () => {
262
+ const filter = { 'field"with"quotes': "test" };
266
263
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("field""with""quotes" = 'test')`);
267
264
  });
268
- it('should handle normal field names', () => {
269
- const filter = { fieldName: 'test' };
265
+ it("should handle normal field names", () => {
266
+ const filter = { fieldName: "test" };
270
267
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("fieldName" = 'test')`);
271
268
  });
272
269
  });
273
- describe('String value handling', () => {
274
- it('should escape single quotes in string values', () => {
270
+ describe("String value handling", () => {
271
+ it("should escape single quotes in string values", () => {
275
272
  const filter = { name: "John's" };
276
273
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = 'John''s')`);
277
274
  });
278
- it('should escape multiple single quotes', () => {
275
+ it("should escape multiple single quotes", () => {
279
276
  const filter = { name: "It's John's" };
280
277
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = 'It''s John''s')`);
281
278
  });
282
- it('should handle column references with $ prefix', () => {
283
- const filter = { name: '$other_column' };
279
+ it("should handle column references with $ prefix", () => {
280
+ const filter = { name: "$other_column" };
284
281
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = "other_column")`);
285
282
  });
286
- it('should handle escaped $ prefix', () => {
287
- const filter = { name: '\\$literal' };
283
+ it("should handle escaped $ prefix", () => {
284
+ const filter = { name: "\\$literal" };
288
285
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = '$literal')`);
289
286
  });
290
- it('should handle backslash not followed by $', () => {
291
- const filter = { name: '\\literal' };
287
+ it("should handle backslash not followed by $", () => {
288
+ const filter = { name: "\\literal" };
292
289
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = '\\literal')`);
293
290
  });
294
- it('should escape double quotes in column references', () => {
291
+ it("should escape double quotes in column references", () => {
295
292
  const filter = { name: '$col"with"quotes' };
296
293
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = "col""with""quotes")`);
297
294
  });
298
295
  });
299
- describe('Error cases', () => {
300
- it('should throw error for unknown operators', () => {
301
- const filter = { name: { $unknown: 'test' } };
302
- expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow('Unknown operator: $unknown');
296
+ describe("Error cases", () => {
297
+ it("should throw error for unknown operators", () => {
298
+ const filter = { name: { $unknown: "test" } };
299
+ expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow("Unknown operator: $unknown");
303
300
  });
304
- it('should throw error for invalid object values', () => {
305
- const filter = { name: { invalidKey: 'test' } };
306
- expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow('Invalid object value for field name');
301
+ it("should throw error for invalid object values", () => {
302
+ const filter = { name: { invalidKey: "test" } };
303
+ expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow("Invalid object value for field name");
307
304
  });
308
- it('should throw error for multiple operators in object', () => {
309
- const filter = { name: { $eq: 'test', $ne: 'other' } };
310
- expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow('Invalid object value for field name');
305
+ it("should throw error for multiple operators in object", () => {
306
+ const filter = { name: { $eq: "test", $ne: "other" } };
307
+ expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow("Invalid object value for field name");
311
308
  });
312
- it('should throw error for unknown scalar types', () => {
313
- const filter = { name: Symbol('test') };
314
- expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow('Cannot convert a Symbol value to a string');
309
+ it("should throw error for unknown scalar types", () => {
310
+ const filter = { name: Symbol("test") };
311
+ expect(() => (0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toThrow("Cannot convert a Symbol value to a string");
315
312
  });
316
313
  });
317
- describe('Complex nested scenarios', () => {
318
- it('should handle deeply nested conditions', () => {
314
+ describe("Complex nested scenarios", () => {
315
+ it("should handle deeply nested conditions", () => {
319
316
  const filter = {
320
317
  $and: [
321
- { name: 'John' },
318
+ { name: "John" },
322
319
  {
323
- $or: [
324
- { age: { $gte: 30 } },
325
- { city: { $in: ['NYC', 'LA'] } }
326
- ]
327
- }
328
- ]
320
+ $or: [{ age: { $gte: 30 } }, { city: { $in: ["NYC", "LA"] } }],
321
+ },
322
+ ],
329
323
  };
330
- expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`((("name" = 'John') AND (((\"age\" >= 30) OR (\"city\" IN ('NYC', 'LA'))))))`);
324
+ expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`((("name" = 'John') AND ((("age" >= 30) OR ("city" IN ('NYC', 'LA'))))))`);
331
325
  });
332
- it('should handle mixed operators and conditions', () => {
326
+ it("should handle mixed operators and conditions", () => {
333
327
  const filter = {
334
- name: { $ne: 'John' },
335
- $and: [
336
- { age: { $gte: 25 } },
337
- { age: { $lte: 65 } }
338
- ],
339
- $or: [
340
- { city: 'NYC' },
341
- { state: 'CA' }
342
- ]
328
+ name: { $ne: "John" },
329
+ $and: [{ age: { $gte: 25 } }, { age: { $lte: 65 } }],
330
+ $or: [{ city: "NYC" }, { state: "CA" }],
343
331
  };
344
332
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(("name" <> 'John' OR "name" IS NULL) AND (("age" >= 25) AND ("age" <= 65)) AND (("city" = 'NYC') OR ("state" = 'CA')))`);
345
333
  });
346
- it('should handle arrays with complex conditions', () => {
334
+ it("should handle arrays with complex conditions", () => {
347
335
  const filter = [
348
- { name: 'John', age: { $gte: 30 } },
349
- { city: { $in: ['NYC', 'LA'] }, active: true }
336
+ { name: "John", age: { $gte: 30 } },
337
+ { city: { $in: ["NYC", "LA"] }, active: true },
350
338
  ];
351
339
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`(("name" = 'John' AND "age" >= 30) OR ("city" IN ('NYC', 'LA') AND "active" = 1))`);
352
340
  });
353
341
  });
354
- describe('Edge cases', () => {
355
- it('should handle empty strings', () => {
356
- const filter = { name: '' };
342
+ describe("Edge cases", () => {
343
+ it("should handle empty strings", () => {
344
+ const filter = { name: "" };
357
345
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("name" = '')`);
358
346
  });
359
- it('should handle zero values', () => {
347
+ it("should handle zero values", () => {
360
348
  const filter = { count: 0 };
361
349
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("count" = 0)`);
362
350
  });
363
- it('should handle boolean false', () => {
351
+ it("should handle boolean false", () => {
364
352
  const filter = { active: false };
365
353
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("active" = 0)`);
366
354
  });
367
- it('should handle very long strings', () => {
368
- const longString = 'a'.repeat(1000);
355
+ it("should handle very long strings", () => {
356
+ const longString = "a".repeat(1000);
369
357
  const filter = { description: longString };
370
358
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("description" = '${longString}')`);
371
359
  });
372
- it('should handle special characters in field names', () => {
373
- const filter = { 'field-with-dashes': 'test', 'field_with_underscores': 'test2' };
360
+ it("should handle special characters in field names", () => {
361
+ const filter = { "field-with-dashes": "test", field_with_underscores: "test2" };
374
362
  expect((0, data_query_sqlite_1.dataFilterToSqlWhere)(filter)).toBe(`("field-with-dashes" = 'test' AND "field_with_underscores" = 'test2')`);
375
363
  });
376
364
  });