@tachybase/database 0.23.8

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 (226) hide show
  1. package/.turbo/turbo-build.log +10 -0
  2. package/LICENSE +201 -0
  3. package/lib/collection-factory.d.ts +17 -0
  4. package/lib/collection-factory.js +52 -0
  5. package/lib/collection-group-manager.d.ts +26 -0
  6. package/lib/collection-group-manager.js +57 -0
  7. package/lib/collection-importer.d.ts +7 -0
  8. package/lib/collection-importer.js +74 -0
  9. package/lib/collection.d.ts +138 -0
  10. package/lib/collection.js +686 -0
  11. package/lib/database-utils/index.d.ts +9 -0
  12. package/lib/database-utils/index.js +71 -0
  13. package/lib/database-utils/traverseJSON.d.ts +10 -0
  14. package/lib/database-utils/traverseJSON.js +126 -0
  15. package/lib/database.d.ts +201 -0
  16. package/lib/database.js +765 -0
  17. package/lib/decorators/must-have-filter-decorator.d.ts +2 -0
  18. package/lib/decorators/must-have-filter-decorator.js +38 -0
  19. package/lib/decorators/target-collection-decorator.d.ts +2 -0
  20. package/lib/decorators/target-collection-decorator.js +47 -0
  21. package/lib/decorators/transaction-decorator.d.ts +1 -0
  22. package/lib/decorators/transaction-decorator.js +88 -0
  23. package/lib/eager-loading/eager-loading-tree.d.ts +31 -0
  24. package/lib/eager-loading/eager-loading-tree.js +439 -0
  25. package/lib/errors/identifier-error.d.ts +3 -0
  26. package/lib/errors/identifier-error.js +35 -0
  27. package/lib/errors/zero-column-table-error.d.ts +2 -0
  28. package/lib/errors/zero-column-table-error.js +31 -0
  29. package/lib/features/references-map.d.ts +18 -0
  30. package/lib/features/references-map.js +109 -0
  31. package/lib/features/referential-integrity-check.d.ts +8 -0
  32. package/lib/features/referential-integrity-check.js +83 -0
  33. package/lib/field-repository/array-field-repository.d.ts +28 -0
  34. package/lib/field-repository/array-field-repository.js +197 -0
  35. package/lib/fields/array-field.d.ts +11 -0
  36. package/lib/fields/array-field.js +57 -0
  37. package/lib/fields/belongs-to-field.d.ts +17 -0
  38. package/lib/fields/belongs-to-field.js +154 -0
  39. package/lib/fields/belongs-to-many-field.d.ts +20 -0
  40. package/lib/fields/belongs-to-many-field.js +187 -0
  41. package/lib/fields/boolean-field.d.ts +8 -0
  42. package/lib/fields/boolean-field.js +36 -0
  43. package/lib/fields/context-field.d.ts +14 -0
  44. package/lib/fields/context-field.js +70 -0
  45. package/lib/fields/date-field.d.ts +13 -0
  46. package/lib/fields/date-field.js +64 -0
  47. package/lib/fields/field.d.ts +43 -0
  48. package/lib/fields/field.js +156 -0
  49. package/lib/fields/has-inverse-field.d.ts +4 -0
  50. package/lib/fields/has-inverse-field.js +15 -0
  51. package/lib/fields/has-many-field.d.ts +68 -0
  52. package/lib/fields/has-many-field.js +156 -0
  53. package/lib/fields/has-one-field.d.ts +68 -0
  54. package/lib/fields/has-one-field.js +150 -0
  55. package/lib/fields/index.d.ts +46 -0
  56. package/lib/fields/index.js +65 -0
  57. package/lib/fields/json-field.d.ts +14 -0
  58. package/lib/fields/json-field.js +54 -0
  59. package/lib/fields/nanoid-field.d.ts +13 -0
  60. package/lib/fields/nanoid-field.js +58 -0
  61. package/lib/fields/number-field.d.ts +41 -0
  62. package/lib/fields/number-field.js +85 -0
  63. package/lib/fields/password-field.d.ts +21 -0
  64. package/lib/fields/password-field.js +95 -0
  65. package/lib/fields/radio-field.d.ts +16 -0
  66. package/lib/fields/radio-field.js +66 -0
  67. package/lib/fields/relation-field.d.ts +21 -0
  68. package/lib/fields/relation-field.js +79 -0
  69. package/lib/fields/set-field.d.ts +10 -0
  70. package/lib/fields/set-field.js +46 -0
  71. package/lib/fields/sort-field.d.ts +16 -0
  72. package/lib/fields/sort-field.js +187 -0
  73. package/lib/fields/string-field.d.ts +8 -0
  74. package/lib/fields/string-field.js +36 -0
  75. package/lib/fields/text-field.d.ts +8 -0
  76. package/lib/fields/text-field.js +36 -0
  77. package/lib/fields/time-field.d.ts +8 -0
  78. package/lib/fields/time-field.js +36 -0
  79. package/lib/fields/uid-field.d.ts +13 -0
  80. package/lib/fields/uid-field.js +63 -0
  81. package/lib/fields/uuid-field.d.ts +9 -0
  82. package/lib/fields/uuid-field.js +45 -0
  83. package/lib/fields/virtual-field.d.ts +8 -0
  84. package/lib/fields/virtual-field.js +36 -0
  85. package/lib/filter-match.d.ts +1 -0
  86. package/lib/filter-match.js +66 -0
  87. package/lib/filter-parser.d.ts +21 -0
  88. package/lib/filter-parser.js +230 -0
  89. package/lib/helpers.d.ts +3 -0
  90. package/lib/helpers.js +167 -0
  91. package/lib/index.d.ts +30 -0
  92. package/lib/index.js +114 -0
  93. package/lib/inherited-collection.d.ts +14 -0
  94. package/lib/inherited-collection.js +138 -0
  95. package/lib/inherited-map.d.ts +21 -0
  96. package/lib/inherited-map.js +113 -0
  97. package/lib/inherited-sync-runner.d.ts +4 -0
  98. package/lib/inherited-sync-runner.js +175 -0
  99. package/lib/listeners/adjacency-list.d.ts +2 -0
  100. package/lib/listeners/adjacency-list.js +42 -0
  101. package/lib/listeners/append-child-collection-name-after-repository-find.d.ts +6 -0
  102. package/lib/listeners/append-child-collection-name-after-repository-find.js +66 -0
  103. package/lib/listeners/index.d.ts +2 -0
  104. package/lib/listeners/index.js +33 -0
  105. package/lib/magic-attribute-model.d.ts +8 -0
  106. package/lib/magic-attribute-model.js +203 -0
  107. package/lib/migration.d.ts +35 -0
  108. package/lib/migration.js +103 -0
  109. package/lib/mock-database.d.ts +25 -0
  110. package/lib/mock-database.js +126 -0
  111. package/lib/model-hook.d.ts +12 -0
  112. package/lib/model-hook.js +92 -0
  113. package/lib/model.d.ts +23 -0
  114. package/lib/model.js +152 -0
  115. package/lib/operators/array.d.ts +2 -0
  116. package/lib/operators/array.js +158 -0
  117. package/lib/operators/association.d.ts +2 -0
  118. package/lib/operators/association.js +35 -0
  119. package/lib/operators/boolean.d.ts +2 -0
  120. package/lib/operators/boolean.js +38 -0
  121. package/lib/operators/child-collection.d.ts +2 -0
  122. package/lib/operators/child-collection.js +67 -0
  123. package/lib/operators/date.d.ts +2 -0
  124. package/lib/operators/date.js +140 -0
  125. package/lib/operators/empty.d.ts +5 -0
  126. package/lib/operators/empty.js +89 -0
  127. package/lib/operators/eq.d.ts +2 -0
  128. package/lib/operators/eq.js +35 -0
  129. package/lib/operators/index.d.ts +5 -0
  130. package/lib/operators/index.js +56 -0
  131. package/lib/operators/jsonb.d.ts +2 -0
  132. package/lib/operators/jsonb.js +50 -0
  133. package/lib/operators/ne.d.ts +2 -0
  134. package/lib/operators/ne.js +40 -0
  135. package/lib/operators/notIn.d.ts +2 -0
  136. package/lib/operators/notIn.js +33 -0
  137. package/lib/operators/string.d.ts +2 -0
  138. package/lib/operators/string.js +109 -0
  139. package/lib/operators/utils.d.ts +4 -0
  140. package/lib/operators/utils.js +40 -0
  141. package/lib/options-parser.d.ts +37 -0
  142. package/lib/options-parser.js +332 -0
  143. package/lib/playground.d.ts +1 -0
  144. package/lib/playground.js +43 -0
  145. package/lib/query-interface/mysql-query-interface.d.ts +35 -0
  146. package/lib/query-interface/mysql-query-interface.js +122 -0
  147. package/lib/query-interface/postgres-query-interface.d.ts +32 -0
  148. package/lib/query-interface/postgres-query-interface.js +189 -0
  149. package/lib/query-interface/query-interface-builder.d.ts +2 -0
  150. package/lib/query-interface/query-interface-builder.js +46 -0
  151. package/lib/query-interface/query-interface.d.ts +42 -0
  152. package/lib/query-interface/query-interface.js +46 -0
  153. package/lib/query-interface/sqlite-query-interface.d.ts +35 -0
  154. package/lib/query-interface/sqlite-query-interface.js +131 -0
  155. package/lib/relation-repository/belongs-to-many-repository.d.ts +21 -0
  156. package/lib/relation-repository/belongs-to-many-repository.js +280 -0
  157. package/lib/relation-repository/belongs-to-repository.d.ts +6 -0
  158. package/lib/relation-repository/belongs-to-repository.js +39 -0
  159. package/lib/relation-repository/hasmany-repository.d.ts +10 -0
  160. package/lib/relation-repository/hasmany-repository.js +182 -0
  161. package/lib/relation-repository/hasone-repository.d.ts +6 -0
  162. package/lib/relation-repository/hasone-repository.js +39 -0
  163. package/lib/relation-repository/multiple-relation-repository.d.ts +20 -0
  164. package/lib/relation-repository/multiple-relation-repository.js +229 -0
  165. package/lib/relation-repository/relation-repository.d.ts +29 -0
  166. package/lib/relation-repository/relation-repository.js +202 -0
  167. package/lib/relation-repository/single-relation-repository.d.ts +25 -0
  168. package/lib/relation-repository/single-relation-repository.js +162 -0
  169. package/lib/relation-repository/types.d.ts +7 -0
  170. package/lib/relation-repository/types.js +15 -0
  171. package/lib/repositories/tree-repository/adjacency-list-repository.d.ts +18 -0
  172. package/lib/repositories/tree-repository/adjacency-list-repository.js +183 -0
  173. package/lib/repositories/view-repository.d.ts +3 -0
  174. package/lib/repositories/view-repository.js +32 -0
  175. package/lib/repository.d.ts +206 -0
  176. package/lib/repository.js +597 -0
  177. package/lib/sql-collection/index.d.ts +2 -0
  178. package/lib/sql-collection/index.js +23 -0
  179. package/lib/sql-collection/query-generator.d.ts +10 -0
  180. package/lib/sql-collection/query-generator.js +70 -0
  181. package/lib/sql-collection/sql-collection.d.ts +7 -0
  182. package/lib/sql-collection/sql-collection.js +69 -0
  183. package/lib/sql-collection/sql-model.d.ts +16 -0
  184. package/lib/sql-collection/sql-model.js +168 -0
  185. package/lib/sql-parser/index.d.ts +10 -0
  186. package/lib/sql-parser/index.js +10699 -0
  187. package/lib/sql-parser/postgres.d.ts +10 -0
  188. package/lib/sql-parser/postgres.js +31506 -0
  189. package/lib/sql-parser/sql.pegjs +1297 -0
  190. package/lib/sync-runner.d.ts +30 -0
  191. package/lib/sync-runner.js +277 -0
  192. package/lib/types.d.ts +49 -0
  193. package/lib/types.js +15 -0
  194. package/lib/update-associations.d.ts +60 -0
  195. package/lib/update-associations.js +405 -0
  196. package/lib/update-guard.d.ts +28 -0
  197. package/lib/update-guard.js +202 -0
  198. package/lib/utils.d.ts +7 -0
  199. package/lib/utils.js +127 -0
  200. package/lib/value-parsers/array-value-parser.d.ts +8 -0
  201. package/lib/value-parsers/array-value-parser.js +58 -0
  202. package/lib/value-parsers/base-value-parser.d.ts +12 -0
  203. package/lib/value-parsers/base-value-parser.js +63 -0
  204. package/lib/value-parsers/boolean-value-parser.d.ts +4 -0
  205. package/lib/value-parsers/boolean-value-parser.js +52 -0
  206. package/lib/value-parsers/date-value-parser.d.ts +5 -0
  207. package/lib/value-parsers/date-value-parser.js +88 -0
  208. package/lib/value-parsers/index.d.ts +12 -0
  209. package/lib/value-parsers/index.js +78 -0
  210. package/lib/value-parsers/json-value-parser.d.ts +4 -0
  211. package/lib/value-parsers/json-value-parser.js +47 -0
  212. package/lib/value-parsers/number-value-parser.d.ts +4 -0
  213. package/lib/value-parsers/number-value-parser.js +58 -0
  214. package/lib/value-parsers/string-value-parser.d.ts +8 -0
  215. package/lib/value-parsers/string-value-parser.js +64 -0
  216. package/lib/value-parsers/to-many-value-parser.d.ts +13 -0
  217. package/lib/value-parsers/to-many-value-parser.js +108 -0
  218. package/lib/value-parsers/to-one-value-parser.d.ts +4 -0
  219. package/lib/value-parsers/to-one-value-parser.js +48 -0
  220. package/lib/view/field-type-map.d.ts +97 -0
  221. package/lib/view/field-type-map.js +90 -0
  222. package/lib/view/view-inference.d.ts +32 -0
  223. package/lib/view/view-inference.js +146 -0
  224. package/lib/view-collection.d.ts +6 -0
  225. package/lib/view-collection.js +45 -0
  226. package/package.json +38 -0
@@ -0,0 +1,89 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var empty_exports = {};
30
+ __export(empty_exports, {
31
+ default: () => empty_default
32
+ });
33
+ module.exports = __toCommonJS(empty_exports);
34
+ var import_lodash = __toESM(require("lodash"));
35
+ var import_sequelize = require("sequelize");
36
+ var import_fields = require("../fields");
37
+ var import_array = __toESM(require("./array"));
38
+ const findFilterFieldType = /* @__PURE__ */ __name((ctx) => {
39
+ const db = ctx.db;
40
+ const path = ctx.path.split(".");
41
+ path.pop();
42
+ const fieldName = path.pop();
43
+ let model = ctx.model;
44
+ const associationPath = path;
45
+ for (const association of associationPath) {
46
+ if (import_lodash.default.isNumber((0, import_lodash.parseInt)(association)) || association.startsWith("$")) {
47
+ continue;
48
+ }
49
+ model = model.associations[association].target;
50
+ }
51
+ const collection = db.modelCollection.get(model);
52
+ return collection.getField(fieldName);
53
+ }, "findFilterFieldType");
54
+ var empty_default = {
55
+ $empty(_, ctx) {
56
+ const field = findFilterFieldType(ctx);
57
+ if (field instanceof import_fields.StringField) {
58
+ return {
59
+ [import_sequelize.Op.or]: {
60
+ [import_sequelize.Op.is]: null,
61
+ [import_sequelize.Op.eq]: ""
62
+ }
63
+ };
64
+ }
65
+ if (field instanceof import_fields.ArrayField) {
66
+ return import_array.default.$arrayEmpty(_, ctx);
67
+ }
68
+ return {
69
+ [import_sequelize.Op.is]: null
70
+ };
71
+ },
72
+ $notEmpty(_, ctx) {
73
+ const field = findFilterFieldType(ctx);
74
+ if (field instanceof import_fields.StringField) {
75
+ return {
76
+ [import_sequelize.Op.and]: {
77
+ [import_sequelize.Op.not]: null,
78
+ [import_sequelize.Op.ne]: ""
79
+ }
80
+ };
81
+ }
82
+ if (field instanceof import_fields.ArrayField) {
83
+ return import_array.default.$arrayNotEmpty(_, ctx);
84
+ }
85
+ return {
86
+ [import_sequelize.Op.not]: null
87
+ };
88
+ }
89
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: Record<string, any>;
2
+ export default _default;
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var eq_exports = {};
19
+ __export(eq_exports, {
20
+ default: () => eq_default
21
+ });
22
+ module.exports = __toCommonJS(eq_exports);
23
+ var import_sequelize = require("sequelize");
24
+ var eq_default = {
25
+ $eq(val) {
26
+ if (Array.isArray(val)) {
27
+ return {
28
+ [import_sequelize.Op.in]: val
29
+ };
30
+ }
31
+ return {
32
+ [import_sequelize.Op.eq]: val
33
+ };
34
+ }
35
+ };
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ $empty(_: any, ctx: any): any;
3
+ $notEmpty(_: any, ctx: any): any;
4
+ };
5
+ export default _default;
@@ -0,0 +1,56 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var operators_exports = {};
29
+ __export(operators_exports, {
30
+ default: () => operators_default
31
+ });
32
+ module.exports = __toCommonJS(operators_exports);
33
+ var import_array = __toESM(require("./array"));
34
+ var import_association = __toESM(require("./association"));
35
+ var import_boolean = __toESM(require("./boolean"));
36
+ var import_child_collection = __toESM(require("./child-collection"));
37
+ var import_date = __toESM(require("./date"));
38
+ var import_empty = __toESM(require("./empty"));
39
+ var import_eq = __toESM(require("./eq"));
40
+ var import_jsonb = __toESM(require("./jsonb"));
41
+ var import_ne = __toESM(require("./ne"));
42
+ var import_notIn = __toESM(require("./notIn"));
43
+ var import_string = __toESM(require("./string"));
44
+ var operators_default = {
45
+ ...import_association.default,
46
+ ...import_date.default,
47
+ ...import_array.default,
48
+ ...import_empty.default,
49
+ ...import_string.default,
50
+ ...import_eq.default,
51
+ ...import_ne.default,
52
+ ...import_notIn.default,
53
+ ...import_boolean.default,
54
+ ...import_child_collection.default,
55
+ ...import_jsonb.default
56
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: Record<string, any>;
2
+ export default _default;
@@ -0,0 +1,50 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var jsonb_exports = {};
20
+ __export(jsonb_exports, {
21
+ default: () => jsonb_default
22
+ });
23
+ module.exports = __toCommonJS(jsonb_exports);
24
+ var import_sequelize = require("sequelize");
25
+ var import_utils = require("./utils");
26
+ function escapeLike(value) {
27
+ return value.replace(/[_%]/g, "\\$&");
28
+ }
29
+ __name(escapeLike, "escapeLike");
30
+ var jsonb_default = {
31
+ $containsJsonbValue(value, ctx) {
32
+ if (Array.isArray(value)) {
33
+ const conditions = value.map((item) => ({
34
+ ["::text"]: {
35
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.iLike : import_sequelize.Op.like]: `%${escapeLike(item)}%`
36
+ }
37
+ }));
38
+ return {
39
+ [import_sequelize.Op.or]: conditions
40
+ };
41
+ }
42
+ return {
43
+ // 先将 jsonb 转换为字符串, 实际测试发现这种语法可行
44
+ ["::text"]: {
45
+ // 使用 Op.like 操作符来检查 JSONB 字段是否包含特定的字符串
46
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.iLike : import_sequelize.Op.like]: `%${escapeLike(value)}%`
47
+ }
48
+ };
49
+ }
50
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: Record<string, any>;
2
+ export default _default;
@@ -0,0 +1,40 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var ne_exports = {};
19
+ __export(ne_exports, {
20
+ default: () => ne_default
21
+ });
22
+ module.exports = __toCommonJS(ne_exports);
23
+ var import_sequelize = require("sequelize");
24
+ var ne_default = {
25
+ $ne(val, ctx) {
26
+ if (Array.isArray(val)) {
27
+ return {
28
+ [import_sequelize.Op.notIn]: val
29
+ };
30
+ }
31
+ return val === null ? {
32
+ [import_sequelize.Op.ne]: null
33
+ } : {
34
+ [import_sequelize.Op.or]: {
35
+ [import_sequelize.Op.ne]: val,
36
+ [import_sequelize.Op.is]: null
37
+ }
38
+ };
39
+ }
40
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: Record<string, any>;
2
+ export default _default;
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var notIn_exports = {};
19
+ __export(notIn_exports, {
20
+ default: () => notIn_default
21
+ });
22
+ module.exports = __toCommonJS(notIn_exports);
23
+ var import_sequelize = require("sequelize");
24
+ var notIn_default = {
25
+ $notIn(val, ctx) {
26
+ return {
27
+ [import_sequelize.Op.or]: {
28
+ [import_sequelize.Op.notIn]: val,
29
+ [import_sequelize.Op.is]: null
30
+ }
31
+ };
32
+ }
33
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: Record<string, any>;
2
+ export default _default;
@@ -0,0 +1,109 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var string_exports = {};
20
+ __export(string_exports, {
21
+ default: () => string_default
22
+ });
23
+ module.exports = __toCommonJS(string_exports);
24
+ var import_sequelize = require("sequelize");
25
+ var import_utils = require("./utils");
26
+ function escapeLike(value) {
27
+ return value.replace(/[_%]/g, "\\$&");
28
+ }
29
+ __name(escapeLike, "escapeLike");
30
+ var string_default = {
31
+ $includes(value, ctx) {
32
+ if (Array.isArray(value)) {
33
+ const conditions = value.map((item) => ({
34
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.iLike : import_sequelize.Op.like]: `%${escapeLike(item)}%`
35
+ }));
36
+ return {
37
+ [import_sequelize.Op.or]: conditions
38
+ };
39
+ }
40
+ return {
41
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.iLike : import_sequelize.Op.like]: `%${escapeLike(value)}%`
42
+ };
43
+ },
44
+ $notIncludes(value, ctx) {
45
+ if (Array.isArray(value)) {
46
+ const conditions = value.map((item) => ({
47
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.notILike : import_sequelize.Op.notLike]: `%${escapeLike(item)}%`
48
+ }));
49
+ return {
50
+ [import_sequelize.Op.and]: conditions
51
+ };
52
+ }
53
+ return {
54
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.notILike : import_sequelize.Op.notLike]: `%${escapeLike(value)}%`
55
+ };
56
+ },
57
+ $startsWith(value, ctx) {
58
+ if (Array.isArray(value)) {
59
+ const conditions = value.map((item) => ({
60
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.iLike : import_sequelize.Op.like]: `${escapeLike(item)}%`
61
+ }));
62
+ return {
63
+ [import_sequelize.Op.or]: conditions
64
+ };
65
+ }
66
+ return {
67
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.iLike : import_sequelize.Op.like]: `${escapeLike(value)}%`
68
+ };
69
+ },
70
+ $notStartsWith(value, ctx) {
71
+ if (Array.isArray(value)) {
72
+ const conditions = value.map((item) => ({
73
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.notILike : import_sequelize.Op.notLike]: `${escapeLike(item)}%`
74
+ }));
75
+ return {
76
+ [import_sequelize.Op.and]: conditions
77
+ };
78
+ }
79
+ return {
80
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.notILike : import_sequelize.Op.notLike]: `${escapeLike(value)}%`
81
+ };
82
+ },
83
+ $endWith(value, ctx) {
84
+ if (Array.isArray(value)) {
85
+ const conditions = value.map((item) => ({
86
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.iLike : import_sequelize.Op.like]: `%${escapeLike(item)}`
87
+ }));
88
+ return {
89
+ [import_sequelize.Op.or]: conditions
90
+ };
91
+ }
92
+ return {
93
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.iLike : import_sequelize.Op.like]: `%${escapeLike(value)}`
94
+ };
95
+ },
96
+ $notEndWith(value, ctx) {
97
+ if (Array.isArray(value)) {
98
+ const conditions = value.map((item) => ({
99
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.notILike : import_sequelize.Op.notLike]: `%${escapeLike(item)}`
100
+ }));
101
+ return {
102
+ [import_sequelize.Op.and]: conditions
103
+ };
104
+ }
105
+ return {
106
+ [(0, import_utils.isPg)(ctx) ? import_sequelize.Op.notILike : import_sequelize.Op.notLike]: `%${escapeLike(value)}`
107
+ };
108
+ }
109
+ };
@@ -0,0 +1,4 @@
1
+ declare const getDialect: (ctx: any) => any;
2
+ declare const isPg: (ctx: any) => boolean;
3
+ declare const isMySQL: (ctx: any) => boolean;
4
+ export { getDialect, isPg, isMySQL };
@@ -0,0 +1,40 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var utils_exports = {};
20
+ __export(utils_exports, {
21
+ getDialect: () => getDialect,
22
+ isMySQL: () => isMySQL,
23
+ isPg: () => isPg
24
+ });
25
+ module.exports = __toCommonJS(utils_exports);
26
+ const getDialect = /* @__PURE__ */ __name((ctx) => {
27
+ return ctx.db.sequelize.getDialect();
28
+ }, "getDialect");
29
+ const isPg = /* @__PURE__ */ __name((ctx) => {
30
+ return getDialect(ctx) === "postgres";
31
+ }, "isPg");
32
+ const isMySQL = /* @__PURE__ */ __name((ctx) => {
33
+ return getDialect(ctx) === "mysql" || getDialect(ctx) === "mariadb";
34
+ }, "isMySQL");
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ getDialect,
38
+ isMySQL,
39
+ isPg
40
+ });
@@ -0,0 +1,37 @@
1
+ import { ModelStatic } from 'sequelize';
2
+ import { Collection } from './collection';
3
+ import { Database } from './database';
4
+ import FilterParser from './filter-parser';
5
+ import { Appends, Except, FindOptions } from './repository';
6
+ interface OptionsParserContext {
7
+ collection: Collection;
8
+ targetKey?: string;
9
+ }
10
+ export declare class OptionsParser {
11
+ options: FindOptions;
12
+ database: Database;
13
+ collection: Collection;
14
+ model: ModelStatic<any>;
15
+ filterParser: FilterParser;
16
+ context: OptionsParserContext;
17
+ constructor(options: FindOptions, context: OptionsParserContext);
18
+ static appendInheritInspectAttribute(include: any, collection: any): any;
19
+ isAssociation(key: string): boolean;
20
+ isAssociationPath(path: string): boolean;
21
+ toSequelizeParams(): any;
22
+ /**
23
+ * parser sort options
24
+ * @param filterParams
25
+ * @protected
26
+ */
27
+ protected parseSort(filterParams: any): any;
28
+ protected parseFields(filterParams: any): any;
29
+ protected parseExcept(except: Except, filterParams: any): any;
30
+ protected parseAppendWithOptions(append: string): {
31
+ name: string;
32
+ options?: object;
33
+ raw?: string;
34
+ };
35
+ protected parseAppends(appends: Appends, filterParams: any): any;
36
+ }
37
+ export {};