@saltcorn/data 1.6.0-beta.9 → 1.6.0-rc.2

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 (238) hide show
  1. package/dist/base-plugin/actions.d.ts.map +1 -1
  2. package/dist/base-plugin/actions.js +17 -14
  3. package/dist/base-plugin/actions.js.map +1 -1
  4. package/dist/base-plugin/fileviews.d.ts +6 -0
  5. package/dist/base-plugin/fileviews.d.ts.map +1 -1
  6. package/dist/base-plugin/fileviews.js +14 -0
  7. package/dist/base-plugin/fileviews.js.map +1 -1
  8. package/dist/base-plugin/index.d.ts +13 -3
  9. package/dist/base-plugin/index.d.ts.map +1 -1
  10. package/dist/base-plugin/viewtemplates/edit.d.ts +1 -0
  11. package/dist/base-plugin/viewtemplates/edit.d.ts.map +1 -1
  12. package/dist/base-plugin/viewtemplates/edit.js +16 -1
  13. package/dist/base-plugin/viewtemplates/edit.js.map +1 -1
  14. package/dist/base-plugin/viewtemplates/feed.d.ts +1 -1
  15. package/dist/base-plugin/viewtemplates/feed.d.ts.map +1 -1
  16. package/dist/base-plugin/viewtemplates/feed.js +27 -7
  17. package/dist/base-plugin/viewtemplates/feed.js.map +1 -1
  18. package/dist/base-plugin/viewtemplates/filter.d.ts +1 -0
  19. package/dist/base-plugin/viewtemplates/filter.d.ts.map +1 -1
  20. package/dist/base-plugin/viewtemplates/filter.js +31 -8
  21. package/dist/base-plugin/viewtemplates/filter.js.map +1 -1
  22. package/dist/base-plugin/viewtemplates/list.d.ts +2 -1
  23. package/dist/base-plugin/viewtemplates/list.d.ts.map +1 -1
  24. package/dist/base-plugin/viewtemplates/list.js +24 -8
  25. package/dist/base-plugin/viewtemplates/list.js.map +1 -1
  26. package/dist/base-plugin/viewtemplates/listshowlist.d.ts +1 -1
  27. package/dist/base-plugin/viewtemplates/listshowlist.d.ts.map +1 -1
  28. package/dist/base-plugin/viewtemplates/listshowlist.js +4 -1
  29. package/dist/base-plugin/viewtemplates/listshowlist.js.map +1 -1
  30. package/dist/base-plugin/viewtemplates/room.d.ts +1 -0
  31. package/dist/base-plugin/viewtemplates/room.d.ts.map +1 -1
  32. package/dist/base-plugin/viewtemplates/room.js +13 -2
  33. package/dist/base-plugin/viewtemplates/room.js.map +1 -1
  34. package/dist/base-plugin/viewtemplates/show.d.ts.map +1 -1
  35. package/dist/base-plugin/viewtemplates/show.js +24 -5
  36. package/dist/base-plugin/viewtemplates/show.js.map +1 -1
  37. package/dist/db/state.d.ts.map +1 -1
  38. package/dist/db/state.js +1 -0
  39. package/dist/db/state.js.map +1 -1
  40. package/dist/models/config.d.ts.map +1 -1
  41. package/dist/models/config.js +21 -0
  42. package/dist/models/config.js.map +1 -1
  43. package/dist/models/crash.d.ts +2 -1
  44. package/dist/models/crash.d.ts.map +1 -1
  45. package/dist/models/crash.js +1 -1
  46. package/dist/models/crash.js.map +1 -1
  47. package/dist/models/discovery.d.ts +14 -0
  48. package/dist/models/discovery.d.ts.map +1 -1
  49. package/dist/models/discovery.js +63 -0
  50. package/dist/models/discovery.js.map +1 -1
  51. package/dist/models/expression.d.ts.map +1 -1
  52. package/dist/models/expression.js +32 -4
  53. package/dist/models/expression.js.map +1 -1
  54. package/dist/models/field.d.ts.map +1 -1
  55. package/dist/models/field.js +14 -3
  56. package/dist/models/field.js.map +1 -1
  57. package/dist/models/file.d.ts.map +1 -1
  58. package/dist/models/file.js +8 -5
  59. package/dist/models/file.js.map +1 -1
  60. package/dist/models/index.d.ts +13 -3
  61. package/dist/models/index.d.ts.map +1 -1
  62. package/dist/models/index.js +1 -1
  63. package/dist/models/index.js.map +1 -1
  64. package/dist/models/layout.d.ts +1 -1
  65. package/dist/models/layout.d.ts.map +1 -1
  66. package/dist/models/layout.js +18 -8
  67. package/dist/models/layout.js.map +1 -1
  68. package/dist/models/page.d.ts.map +1 -1
  69. package/dist/models/page.js +18 -4
  70. package/dist/models/page.js.map +1 -1
  71. package/dist/models/page_group.d.ts.map +1 -1
  72. package/dist/models/page_group.js +4 -1
  73. package/dist/models/page_group.js.map +1 -1
  74. package/dist/models/page_group_member.d.ts.map +1 -1
  75. package/dist/models/page_group_member.js +3 -1
  76. package/dist/models/page_group_member.js.map +1 -1
  77. package/dist/models/plugin.d.ts.map +1 -1
  78. package/dist/models/plugin.js +5 -2
  79. package/dist/models/plugin.js.map +1 -1
  80. package/dist/models/table.d.ts +2 -0
  81. package/dist/models/table.d.ts.map +1 -1
  82. package/dist/models/table.js +12 -2
  83. package/dist/models/table.js.map +1 -1
  84. package/dist/models/trigger.d.ts +4 -2
  85. package/dist/models/trigger.d.ts.map +1 -1
  86. package/dist/models/trigger.js +45 -16
  87. package/dist/models/trigger.js.map +1 -1
  88. package/dist/models/workflow_step.d.ts.map +1 -1
  89. package/dist/models/workflow_step.js +3 -2
  90. package/dist/models/workflow_step.js.map +1 -1
  91. package/dist/plugin-helper.d.ts.map +1 -1
  92. package/dist/plugin-helper.js +5 -2
  93. package/dist/plugin-helper.js.map +1 -1
  94. package/dist/setup-test-schema.d.ts +2 -0
  95. package/dist/setup-test-schema.d.ts.map +1 -0
  96. package/dist/setup-test-schema.js +34 -0
  97. package/dist/setup-test-schema.js.map +1 -0
  98. package/dist/tests/actions.test.d.ts +2 -0
  99. package/dist/tests/actions.test.d.ts.map +1 -0
  100. package/dist/tests/actions.test.js +1104 -0
  101. package/dist/tests/actions.test.js.map +1 -0
  102. package/dist/tests/auth.test.d.ts +2 -0
  103. package/dist/tests/auth.test.d.ts.map +1 -0
  104. package/dist/tests/auth.test.js +927 -0
  105. package/dist/tests/auth.test.js.map +1 -0
  106. package/dist/tests/auxtest.test.d.ts +2 -0
  107. package/dist/tests/auxtest.test.d.ts.map +1 -0
  108. package/dist/tests/auxtest.test.js +631 -0
  109. package/dist/tests/auxtest.test.js.map +1 -0
  110. package/dist/tests/base.test.d.ts +2 -0
  111. package/dist/tests/base.test.d.ts.map +1 -0
  112. package/dist/tests/base.test.js +27 -0
  113. package/dist/tests/base.test.js.map +1 -0
  114. package/dist/tests/calc.test.d.ts +2 -0
  115. package/dist/tests/calc.test.d.ts.map +1 -0
  116. package/dist/tests/calc.test.js +1465 -0
  117. package/dist/tests/calc.test.js.map +1 -0
  118. package/dist/tests/composite_pk.test.d.ts +2 -0
  119. package/dist/tests/composite_pk.test.d.ts.map +1 -0
  120. package/dist/tests/composite_pk.test.js +98 -0
  121. package/dist/tests/composite_pk.test.js.map +1 -0
  122. package/dist/tests/config.test.d.ts +2 -0
  123. package/dist/tests/config.test.d.ts.map +1 -0
  124. package/dist/tests/config.test.js +86 -0
  125. package/dist/tests/config.test.js.map +1 -0
  126. package/dist/tests/db.test.d.ts +2 -0
  127. package/dist/tests/db.test.d.ts.map +1 -0
  128. package/dist/tests/db.test.js +179 -0
  129. package/dist/tests/db.test.js.map +1 -0
  130. package/dist/tests/discover.test.d.ts +2 -0
  131. package/dist/tests/discover.test.d.ts.map +1 -0
  132. package/dist/tests/discover.test.js +330 -0
  133. package/dist/tests/discover.test.js.map +1 -0
  134. package/dist/tests/edit.test.d.ts +2 -0
  135. package/dist/tests/edit.test.d.ts.map +1 -0
  136. package/dist/tests/edit.test.js +1186 -0
  137. package/dist/tests/edit.test.js.map +1 -0
  138. package/dist/tests/email.test.d.ts +2 -0
  139. package/dist/tests/email.test.d.ts.map +1 -0
  140. package/dist/tests/email.test.js +255 -0
  141. package/dist/tests/email.test.js.map +1 -0
  142. package/dist/tests/exact_views.test.d.ts +2 -0
  143. package/dist/tests/exact_views.test.d.ts.map +1 -0
  144. package/dist/tests/exact_views.test.js +1363 -0
  145. package/dist/tests/exact_views.test.js.map +1 -0
  146. package/dist/tests/field.test.d.ts +2 -0
  147. package/dist/tests/field.test.d.ts.map +1 -0
  148. package/dist/tests/field.test.js +589 -0
  149. package/dist/tests/field.test.js.map +1 -0
  150. package/dist/tests/fieldviews.test.d.ts +2 -0
  151. package/dist/tests/fieldviews.test.d.ts.map +1 -0
  152. package/dist/tests/fieldviews.test.js +74 -0
  153. package/dist/tests/fieldviews.test.js.map +1 -0
  154. package/dist/tests/file.test.d.ts +2 -0
  155. package/dist/tests/file.test.d.ts.map +1 -0
  156. package/dist/tests/file.test.js +165 -0
  157. package/dist/tests/file.test.js.map +1 -0
  158. package/dist/tests/filter.test.d.ts +2 -0
  159. package/dist/tests/filter.test.d.ts.map +1 -0
  160. package/dist/tests/filter.test.js +499 -0
  161. package/dist/tests/filter.test.js.map +1 -0
  162. package/dist/tests/form.test.d.ts +2 -0
  163. package/dist/tests/form.test.d.ts.map +1 -0
  164. package/dist/tests/form.test.js +343 -0
  165. package/dist/tests/form.test.js.map +1 -0
  166. package/dist/tests/list.test.d.ts +2 -0
  167. package/dist/tests/list.test.d.ts.map +1 -0
  168. package/dist/tests/list.test.js +1236 -0
  169. package/dist/tests/list.test.js.map +1 -0
  170. package/dist/tests/mail_queue.test.d.ts +2 -0
  171. package/dist/tests/mail_queue.test.d.ts.map +1 -0
  172. package/dist/tests/mail_queue.test.js +122 -0
  173. package/dist/tests/mail_queue.test.js.map +1 -0
  174. package/dist/tests/models.test.d.ts +2 -0
  175. package/dist/tests/models.test.d.ts.map +1 -0
  176. package/dist/tests/models.test.js +417 -0
  177. package/dist/tests/models.test.js.map +1 -0
  178. package/dist/tests/page.test.d.ts +2 -0
  179. package/dist/tests/page.test.d.ts.map +1 -0
  180. package/dist/tests/page.test.js +91 -0
  181. package/dist/tests/page.test.js.map +1 -0
  182. package/dist/tests/page_group.test.d.ts +2 -0
  183. package/dist/tests/page_group.test.d.ts.map +1 -0
  184. package/dist/tests/page_group.test.js +52 -0
  185. package/dist/tests/page_group.test.js.map +1 -0
  186. package/dist/tests/plugin.test.d.ts +2 -0
  187. package/dist/tests/plugin.test.d.ts.map +1 -0
  188. package/dist/tests/plugin.test.js +66 -0
  189. package/dist/tests/plugin.test.js.map +1 -0
  190. package/dist/tests/show.test.d.ts +2 -0
  191. package/dist/tests/show.test.d.ts.map +1 -0
  192. package/dist/tests/show.test.js +613 -0
  193. package/dist/tests/show.test.js.map +1 -0
  194. package/dist/tests/state.test.d.ts +2 -0
  195. package/dist/tests/state.test.d.ts.map +1 -0
  196. package/dist/tests/state.test.js +82 -0
  197. package/dist/tests/state.test.js.map +1 -0
  198. package/dist/tests/table.test.d.ts +2 -0
  199. package/dist/tests/table.test.d.ts.map +1 -0
  200. package/dist/tests/table.test.js +3211 -0
  201. package/dist/tests/table.test.js.map +1 -0
  202. package/dist/tests/table_history.test.d.ts +2 -0
  203. package/dist/tests/table_history.test.d.ts.map +1 -0
  204. package/dist/tests/table_history.test.js +415 -0
  205. package/dist/tests/table_history.test.js.map +1 -0
  206. package/dist/tests/table_sync_info.test.d.ts +2 -0
  207. package/dist/tests/table_sync_info.test.d.ts.map +1 -0
  208. package/dist/tests/table_sync_info.test.js +62 -0
  209. package/dist/tests/table_sync_info.test.js.map +1 -0
  210. package/dist/tests/tag.test.d.ts +2 -0
  211. package/dist/tests/tag.test.d.ts.map +1 -0
  212. package/dist/tests/tag.test.js +97 -0
  213. package/dist/tests/tag.test.js.map +1 -0
  214. package/dist/tests/user.test.d.ts +2 -0
  215. package/dist/tests/user.test.d.ts.map +1 -0
  216. package/dist/tests/user.test.js +467 -0
  217. package/dist/tests/user.test.js.map +1 -0
  218. package/dist/tests/view.test.d.ts +2 -0
  219. package/dist/tests/view.test.d.ts.map +1 -0
  220. package/dist/tests/view.test.js +703 -0
  221. package/dist/tests/view.test.js.map +1 -0
  222. package/dist/tests/workflow.test.d.ts +2 -0
  223. package/dist/tests/workflow.test.d.ts.map +1 -0
  224. package/dist/tests/workflow.test.js +303 -0
  225. package/dist/tests/workflow.test.js.map +1 -0
  226. package/dist/tests/workflow_run.test.d.ts +2 -0
  227. package/dist/tests/workflow_run.test.d.ts.map +1 -0
  228. package/dist/tests/workflow_run.test.js +922 -0
  229. package/dist/tests/workflow_run.test.js.map +1 -0
  230. package/dist/utils.d.ts +1 -0
  231. package/dist/utils.d.ts.map +1 -1
  232. package/dist/utils.js +31 -2
  233. package/dist/utils.js.map +1 -1
  234. package/dist/viewable_fields.d.ts +3 -2
  235. package/dist/viewable_fields.d.ts.map +1 -1
  236. package/dist/viewable_fields.js +57 -29
  237. package/dist/viewable_fields.js.map +1 -1
  238. package/package.json +12 -9
@@ -0,0 +1,631 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const view_1 = __importDefault(require("../models/view"));
7
+ const db_1 = __importDefault(require("../db"));
8
+ const table_1 = __importDefault(require("../models/table"));
9
+ const field_1 = __importDefault(require("../models/field"));
10
+ const async_json_stream_1 = __importDefault(require("../models/internal/async_json_stream"));
11
+ const fs = require("fs");
12
+ const { get_parent_views, get_child_views, get_inbound_relation_opts, get_inbound_self_relation_opts, get_many_to_many_relation_opts, stateFieldsToWhere, field_picker_fields, readState, generate_joined_query, stateToQueryString, } = require("../plugin-helper");
13
+ const { getState } = require("../db/state");
14
+ const { satisfies, urlStringToObject, cloneName, objectToQueryString, validSqlId, } = require("../utils");
15
+ const test_expect_1 = require("@saltcorn/db-common/test_expect");
16
+ const mocks_1 = __importDefault(require("./mocks"));
17
+ const common_helpers_1 = require("./common_helpers");
18
+ const assertions_1 = require("./assertions");
19
+ const expression_1 = __importDefault(require("../models/expression"));
20
+ const { freeVariables, add_free_variables_to_joinfields } = expression_1.default;
21
+ const PlainDate = require("@saltcorn/plain-date");
22
+ const { mockReqRes } = mocks_1.default;
23
+ getState().registerPlugin("base", require("../base-plugin"));
24
+ (0, test_expect_1.beforeAll)(async () => {
25
+ await require("../db/reset_schema")();
26
+ await require("../db/fixtures")();
27
+ });
28
+ (0, test_expect_1.afterAll)(db_1.default.close);
29
+ (0, test_expect_1.describe)("string manipulators", () => {
30
+ (0, test_expect_1.it)("cloneName", async () => {
31
+ (0, test_expect_1.expect)(cloneName("Foo", [])).toBe("Foo-copy");
32
+ (0, test_expect_1.expect)(cloneName("Foo", ["Foo-copy"])).toBe("Foo-copy-1");
33
+ });
34
+ (0, test_expect_1.it)("validSqlId", async () => {
35
+ (0, test_expect_1.expect)(validSqlId("Sr. Søejer")).toBe("sr_soejer");
36
+ });
37
+ });
38
+ (0, test_expect_1.describe)("stateToQueryString", () => {
39
+ (0, test_expect_1.it)("makes query string", async () => {
40
+ (0, test_expect_1.expect)(stateToQueryString({ x: "5" })).toBe("?x=5");
41
+ (0, test_expect_1.expect)(stateToQueryString({ x: "5", y: "goo" })).toBe("?x=5&y=goo");
42
+ });
43
+ (0, test_expect_1.it)("makes query string with array", async () => {
44
+ (0, test_expect_1.expect)(stateToQueryString({ x: [5, 6] })).toBe("?x=5&x=6");
45
+ (0, test_expect_1.expect)(stateToQueryString({ x: [5] })).toBe("?x=5");
46
+ (0, test_expect_1.expect)(stateToQueryString({ x: [5, 6], z: true })).toBe("?x=5&x=6&z=true");
47
+ });
48
+ (0, test_expect_1.it)("makes query string with lt/gt", async () => {
49
+ (0, test_expect_1.expect)(stateToQueryString({ x: { lt: 5 } })).toBe("?_lt_x=5");
50
+ (0, test_expect_1.expect)(stateToQueryString({ x: { lt: 5, gt: 1 } })).toBe("?_gt_x=1&_lt_x=5");
51
+ (0, test_expect_1.expect)(stateToQueryString({ x: { lt: 5 }, y: "foo" })).toBe("?_lt_x=5&y=foo");
52
+ (0, test_expect_1.expect)(stateToQueryString({ x: { gt: 5 } })).toBe("?_gt_x=5");
53
+ (0, test_expect_1.expect)(stateToQueryString({ x: { lt: 5, equal: true } })).toBe("?_lte_x=5");
54
+ });
55
+ (0, test_expect_1.it)("handles date", async () => {
56
+ (0, test_expect_1.expect)(stateToQueryString({ pubdate: new PlainDate("2025-10-15") })).toBe("?pubdate=2025-10-15");
57
+ (0, test_expect_1.expect)(stateToQueryString({ pubdate: { gt: new PlainDate("2025-10-15") } })).toBe("?_gt_pubdate=2025-10-15");
58
+ (0, test_expect_1.expect)(stateToQueryString({ pubdate: new Date("2025-10-15") })).toBe("?pubdate=2025-10-15T00%3A00%3A00.000Z");
59
+ (0, test_expect_1.expect)(stateToQueryString({ pubdate: { lt: new Date("2025-10-15") } })).toBe("?_lt_pubdate=2025-10-15T00%3A00%3A00.000Z");
60
+ });
61
+ });
62
+ (0, test_expect_1.describe)("async_json_stream", () => {
63
+ (0, test_expect_1.it)("writes test file", async () => {
64
+ const data = [
65
+ { name: "Tom", age: 13 },
66
+ { name: "Harry", age: 41 },
67
+ ];
68
+ fs.writeFileSync("/tmp/testjsondata.json", JSON.stringify(data));
69
+ });
70
+ (0, test_expect_1.it)("reads", async () => {
71
+ const data = [];
72
+ await (0, async_json_stream_1.default)("/tmp/testjsondata.json", async (person) => {
73
+ data.push(person);
74
+ });
75
+ (0, test_expect_1.expect)(data.length).toBe(2);
76
+ });
77
+ });
78
+ (0, test_expect_1.describe)("generate_joined_query", () => {
79
+ (0, test_expect_1.it)("should generate state", async () => {
80
+ const table = table_1.default.findOne({ name: "books" });
81
+ (0, assertions_1.assertIsSet)(table);
82
+ const q = generate_joined_query({ table, state: { author: "Leo" } });
83
+ (0, test_expect_1.expect)(q?.where?.author?.ilike).toBe("Leo");
84
+ const rows = await table.getJoinedRows(q);
85
+ (0, test_expect_1.expect)(rows.length).toBe(1);
86
+ (0, test_expect_1.expect)(rows[0].author).toBe("Leo Tolstoy");
87
+ });
88
+ (0, test_expect_1.it)("should generate FTS state", async () => {
89
+ const table = table_1.default.findOne({ name: "books" });
90
+ (0, assertions_1.assertIsSet)(table);
91
+ const q = generate_joined_query({ table, state: { _fts_books: "Leo" } });
92
+ (0, test_expect_1.expect)(q?.where?._fts?.searchTerm).toBe("Leo");
93
+ const rows = await table.getJoinedRows(q);
94
+ (0, test_expect_1.expect)(rows.length).toBe(1);
95
+ (0, test_expect_1.expect)(rows[0].author).toBe("Leo Tolstoy");
96
+ });
97
+ (0, test_expect_1.it)("should generate FTS state with inlcude key summary", async () => {
98
+ const table = table_1.default.findOne({ name: "patients" });
99
+ (0, assertions_1.assertIsSet)(table);
100
+ const q = generate_joined_query({
101
+ table,
102
+ state: { _fts_patients: "Herman" },
103
+ joinFields: {
104
+ pages: { ref: "favbook", target: "pages" },
105
+ author: { ref: "favbook", target: "author" },
106
+ },
107
+ });
108
+ (0, test_expect_1.expect)(q?.where?._fts?.searchTerm).toBe("Herman");
109
+ const rows = await table.getJoinedRows(q);
110
+ (0, test_expect_1.expect)(rows.length).toBe(1);
111
+ (0, test_expect_1.expect)(rows[0].author).toBe("Herman Melville");
112
+ });
113
+ (0, test_expect_1.it)("should generate formulas", async () => {
114
+ const table = table_1.default.findOne({ name: "books" });
115
+ (0, assertions_1.assertIsSet)(table);
116
+ const q = generate_joined_query({ table, formulas: ["publisher.name"] });
117
+ (0, test_expect_1.expect)(q?.joinFields?.publisher_name?.target).toBe("name");
118
+ const rows = await table.getJoinedRows(q);
119
+ (0, test_expect_1.expect)(rows.length).toBe(2);
120
+ });
121
+ (0, test_expect_1.it)("should generate for show view", async () => {
122
+ const user = { id: 1 };
123
+ const table = table_1.default.findOne({ name: "books" });
124
+ (0, assertions_1.assertIsSet)(table);
125
+ const view = view_1.default.findOne({ name: "authorshow" });
126
+ (0, assertions_1.assertIsSet)(view);
127
+ const q = generate_joined_query({
128
+ table,
129
+ state: { id: "1" },
130
+ ...view.configuration,
131
+ user,
132
+ });
133
+ (0, test_expect_1.expect)(q?.where?.id).toBe(1);
134
+ (0, test_expect_1.expect)(q?.forUser?.id).toBe(1);
135
+ (0, test_expect_1.expect)(q.aggregations.count_patients_favbook_name_undefined.field).toBe("name");
136
+ const rows = await table.getJoinedRows(q);
137
+ (0, test_expect_1.expect)(rows.length).toBe(1);
138
+ });
139
+ });
140
+ (0, test_expect_1.describe)("Half-H notation for joinfields", () => {
141
+ // deciding between ㅏ Ⱶ Ͱ
142
+ // publisherͰname
143
+ // publisherⱵname
144
+ // publisherㅏname
145
+ (0, test_expect_1.it)("freeVariables", () => {
146
+ (0, test_expect_1.expect)([...freeVariables("2+xⱵk")]).toEqual(["xⱵk"]);
147
+ });
148
+ (0, test_expect_1.it)("add_free_variables_to_joinfields", () => {
149
+ const table = table_1.default.findOne({ name: "books" });
150
+ (0, assertions_1.assertIsSet)(table);
151
+ const joinFields = {};
152
+ const freeVars = freeVariables("publisherⱵname");
153
+ add_free_variables_to_joinfields(freeVars, joinFields, table.fields);
154
+ (0, test_expect_1.expect)(joinFields).toStrictEqual({
155
+ publisherⱵname: {
156
+ ref: "publisher",
157
+ target: "name",
158
+ },
159
+ });
160
+ });
161
+ (0, test_expect_1.it)("should generate formulas", async () => {
162
+ const table = table_1.default.findOne({ name: "books" });
163
+ (0, assertions_1.assertIsSet)(table);
164
+ const q = generate_joined_query({
165
+ table,
166
+ state: { pages: 728 },
167
+ formulas: ["publisherⱵname"],
168
+ });
169
+ (0, test_expect_1.expect)(q?.joinFields?.publisherⱵname?.target).toBe("name");
170
+ const rows = await table.getJoinedRows(q);
171
+ (0, test_expect_1.expect)(rows.length).toBe(1);
172
+ (0, test_expect_1.expect)(rows[0].publisher).toBe(1);
173
+ (0, test_expect_1.expect)(rows[0].publisherⱵname).toBe("AK Press");
174
+ });
175
+ });
176
+ (0, test_expect_1.describe)("plugin helper", () => {
177
+ (0, test_expect_1.it)("get parent views", async () => {
178
+ const patients = table_1.default.findOne({ name: "patients" });
179
+ const x = await get_parent_views(patients, "foobar");
180
+ (0, test_expect_1.expect)(x[0].views.map((v) => v.name).sort()).toStrictEqual([
181
+ "admin_authoredit",
182
+ "author_multi_edit",
183
+ "authoredit",
184
+ "authoredit_identicals",
185
+ "authoredit_with_independent_list",
186
+ "authoredit_with_independent_list_legacy",
187
+ "authoredit_with_show",
188
+ "authoredit_with_show_legacy",
189
+ "authorshow",
190
+ "authorshow_with_list_legacy",
191
+ "show_author_with_disc_books_list",
192
+ ]);
193
+ });
194
+ (0, test_expect_1.it)("get child views", async () => {
195
+ const books = table_1.default.findOne({ name: "books" });
196
+ const x = await get_child_views(books, "foobar");
197
+ (0, test_expect_1.expect)(x[1].views.map((v) => v.name)).toStrictEqual(["patientlist"]);
198
+ });
199
+ (0, test_expect_1.describe)("inbound relations", () => {
200
+ const expectedBase = [
201
+ ".users.user_interested_in_topic$user.topic.blog_in_topic$topic",
202
+ ".users.user_interested_in_topic$user.topic.blog_in_topic$topic.post",
203
+ ".users.user_interested_in_topic$user.topic.inbound_inbound$topic.bp_inbound.post",
204
+ ".users.discusses_books$discussant.book.patients$favbook",
205
+ ];
206
+ (0, test_expect_1.it)("single keys to source and rel table", async () => {
207
+ const sourceTbl = table_1.default.findOne({ name: "users" });
208
+ const opts = await get_inbound_relation_opts(sourceTbl, "top_view");
209
+ for (const expected of expectedBase) {
210
+ const actual = opts.find((val) => val.path === expected && val.views.length > 0);
211
+ (0, test_expect_1.expect)(actual).toBeDefined();
212
+ }
213
+ });
214
+ (0, test_expect_1.it)("multiple keys to source and single key to rel table", async () => {
215
+ await (0, common_helpers_1.createAnotherUserField)();
216
+ const expected = [...expectedBase];
217
+ expected.push(".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic.post", ".users.user_interested_in_topic$another_user.topic.inbound_inbound$topic.bp_inbound.post");
218
+ const sourceTbl = table_1.default.findOne({ name: "users" });
219
+ const opts = await get_inbound_relation_opts(sourceTbl, "top_view");
220
+ for (const expectedPath of expected) {
221
+ const actual = opts.find((val) => val.path === expectedPath && val.views.length > 0);
222
+ (0, test_expect_1.expect)(actual).toBeDefined();
223
+ }
224
+ });
225
+ (0, test_expect_1.it)("multiple keys to source and rel table", async () => {
226
+ await (0, common_helpers_1.createAnotherUserField)();
227
+ await (0, common_helpers_1.createSecondTopicField)();
228
+ const expected = [...expectedBase];
229
+ expected.push(".users.user_interested_in_topic$another_user.topic.blog_in_topic$second_topic", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic", ".users.user_interested_in_topic$user.topic.blog_in_topic$second_topic", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$second_topic.post", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic.post", ".users.user_interested_in_topic$another_user.topic.inbound_inbound$topic.bp_inbound.post", ".users.user_interested_in_topic$user.topic.blog_in_topic$second_topic.post");
230
+ const sourceTbl = table_1.default.findOne({ name: "users" });
231
+ const opts = await get_inbound_relation_opts(sourceTbl, "top_view");
232
+ for (const expectedPath of expected) {
233
+ const actual = opts.find((val) => val.path === expectedPath && val.views.length > 0);
234
+ (0, test_expect_1.expect)(actual).toBeDefined();
235
+ }
236
+ });
237
+ (0, test_expect_1.it)("multiple inbound tables", async () => {
238
+ await (0, common_helpers_1.createAnotherUserField)();
239
+ await (0, common_helpers_1.createSecondTopicField)();
240
+ await (0, common_helpers_1.createMultipleInbounds)();
241
+ const expected = [...expectedBase];
242
+ expected.push(".users.second_inbound$user.topic.blog_in_topic$second_topic", ".users.second_inbound$user.topic.blog_in_topic$topic", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$second_topic", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic", ".users.user_interested_in_topic$user.topic.blog_in_topic$second_topic", ".users.second_inbound$user.topic.blog_in_topic$second_topic.post", ".users.second_inbound$user.topic.blog_in_topic$topic.post", ".users.second_inbound$user.topic.inbound_inbound$topic.bp_inbound.post", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$second_topic.post", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic.post", ".users.user_interested_in_topic$another_user.topic.inbound_inbound$topic.bp_inbound.post", ".users.user_interested_in_topic$user.topic.blog_in_topic$second_topic.post");
243
+ const sourceTbl = table_1.default.findOne({ name: "users" });
244
+ const opts = await get_inbound_relation_opts(sourceTbl, "top_view");
245
+ for (const expectedPath of expected) {
246
+ const actual = opts.find((val) => val.path === expectedPath && val.views.length > 0);
247
+ (0, test_expect_1.expect)(actual).toBeDefined();
248
+ }
249
+ });
250
+ (0, test_expect_1.it)("key to source from level two", async () => {
251
+ await (0, common_helpers_1.createAnotherUserField)();
252
+ await (0, common_helpers_1.createSecondTopicField)();
253
+ await (0, common_helpers_1.createMultipleInbounds)();
254
+ await (0, common_helpers_1.createKeyFromLevelTwo)();
255
+ const oldTbl = table_1.default.findOne({ name: "second_inbound" });
256
+ if (oldTbl)
257
+ await oldTbl.delete();
258
+ const expected = [...expectedBase];
259
+ expected.push(".users.user_interested_in_topic$another_user.topic.blog_in_topic$second_topic", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic", ".users.user_interested_in_topic$user.topic.blog_in_topic$second_topic", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$second_topic.post", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic.post", ".users.user_interested_in_topic$another_user.topic.inbound_inbound$topic.bp_inbound.post", ".users.user_interested_in_topic$another_user.topic.inbound_inbound$topic.post_from_level_two", ".users.user_interested_in_topic$user.topic.blog_in_topic$second_topic.post", ".users.user_interested_in_topic$user.topic.inbound_inbound$topic.post_from_level_two");
260
+ const sourceTbl = table_1.default.findOne({ name: "users" });
261
+ const opts = await get_inbound_relation_opts(sourceTbl, "top_view");
262
+ for (const expectedPath of expected) {
263
+ const actual = opts.find((val) => val.path === expectedPath && val.views.length > 0);
264
+ (0, test_expect_1.expect)(actual).toBeDefined();
265
+ }
266
+ });
267
+ (0, test_expect_1.it)("three levels inbound", async () => {
268
+ await (0, common_helpers_1.createAnotherUserField)();
269
+ await (0, common_helpers_1.createSecondTopicField)();
270
+ await (0, common_helpers_1.createMultipleInbounds)();
271
+ await (0, common_helpers_1.createKeyFromLevelTwo)();
272
+ const oldTbl = table_1.default.findOne({ name: "second_inbound" });
273
+ if (oldTbl)
274
+ await oldTbl.delete();
275
+ await (0, common_helpers_1.createLevelThreeInbound)();
276
+ const expected = [...expectedBase];
277
+ expected.push(".users.user_interested_in_topic$another_user.topic.blog_in_topic$second_topic", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic", ".users.user_interested_in_topic$user.topic.blog_in_topic$second_topic", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$second_topic.post", ".users.user_interested_in_topic$another_user.topic.blog_in_topic$topic.post", ".users.user_interested_in_topic$another_user.topic.inbound_inbound$topic.bp_inbound.post", ".users.user_interested_in_topic$another_user.topic.inbound_inbound$topic.post_from_level_two", ".users.user_interested_in_topic$another_user.topic.inbound_level_three$topic.inbound_level_two.bp_inbound.post", ".users.user_interested_in_topic$another_user.topic.inbound_level_three$topic.inbound_level_two.post_from_level_two", ".users.user_interested_in_topic$user.topic.blog_in_topic$second_topic.post", ".users.user_interested_in_topic$user.topic.inbound_inbound$topic.post_from_level_two", ".users.user_interested_in_topic$user.topic.inbound_level_three$topic.inbound_level_two.bp_inbound.post", ".users.user_interested_in_topic$user.topic.inbound_level_three$topic.inbound_level_two.post_from_level_two");
278
+ const sourceTbl = table_1.default.findOne({ name: "users" });
279
+ const opts = await get_inbound_relation_opts(sourceTbl, "top_view");
280
+ for (const expectedPath of expected) {
281
+ const actual = opts.find((val) => val.path === expectedPath && val.views.length > 0);
282
+ (0, test_expect_1.expect)(actual).toBeDefined();
283
+ }
284
+ });
285
+ (0, test_expect_1.it)("no inbound relations", async () => {
286
+ const targetTbl = table_1.default.findOne({ name: "publisher" });
287
+ (0, assertions_1.assertIsSet)(targetTbl);
288
+ const allRels = await get_inbound_relation_opts(targetTbl, "top_view");
289
+ (0, test_expect_1.expect)(allRels).toEqual([]);
290
+ });
291
+ (0, test_expect_1.it)("employee department relation", async () => {
292
+ const employee = table_1.default.findOne({ name: "employee" });
293
+ (0, assertions_1.assertIsSet)(employee);
294
+ const result = await get_inbound_self_relation_opts(employee, "show_employee");
295
+ (0, test_expect_1.expect)(result.length).toBe(1);
296
+ (0, test_expect_1.expect)(result[0].path).toBe(".employee.department.manager");
297
+ (0, test_expect_1.expect)(result[0].views.length).toBe(3);
298
+ (0, test_expect_1.expect)(result[0].views[0].name).toBe("create_employee");
299
+ });
300
+ (0, test_expect_1.it)("simple post topic relation", async () => {
301
+ await (0, common_helpers_1.prepareSimpleTopicPostRelation)();
302
+ const simplePosts = table_1.default.findOne({ name: "simple_posts" });
303
+ (0, assertions_1.assertIsSet)(simplePosts);
304
+ const users = table_1.default.findOne({ name: "users" });
305
+ (0, assertions_1.assertIsSet)(users);
306
+ const expected = [
307
+ ".users.favsimpletopic.simple_posts$topic",
308
+ ".users.favsimpletopic.simple_post_inbound$topic.post",
309
+ ];
310
+ const opts = await get_inbound_relation_opts(users, "show_user_with_simple_posts_list");
311
+ for (const expectedPath of expected) {
312
+ const actual = opts.find((val) => val.path === expectedPath && val.views.length > 0);
313
+ (0, test_expect_1.expect)(actual).toBeDefined();
314
+ }
315
+ });
316
+ });
317
+ (0, test_expect_1.describe)("many to many relations", () => {
318
+ (0, test_expect_1.it)("artist_plays_on_album", async () => {
319
+ const artists = table_1.default.findOne({ name: "artists" });
320
+ const opts = await get_many_to_many_relation_opts(artists, "show_artist", null, [".artists"]);
321
+ const expected = [".artists.artist_plays_on_album$artist.album"];
322
+ for (const expectedPath of expected) {
323
+ const actual = opts.find((val) => val.path === expectedPath && val.views.length > 0);
324
+ (0, test_expect_1.expect)(actual).toBeDefined();
325
+ }
326
+ });
327
+ (0, test_expect_1.it)("show pressing_job with embedded fan club feed", async () => {
328
+ const pressingJob = table_1.default.findOne({ name: "pressing_job" });
329
+ const opts = await get_many_to_many_relation_opts(pressingJob, "show_pressing_job", null, [".pressing_job"]);
330
+ const expected = [
331
+ ".pressing_job.album.artist_plays_on_album$album.artist.fan_club$artist",
332
+ ];
333
+ for (const expectedPath of expected) {
334
+ const actual = opts.find((val) => val.path === expectedPath && val.views.length > 0);
335
+ (0, test_expect_1.expect)(actual).toBeDefined();
336
+ }
337
+ });
338
+ });
339
+ });
340
+ (0, test_expect_1.describe)("stateFieldsToWhere", () => {
341
+ const fields = [
342
+ new field_1.default({ name: "astr", type: "String" }),
343
+ new field_1.default({ name: "age", type: "Integer" }),
344
+ new field_1.default({ name: "dob", type: "Date", attributes: { day_only: true } }),
345
+ new field_1.default({ name: "tob", type: "Date", attributes: { day_only: false } }),
346
+ new field_1.default({ name: "favbook", type: "Key to books" }),
347
+ { name: "props", type: { name: "JSON" } },
348
+ {
349
+ name: "attrs",
350
+ type: { name: "JSON" },
351
+ attributes: {
352
+ hasSchema: true,
353
+ schema: [{ key: "name", type: "String" }],
354
+ },
355
+ },
356
+ ];
357
+ (0, test_expect_1.it)("normal field", async () => {
358
+ const w = stateFieldsToWhere({
359
+ fields,
360
+ state: { astr: "foo", bstr: "bar" },
361
+ });
362
+ (0, test_expect_1.expect)(w).toStrictEqual({ astr: { ilike: "foo" } });
363
+ });
364
+ (0, test_expect_1.it)("int field bounds", async () => {
365
+ const w = stateFieldsToWhere({
366
+ fields,
367
+ state: { _gte_age: 5, _lte_age: 15 },
368
+ });
369
+ (0, test_expect_1.expect)(w).toStrictEqual({
370
+ age: [
371
+ { equal: true, gt: 5 },
372
+ { equal: true, lt: 15 },
373
+ ],
374
+ });
375
+ });
376
+ (0, test_expect_1.it)("not", async () => {
377
+ const w = stateFieldsToWhere({
378
+ fields,
379
+ state: { _not_age: 5 },
380
+ });
381
+ (0, test_expect_1.expect)(w).toStrictEqual({
382
+ not: { age: 5 },
383
+ });
384
+ });
385
+ (0, test_expect_1.it)("date bounds", async () => {
386
+ const w = stateFieldsToWhere({
387
+ fields,
388
+ state: { _fromneqdate_dob: 5, _toneqdate_dob: 15 },
389
+ });
390
+ (0, test_expect_1.expect)(w).toStrictEqual({
391
+ dob: [
392
+ { gt: new PlainDate(5), day_only: true },
393
+ { lt: new PlainDate(15), day_only: true },
394
+ ],
395
+ });
396
+ });
397
+ (0, test_expect_1.it)("date bounds inclusive", async () => {
398
+ const w = stateFieldsToWhere({
399
+ fields,
400
+ state: { _fromdate_dob: "2025-07-24", _todate_dob: "2025-07-27" },
401
+ });
402
+ (0, test_expect_1.expect)(w).toStrictEqual({
403
+ dob: [
404
+ { gt: new PlainDate("2025-07-24"), equal: true, day_only: true },
405
+ { lt: new PlainDate("2025-07-27"), equal: true, day_only: true },
406
+ ],
407
+ });
408
+ });
409
+ (0, test_expect_1.it)("date bounds inclusive with time", async () => {
410
+ const w = stateFieldsToWhere({
411
+ fields,
412
+ state: { _fromdate_tob: "2025-07-24", _todate_tob: "2025-07-27" },
413
+ });
414
+ (0, test_expect_1.expect)(w).toStrictEqual({
415
+ tob: [
416
+ { gt: new Date("2025-07-24"), equal: true, day_only: false },
417
+ { lt: new Date("2025-07-28"), equal: true, day_only: false },
418
+ ],
419
+ });
420
+ });
421
+ (0, test_expect_1.it)("normal field not approx", async () => {
422
+ const w = stateFieldsToWhere({
423
+ fields,
424
+ state: { astr: "foo" },
425
+ approximate: false,
426
+ });
427
+ (0, test_expect_1.expect)(w).toStrictEqual({ astr: "foo" });
428
+ });
429
+ (0, test_expect_1.it)("foreign field ", async () => {
430
+ const w = stateFieldsToWhere({
431
+ fields,
432
+ state: { bstr: "foo" },
433
+ approximate: false,
434
+ });
435
+ (0, test_expect_1.expect)(w).toStrictEqual({});
436
+ });
437
+ (0, test_expect_1.it)("foreign field ", async () => {
438
+ const w = stateFieldsToWhere({
439
+ fields,
440
+ state: { bstr: { slugify: "foo" } },
441
+ approximate: false,
442
+ });
443
+ (0, test_expect_1.expect)(w).toStrictEqual({});
444
+ });
445
+ (0, test_expect_1.it)("json field", async () => {
446
+ const w = stateFieldsToWhere({
447
+ fields,
448
+ state: { props: { name: "Tom" } },
449
+ });
450
+ (0, test_expect_1.expect)(w).toStrictEqual({ props: [{ json: { name: "Tom" } }] });
451
+ });
452
+ (0, test_expect_1.it)("json field schema string", async () => {
453
+ const w = stateFieldsToWhere({
454
+ fields,
455
+ state: { attrs: { name: "Tom" } },
456
+ });
457
+ (0, test_expect_1.expect)(w).toStrictEqual({ attrs: [{ json: { name: { ilike: "Tom" } } }] });
458
+ });
459
+ (0, test_expect_1.it)("json field int bounds", async () => {
460
+ const w = stateFieldsToWhere({
461
+ fields,
462
+ state: { attrs: { cars__gte: 2, cars__lte: 4 } },
463
+ });
464
+ (0, test_expect_1.expect)(w).toStrictEqual({
465
+ attrs: [{ json: { cars: { gte: 2, lte: 4 } } }],
466
+ });
467
+ });
468
+ (0, test_expect_1.it)("array or", async () => {
469
+ const w = stateFieldsToWhere({
470
+ fields,
471
+ state: { astr: ["foo", "bar"] },
472
+ });
473
+ (0, test_expect_1.expect)(w).toStrictEqual({ astr: { or: ["foo", "bar"] } });
474
+ });
475
+ (0, test_expect_1.it)("multifield or", async () => {
476
+ const w = stateFieldsToWhere({
477
+ fields,
478
+ state: { age: 15, astr: "foo", _or_field: ["age", "astr"] },
479
+ });
480
+ (0, test_expect_1.expect)(w).toStrictEqual({ or: [{ age: 15 }, { astr: { ilike: "foo" } }] });
481
+ });
482
+ (0, test_expect_1.it)("fkey", async () => {
483
+ (0, test_expect_1.expect)(stateFieldsToWhere({
484
+ fields,
485
+ state: { favbook: 1 },
486
+ })).toStrictEqual({ favbook: 1 });
487
+ });
488
+ (0, test_expect_1.it)("array or fkey", async () => {
489
+ (0, test_expect_1.expect)(stateFieldsToWhere({
490
+ fields,
491
+ state: { favbook: [1, 2] },
492
+ })).toStrictEqual({ favbook: { or: [1, 2] } });
493
+ });
494
+ (0, test_expect_1.it)("readState array or fkey", async () => {
495
+ const state = { favbook: ["1", "2"] };
496
+ readState(state, fields, mockReqRes.req);
497
+ (0, test_expect_1.expect)(state).toStrictEqual({ favbook: [1, 2] });
498
+ });
499
+ (0, test_expect_1.it)("or array age", async () => {
500
+ (0, test_expect_1.expect)(stateFieldsToWhere({
501
+ fields,
502
+ state: { or: [{ age: 1 }] },
503
+ })).toStrictEqual({ or: [{ age: 1 }] });
504
+ });
505
+ (0, test_expect_1.it)("age gt", async () => {
506
+ (0, test_expect_1.expect)(stateFieldsToWhere({
507
+ fields,
508
+ state: { age: { gt: 4 } },
509
+ })).toStrictEqual({ age: { gt: 4 } });
510
+ });
511
+ (0, test_expect_1.it)("and passthorugh", async () => {
512
+ (0, test_expect_1.expect)(stateFieldsToWhere({
513
+ fields,
514
+ state: { and: [{ age: { gt: 4 } }, { age: { lt: 40 } }] },
515
+ })).toStrictEqual({ and: [{ age: { gt: 4 } }, { age: { lt: 40 } }] });
516
+ });
517
+ (0, test_expect_1.it)("age in", async () => {
518
+ (0, test_expect_1.expect)(stateFieldsToWhere({
519
+ fields,
520
+ state: { age: { in: [1, 2] } },
521
+ })).toStrictEqual({ age: { in: [1, 2] } });
522
+ });
523
+ (0, test_expect_1.it)("readState fkey", async () => {
524
+ const state = { favbook: "1" };
525
+ readState(state, fields, mockReqRes.req);
526
+ (0, test_expect_1.expect)(state).toStrictEqual({ favbook: 1 });
527
+ });
528
+ (0, test_expect_1.it)("join field", async () => {
529
+ const table = table_1.default.findOne({ name: "patients" });
530
+ const myFields = await table?.getFields();
531
+ const w = stateFieldsToWhere({
532
+ fields: myFields,
533
+ state: { "favbook.books->author": "Herman" },
534
+ });
535
+ if (db_1.default.isSQLite)
536
+ (0, test_expect_1.expect)(w).toStrictEqual({
537
+ favbook: [
538
+ {
539
+ inSelect: {
540
+ field: "id",
541
+ table: "books",
542
+ tenant: undefined,
543
+ where: { author: { ilike: "Herman" } },
544
+ },
545
+ },
546
+ ],
547
+ });
548
+ else
549
+ (0, test_expect_1.expect)(w).toStrictEqual({
550
+ favbook: [
551
+ {
552
+ inSelect: {
553
+ field: "id",
554
+ table: "books",
555
+ tenant: db_1.default.getTenantSchema(),
556
+ where: { author: { ilike: "Herman" } },
557
+ },
558
+ },
559
+ ],
560
+ });
561
+ });
562
+ });
563
+ (0, test_expect_1.describe)("satisfies", () => {
564
+ (0, test_expect_1.it)("works", async () => {
565
+ (0, test_expect_1.expect)(satisfies({ x: 5 })({ x: 5 })).toBe(true);
566
+ (0, test_expect_1.expect)(satisfies({ x: 5 })({ x: 5, y: 7 })).toBe(true);
567
+ (0, test_expect_1.expect)(satisfies({ x: 5 })({ x: 6 })).toBe(false);
568
+ (0, test_expect_1.expect)(satisfies({ x: 5 })({ y: 6 })).toBe(false);
569
+ (0, test_expect_1.expect)(satisfies({})({ y: 6 })).toBe(true);
570
+ (0, test_expect_1.expect)(satisfies()({ y: 6 })).toBe(true);
571
+ (0, test_expect_1.expect)(satisfies({ x: { or: [5, 6] } })({ x: 5 })).toBe(true);
572
+ (0, test_expect_1.expect)(satisfies({ x: { or: [5, 6] } })({ x: 8 })).toBe(false);
573
+ (0, test_expect_1.expect)(satisfies({ x: { or: [5, 6] } })({ y: 8 })).toBe(false);
574
+ (0, test_expect_1.expect)(satisfies({ x: { in: [5, 6] } })({ x: 5 })).toBe(true);
575
+ (0, test_expect_1.expect)(satisfies({ x: { in: [5, 6] } })({ x: 8 })).toBe(false);
576
+ (0, test_expect_1.expect)(satisfies({ x: { in: [5, 6] } })({ y: 8 })).toBe(false);
577
+ (0, test_expect_1.expect)(satisfies({ x: 5, y: 7 })({ x: 5, y: 7 })).toBe(true);
578
+ (0, test_expect_1.expect)(satisfies({ x: 5, y: 8 })({ x: 5, y: 7 })).toBe(false);
579
+ (0, test_expect_1.expect)(satisfies({ x: 4, y: 8 })({ x: 5, y: 7 })).toBe(false);
580
+ });
581
+ });
582
+ (0, test_expect_1.describe)("urlStringToObject", () => {
583
+ (0, test_expect_1.it)("works", async () => {
584
+ (0, test_expect_1.expect)(urlStringToObject(null)).toStrictEqual({});
585
+ (0, test_expect_1.expect)(urlStringToObject("")).toStrictEqual({});
586
+ (0, test_expect_1.expect)(urlStringToObject("http://bar.com")).toStrictEqual({});
587
+ (0, test_expect_1.expect)(urlStringToObject("http://bar.com?a=1&b=foo")).toStrictEqual({
588
+ a: "1",
589
+ b: "foo",
590
+ });
591
+ (0, test_expect_1.expect)(urlStringToObject("http://bar.com?a=1&b=foo#mylink")).toStrictEqual({
592
+ a: "1",
593
+ b: "foo",
594
+ });
595
+ });
596
+ });
597
+ (0, test_expect_1.describe)("plugin helper", () => {
598
+ (0, test_expect_1.it)("field_picker_fields", async () => {
599
+ const flds = await field_picker_fields({
600
+ table: table_1.default.findOne({ name: "patients" }),
601
+ viewname: "myView",
602
+ req: mockReqRes.req,
603
+ });
604
+ (0, test_expect_1.expect)(flds.length).toBeGreaterThan(1);
605
+ const flds1 = await field_picker_fields({
606
+ table: table_1.default.findOne({ name: "books" }),
607
+ viewname: "myView",
608
+ req: mockReqRes.req,
609
+ });
610
+ (0, test_expect_1.expect)(flds1.length).toBeGreaterThan(1);
611
+ });
612
+ });
613
+ (0, test_expect_1.describe)("objectToQueryString", () => {
614
+ (0, test_expect_1.it)("ordinary works", async () => {
615
+ (0, test_expect_1.expect)(objectToQueryString({})).toBe("");
616
+ (0, test_expect_1.expect)(objectToQueryString({ a: 5 })).toBe("a=5");
617
+ (0, test_expect_1.expect)(objectToQueryString({ a: 5, b: "Foo" })).toBe("a=5&b=Foo");
618
+ (0, test_expect_1.expect)(objectToQueryString({ a: 5, b: "F oo" })).toBe("a=5&b=F%20oo");
619
+ (0, test_expect_1.expect)(objectToQueryString({ a: 5, b: "Foo" })).toBe("a=5&b=Foo");
620
+ (0, test_expect_1.expect)(objectToQueryString({ and: [{ a: 5 }, { b: "Foo" }] })).toBe("a=5&b=Foo");
621
+ (0, test_expect_1.expect)(objectToQueryString({ eq: ["a", 5] })).toBe("a=5");
622
+ (0, test_expect_1.expect)(objectToQueryString({ a: null })).toBe("a=null");
623
+ });
624
+ (0, test_expect_1.it)("collects or", async () => {
625
+ (0, test_expect_1.expect)(objectToQueryString({ or: [{ a: 5 }, { a: 7 }] })).toBe("a=5&a=7");
626
+ (0, test_expect_1.expect)(objectToQueryString({ a: { or: ["Foo", "Bar"] } })).toBe("a=Foo&a=Bar");
627
+ (0, test_expect_1.expect)(objectToQueryString({ a: ["Foo", "Bar"] })).toBe("a=Foo&a=Bar");
628
+ (0, test_expect_1.expect)(objectToQueryString({ a: { in: ["Foo", "Bar"] } })).toBe("a=Foo&a=Bar");
629
+ });
630
+ });
631
+ //# sourceMappingURL=auxtest.test.js.map