functional-models 3.9.5 → 3.11.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 (84) hide show
  1. package/cjs/errors.cjs +38 -0
  2. package/cjs/errors.cjs.map +7 -0
  3. package/cjs/index.cjs +2426 -0
  4. package/cjs/index.cjs.map +7 -0
  5. package/cjs/lib.cjs +431 -0
  6. package/cjs/lib.cjs.map +7 -0
  7. package/cjs/models.cjs +571 -0
  8. package/cjs/models.cjs.map +7 -0
  9. package/cjs/orm/index.cjs +1765 -0
  10. package/cjs/orm/index.cjs.map +7 -0
  11. package/cjs/orm/internal-libs.cjs +136 -0
  12. package/cjs/orm/internal-libs.cjs.map +7 -0
  13. package/cjs/orm/libs.cjs +88 -0
  14. package/cjs/orm/libs.cjs.map +7 -0
  15. package/cjs/orm/models.cjs +1027 -0
  16. package/cjs/orm/models.cjs.map +7 -0
  17. package/cjs/orm/properties.cjs +989 -0
  18. package/cjs/orm/properties.cjs.map +7 -0
  19. package/cjs/orm/query.cjs +376 -0
  20. package/cjs/orm/query.cjs.map +7 -0
  21. package/cjs/orm/types.cjs +59 -0
  22. package/cjs/orm/types.cjs.map +7 -0
  23. package/cjs/orm/validation.cjs +301 -0
  24. package/cjs/orm/validation.cjs.map +7 -0
  25. package/cjs/properties.cjs +998 -0
  26. package/cjs/properties.cjs.map +7 -0
  27. package/cjs/serialization.cjs +75 -0
  28. package/cjs/serialization.cjs.map +7 -0
  29. package/cjs/types.cjs +65 -0
  30. package/cjs/types.cjs.map +7 -0
  31. package/cjs/utils.cjs +187 -0
  32. package/cjs/utils.cjs.map +7 -0
  33. package/cjs/validation.cjs +431 -0
  34. package/cjs/validation.cjs.map +7 -0
  35. package/errors.js +3 -4
  36. package/errors.js.map +1 -1
  37. package/index.d.ts +13 -13
  38. package/index.js +13 -52
  39. package/index.js.map +1 -1
  40. package/lib.d.ts +5 -5
  41. package/lib.js +45 -65
  42. package/lib.js.map +1 -1
  43. package/models.d.ts +1 -1
  44. package/models.js +22 -30
  45. package/models.js.map +1 -1
  46. package/orm/index.d.ts +9 -9
  47. package/orm/index.js +9 -48
  48. package/orm/index.js.map +1 -1
  49. package/orm/internal-libs.js +7 -11
  50. package/orm/internal-libs.js.map +1 -1
  51. package/orm/libs.d.ts +1 -1
  52. package/orm/libs.js +8 -16
  53. package/orm/libs.js.map +1 -1
  54. package/orm/models.d.ts +2 -2
  55. package/orm/models.js +20 -26
  56. package/orm/models.js.map +1 -1
  57. package/orm/properties.d.ts +28 -28
  58. package/orm/properties.js +28 -36
  59. package/orm/properties.js.map +1 -1
  60. package/orm/query.d.ts +1 -1
  61. package/orm/query.js +31 -52
  62. package/orm/query.js.map +1 -1
  63. package/orm/types.d.ts +2 -2
  64. package/orm/types.js +7 -10
  65. package/orm/types.js.map +1 -1
  66. package/orm/validation.d.ts +2 -2
  67. package/orm/validation.js +5 -13
  68. package/orm/validation.js.map +1 -1
  69. package/package.json +50 -65
  70. package/properties.d.ts +133 -133
  71. package/properties.js +66 -94
  72. package/properties.js.map +1 -1
  73. package/serialization.d.ts +1 -1
  74. package/serialization.js +3 -9
  75. package/serialization.js.map +1 -1
  76. package/types.d.ts +6 -1
  77. package/types.js +4 -6
  78. package/types.js.map +1 -1
  79. package/utils.d.ts +2 -1
  80. package/utils.js +8 -23
  81. package/utils.js.map +1 -1
  82. package/validation.d.ts +1 -1
  83. package/validation.js +19 -50
  84. package/validation.js.map +1 -1
@@ -0,0 +1,1765 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
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
+
30
+ // src/orm/index.ts
31
+ var orm_exports = {};
32
+ __export(orm_exports, {
33
+ AllowableEqualitySymbols: () => AllowableEqualitySymbols,
34
+ DatastoreValueType: () => DatastoreValueType,
35
+ EqualitySymbol: () => EqualitySymbol,
36
+ ForeignKeyProperty: () => ForeignKeyProperty,
37
+ LastModifiedDateProperty: () => LastModifiedDateProperty,
38
+ PrimaryKeyProperty: () => PrimaryKeyProperty,
39
+ SortOrder: () => SortOrder,
40
+ and: () => and,
41
+ booleanQuery: () => booleanQuery,
42
+ buildOrmValidatorContext: () => buildOrmValidatorContext,
43
+ createOrm: () => createOrm,
44
+ datesAfter: () => datesAfter,
45
+ datesBefore: () => datesBefore,
46
+ isALinkToken: () => isALinkToken,
47
+ isPropertyBasedQuery: () => isPropertyBasedQuery,
48
+ numberQuery: () => numberQuery,
49
+ or: () => or,
50
+ ormPropertyConfig: () => ormPropertyConfig,
51
+ pagination: () => pagination,
52
+ properties: () => properties_exports,
53
+ property: () => property,
54
+ query: () => query_exports,
55
+ queryBuilder: () => queryBuilder,
56
+ sort: () => sort,
57
+ take: () => take,
58
+ textQuery: () => textQuery,
59
+ threeitize: () => threeitize,
60
+ types: () => types_exports,
61
+ unique: () => unique,
62
+ uniqueTogether: () => uniqueTogether,
63
+ validateOrmSearch: () => validateOrmSearch,
64
+ validation: () => validation_exports
65
+ });
66
+ module.exports = __toCommonJS(orm_exports);
67
+
68
+ // src/orm/query.ts
69
+ var query_exports = {};
70
+ __export(query_exports, {
71
+ and: () => and,
72
+ booleanQuery: () => booleanQuery,
73
+ datesAfter: () => datesAfter,
74
+ datesBefore: () => datesBefore,
75
+ isALinkToken: () => isALinkToken,
76
+ isPropertyBasedQuery: () => isPropertyBasedQuery,
77
+ numberQuery: () => numberQuery,
78
+ or: () => or,
79
+ pagination: () => pagination,
80
+ property: () => property,
81
+ queryBuilder: () => queryBuilder,
82
+ sort: () => sort,
83
+ take: () => take,
84
+ textQuery: () => textQuery,
85
+ threeitize: () => threeitize,
86
+ validateOrmSearch: () => validateOrmSearch
87
+ });
88
+ var import_merge = __toESM(require("lodash/merge.js"), 1);
89
+ var import_omit = __toESM(require("lodash/omit.js"), 1);
90
+
91
+ // src/orm/types.ts
92
+ var types_exports = {};
93
+ __export(types_exports, {
94
+ AllowableEqualitySymbols: () => AllowableEqualitySymbols,
95
+ DatastoreValueType: () => DatastoreValueType,
96
+ EqualitySymbol: () => EqualitySymbol,
97
+ SortOrder: () => SortOrder
98
+ });
99
+ var EqualitySymbol = /* @__PURE__ */ ((EqualitySymbol2) => {
100
+ EqualitySymbol2["eq"] = "=";
101
+ EqualitySymbol2["lt"] = "<";
102
+ EqualitySymbol2["lte"] = "<=";
103
+ EqualitySymbol2["gt"] = ">";
104
+ EqualitySymbol2["gte"] = ">=";
105
+ EqualitySymbol2["ne"] = "!=";
106
+ return EqualitySymbol2;
107
+ })(EqualitySymbol || {});
108
+ var DatastoreValueType = /* @__PURE__ */ ((DatastoreValueType2) => {
109
+ DatastoreValueType2["string"] = "string";
110
+ DatastoreValueType2["number"] = "number";
111
+ DatastoreValueType2["date"] = "date";
112
+ DatastoreValueType2["object"] = "object";
113
+ DatastoreValueType2["boolean"] = "boolean";
114
+ return DatastoreValueType2;
115
+ })(DatastoreValueType || {});
116
+ var AllowableEqualitySymbols = Object.values(EqualitySymbol);
117
+ var SortOrder = /* @__PURE__ */ ((SortOrder2) => {
118
+ SortOrder2["asc"] = "asc";
119
+ SortOrder2["dsc"] = "dsc";
120
+ return SortOrder2;
121
+ })(SortOrder || {});
122
+
123
+ // src/orm/query.ts
124
+ var THREE = 3;
125
+ var _objectize = (key, value) => {
126
+ return value ? {
127
+ [key]: value
128
+ } : {};
129
+ };
130
+ var _additionalLink = (data) => {
131
+ const inner = _builderV2(data);
132
+ const partialLink = (0, import_omit.default)(_link(data), ["and", "or"]);
133
+ return {
134
+ ...inner,
135
+ ...partialLink
136
+ };
137
+ };
138
+ var _link = (data) => {
139
+ return {
140
+ and: () => {
141
+ return _queryBuilder({ ...data, query: data.query.concat("AND") });
142
+ },
143
+ or: () => {
144
+ return _queryBuilder({ ...data, query: data.query.concat("OR") });
145
+ },
146
+ compile: () => {
147
+ return data;
148
+ },
149
+ take: (num) => {
150
+ return _additionalLink({ ...data, take: take(num) });
151
+ },
152
+ sort: (key, order = "asc" /* asc */) => {
153
+ return _additionalLink({ ...data, sort: sort(key, order) });
154
+ },
155
+ pagination: (value) => {
156
+ return _additionalLink({ ...data, page: pagination(value) });
157
+ }
158
+ };
159
+ };
160
+ var _canCompile = (obj) => {
161
+ return Boolean(obj.compile);
162
+ };
163
+ var _builderV2 = (data) => {
164
+ const _myProperty = (name, value, options) => {
165
+ const p = property(name, value, options);
166
+ return _link((0, import_merge.default)(data, { query: data.query.concat(p) }));
167
+ };
168
+ const complex = (subBuilderFunc) => {
169
+ const subBuilder = _queryBuilder();
170
+ const result = subBuilderFunc(subBuilder);
171
+ if (_canCompile(result)) {
172
+ const queryTokens = [result.compile().query];
173
+ return _link(
174
+ (0, import_merge.default)(data, {
175
+ query: data.query.concat(queryTokens)
176
+ })
177
+ );
178
+ }
179
+ return _link((0, import_merge.default)(data, { query: data.query.concat([result.query]) }));
180
+ };
181
+ const thisDatesBefore = (key, jsDate, { valueType = "date" /* date */, equalToAndBefore = true } = {}) => {
182
+ const p = datesBefore(key, jsDate, { valueType, equalToAndBefore });
183
+ return _link((0, import_merge.default)(data, { query: data.query.concat(p) }));
184
+ };
185
+ const thisDatesAfter = (key, jsDate, { valueType = "date" /* date */, equalToAndAfter = true } = {}) => {
186
+ const p = datesAfter(key, jsDate, { valueType, equalToAndAfter });
187
+ return _link((0, import_merge.default)(data, { query: data.query.concat(p) }));
188
+ };
189
+ return {
190
+ datesBefore: thisDatesBefore,
191
+ datesAfter: thisDatesAfter,
192
+ complex,
193
+ property: _myProperty
194
+ };
195
+ };
196
+ var _queryBuilder = (data = void 0) => {
197
+ const theData = (0, import_merge.default)(
198
+ {
199
+ query: []
200
+ },
201
+ data
202
+ );
203
+ const builder = _builderV2(theData);
204
+ const linkData = _additionalLink(theData);
205
+ return {
206
+ ...builder,
207
+ ...linkData,
208
+ compile: () => {
209
+ return {
210
+ ..._objectize("take", theData.take),
211
+ ..._objectize("sort", theData.sort),
212
+ ..._objectize("page", theData.page),
213
+ query: []
214
+ };
215
+ }
216
+ };
217
+ };
218
+ var property = (key, value, options = {}) => {
219
+ const {
220
+ equalitySymbol = "=" /* eq */,
221
+ caseSensitive,
222
+ startsWith,
223
+ endsWith,
224
+ includes,
225
+ type
226
+ } = options;
227
+ const typeToUse = type || "string" /* string */;
228
+ if (!AllowableEqualitySymbols.includes(equalitySymbol)) {
229
+ throw new Error(`${equalitySymbol} is not a valid symbol`);
230
+ }
231
+ if (equalitySymbol !== "=" /* eq */ && equalitySymbol !== "!=" /* ne */ && typeToUse === "string" /* string */) {
232
+ throw new Error(`Cannot use a non = symbol for a string type`);
233
+ }
234
+ const propertyEntry = {
235
+ type: "property",
236
+ key,
237
+ value,
238
+ valueType: typeToUse,
239
+ equalitySymbol,
240
+ options: {
241
+ ..._objectize("caseSensitive", caseSensitive),
242
+ ..._objectize("startsWith", startsWith),
243
+ ..._objectize("endsWith", endsWith),
244
+ ..._objectize("includes", includes)
245
+ }
246
+ };
247
+ return propertyEntry;
248
+ };
249
+ var take = (max) => {
250
+ const parsed = parseInt(`${max}`, 10);
251
+ if (Number.isNaN(parsed)) {
252
+ throw new Error(`Number "${max}" is not integerable`);
253
+ }
254
+ return parsed;
255
+ };
256
+ var sort = (key, order = "asc" /* asc */) => {
257
+ if (order !== "asc" /* asc */ && order !== "dsc" /* dsc */) {
258
+ throw new Error("Sort must be either asc or dsc");
259
+ }
260
+ return {
261
+ key,
262
+ order
263
+ };
264
+ };
265
+ var pagination = (value) => {
266
+ return value;
267
+ };
268
+ var datesAfter = (key, jsDate, options = {
269
+ valueType: "date" /* date */,
270
+ equalToAndAfter: true
271
+ }) => {
272
+ const { valueType = "date" /* date */, equalToAndAfter = true } = options;
273
+ return {
274
+ type: "datesAfter",
275
+ key,
276
+ date: isDate(jsDate) ? jsDate.toISOString() : jsDate,
277
+ valueType,
278
+ options: {
279
+ equalToAndAfter
280
+ }
281
+ };
282
+ };
283
+ var isDate = (obj) => {
284
+ return Boolean(obj.toISOString);
285
+ };
286
+ var datesBefore = (key, jsDate, options = {
287
+ valueType: "date" /* date */,
288
+ equalToAndBefore: true
289
+ }) => {
290
+ const { valueType = "date" /* date */, equalToAndBefore = true } = options;
291
+ return {
292
+ type: "datesBefore",
293
+ key,
294
+ date: isDate(jsDate) ? jsDate.toISOString() : jsDate,
295
+ valueType,
296
+ options: {
297
+ equalToAndBefore
298
+ }
299
+ };
300
+ };
301
+ var queryBuilder = () => {
302
+ return _queryBuilder();
303
+ };
304
+ var isPropertyBasedQuery = (value) => {
305
+ if (!value || !value.type) {
306
+ return false;
307
+ }
308
+ return value.type === "property" || value.type === "datesBefore" || value.type === "datesAfter";
309
+ };
310
+ var isALinkToken = (value) => {
311
+ if (!value) {
312
+ return false;
313
+ }
314
+ if (typeof value !== "string") {
315
+ return false;
316
+ }
317
+ value = value.toLowerCase();
318
+ return value === "and" || value === "or";
319
+ };
320
+ var and = () => "AND";
321
+ var or = () => "OR";
322
+ var textQuery = (key, value, options) => property(
323
+ key,
324
+ value,
325
+ Object.assign({}, options, {
326
+ equalitySymbol: void 0,
327
+ type: "string" /* string */
328
+ })
329
+ );
330
+ var numberQuery = (key, value, equalitySymbol = "=" /* eq */) => property(key, value, {
331
+ equalitySymbol,
332
+ type: "number" /* number */
333
+ });
334
+ var booleanQuery = (key, value) => property(key, value, {
335
+ type: "boolean" /* boolean */,
336
+ equalitySymbol: "=" /* eq */
337
+ });
338
+ var threeitize = (data) => {
339
+ if (data.length === 0 || data.length === 1) {
340
+ return [];
341
+ }
342
+ if (data.length % 2 === 0) {
343
+ throw new Error("Must be an odd number of 3 or greater.");
344
+ }
345
+ const three = data.slice(0, THREE);
346
+ const rest = data.slice(2);
347
+ const moreThrees = threeitize(rest);
348
+ return [three, ...moreThrees];
349
+ };
350
+ var _validateTokenTypes = (token) => {
351
+ if (Array.isArray(token)) {
352
+ token.forEach(_validateTokenTypes);
353
+ return;
354
+ }
355
+ if (isPropertyBasedQuery(token)) {
356
+ return;
357
+ }
358
+ if (isALinkToken(token)) {
359
+ return;
360
+ }
361
+ throw new Error(`Unknown token type ${token}`);
362
+ };
363
+ var _validateTokenStructure = (o) => {
364
+ const first = o[0];
365
+ if (first === "AND" || first === "OR") {
366
+ throw new Error("Cannot have AND or OR at the very start.");
367
+ }
368
+ const last = o[o.length - 1];
369
+ if (last === "AND" || last === "OR") {
370
+ throw new Error("Cannot have AND or OR at the very end.");
371
+ }
372
+ if (o.every((x) => x !== "AND" && x !== "OR")) {
373
+ o.every(_validateArrayOrQuery);
374
+ return;
375
+ }
376
+ const totalLinks = o.filter((x) => x === "AND" || x === "OR");
377
+ const nonLinks = o.filter((x) => x !== "AND" && x !== "OR");
378
+ if (totalLinks.length !== nonLinks.length - 1) {
379
+ throw new Error("Must separate each statement with an AND or OR");
380
+ }
381
+ const threes = threeitize(o).reverse();
382
+ threes.forEach(([a, l, b]) => {
383
+ if (l !== "AND" && l !== "OR") {
384
+ if (isPropertyBasedQuery(l)) {
385
+ throw new Error("Must have AND/OR between property queries");
386
+ }
387
+ throw new Error("Must have AND/OR between nested queries");
388
+ }
389
+ _validateArrayOrQuery(a);
390
+ _validateArrayOrQuery(b);
391
+ });
392
+ return;
393
+ };
394
+ var _validateArrayOrQuery = (o) => {
395
+ if (Array.isArray(o)) {
396
+ _validateTokenStructure(o);
397
+ return;
398
+ }
399
+ if (isPropertyBasedQuery(o)) {
400
+ return;
401
+ }
402
+ throw new Error("Order of link tokens and queries invalid");
403
+ };
404
+ var validateOrmSearch = (search) => {
405
+ if (Array.isArray(search.query) === false) {
406
+ throw new Error(`Query must be an array`);
407
+ }
408
+ if (search.query.length < 1) {
409
+ return;
410
+ }
411
+ _validateTokenTypes(search.query);
412
+ _validateTokenStructure(search.query);
413
+ };
414
+
415
+ // src/orm/validation.ts
416
+ var validation_exports = {};
417
+ __export(validation_exports, {
418
+ buildOrmValidatorContext: () => buildOrmValidatorContext,
419
+ unique: () => unique,
420
+ uniqueTogether: () => uniqueTogether
421
+ });
422
+ var import_flow = __toESM(require("lodash/flow.js"), 1);
423
+ var _doUniqueCheck = async (query, model, instanceData, buildErrorMessage) => {
424
+ const results = await model.search(query);
425
+ const resultsLength = results.instances.length;
426
+ if (resultsLength < 1) {
427
+ return void 0;
428
+ }
429
+ const ids = await Promise.all(
430
+ results.instances.map((x) => x.getPrimaryKey())
431
+ );
432
+ const instanceId = instanceData[model.getModelDefinition().primaryKeyName];
433
+ if (ids.length === 1 && ids[0] === instanceId) {
434
+ return void 0;
435
+ }
436
+ if (ids.length > 1) {
437
+ if (ids.find((x) => x === instanceId)) {
438
+ return void 0;
439
+ }
440
+ }
441
+ return buildErrorMessage();
442
+ };
443
+ var uniqueTogether = (propertyKeyArray) => {
444
+ const _uniqueTogether = async (model, instanceData, options) => {
445
+ if (options?.noOrmValidation) {
446
+ return void 0;
447
+ }
448
+ const properties = propertyKeyArray.map((key) => {
449
+ return [key, instanceData[key]];
450
+ });
451
+ const query = (0, import_flow.default)(
452
+ properties.map(([key, value], index) => {
453
+ return (b) => {
454
+ if (index + 1 >= properties.length) {
455
+ return b.property(key, value, { caseSensitive: false });
456
+ }
457
+ return b.property(key, value, { caseSensitive: false }).and();
458
+ };
459
+ })
460
+ )(queryBuilder().take(2)).compile();
461
+ return _doUniqueCheck(query, model, instanceData, () => {
462
+ return propertyKeyArray.length > 1 ? `${propertyKeyArray.join(
463
+ ","
464
+ )} must be unique together. Another instance found.` : `${propertyKeyArray[0]} must be unique. Another instance found.`;
465
+ });
466
+ };
467
+ return _uniqueTogether;
468
+ };
469
+ var unique = (propertyKey) => {
470
+ const _unique = (value, model, instanceData, options) => {
471
+ return uniqueTogether([propertyKey])(model, instanceData, options);
472
+ };
473
+ return _unique;
474
+ };
475
+ var buildOrmValidatorContext = ({
476
+ noOrmValidation = false
477
+ }) => ({
478
+ noOrmValidation
479
+ });
480
+
481
+ // src/orm/properties.ts
482
+ var properties_exports = {};
483
+ __export(properties_exports, {
484
+ ForeignKeyProperty: () => ForeignKeyProperty,
485
+ LastModifiedDateProperty: () => LastModifiedDateProperty,
486
+ PrimaryKeyProperty: () => PrimaryKeyProperty,
487
+ ormPropertyConfig: () => ormPropertyConfig
488
+ });
489
+ var import_merge5 = __toESM(require("lodash/merge.js"), 1);
490
+ var import_identity = __toESM(require("lodash/identity.js"), 1);
491
+
492
+ // src/types.ts
493
+ var ApiMethod = /* @__PURE__ */ ((ApiMethod2) => {
494
+ ApiMethod2["create"] = "create";
495
+ ApiMethod2["retrieve"] = "retrieve";
496
+ ApiMethod2["update"] = "update";
497
+ ApiMethod2["delete"] = "delete";
498
+ ApiMethod2["search"] = "search";
499
+ return ApiMethod2;
500
+ })(ApiMethod || {});
501
+
502
+ // src/properties.ts
503
+ var import_merge4 = __toESM(require("lodash/merge.js"), 1);
504
+ var import_get3 = __toESM(require("lodash/get.js"), 1);
505
+
506
+ // node_modules/uuid/dist-node/stringify.js
507
+ var byteToHex = [];
508
+ for (let i = 0; i < 256; ++i) {
509
+ byteToHex.push((i + 256).toString(16).slice(1));
510
+ }
511
+ function unsafeStringify(arr, offset = 0) {
512
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
513
+ }
514
+
515
+ // node_modules/uuid/dist-node/rng.js
516
+ var rnds8 = new Uint8Array(16);
517
+ function rng() {
518
+ return crypto.getRandomValues(rnds8);
519
+ }
520
+
521
+ // node_modules/uuid/dist-node/v4.js
522
+ function v4(options, buf, offset) {
523
+ if (!buf && !options && crypto.randomUUID) {
524
+ return crypto.randomUUID();
525
+ }
526
+ return _v4(options, buf, offset);
527
+ }
528
+ function _v4(options, buf, offset) {
529
+ options = options || {};
530
+ const rnds = options.random ?? options.rng?.() ?? rng();
531
+ if (rnds.length < 16) {
532
+ throw new Error("Random bytes length must be >= 16");
533
+ }
534
+ rnds[6] = rnds[6] & 15 | 64;
535
+ rnds[8] = rnds[8] & 63 | 128;
536
+ if (buf) {
537
+ offset = offset || 0;
538
+ if (offset < 0 || offset + 16 > buf.length) {
539
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
540
+ }
541
+ for (let i = 0; i < 16; ++i) {
542
+ buf[offset + i] = rnds[i];
543
+ }
544
+ return buf;
545
+ }
546
+ return unsafeStringify(rnds);
547
+ }
548
+ var v4_default = v4;
549
+
550
+ // src/validation.ts
551
+ var import_isEmpty = __toESM(require("lodash/isEmpty.js"), 1);
552
+ var import_merge2 = __toESM(require("lodash/merge.js"), 1);
553
+ var import_flatMap = __toESM(require("lodash/flatMap.js"), 1);
554
+ var import_get = __toESM(require("lodash/get.js"), 1);
555
+
556
+ // src/utils.ts
557
+ var import_async_lock = __toESM(require("async-lock"), 1);
558
+ var import_get_random_values = __toESM(require("get-random-values"), 1);
559
+ var getRandomValues = () => {
560
+ const array = new Uint8Array(1);
561
+ if (typeof window !== "undefined") {
562
+ if (window.crypto) {
563
+ return window.crypto.getRandomValues(array);
564
+ }
565
+ if (window.msCrypto) {
566
+ return window.msCrypto.getRandomValues(array);
567
+ }
568
+ }
569
+ return (0, import_get_random_values.default)(array);
570
+ };
571
+ var toTitleCase = (string) => {
572
+ return `${string.slice(0, 1).toUpperCase()}${string.slice(1)}`;
573
+ };
574
+ var PluralEndings = /* @__PURE__ */ ((PluralEndings2) => {
575
+ PluralEndings2["ves"] = "fe";
576
+ PluralEndings2["ies"] = "y";
577
+ PluralEndings2["i"] = "us";
578
+ PluralEndings2["zes"] = "ze";
579
+ PluralEndings2["ses"] = "s";
580
+ PluralEndings2["es"] = "e";
581
+ PluralEndings2["s"] = "";
582
+ return PluralEndings2;
583
+ })(PluralEndings || {});
584
+ var _singularizingRe = new RegExp(
585
+ `(${Object.keys(PluralEndings).join("|")})$`,
586
+ "u"
587
+ );
588
+ var singularize = (word) => {
589
+ return word.replace(_singularizingRe, (r) => PluralEndings[r]);
590
+ };
591
+ var flowFindFirst = (funcs) => (input) => {
592
+ return funcs.reduce((acc, func) => {
593
+ if (acc) {
594
+ return acc;
595
+ }
596
+ return func(input);
597
+ }, void 0);
598
+ };
599
+ var memoizeSync = (method) => {
600
+ let value = void 0;
601
+ let called = false;
602
+ return (...args) => {
603
+ if (!called) {
604
+ called = true;
605
+ value = method(...args);
606
+ }
607
+ return value;
608
+ };
609
+ };
610
+ var memoizeAsync = (method) => {
611
+ const key = v4_default();
612
+ const lock = new import_async_lock.default();
613
+ let value = void 0;
614
+ let called = false;
615
+ return async (...args) => {
616
+ return lock.acquire(key, async () => {
617
+ if (!called) {
618
+ called = true;
619
+ value = await method(...args);
620
+ }
621
+ return value;
622
+ });
623
+ };
624
+ };
625
+ var createUuid = v4_default;
626
+
627
+ // src/validation.ts
628
+ var multiValidator = (validators) => {
629
+ const flow3 = flowFindFirst(
630
+ validators
631
+ );
632
+ return flow3;
633
+ };
634
+ var filterEmpty = (array) => {
635
+ return array.filter((x) => x);
636
+ };
637
+ var _trueOrError = (method, error) => (value) => {
638
+ if (method(value) === false) {
639
+ return error;
640
+ }
641
+ return void 0;
642
+ };
643
+ var _typeOrError = (type, errorMessage) => (value) => {
644
+ if (typeof value !== type) {
645
+ return errorMessage;
646
+ }
647
+ return void 0;
648
+ };
649
+ var isType = (type) => (value) => {
650
+ return _typeOrError(type, `Must be a ${type}`)(value);
651
+ };
652
+ var isNumber = isType("number");
653
+ var isInteger = _trueOrError(Number.isInteger, "Must be an integer");
654
+ var isObject = multiValidator([
655
+ isType("object"),
656
+ (x) => Array.isArray(x) ? "Must be an object, but got an array" : void 0
657
+ ]);
658
+ var isBoolean = isType("boolean");
659
+ var isString = isType("string");
660
+ var isArray = _trueOrError(
661
+ (v) => Array.isArray(v),
662
+ "Value is not an array"
663
+ );
664
+ var PRIMITIVE_TO_SPECIAL_TYPE_VALIDATOR = {
665
+ ["boolean" /* boolean */]: isBoolean,
666
+ ["string" /* string */]: isString,
667
+ ["integer" /* integer */]: isInteger,
668
+ ["number" /* number */]: isNumber,
669
+ ["object" /* object */]: isObject
670
+ };
671
+ var meetsRegex = (regex, flags, errorMessage = "Format was invalid") => (value) => {
672
+ const reg = new RegExp(regex, flags);
673
+ return _trueOrError((v) => reg.test(v), errorMessage)(value);
674
+ };
675
+ var choices = (choiceArray) => (value) => {
676
+ if (Array.isArray(value)) {
677
+ const bad = value.find((v) => !choiceArray.includes(v));
678
+ if (bad) {
679
+ return `${bad} is not a valid choice`;
680
+ }
681
+ } else {
682
+ if (!choiceArray.includes(value)) {
683
+ return `${value} is not a valid choice`;
684
+ }
685
+ }
686
+ return void 0;
687
+ };
688
+ var isDate2 = (value) => {
689
+ if (!value) {
690
+ return "Date value is empty";
691
+ }
692
+ if (!value.toISOString) {
693
+ return "Value is not a date";
694
+ }
695
+ return void 0;
696
+ };
697
+ var isRequired = (value) => {
698
+ if (value === true || value === false) {
699
+ return void 0;
700
+ }
701
+ if (isNumber(value) === void 0) {
702
+ return void 0;
703
+ }
704
+ const empty = (0, import_isEmpty.default)(value);
705
+ if (empty) {
706
+ if (isDate2(value)) {
707
+ return "A value is required";
708
+ }
709
+ }
710
+ return void 0;
711
+ };
712
+ var maxNumber = (max) => (value) => {
713
+ const numberError = isNumber(value);
714
+ if (numberError) {
715
+ return numberError;
716
+ }
717
+ if (value && value > max) {
718
+ return `The maximum is ${max}`;
719
+ }
720
+ return void 0;
721
+ };
722
+ var minNumber = (min) => (value) => {
723
+ const numberError = isNumber(value);
724
+ if (numberError) {
725
+ return numberError;
726
+ }
727
+ if (value && value < min) {
728
+ return `The minimum is ${min}`;
729
+ }
730
+ return void 0;
731
+ };
732
+ var maxTextLength = (max) => (value) => {
733
+ const stringError = isString(value);
734
+ if (stringError) {
735
+ return stringError;
736
+ }
737
+ if (value && value.length > max) {
738
+ return `The maximum length is ${max}`;
739
+ }
740
+ return void 0;
741
+ };
742
+ var minTextLength = (min) => (value) => {
743
+ const stringError = isString(value);
744
+ if (stringError) {
745
+ return stringError;
746
+ }
747
+ if (value && value.length < min) {
748
+ return `The minimum length is ${min}`;
749
+ }
750
+ return void 0;
751
+ };
752
+ var aggregateValidator = (value, methodOrMethods) => {
753
+ const toDo = Array.isArray(methodOrMethods) ? methodOrMethods : [methodOrMethods];
754
+ const _aggregativeValidator = async (model, instanceData, propertyConfiguration) => {
755
+ const values = await Promise.all(
756
+ toDo.map((method) => {
757
+ return method(value, model, instanceData, propertyConfiguration);
758
+ })
759
+ );
760
+ return filterEmpty(values);
761
+ };
762
+ return _aggregativeValidator;
763
+ };
764
+ var emptyValidator = () => void 0;
765
+ var _boolChoice = (method) => (configValue) => {
766
+ const func = method(configValue);
767
+ const validatorWrapper = func;
768
+ return validatorWrapper;
769
+ };
770
+ var simpleFuncWrap = (validator) => () => {
771
+ return validator;
772
+ };
773
+ var includeOrDont = (method) => (configValue) => {
774
+ if (configValue === false) {
775
+ return emptyValidator;
776
+ }
777
+ const func = method();
778
+ const validatorWrapper = func;
779
+ return validatorWrapper;
780
+ };
781
+ var CONFIG_TO_VALIDATE_METHOD = () => ({
782
+ required: includeOrDont(simpleFuncWrap(isRequired)),
783
+ isInteger: _boolChoice(simpleFuncWrap(isInteger)),
784
+ isNumber: _boolChoice(simpleFuncWrap(isNumber)),
785
+ isString: _boolChoice(simpleFuncWrap(isString)),
786
+ isArray: _boolChoice(simpleFuncWrap(isArray)),
787
+ isBoolean: _boolChoice(simpleFuncWrap(isBoolean)),
788
+ choices: _boolChoice(choices)
789
+ });
790
+ var createPropertyValidator = (valueGetter, config) => {
791
+ const _propertyValidator = async (model, instanceData, propertyConfiguration) => {
792
+ return Promise.resolve().then(async () => {
793
+ const configToValidateMethod = CONFIG_TO_VALIDATE_METHOD();
794
+ if (!config) {
795
+ config = {};
796
+ }
797
+ const validators = [
798
+ ...Object.entries(config).map(([key, value2]) => {
799
+ const method = configToValidateMethod[key];
800
+ if (method) {
801
+ return method(value2);
802
+ }
803
+ return emptyValidator;
804
+ }),
805
+ ...config.validators ? config.validators : []
806
+ ].filter((x) => x);
807
+ const value = await valueGetter();
808
+ const isRequiredValue = config.required ? true : validators.includes(isRequired);
809
+ if (!value && !isRequiredValue) {
810
+ return [];
811
+ }
812
+ const validator = aggregateValidator(value, validators);
813
+ const errors = await validator(model, instanceData, propertyConfiguration);
814
+ return [...new Set((0, import_flatMap.default)(errors))];
815
+ });
816
+ };
817
+ return _propertyValidator;
818
+ };
819
+ var createModelValidator = (validators, modelValidators) => {
820
+ const _modelValidator = async (instance, propertyConfiguration) => {
821
+ return Promise.resolve().then(async () => {
822
+ if (!instance) {
823
+ throw new Error(`Instance cannot be empty`);
824
+ }
825
+ const model = instance.getModel();
826
+ const keysAndFunctions = Object.entries(validators);
827
+ const instanceData = await instance.toObj();
828
+ const propertyValidationErrors = await Promise.all(
829
+ keysAndFunctions.map(async ([key, validator]) => {
830
+ return [
831
+ key,
832
+ await validator(model, instanceData, propertyConfiguration)
833
+ ];
834
+ })
835
+ );
836
+ const modelValidationErrors = (await Promise.all(
837
+ modelValidators ? modelValidators.map((validator) => {
838
+ return validator(model, instanceData, propertyConfiguration);
839
+ }) : []
840
+ )).filter((x) => x);
841
+ const propertyErrors = propertyValidationErrors.filter(([, errors]) => Boolean(errors) && errors.length > 0).reduce((acc, [key, errors]) => {
842
+ return (0, import_merge2.default)(acc, { [String(key)]: errors });
843
+ }, {});
844
+ const final = modelValidationErrors.length > 0 ? (0, import_merge2.default)(propertyErrors, { overall: modelValidationErrors }) : propertyErrors;
845
+ if ((0, import_isEmpty.default)(final)) {
846
+ return void 0;
847
+ }
848
+ return final;
849
+ });
850
+ };
851
+ return _modelValidator;
852
+ };
853
+ var optionalValidator = (validator) => {
854
+ return (v) => {
855
+ if (v === void 0 || v === null) {
856
+ return void 0;
857
+ }
858
+ return validator(v);
859
+ };
860
+ };
861
+ var UUID_VALIDATOR = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
862
+ var isValidUuid = (uuid) => {
863
+ const stringError = isString(uuid);
864
+ if (stringError) {
865
+ return stringError;
866
+ }
867
+ return meetsRegex(UUID_VALIDATOR, "g", "Invalid UUID format")(uuid);
868
+ };
869
+
870
+ // src/lib.ts
871
+ var import_openapi_types = require("openapi-types");
872
+ var import_kebabCase = __toESM(require("lodash/kebabCase.js"), 1);
873
+ var import_flow2 = __toESM(require("lodash/flow.js"), 1);
874
+ var import_merge3 = __toESM(require("lodash/merge.js"), 1);
875
+ var import_get2 = __toESM(require("lodash/get.js"), 1);
876
+ var import_zod = require("zod");
877
+ var HttpMethods = import_openapi_types.OpenAPIV3.HttpMethods;
878
+ var NULL_ENDPOINT = "NULL";
879
+ var NULL_METHOD = HttpMethods.HEAD;
880
+ var ID_KEY = ":id";
881
+ var getCommonTextValidators = (config) => {
882
+ return [
883
+ getValidatorFromConfigElseEmpty(config?.maxLength, maxTextLength),
884
+ getValidatorFromConfigElseEmpty(config?.minLength, minTextLength)
885
+ ];
886
+ };
887
+ var getValidatorFromConfigElseEmpty = (input, validatorGetter) => {
888
+ if (input !== void 0) {
889
+ const validator = validatorGetter(input);
890
+ return validator;
891
+ }
892
+ return emptyValidator;
893
+ };
894
+ var getCommonNumberValidators = (config) => {
895
+ return [
896
+ getValidatorFromConfigElseEmpty(config?.minValue, minNumber),
897
+ getValidatorFromConfigElseEmpty(config?.maxValue, maxNumber)
898
+ ];
899
+ };
900
+ var mergeValidators = (config, ...validators) => {
901
+ return [...validators, ...config?.validators ? config.validators : []];
902
+ };
903
+ var getModelName = (namespace, pluralName) => {
904
+ return `${namespace}/${pluralName}`;
905
+ };
906
+ var buildValidEndpoint = (...components) => {
907
+ const suffix = components.map((x) => {
908
+ if (x === ID_KEY) {
909
+ return x;
910
+ }
911
+ return (0, import_kebabCase.default)(x);
912
+ }).map((s) => s.toLowerCase()).join("/");
913
+ return `/${suffix}`;
914
+ };
915
+ var _generateRestInfo = (method, withId, ...additional) => (pluralName, namespace) => (existing) => {
916
+ if (existing) {
917
+ return {
918
+ // Default add security, then override it.
919
+ security: {},
920
+ ...existing
921
+ };
922
+ }
923
+ const endpoint = withId ? buildValidEndpoint(namespace, pluralName, ID_KEY) : buildValidEndpoint(namespace, pluralName, ...additional);
924
+ return {
925
+ method,
926
+ endpoint,
927
+ // We cannot auto create security.
928
+ security: {}
929
+ };
930
+ };
931
+ var _apiMethodToRestInfoGenerator = {
932
+ ["create" /* create */]: _generateRestInfo(HttpMethods.POST, false),
933
+ ["retrieve" /* retrieve */]: _generateRestInfo(HttpMethods.GET, true),
934
+ ["update" /* update */]: _generateRestInfo(HttpMethods.PUT, true),
935
+ ["delete" /* delete */]: _generateRestInfo(HttpMethods.DELETE, true),
936
+ ["search" /* search */]: _generateRestInfo(HttpMethods.POST, false, "search")
937
+ };
938
+ var getNullRestInfo = () => {
939
+ return {
940
+ endpoint: NULL_ENDPOINT,
941
+ method: NULL_METHOD,
942
+ security: {}
943
+ };
944
+ };
945
+ var _fillOutRestInfo = (pluralName, namespace, partial, nullRest) => {
946
+ const finishedRestInfo = Object.entries(
947
+ ApiMethod
948
+ ).reduce(
949
+ (acc, [, method]) => {
950
+ const existing = partial && partial.rest && partial.rest[method] ? partial.rest[method] : void 0;
951
+ const restInfo = _apiMethodToRestInfoGenerator[method](
952
+ pluralName,
953
+ namespace
954
+ )(existing);
955
+ return (0, import_merge3.default)(acc, {
956
+ [method]: restInfo
957
+ });
958
+ },
959
+ nullRest
960
+ );
961
+ return {
962
+ noPublish: false,
963
+ onlyPublish: [],
964
+ rest: finishedRestInfo,
965
+ createOnlyOne: partial?.createOnlyOne || false
966
+ };
967
+ };
968
+ var populateApiInformation = (pluralName, namespace, partial) => {
969
+ const nullRest = {
970
+ delete: getNullRestInfo(),
971
+ search: getNullRestInfo(),
972
+ update: getNullRestInfo(),
973
+ retrieve: getNullRestInfo(),
974
+ create: getNullRestInfo()
975
+ };
976
+ if (!partial) {
977
+ return _fillOutRestInfo(pluralName, namespace, partial, nullRest);
978
+ }
979
+ if (partial.noPublish) {
980
+ return {
981
+ onlyPublish: [],
982
+ noPublish: true,
983
+ rest: nullRest,
984
+ createOnlyOne: false
985
+ };
986
+ }
987
+ const rest = partial.rest || {};
988
+ if (partial.onlyPublish && partial.onlyPublish.length > 0) {
989
+ return partial.onlyPublish.reduce(
990
+ (acc, method) => {
991
+ const restInfo = _apiMethodToRestInfoGenerator[method](
992
+ pluralName,
993
+ namespace
994
+ )(rest[method]);
995
+ return (0, import_merge3.default)(acc, {
996
+ rest: {
997
+ [method]: restInfo
998
+ }
999
+ });
1000
+ },
1001
+ {
1002
+ noPublish: false,
1003
+ onlyPublish: partial.onlyPublish,
1004
+ createOnlyOne: Boolean(partial.createOnlyOne),
1005
+ rest: nullRest
1006
+ }
1007
+ );
1008
+ }
1009
+ return _fillOutRestInfo(pluralName, namespace, partial, nullRest);
1010
+ };
1011
+ var createZodForProperty = (propertyType, config) => () => {
1012
+ const myConfig = config || {};
1013
+ const provided = myConfig.zod;
1014
+ if (provided) {
1015
+ return provided;
1016
+ }
1017
+ const _getZodForPropertyType = (pt) => {
1018
+ if (myConfig.choices) {
1019
+ return import_zod.z.enum(myConfig.choices);
1020
+ }
1021
+ switch (pt) {
1022
+ case "UniqueId":
1023
+ return import_zod.z.string();
1024
+ case "Date":
1025
+ case "Datetime":
1026
+ return import_zod.z.union([import_zod.z.string(), import_zod.z.date()]);
1027
+ case "Integer":
1028
+ return import_zod.z.number().int();
1029
+ case "Number":
1030
+ return import_zod.z.number();
1031
+ case "Boolean":
1032
+ return import_zod.z.boolean();
1033
+ case "Array":
1034
+ return import_zod.z.array(import_zod.z.any());
1035
+ case "Object":
1036
+ return import_zod.z.object().loose();
1037
+ case "Email":
1038
+ return import_zod.z.email();
1039
+ case "Text":
1040
+ case "BigText":
1041
+ return import_zod.z.string();
1042
+ case "ModelReference":
1043
+ return import_zod.z.union([import_zod.z.string(), import_zod.z.number()]);
1044
+ default:
1045
+ return import_zod.z.any();
1046
+ }
1047
+ };
1048
+ const baseSchema = _getZodForPropertyType(propertyType);
1049
+ const choices2 = config?.choices;
1050
+ const schemaFromChoices = choices2 && Array.isArray(choices2) && choices2.length > 0 ? import_zod.z.union(choices2.map((c) => import_zod.z.literal(c))) : baseSchema;
1051
+ const finalSchema = (0, import_flow2.default)([
1052
+ (s) => typeof myConfig.minValue === "number" ? s.min(myConfig.minValue) : s,
1053
+ (s) => typeof myConfig.maxValue === "number" ? s.max(myConfig.maxValue) : s,
1054
+ (s) => typeof myConfig.minLength === "number" ? s.min(myConfig.minLength) : s,
1055
+ (s) => typeof myConfig.maxLength === "number" ? s.max(myConfig.maxLength) : s,
1056
+ (s) => myConfig.defaultValue !== void 0 ? s.default(myConfig.defaultValue) : s,
1057
+ (s) => myConfig.required ? s : s.optional(),
1058
+ // Attach description for Zod consumers and OpenAPI generators.
1059
+ (s) => {
1060
+ if (myConfig.description) {
1061
+ if (typeof s.openapi === "function") {
1062
+ return s.openapi({ description: myConfig.description });
1063
+ }
1064
+ return s.meta ? s.meta({ description: myConfig.description }) : s.describe(myConfig.description);
1065
+ }
1066
+ return s;
1067
+ }
1068
+ ])(schemaFromChoices);
1069
+ return finalSchema;
1070
+ };
1071
+
1072
+ // src/properties.ts
1073
+ var Property = (propertyType, config = {}, additionalMetadata = {}) => {
1074
+ if (!propertyType && !config?.typeOverride) {
1075
+ throw new Error(`Property type must be provided.`);
1076
+ }
1077
+ if (config?.typeOverride) {
1078
+ propertyType = config.typeOverride;
1079
+ }
1080
+ const getConstantValue = () => config?.value !== void 0 ? config.value : void 0;
1081
+ const getDefaultValue = () => config?.defaultValue !== void 0 ? config.defaultValue : void 0;
1082
+ const getChoices = () => config?.choices || [];
1083
+ const lazyLoadMethod = config?.lazyLoadMethod || false;
1084
+ const valueSelector = config?.valueSelector || ((x) => x);
1085
+ if (typeof valueSelector !== "function") {
1086
+ throw new Error(`valueSelector must be a function`);
1087
+ }
1088
+ const createGetter = (instanceValue, modelData, instance) => {
1089
+ const constantValue = getConstantValue();
1090
+ if (constantValue !== void 0) {
1091
+ return () => constantValue;
1092
+ }
1093
+ const defaultValue = getDefaultValue();
1094
+ if (defaultValue !== void 0 && (instanceValue === null || instanceValue === void 0)) {
1095
+ return () => defaultValue;
1096
+ }
1097
+ const method = lazyLoadMethod ? lazyLoadMethod : config.lazyLoadMethodAtomic ? memoizeAsync(config.lazyLoadMethodAtomic) : typeof instanceValue === "function" ? instanceValue : () => instanceValue;
1098
+ const valueGetter = memoizeSync(() => {
1099
+ const result = method(
1100
+ instanceValue,
1101
+ modelData,
1102
+ // @ts-ignore
1103
+ instance
1104
+ );
1105
+ return valueSelector(result);
1106
+ });
1107
+ return valueGetter;
1108
+ };
1109
+ const getValidator = (valueGetter) => {
1110
+ const validator = createPropertyValidator(valueGetter, config);
1111
+ const _propertyValidatorWrapper = async (model, instanceData, propertyConfiguration) => {
1112
+ return validator(model, instanceData, propertyConfiguration);
1113
+ };
1114
+ return _propertyValidatorWrapper;
1115
+ };
1116
+ const getZod = () => {
1117
+ const provided = config?.zod;
1118
+ if (provided) {
1119
+ return provided;
1120
+ }
1121
+ return createZodForProperty(propertyType, config)();
1122
+ };
1123
+ const propertyInstance = {
1124
+ ...additionalMetadata,
1125
+ getConfig: () => config || {},
1126
+ getChoices,
1127
+ getDefaultValue,
1128
+ getConstantValue,
1129
+ getPropertyType: () => propertyType,
1130
+ createGetter,
1131
+ getZod,
1132
+ getValidator
1133
+ };
1134
+ return propertyInstance;
1135
+ };
1136
+ var isDate3 = (value) => {
1137
+ if (value === null) {
1138
+ return false;
1139
+ }
1140
+ return typeof value === "object" && value.toISOString;
1141
+ };
1142
+ var DatetimeProperty = (config = {}, additionalMetadata = {}) => Property(
1143
+ "Datetime" /* Datetime */,
1144
+ (0, import_merge4.default)(
1145
+ {
1146
+ lazyLoadMethod: (value) => {
1147
+ if (isDate3(value)) {
1148
+ if (config.formatFunction) {
1149
+ return config.formatFunction(value, config.format);
1150
+ }
1151
+ return value.toISOString();
1152
+ }
1153
+ if (!value && config?.autoNow) {
1154
+ const date = /* @__PURE__ */ new Date();
1155
+ if (config.formatFunction) {
1156
+ return config.formatFunction(date, config.format);
1157
+ }
1158
+ return date.toISOString();
1159
+ }
1160
+ return value;
1161
+ }
1162
+ },
1163
+ config
1164
+ ),
1165
+ additionalMetadata
1166
+ );
1167
+ var TextProperty = (config = {}, additionalMetadata = {}) => Property(
1168
+ "Text" /* Text */,
1169
+ (0, import_merge4.default)(config, {
1170
+ isString: true,
1171
+ // @ts-ignore
1172
+ validators: mergeValidators(config, ...getCommonTextValidators(config))
1173
+ }),
1174
+ additionalMetadata
1175
+ );
1176
+ var IntegerProperty = (config = {}, additionalMetadata = {}) => Property(
1177
+ "Integer" /* Integer */,
1178
+ (0, import_merge4.default)(config, {
1179
+ isInteger: true,
1180
+ validators: mergeValidators(
1181
+ config,
1182
+ ...getCommonNumberValidators(config)
1183
+ )
1184
+ }),
1185
+ additionalMetadata
1186
+ );
1187
+ var UuidProperty = (config = {}, additionalMetadata = {}) => Property(
1188
+ "UniqueId" /* UniqueId */,
1189
+ (0, import_merge4.default)(config, {
1190
+ isString: true,
1191
+ validators: mergeValidators(
1192
+ config,
1193
+ config.required ? isValidUuid : optionalValidator(isValidUuid)
1194
+ ),
1195
+ lazyLoadMethod: (value) => {
1196
+ if (!value) {
1197
+ if (config.autoNow) {
1198
+ return v4_default();
1199
+ }
1200
+ }
1201
+ return value;
1202
+ }
1203
+ }),
1204
+ additionalMetadata
1205
+ );
1206
+
1207
+ // src/orm/internal-libs.ts
1208
+ var _getModelIdPropertyType = (config = {}) => {
1209
+ return config.dataType || "UniqueId" /* UniqueId */;
1210
+ };
1211
+ var getPrimaryKeyGenerator = (config = {}) => {
1212
+ const custom = config.primaryKeyGenerator;
1213
+ if (custom) {
1214
+ return custom;
1215
+ }
1216
+ const idType = _getModelIdPropertyType(config);
1217
+ switch (idType) {
1218
+ case "Integer" /* Integer */:
1219
+ return () => Promise.resolve(getRandomValues()[0]);
1220
+ default: {
1221
+ return () => Promise.resolve(createUuid());
1222
+ }
1223
+ }
1224
+ };
1225
+
1226
+ // src/orm/properties.ts
1227
+ var _defaultPropertyConfig = {
1228
+ unique: void 0
1229
+ };
1230
+ var LastModifiedDateProperty = (config = {}) => {
1231
+ const additionalMetadata = { lastModifiedUpdateMethod: () => /* @__PURE__ */ new Date() };
1232
+ return DatetimeProperty(config, additionalMetadata);
1233
+ };
1234
+ var ForeignKeyProperty = (model, config = {}) => {
1235
+ const _getModel = () => {
1236
+ if (typeof model === "function") {
1237
+ return model();
1238
+ }
1239
+ return model;
1240
+ };
1241
+ const _getProperty = () => {
1242
+ if (config.dataType === "UniqueId" /* UniqueId */) {
1243
+ return UuidProperty(
1244
+ (0, import_merge5.default)(config, {
1245
+ autoNow: false
1246
+ })
1247
+ );
1248
+ }
1249
+ if (config.dataType === "Integer" /* Integer */) {
1250
+ return IntegerProperty(config);
1251
+ }
1252
+ return TextProperty(config);
1253
+ };
1254
+ const property2 = _getProperty();
1255
+ return (0, import_merge5.default)(property2, {
1256
+ getReferencedId: (instanceValues) => {
1257
+ return instanceValues;
1258
+ },
1259
+ getReferencedModel: _getModel
1260
+ });
1261
+ };
1262
+ var PrimaryKeyProperty = (config = {}) => {
1263
+ const _getProperty = () => {
1264
+ const auto = config.auto === void 0 ? true : config.auto ? true : false;
1265
+ const lazyLoadMethod = (value, modelData, instance) => {
1266
+ if (config.primaryKeyGenerator) {
1267
+ return config.primaryKeyGenerator(value, modelData, instance);
1268
+ }
1269
+ if (auto) {
1270
+ return getPrimaryKeyGenerator(config)(value, modelData, instance);
1271
+ }
1272
+ return value;
1273
+ };
1274
+ if (config.dataType === "UniqueId" /* UniqueId */) {
1275
+ return UuidProperty(
1276
+ (0, import_merge5.default)(config, {
1277
+ autoNow: auto,
1278
+ lazyLoadMethod
1279
+ })
1280
+ );
1281
+ }
1282
+ if (config.dataType === "Integer" /* Integer */) {
1283
+ return IntegerProperty(
1284
+ (0, import_merge5.default)(config, {
1285
+ lazyLoadMethod
1286
+ })
1287
+ );
1288
+ }
1289
+ return TextProperty(
1290
+ (0, import_merge5.default)(config, {
1291
+ lazyLoadMethod
1292
+ })
1293
+ );
1294
+ };
1295
+ return _getProperty();
1296
+ };
1297
+ var ormPropertyConfig = (config = _defaultPropertyConfig) => {
1298
+ return (0, import_merge5.default)(config, {
1299
+ validators: [
1300
+ ...config.validators ? config.validators : [],
1301
+ config.unique ? unique(config.unique) : null
1302
+ ].filter(import_identity.default)
1303
+ });
1304
+ };
1305
+
1306
+ // src/orm/models.ts
1307
+ var import_merge8 = __toESM(require("lodash/merge.js"), 1);
1308
+ var import_modern_async = require("modern-async");
1309
+
1310
+ // src/models.ts
1311
+ var import_merge7 = __toESM(require("lodash/merge.js"), 1);
1312
+ var import_zod2 = __toESM(require("zod"), 1);
1313
+
1314
+ // src/serialization.ts
1315
+ var import_merge6 = __toESM(require("lodash/merge.js"), 1);
1316
+ var isModelInstance2 = (obj) => {
1317
+ return Boolean(obj.toObj);
1318
+ };
1319
+ var _getValue = async (value) => {
1320
+ if (value === void 0) {
1321
+ return void 0;
1322
+ }
1323
+ if (value === null) {
1324
+ return null;
1325
+ }
1326
+ const type = typeof value;
1327
+ const asFunction = value;
1328
+ if (type === "function") {
1329
+ return _getValue(await asFunction());
1330
+ }
1331
+ if (isModelInstance2(value)) {
1332
+ return _getValue(await value.toObj());
1333
+ }
1334
+ const asDate = value;
1335
+ if (type === "object" && asDate.toISOString) {
1336
+ return _getValue(asDate.toISOString());
1337
+ }
1338
+ return value;
1339
+ };
1340
+ var toJsonAble = (keyToFunc) => () => {
1341
+ return Object.entries(keyToFunc).reduce(async (acc, [key, value]) => {
1342
+ const realAcc = await acc;
1343
+ const trueValue = await _getValue(await value);
1344
+ if (trueValue === void 0) {
1345
+ return realAcc;
1346
+ }
1347
+ return (0, import_merge6.default)(realAcc, { [key]: trueValue });
1348
+ }, Promise.resolve({}));
1349
+ };
1350
+
1351
+ // src/models.ts
1352
+ var _defaultOptions = () => ({
1353
+ instanceCreatedCallback: void 0
1354
+ });
1355
+ var _convertOptions = (options) => {
1356
+ const r = (0, import_merge7.default)({}, _defaultOptions(), options);
1357
+ return r;
1358
+ };
1359
+ var _addDescription = (schema, description) => {
1360
+ if (!description) {
1361
+ return schema;
1362
+ }
1363
+ if (typeof schema.openapi === "function") {
1364
+ return schema.openapi({ description });
1365
+ }
1366
+ return schema.meta ? schema.meta({ description }) : schema.describe(description);
1367
+ };
1368
+ var _createZod = (modelDefinition) => {
1369
+ if (modelDefinition.schema) {
1370
+ return _addDescription(modelDefinition.schema, modelDefinition.description);
1371
+ }
1372
+ const properties = Object.entries(modelDefinition.properties).reduce(
1373
+ (acc, [key, property2]) => {
1374
+ const asProp = property2;
1375
+ return (0, import_merge7.default)(acc, {
1376
+ [key]: asProp.getZod()
1377
+ });
1378
+ },
1379
+ {}
1380
+ );
1381
+ const obj = import_zod2.default.object(properties);
1382
+ return _addDescription(obj, modelDefinition.description);
1383
+ };
1384
+ var _toModelDefinition = (minimal) => {
1385
+ return {
1386
+ singularName: singularize(minimal.pluralName),
1387
+ displayName: toTitleCase(minimal.pluralName),
1388
+ description: "",
1389
+ primaryKeyName: "id",
1390
+ modelValidators: [],
1391
+ schema: _createZod(minimal),
1392
+ ...minimal
1393
+ };
1394
+ };
1395
+ var _validateModelDefinition = (modelDefinition) => {
1396
+ const primaryKeyName = modelDefinition.primaryKeyName || "id";
1397
+ const primaryKeyProperty = (
1398
+ // @ts-ignore
1399
+ modelDefinition.properties[primaryKeyName]
1400
+ );
1401
+ if (!primaryKeyProperty) {
1402
+ throw new Error(`Property missing for primaryKey named ${primaryKeyName}`);
1403
+ }
1404
+ if (!modelDefinition.pluralName) {
1405
+ throw new Error(`Must include pluralName for model.`);
1406
+ }
1407
+ if (!modelDefinition.namespace) {
1408
+ throw new Error(`Must include namespace for model.`);
1409
+ }
1410
+ };
1411
+ var Model = (minimalModelDefinitions, options) => {
1412
+ _validateModelDefinition(minimalModelDefinitions);
1413
+ let model = null;
1414
+ const theOptions = _convertOptions(options);
1415
+ const modelDefinition = _toModelDefinition(minimalModelDefinitions);
1416
+ const getPrimaryKeyName = () => modelDefinition.primaryKeyName;
1417
+ const getPrimaryKey = (loadedInternals) => {
1418
+ const property2 = loadedInternals.get[getPrimaryKeyName()];
1419
+ return property2();
1420
+ };
1421
+ const create = (instanceValues) => {
1422
+ let instance = null;
1423
+ const startingInternals = {
1424
+ get: {},
1425
+ validators: {},
1426
+ references: {}
1427
+ };
1428
+ const prop = Object.entries(
1429
+ modelDefinition.properties
1430
+ );
1431
+ const loadedInternals = prop.reduce(
1432
+ (acc, [key, property2]) => {
1433
+ const propertyGetter = memoizeSync(
1434
+ () => property2.createGetter(
1435
+ //@ts-ignore
1436
+ instanceValues[key],
1437
+ instanceValues,
1438
+ // NOTE: By the time it gets here, it has already been implemented.
1439
+ instance
1440
+ )()
1441
+ );
1442
+ const propertyValidator = property2.getValidator(propertyGetter);
1443
+ const fleshedOutInstanceProperties = {
1444
+ get: {
1445
+ [key]: () => propertyGetter()
1446
+ },
1447
+ validators: {
1448
+ [key]: propertyValidator
1449
+ }
1450
+ };
1451
+ const asReferenced = property2;
1452
+ const referencedProperty = asReferenced.getReferencedId ? {
1453
+ references: {
1454
+ [key]: () => asReferenced.getReferencedId(
1455
+ // @ts-ignore
1456
+ instanceValues[key]
1457
+ )
1458
+ }
1459
+ } : {};
1460
+ return (0, import_merge7.default)(
1461
+ acc,
1462
+ fleshedOutInstanceProperties,
1463
+ referencedProperty
1464
+ );
1465
+ },
1466
+ startingInternals
1467
+ );
1468
+ const getModel = () => model;
1469
+ const toObj = memoizeAsync(() => {
1470
+ return toJsonAble(loadedInternals.get)();
1471
+ });
1472
+ const validate = memoizeAsync((options2 = {}) => {
1473
+ return Promise.resolve().then(() => {
1474
+ return createModelValidator(
1475
+ loadedInternals.validators,
1476
+ modelDefinition.modelValidators
1477
+ )(instance, options2);
1478
+ });
1479
+ });
1480
+ const getReferences = () => loadedInternals.references;
1481
+ const getValidators = () => loadedInternals.validators;
1482
+ instance = {
1483
+ get: loadedInternals.get,
1484
+ getReferences,
1485
+ getValidators,
1486
+ getModel,
1487
+ toObj,
1488
+ getPrimaryKey: () => getPrimaryKey(loadedInternals),
1489
+ validate
1490
+ };
1491
+ if (theOptions.instanceCreatedCallback) {
1492
+ const toCall = Array.isArray(theOptions.instanceCreatedCallback) ? theOptions.instanceCreatedCallback : [theOptions.instanceCreatedCallback];
1493
+ toCall.map((func) => func(instance));
1494
+ }
1495
+ return instance;
1496
+ };
1497
+ const getApiInfo = memoizeSync(() => {
1498
+ return populateApiInformation(
1499
+ modelDefinition.pluralName,
1500
+ modelDefinition.namespace,
1501
+ modelDefinition.api
1502
+ );
1503
+ });
1504
+ model = {
1505
+ /**
1506
+ * Creates a model instance.
1507
+ */
1508
+ create,
1509
+ getName: () => getModelName(modelDefinition.namespace, modelDefinition.pluralName),
1510
+ getModelDefinition: memoizeSync(() => modelDefinition),
1511
+ getPrimaryKey,
1512
+ getApiInfo
1513
+ };
1514
+ return model;
1515
+ };
1516
+
1517
+ // src/errors.ts
1518
+ var ValidationError = class extends Error {
1519
+ constructor(modelName, keysToErrors) {
1520
+ super(`${modelName} did not pass validation`);
1521
+ this.name = "ValidationError";
1522
+ this.modelName = modelName;
1523
+ this.keysToErrors = keysToErrors;
1524
+ }
1525
+ };
1526
+
1527
+ // src/orm/models.ts
1528
+ var createOrm = ({
1529
+ datastoreAdapter,
1530
+ Model: Model2 = Model
1531
+ }) => {
1532
+ if (!datastoreAdapter) {
1533
+ throw new Error(`Must include a datastoreAdapter`);
1534
+ }
1535
+ const _retrievedObjToModel = (model) => (obj) => {
1536
+ return model.create(obj);
1537
+ };
1538
+ const fetcher = async (model, id) => {
1539
+ const x = retrieve(
1540
+ model,
1541
+ id
1542
+ );
1543
+ return x;
1544
+ };
1545
+ const retrieve = async (model, id) => {
1546
+ const obj = await datastoreAdapter.retrieve(model, id);
1547
+ if (!obj) {
1548
+ return void 0;
1549
+ }
1550
+ return _retrievedObjToModel(model)(obj);
1551
+ };
1552
+ const _defaultOptions2 = () => ({
1553
+ instanceCreatedCallback: void 0
1554
+ });
1555
+ const _convertOptions2 = (options) => {
1556
+ const r = (0, import_merge8.default)(
1557
+ {},
1558
+ _defaultOptions2(),
1559
+ options
1560
+ );
1561
+ return r;
1562
+ };
1563
+ const ThisModel = (modelDefinition, options) => {
1564
+ let model = null;
1565
+ const theOptions = _convertOptions2(options);
1566
+ const search = (ormQuery) => {
1567
+ return datastoreAdapter.search(model, ormQuery).then((result) => {
1568
+ const conversionFunc = _retrievedObjToModel(model);
1569
+ return {
1570
+ // @ts-ignore
1571
+ instances: result.instances.map(conversionFunc),
1572
+ page: result.page
1573
+ };
1574
+ });
1575
+ };
1576
+ const searchOne = (ormQuery) => {
1577
+ ormQuery = (0, import_merge8.default)(ormQuery, { take: 1 });
1578
+ return search(ormQuery).then(({ instances }) => {
1579
+ return instances[0];
1580
+ });
1581
+ };
1582
+ const bulkInsert = async (instances) => {
1583
+ if (datastoreAdapter.bulkInsert) {
1584
+ await datastoreAdapter.bulkInsert(model, instances);
1585
+ return void 0;
1586
+ }
1587
+ await (0, import_modern_async.asyncMap)(instances, (x) => x.save());
1588
+ return void 0;
1589
+ };
1590
+ const bulkDelete = async (keysOrInstances) => {
1591
+ const ids = typeof keysOrInstances[0] === "object" ? keysOrInstances.map(
1592
+ (x) => x.getPrimaryKey()
1593
+ ) : keysOrInstances;
1594
+ if (datastoreAdapter.bulkDelete) {
1595
+ await datastoreAdapter.bulkDelete(model, ids);
1596
+ return void 0;
1597
+ }
1598
+ await (0, import_modern_async.asyncMap)(ids, (id) => model.delete(id));
1599
+ return void 0;
1600
+ };
1601
+ const loadedRetrieve = (id) => {
1602
+ return retrieve(model, id);
1603
+ };
1604
+ const modelValidators = modelDefinition?.uniqueTogether ? (modelDefinition.modelValidators || []).concat(
1605
+ // @ts-ignore
1606
+ uniqueTogether(modelDefinition.uniqueTogether)
1607
+ ) : modelDefinition.modelValidators;
1608
+ const ormModelDefinition = (0, import_merge8.default)({}, modelDefinition, {
1609
+ modelValidators
1610
+ });
1611
+ const _updateLastModifiedIfExistsReturnNewObj = async (instance) => {
1612
+ const hasLastModified = Object.entries(
1613
+ instance.getModel().getModelDefinition().properties
1614
+ ).filter((propertyEntry) => {
1615
+ const property2 = propertyEntry[1];
1616
+ return Boolean("lastModifiedUpdateMethod" in property2);
1617
+ })[0];
1618
+ const doLastModified = async () => {
1619
+ const obj = await instance.toObj();
1620
+ const newInstance = model.create(
1621
+ // @ts-ignore
1622
+ (0, import_merge8.default)(obj, {
1623
+ [hasLastModified[0]]: (
1624
+ // @ts-ignore
1625
+ hasLastModified[1].lastModifiedUpdateMethod()
1626
+ )
1627
+ })
1628
+ );
1629
+ return newInstance;
1630
+ };
1631
+ return hasLastModified ? doLastModified() : instance;
1632
+ };
1633
+ const save = async (instance) => {
1634
+ return Promise.resolve().then(async () => {
1635
+ const newInstance = await _updateLastModifiedIfExistsReturnNewObj(instance);
1636
+ const invalid = await newInstance.validate();
1637
+ if (invalid) {
1638
+ throw new ValidationError(model.getName(), invalid);
1639
+ }
1640
+ const savedObj = await datastoreAdapter.save(newInstance);
1641
+ return _retrievedObjToModel(model)(savedObj);
1642
+ });
1643
+ };
1644
+ const createAndSave = async (data) => {
1645
+ if (datastoreAdapter.createAndSave) {
1646
+ const response = await datastoreAdapter.createAndSave(data);
1647
+ return _retrievedObjToModel(model)(response);
1648
+ }
1649
+ const instance = model.create(await data.toObj());
1650
+ return instance.save();
1651
+ };
1652
+ const deleteObj = (id) => {
1653
+ return Promise.resolve().then(async () => {
1654
+ await datastoreAdapter.delete(model, id);
1655
+ });
1656
+ };
1657
+ const _getSave = (instance) => {
1658
+ if (theOptions.save !== void 0) {
1659
+ return () => theOptions.save(save, instance);
1660
+ }
1661
+ return () => save(instance);
1662
+ };
1663
+ const _getDelete = (instance) => {
1664
+ if (theOptions.delete) {
1665
+ return () => theOptions.delete(deleteObj, instance);
1666
+ }
1667
+ return () => deleteObj(instance.getPrimaryKey());
1668
+ };
1669
+ const instanceCreatedCallback = (instance) => {
1670
+ instance.save = _getSave(instance);
1671
+ instance.delete = _getDelete(instance);
1672
+ if (theOptions.instanceCreatedCallback) {
1673
+ const callbacks = Array.isArray(theOptions.instanceCreatedCallback) ? theOptions.instanceCreatedCallback : [theOptions.instanceCreatedCallback];
1674
+ callbacks.forEach((x) => x(instance));
1675
+ }
1676
+ };
1677
+ const overridedOptions = (0, import_merge8.default)({}, theOptions, {
1678
+ instanceCreatedCallback: [instanceCreatedCallback]
1679
+ });
1680
+ const baseModel = Model2(ormModelDefinition, overridedOptions);
1681
+ const lowerLevelCreate = baseModel.create;
1682
+ const _convertModelInstance = (instance) => {
1683
+ return (0, import_merge8.default)(instance, {
1684
+ create,
1685
+ getModel: () => model,
1686
+ save: _getSave(instance),
1687
+ delete: _getDelete(instance)
1688
+ });
1689
+ };
1690
+ const create = (data) => {
1691
+ const result = lowerLevelCreate(data);
1692
+ return _convertModelInstance(result);
1693
+ };
1694
+ const _countRecursive = async (page = null) => {
1695
+ const results = await model.search(
1696
+ queryBuilder().pagination(page).compile()
1697
+ );
1698
+ const length1 = results.instances.length;
1699
+ if (results.page && results.page !== page) {
1700
+ const length2 = await _countRecursive(results.page);
1701
+ return length1 + length2;
1702
+ }
1703
+ return length1;
1704
+ };
1705
+ const count = async () => {
1706
+ if (datastoreAdapter.count) {
1707
+ return datastoreAdapter.count(model);
1708
+ }
1709
+ return _countRecursive();
1710
+ };
1711
+ model = (0, import_merge8.default)(baseModel, {
1712
+ create,
1713
+ save,
1714
+ delete: deleteObj,
1715
+ retrieve: loadedRetrieve,
1716
+ search,
1717
+ searchOne,
1718
+ createAndSave,
1719
+ bulkInsert,
1720
+ bulkDelete,
1721
+ count
1722
+ });
1723
+ return model;
1724
+ };
1725
+ return {
1726
+ Model: ThisModel,
1727
+ fetcher
1728
+ };
1729
+ };
1730
+ // Annotate the CommonJS export names for ESM import in node:
1731
+ 0 && (module.exports = {
1732
+ AllowableEqualitySymbols,
1733
+ DatastoreValueType,
1734
+ EqualitySymbol,
1735
+ ForeignKeyProperty,
1736
+ LastModifiedDateProperty,
1737
+ PrimaryKeyProperty,
1738
+ SortOrder,
1739
+ and,
1740
+ booleanQuery,
1741
+ buildOrmValidatorContext,
1742
+ createOrm,
1743
+ datesAfter,
1744
+ datesBefore,
1745
+ isALinkToken,
1746
+ isPropertyBasedQuery,
1747
+ numberQuery,
1748
+ or,
1749
+ ormPropertyConfig,
1750
+ pagination,
1751
+ properties,
1752
+ property,
1753
+ query,
1754
+ queryBuilder,
1755
+ sort,
1756
+ take,
1757
+ textQuery,
1758
+ threeitize,
1759
+ types,
1760
+ unique,
1761
+ uniqueTogether,
1762
+ validateOrmSearch,
1763
+ validation
1764
+ });
1765
+ //# sourceMappingURL=index.cjs.map