functional-models 3.0.6 → 3.0.7

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.
package/orm/types.d.ts ADDED
@@ -0,0 +1,551 @@
1
+ import { Arrayable, DataValue, Maybe, ModelInstance, ModelType, DataDescription, PrimaryKeyType, MinimalModelDefinition, PropertyConfig, ValidatorContext, ToObjectResult, ModelInstanceFetcher, ModelFactoryOptions } from '../types';
2
+ /**
3
+ * Equals symbols for doing database matching
4
+ */
5
+ declare enum EqualitySymbol {
6
+ eq = "=",
7
+ lt = "<",
8
+ lte = "<=",
9
+ gt = ">",
10
+ gte = ">="
11
+ }
12
+ /**
13
+ * The value types that map to database types.
14
+ */
15
+ declare enum DatastoreValueType {
16
+ string = "string",
17
+ number = "number",
18
+ date = "date",
19
+ object = "object",
20
+ boolean = "boolean"
21
+ }
22
+ /**
23
+ * A list of allowable equality symbols.
24
+ */
25
+ declare const AllowableEqualitySymbols: EqualitySymbol[];
26
+ /**
27
+ * A function that can save.
28
+ */
29
+ type SaveMethod<TModelExtensions extends object = object, TModelInstanceExtensions extends object = object> = <TData extends DataDescription>(
30
+ /**
31
+ * An instance to save
32
+ */
33
+ instance: ModelInstance<TData, TModelExtensions, TModelInstanceExtensions>) => Promise<OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions>>;
34
+ /**
35
+ * A method that can delete
36
+ */
37
+ type DeleteMethod<TModelExtensions extends object = object, TModelInstanceExtensions extends object = object> = <TData extends DataDescription>(instance: ModelInstance<TData, TModelExtensions, TModelInstanceExtensions>) => Promise<void>;
38
+ /**
39
+ * A function that allows overriding the save functionality for a specific model.
40
+ */
41
+ type SaveOverride<TModelExtensions extends object = object, TModelInstanceExtensions extends object = object> = <TData extends DataDescription>(existingSave: SaveMethod<TModelExtensions, TModelInstanceExtensions>, instance: ModelInstance<TData, TModelExtensions, TModelInstanceExtensions>) => Promise<OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions>>;
42
+ /**
43
+ * A function that allows overriding the delete functionality for a specific model.
44
+ */
45
+ type DeleteOverride<TModelExtensions extends object = object, TModelInstanceExtensions extends object = object> = <TData extends DataDescription>(existingDelete: DeleteMethod<TModelExtensions, TModelInstanceExtensions>, instance: ModelInstance<TData, TModelExtensions, TModelInstanceExtensions>) => Promise<void>;
46
+ /**
47
+ * A result of an ORM search.
48
+ * @interface
49
+ */
50
+ type OrmSearchResult<TData extends DataDescription, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object> = Readonly<{
51
+ /**
52
+ * A list of instances
53
+ */
54
+ instances: readonly OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions>[];
55
+ /**
56
+ * An optional page value. The exact structure is provided by the datastore itself.
57
+ */
58
+ page?: any;
59
+ }>;
60
+ /**
61
+ * ORM based ModelFactory extensions.
62
+ * @interface
63
+ */
64
+ type OrmModelFactoryOptionsExtensions<TModelExtensions extends object = object, TModelInstanceExtensions extends object = object> = Readonly<{
65
+ /**
66
+ * Optional: The save function to override.
67
+ */
68
+ save?: SaveOverride<TModelExtensions, TModelInstanceExtensions>;
69
+ /**
70
+ * Optional: The delete function to override.
71
+ */
72
+ delete?: DeleteOverride<TModelExtensions, TModelInstanceExtensions>;
73
+ }>;
74
+ /**
75
+ * Extensions to the Model type
76
+ * @interface
77
+ */
78
+ type OrmModelExtensions<TModelExtensions extends object = object, TModelInstanceExtensions extends object = object> = Readonly<{
79
+ /**
80
+ * Save the model
81
+ * @param instance - The instance to save.
82
+ */
83
+ save: <TData extends DataDescription>(instance: OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions>) => Promise<OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions>>;
84
+ /**
85
+ * Deletes an instance by its id.
86
+ * @param id - The id to delete
87
+ */
88
+ delete: (id: PrimaryKeyType) => Promise<void>;
89
+ /**
90
+ * Attempts to get an instance by its id
91
+ * @param primaryKey
92
+ */
93
+ retrieve: <TData extends DataDescription>(primaryKey: PrimaryKeyType) => Promise<Maybe<OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions>>>;
94
+ /**
95
+ * Searches instances by the provided search query
96
+ * @param query
97
+ */
98
+ search: <TData extends DataDescription>(query: OrmSearch) => Promise<OrmSearchResult<TData, OrmModel<TData, TModelExtensions, TModelInstanceExtensions>>>;
99
+ /**
100
+ * Searches for a single instance with the given query.
101
+ * @param query
102
+ */
103
+ searchOne: <TData extends DataDescription>(query: Omit<OrmSearch, 'take'>) => Promise<OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions> | undefined>;
104
+ /**
105
+ * Creates and saves an instance. An optimization in some databases
106
+ * @param query
107
+ */
108
+ createAndSave: <TData extends DataDescription>(data: OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions>) => Promise<OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions>>;
109
+ /**
110
+ * Inserts multiple objects at once. Can often see great optimizations in some databases.
111
+ * @param query
112
+ */
113
+ bulkInsert: <TData extends DataDescription>(instances: readonly OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions>[]) => Promise<void>;
114
+ /**
115
+ * Counts the number of models saved in the database.
116
+ */
117
+ count: () => Promise<number>;
118
+ }>;
119
+ /**
120
+ * Instance overrides that give it ORM functions.
121
+ * @interface
122
+ */
123
+ type OrmModelInstanceExtensions<TModelExtensions extends object = object, TModelInstanceExtensions extends object = object> = Readonly<{
124
+ /**
125
+ * Save this model.
126
+ */
127
+ save: <TData extends DataDescription>() => Promise<OrmModelInstance<TData, TModelExtensions, TModelInstanceExtensions>>;
128
+ /**
129
+ * Delete this model.
130
+ */
131
+ delete: () => Promise<void>;
132
+ }>;
133
+ /**
134
+ * ORM based configurations for a model.
135
+ * @interface
136
+ */
137
+ type OrmModelConfigurations = Readonly<{
138
+ /**
139
+ * Validator that there is only a single value in the datastore that has the properties given.
140
+ * Example:
141
+ * ["name", "text"]
142
+ * This will make sure that there can only be a single row in the database that has a unique combination of name and text.
143
+ */
144
+ uniqueTogether?: readonly string[];
145
+ }>;
146
+ /**
147
+ * A minimum orm model definition
148
+ * @interface
149
+ */
150
+ type MinimumOrmModelDefinition<TData extends DataDescription> = MinimalModelDefinition<TData> & OrmModelConfigurations;
151
+ /**
152
+ * A model factory that produces ORM based models.
153
+ *
154
+ */
155
+ type OrmModelFactory<TModelExtensions extends object = object, TModelInstanceExtensions extends object = object, TModelOptionsExtensions extends object = object> = <TData extends DataDescription>(
156
+ /**
157
+ * The model definition for the model
158
+ */
159
+ modelDef: MinimumOrmModelDefinition<TData>,
160
+ /**
161
+ * Additional options for this model.
162
+ */
163
+ options?: ModelFactoryOptions<TData, OrmModelFactoryOptionsExtensions<TModelExtensions, TModelInstanceExtensions> & TModelOptionsExtensions>) => OrmModel<TData, TModelExtensions, TModelInstanceExtensions>;
164
+ /**
165
+ * A search result from a datastore
166
+ * @interface
167
+ */
168
+ type DatastoreSearchResult<T extends DataDescription> = Readonly<{
169
+ /**
170
+ * An array of objects that represent the data from the datastore.
171
+ */
172
+ instances: readonly ToObjectResult<T>[];
173
+ /**
174
+ * Any pagination information.
175
+ */
176
+ page?: any;
177
+ }>;
178
+ /**
179
+ * A model that has ORM functions attached.
180
+ * @interface
181
+ */
182
+ type OrmModel<TData extends DataDescription, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object> = ModelType<TData, OrmModelExtensions<TModelExtensions, TModelInstanceExtensions>, OrmModelInstanceExtensions<TModelExtensions, TModelInstanceExtensions>>;
183
+ /**
184
+ * A Model Instance with ORM functions attached.
185
+ * @interface
186
+ */
187
+ type OrmModelInstance<TData extends DataDescription, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object> = ModelInstance<TData, OrmModelExtensions<TModelExtensions, TModelInstanceExtensions>, OrmModelInstanceExtensions<TModelExtensions, TModelInstanceExtensions>>;
188
+ /**
189
+ * An interface that describes a datastore. By implementing this interface, databases can be swapped.
190
+ * @interface
191
+ */
192
+ type DatastoreAdapter = Readonly<{
193
+ /**
194
+ * Saving a model.
195
+ * @param instance
196
+ */
197
+ save: <TData extends DataDescription, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(instance: ModelInstance<TData, TModelExtensions, TModelInstanceExtensions>) => Promise<ToObjectResult<TData>>;
198
+ /**
199
+ * Deleting an instance.
200
+ * @param model
201
+ * @param id
202
+ */
203
+ delete: <TData extends DataDescription, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(model: OrmModel<TData, TModelExtensions, TModelInstanceExtensions>, id: PrimaryKeyType) => Promise<void>;
204
+ /**
205
+ * Attempts to retrieves an instance.
206
+ * @param model
207
+ * @param primaryKey
208
+ */
209
+ retrieve: <TData extends DataDescription, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(model: OrmModel<TData, TModelExtensions, TModelInstanceExtensions>, primaryKey: PrimaryKeyType) => Promise<Maybe<ToObjectResult<TData>>>;
210
+ /**
211
+ * Searches for instances by a query.
212
+ * @param model
213
+ * @param query
214
+ */
215
+ search: <TData extends DataDescription, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(model: OrmModel<TData, TModelExtensions, TModelInstanceExtensions>, query: OrmSearch) => Promise<DatastoreSearchResult<TData>>;
216
+ /**
217
+ * Optional: An optimized bulkInsert function. (Highly recommended)
218
+ * @param model
219
+ * @param instances
220
+ */
221
+ bulkInsert?: <TData extends DataDescription, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(model: OrmModel<TData, TModelExtensions, TModelInstanceExtensions>, instances: readonly ModelInstance<TData, TModelExtensions, TModelInstanceExtensions>[]) => Promise<void>;
222
+ /**
223
+ * Optional: An optimized createAndSave function.
224
+ * @param instance
225
+ */
226
+ createAndSave?: <TData extends DataDescription, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(instance: ModelInstance<TData, TModelExtensions, TModelInstanceExtensions>) => Promise<ToObjectResult<TData>>;
227
+ /**
228
+ * Optional: An optimized counting function. Highly recommended.
229
+ * @param model
230
+ */
231
+ count?: <TData extends DataDescription, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(model: OrmModel<TData, TModelExtensions, TModelInstanceExtensions>) => Promise<number>;
232
+ }>;
233
+ /**
234
+ * A search that describes a property and its value.
235
+ * @interface
236
+ */
237
+ type PropertyQuery = Readonly<{
238
+ /**
239
+ * Distinguishes this as a property query.
240
+ */
241
+ type: 'property';
242
+ /**
243
+ * The property's key
244
+ */
245
+ key: string;
246
+ /**
247
+ * The value to search for.
248
+ */
249
+ value: any;
250
+ /**
251
+ * The type of database value.
252
+ */
253
+ valueType: DatastoreValueType;
254
+ /**
255
+ * How the value should be compared.
256
+ */
257
+ equalitySymbol: EqualitySymbol;
258
+ /**
259
+ * Options for additional matching.
260
+ */
261
+ options: {
262
+ /**
263
+ * Should this be a case sensitive search. (for text)
264
+ */
265
+ caseSensitive?: boolean;
266
+ /**
267
+ * Indicates that the value is a "startsWith" query.
268
+ */
269
+ startsWith?: boolean;
270
+ /**
271
+ * Indicates that the value is a "endsWith" query.
272
+ */
273
+ endsWith?: boolean;
274
+ };
275
+ }>;
276
+ /**
277
+ * A search that looks at dated objects after the given date.
278
+ * @interface
279
+ */
280
+ type DatesAfterQuery = Readonly<{
281
+ /**
282
+ * Distinguishes this query
283
+ */
284
+ type: 'datesAfter';
285
+ /**
286
+ * The property's key
287
+ */
288
+ key: string;
289
+ /**
290
+ * The date value being examined.
291
+ */
292
+ date: string;
293
+ /**
294
+ * The database type.
295
+ */
296
+ valueType: DatastoreValueType;
297
+ /**
298
+ * Options for additional searching
299
+ */
300
+ options: {
301
+ /**
302
+ * Should this search be equalsTo as well as after?
303
+ */
304
+ equalToAndAfter: boolean;
305
+ };
306
+ }>;
307
+ /**
308
+ * A search query that looks at dates before the given date.
309
+ * @interface
310
+ */
311
+ type DatesBeforeQuery = Readonly<{
312
+ /**
313
+ * Distinguishes this query
314
+ */
315
+ type: 'datesBefore';
316
+ /**
317
+ * The property's key.
318
+ */
319
+ key: string;
320
+ /**
321
+ * The date value being examined.
322
+ */
323
+ date: string;
324
+ /**
325
+ * The database value type.
326
+ */
327
+ valueType: DatastoreValueType;
328
+ /**
329
+ * Options for additional searching
330
+ */
331
+ options: {
332
+ /**
333
+ * Should this search be equalsTo as well as before?
334
+ */
335
+ equalToAndBefore: boolean;
336
+ };
337
+ }>;
338
+ /**
339
+ * Additional configurations for ORM based properties.
340
+ * @interface
341
+ */
342
+ type OrmPropertyConfig<T extends Arrayable<DataValue>> = PropertyConfig<T> & Readonly<{
343
+ /**
344
+ * Validator: Checks to make sure that there is only one instance in a datastore that has this property's value.
345
+ * NOTE: The value is a property KEY. Not true or false.
346
+ */
347
+ unique?: string;
348
+ }>;
349
+ /**
350
+ * Additional context that is provided for ORM based instance.
351
+ * @interface
352
+ */
353
+ type OrmValidatorContext = Readonly<{
354
+ /**
355
+ * IMPORTANT: Sometimes you do not want to do any ORM based validation because of speed.
356
+ * This disables any orm based validation, and only runs non-orm validation.
357
+ */
358
+ noOrmValidation?: boolean;
359
+ }> & ValidatorContext;
360
+ /**
361
+ * Options for a property query.
362
+ */
363
+ type PropertyOptions = {
364
+ /**
365
+ * Is this a case sensitive search?
366
+ */
367
+ caseSensitive?: boolean;
368
+ /**
369
+ * Is the value a startsWith query?
370
+ */
371
+ startsWith?: boolean;
372
+ /**
373
+ * Is the value a endsWith query?
374
+ */
375
+ endsWith?: boolean;
376
+ /**
377
+ * The type of value
378
+ */
379
+ type?: DatastoreValueType;
380
+ /**
381
+ * An equality symbol.
382
+ */
383
+ equalitySymbol?: EqualitySymbol;
384
+ };
385
+ /**
386
+ * An object that has both an Orm Model Factory (that can make Orm Models) as well as a loaded fetcher
387
+ * that can retrieve referenced models as needed. See {@see "functional-models.ModelReference"}
388
+ * @interface
389
+ */
390
+ type Orm = {
391
+ /**
392
+ * A model factory that can produce {@link OrmModel}
393
+ */
394
+ Model: OrmModelFactory;
395
+ /**
396
+ * A fetcher for use with Model References
397
+ */
398
+ fetcher: ModelInstanceFetcher<OrmModelExtensions, OrmModelInstanceExtensions>;
399
+ };
400
+ /**
401
+ * The sort order.
402
+ */
403
+ declare enum SortOrder {
404
+ asc = "asc",
405
+ dsc = "dsc"
406
+ }
407
+ /**
408
+ * The number of instances to receive back from a query.
409
+ */
410
+ type MaxMatchStatement = number;
411
+ /**
412
+ * Defines how a sort should happen. Which column and what order.
413
+ * @interface
414
+ */
415
+ type SortStatement = {
416
+ /**
417
+ * The property's key/name. Also could be a "column"
418
+ */
419
+ key: string;
420
+ /**
421
+ * Ascending or Descending sort.
422
+ */
423
+ order: SortOrder;
424
+ };
425
+ /**
426
+ * Pagination can be anything.
427
+ */
428
+ type PaginationQuery = any;
429
+ /**
430
+ * A query to a search function.
431
+ * @interface
432
+ */
433
+ type OrmSearch = {
434
+ /**
435
+ * Optional: A number of max records to return.
436
+ */
437
+ take?: MaxMatchStatement;
438
+ /**
439
+ * Optional: Sorting.
440
+ */
441
+ sort?: SortStatement;
442
+ /**
443
+ * Optional: Pagination information
444
+ */
445
+ page?: PaginationQuery;
446
+ /**
447
+ * Optional: Querying tokens.
448
+ */
449
+ query: readonly QueryTokens[];
450
+ };
451
+ /**
452
+ * Statements that make up the meat of QueryTokens
453
+ */
454
+ type Query = PropertyQuery | DatesAfterQuery | DatesBeforeQuery;
455
+ /**
456
+ * A token type that links two queries together.
457
+ */
458
+ type BooleanQuery = 'AND' | 'OR';
459
+ /**
460
+ * A generic structure of querys.
461
+ */
462
+ type QueryTokens = readonly QueryTokens[][] | readonly QueryTokens[] | BooleanQuery | Query;
463
+ /**
464
+ * Builder functions that are not property related.
465
+ * @interface
466
+ */
467
+ type NonQueryBuilder = Readonly<{
468
+ /**
469
+ * Creates a pagination.
470
+ * @param value - Can be anything
471
+ */
472
+ pagination: (value: any) => BuilderV2Link & InnerBuilderV2;
473
+ /**
474
+ * Creates a sort.
475
+ * @param key - The key to sort on
476
+ * @param sortOrder - The order to sort by. Defaults to ascending.
477
+ */
478
+ sort: (key: string, sortOrder?: SortOrder) => BuilderV2Link & InnerBuilderV2;
479
+ /**
480
+ * Maximum number of elements to return.
481
+ * @param count - The count
482
+ */
483
+ take: (count: number) => BuilderV2Link & InnerBuilderV2;
484
+ /**
485
+ * Compiles the builder into a search query.
486
+ */
487
+ compile: () => OrmSearch;
488
+ }>;
489
+ /**
490
+ * An in between or ending type to a builder creating a SearchQuery
491
+ * @interface
492
+ */
493
+ type BuilderV2Link = NonQueryBuilder & Readonly<{
494
+ /**
495
+ * Links together two or more {@link Query} or complex queries.
496
+ */
497
+ and: () => QueryBuilder;
498
+ /**
499
+ * Links together two or more {@link Query} or complex queries.
500
+ */
501
+ or: () => QueryBuilder;
502
+ }>;
503
+ /**
504
+ * A function that can either take a builder or raw QueryTokens[] and create a sub-query.
505
+ * @param builder - Can be either a BuilderV2 or a hand written Query
506
+ **/
507
+ type SubBuilderFunction = (builder: QueryBuilder) => Omit<OrmSearch, 'take' | 'sort' | 'page'> | (QueryBuilder | BuilderV2Link);
508
+ /**
509
+ * A search builder is a structured way to create a complex query.
510
+ * @interface
511
+ */
512
+ type QueryBuilder = InnerBuilderV2 & NonQueryBuilder;
513
+ /**
514
+ * A builder for version 3.0 search queries.
515
+ * @interface
516
+ */
517
+ type InnerBuilderV2 = {
518
+ /**
519
+ * Creates a query that has nested property queries.
520
+ * @param subBuilderFunc - A function that can return a Builder
521
+ */
522
+ complex: (subBuilderFunc: SubBuilderFunction) => BuilderV2Link;
523
+ /**
524
+ * Searches for elements that are after the given date.
525
+ * @param key - The property name/key to use.
526
+ * @param jsDate - The date to search.
527
+ * @param options - Additional options.
528
+ */
529
+ datesAfter: (key: string, jsDate: Date | string, options: {
530
+ valueType?: DatastoreValueType;
531
+ equalToAndAfter?: boolean;
532
+ } | undefined) => BuilderV2Link;
533
+ /**
534
+ * Searches for elements that are before the given date.
535
+ * @param key - The property name/key to use.
536
+ * @param jsDate - The date to search.
537
+ * @param options - Additional options.
538
+ */
539
+ datesBefore: (key: string, jsDate: Date | string, options: {
540
+ valueType?: DatastoreValueType;
541
+ equalToAndBefore?: boolean;
542
+ } | undefined) => BuilderV2Link;
543
+ /**
544
+ * Search a value
545
+ * @param key - The property name/key to use.
546
+ * @param value - The value to match.
547
+ * @param options - Additional options.
548
+ */
549
+ property: (key: string, value: any, options?: Partial<PropertyOptions>) => BuilderV2Link;
550
+ };
551
+ export { PropertyQuery, SortStatement, DatesAfterQuery, DatesBeforeQuery, PaginationQuery, MaxMatchStatement, OrmModel, OrmModelInstance, DatastoreAdapter, OrmModelFactory, SaveOverride, DeleteOverride, OrmPropertyConfig, DatastoreSearchResult, OrmValidatorContext, OrmSearchResult, EqualitySymbol, DatastoreValueType, AllowableEqualitySymbols, PropertyOptions, Orm, OrmModelExtensions, OrmModelInstanceExtensions, OrmModelFactoryOptionsExtensions, MinimumOrmModelDefinition, QueryBuilder, BuilderV2Link, SubBuilderFunction, OrmSearch, Query, BooleanQuery, QueryTokens, InnerBuilderV2, SortOrder, };
package/orm/types.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SortOrder = exports.AllowableEqualitySymbols = exports.DatastoreValueType = exports.EqualitySymbol = void 0;
4
+ /**
5
+ * Equals symbols for doing database matching
6
+ */
7
+ var EqualitySymbol;
8
+ (function (EqualitySymbol) {
9
+ // Equals
10
+ EqualitySymbol["eq"] = "=";
11
+ // Less than
12
+ EqualitySymbol["lt"] = "<";
13
+ // Equal to or less than
14
+ EqualitySymbol["lte"] = "<=";
15
+ // Greater than
16
+ EqualitySymbol["gt"] = ">";
17
+ // Equal to or greater than
18
+ EqualitySymbol["gte"] = ">=";
19
+ })(EqualitySymbol || (exports.EqualitySymbol = EqualitySymbol = {}));
20
+ /**
21
+ * The value types that map to database types.
22
+ */
23
+ var DatastoreValueType;
24
+ (function (DatastoreValueType) {
25
+ DatastoreValueType["string"] = "string";
26
+ DatastoreValueType["number"] = "number";
27
+ DatastoreValueType["date"] = "date";
28
+ DatastoreValueType["object"] = "object";
29
+ DatastoreValueType["boolean"] = "boolean";
30
+ })(DatastoreValueType || (exports.DatastoreValueType = DatastoreValueType = {}));
31
+ /**
32
+ * A list of allowable equality symbols.
33
+ */
34
+ const AllowableEqualitySymbols = Object.values(EqualitySymbol);
35
+ exports.AllowableEqualitySymbols = AllowableEqualitySymbols;
36
+ /**
37
+ * The sort order.
38
+ */
39
+ var SortOrder;
40
+ (function (SortOrder) {
41
+ SortOrder["asc"] = "asc";
42
+ SortOrder["dsc"] = "dsc";
43
+ })(SortOrder || (exports.SortOrder = SortOrder = {}));
44
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/orm/types.ts"],"names":[],"mappings":";;;AAgBA;;GAEG;AACH,IAAK,cAWJ;AAXD,WAAK,cAAc;IACjB,SAAS;IACT,0BAAQ,CAAA;IACR,YAAY;IACZ,0BAAQ,CAAA;IACR,wBAAwB;IACxB,4BAAU,CAAA;IACV,eAAe;IACf,0BAAQ,CAAA;IACR,2BAA2B;IAC3B,4BAAU,CAAA;AACZ,CAAC,EAXI,cAAc,8BAAd,cAAc,QAWlB;AAED;;GAEG;AACH,IAAK,kBAMJ;AAND,WAAK,kBAAkB;IACrB,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,mCAAa,CAAA;IACb,uCAAiB,CAAA;IACjB,yCAAmB,CAAA;AACrB,CAAC,EANI,kBAAkB,kCAAlB,kBAAkB,QAMtB;AAED;;GAEG;AACH,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;AAqvB5D,4DAAwB;AAxM1B;;GAEG;AACH,IAAK,SAGJ;AAHD,WAAK,SAAS;IACZ,wBAAW,CAAA;IACX,wBAAW,CAAA;AACb,CAAC,EAHI,SAAS,yBAAT,SAAS,QAGb"}
@@ -0,0 +1,21 @@
1
+ import { PropertyValidatorComponentAsync, DataDescription, ModelValidatorComponent } from '../types';
2
+ import { OrmValidatorContext, OrmModelExtensions, OrmModelInstanceExtensions } from './types';
3
+ /**
4
+ * A validator that ensures that there is only one instance stored, that has a unique combination of values.
5
+ * @param propertyKeyArray - An array of property names that create the unique match.
6
+ */
7
+ declare const uniqueTogether: <T extends DataDescription>(propertyKeyArray: readonly string[]) => ModelValidatorComponent<T, OrmModelExtensions, OrmModelInstanceExtensions>;
8
+ /**
9
+ * Validates that a stored instance is the only one that has a value for a specific property.
10
+ * This only validates before the instance goes into the datastore.
11
+ * @param propertyKey - The property key to check.
12
+ */
13
+ declare const unique: <T extends DataDescription>(propertyKey: string) => PropertyValidatorComponentAsync<T, OrmModelExtensions, OrmModelInstanceExtensions>;
14
+ /**
15
+ * Creates a base orm context.
16
+ * @param noOrmValidation - Determines if the validation process should ignore any ORM related validation. (If you don't want to do a database query for a specific validation).
17
+ */
18
+ declare const buildOrmValidatorContext: ({ noOrmValidation, }: {
19
+ noOrmValidation?: boolean | undefined;
20
+ }) => OrmValidatorContext;
21
+ export { unique, uniqueTogether, buildOrmValidatorContext };