@bedrockio/model 0.7.6 → 0.8.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.
package/src/search.js CHANGED
@@ -1,9 +1,16 @@
1
1
  import yd from '@bedrockio/yada';
2
2
  import logger from '@bedrockio/logger';
3
3
  import mongoose from 'mongoose';
4
- import { get, pick, isEmpty, escapeRegExp, isPlainObject } from 'lodash';
4
+ import { pick, isEmpty, escapeRegExp, isPlainObject } from 'lodash';
5
+
6
+ import {
7
+ getField,
8
+ isArrayField,
9
+ isDateField,
10
+ isNumberField,
11
+ resolveRefPath,
12
+ } from './utils';
5
13
 
6
- import { isArrayField, isDateField, isNumberField, getField } from './utils';
7
14
  import { SEARCH_DEFAULTS } from './const';
8
15
  import { OBJECT_ID_SCHEMA } from './validation';
9
16
  import { debug } from './env';
@@ -11,14 +18,11 @@ import { mergeQuery, wrapQuery } from './query';
11
18
 
12
19
  import warn from './warn';
13
20
 
14
- const { SchemaTypes } = mongoose;
15
21
  const { ObjectId } = mongoose.Types;
16
22
 
17
23
  export function applySearch(schema, definition) {
18
24
  validateDefinition(definition);
19
25
  validateSearchFields(schema, definition);
20
- applySearchCache(schema, definition);
21
- applySearchSync(schema, definition);
22
26
 
23
27
  const { query: searchQuery, fields: searchFields } = definition.search || {};
24
28
 
@@ -317,61 +321,6 @@ function parseRegexQuery(str) {
317
321
 
318
322
  // Search field caching
319
323
 
320
- function applySearchCache(schema, definition) {
321
- if (!definition.search?.cache) {
322
- return;
323
- }
324
-
325
- createCacheFields(schema, definition);
326
- applyCacheHook(schema, definition);
327
-
328
- schema.static(
329
- 'syncCacheFields',
330
- async function syncCacheFields(options = {}) {
331
- assertIncludeModule(this);
332
-
333
- const { force } = options;
334
- const { cache = {} } = definition.search || {};
335
-
336
- const paths = getCachePaths(definition);
337
-
338
- const cachedFields = Object.keys(cache);
339
-
340
- if (!cachedFields.length) {
341
- throw new Error('No search fields to sync.');
342
- }
343
-
344
- const query = {};
345
-
346
- if (!force) {
347
- const $or = Object.keys(cache).map((cachedField) => {
348
- return {
349
- [cachedField]: null,
350
- };
351
- });
352
- query.$or = $or;
353
- }
354
-
355
- const docs = await this.find(query).include(paths);
356
-
357
- const ops = docs.map((doc) => {
358
- return {
359
- updateOne: {
360
- filter: {
361
- _id: doc._id,
362
- },
363
- update: {
364
- $set: getUpdates(doc, paths, definition),
365
- },
366
- },
367
- };
368
- });
369
-
370
- return await this.bulkWrite(ops);
371
- }
372
- );
373
- }
374
-
375
324
  function validateSearchFields(schema, definition) {
376
325
  const { fields } = definition.search || {};
377
326
 
@@ -386,126 +335,11 @@ function validateSearchFields(schema, definition) {
386
335
  }
387
336
  }
388
337
 
389
- function createCacheFields(schema, definition) {
390
- for (let [cachedField, def] of Object.entries(definition.search.cache)) {
391
- // Fall back to string type for virtuals or not defined.
392
- const { type = 'String', path, ...rest } = def;
393
-
394
- schema.add({
395
- [cachedField]: type,
396
- });
397
- schema.obj[cachedField] = {
398
- type,
399
- ...rest,
400
- };
401
- }
402
- }
403
-
404
- function applyCacheHook(schema, definition) {
405
- schema.pre('save', async function () {
406
- assertIncludeModule(this.constructor);
407
- assertAssignModule(this.constructor);
408
-
409
- const doc = this;
410
- const paths = getCachePaths(definition, (cachedField, def) => {
411
- if (def.lazy) {
412
- return !get(doc, cachedField);
413
- } else {
414
- return true;
415
- }
416
- });
417
-
418
- await this.include(paths);
419
- this.assign(getUpdates(this, paths, definition));
420
- });
421
- }
422
-
423
- // Search field syncing
424
-
425
- function applySearchSync(schema, definition) {
426
- if (!definition.search?.sync) {
427
- return;
428
- }
429
-
430
- schema.post('save', async function postSave() {
431
- for (let entry of definition.search.sync) {
432
- const { ref, path } = entry;
433
- const Model = mongoose.models[ref];
434
- const docs = await Model.find({
435
- [path]: this.id,
436
- });
437
-
438
- await Promise.all(
439
- docs.map(async (doc) => {
440
- await doc.save();
441
- })
442
- );
443
- }
444
- });
445
- }
446
-
447
338
  // Utils
448
339
 
449
340
  function isForeignField(schema, path) {
450
341
  if (!path.includes('.')) {
451
342
  return false;
452
343
  }
453
- return !!getRefField(schema, path);
454
- }
455
-
456
- function getRefField(schema, path) {
457
- const split = path.split('.');
458
- for (let i = 1; i < split.length; i++) {
459
- const base = split.slice(0, i);
460
- const rest = split.slice(i);
461
- const type = schema.path(base.join('.'));
462
- if (type instanceof SchemaTypes.ObjectId) {
463
- return {
464
- type,
465
- base,
466
- rest,
467
- };
468
- }
469
- }
470
- }
471
-
472
- function getUpdates(doc, paths, definition) {
473
- const updates = {};
474
-
475
- const entries = Object.entries(definition.search.cache).filter((entry) => {
476
- return paths.includes(entry[1].path);
477
- });
478
- for (let [cachedField, def] of entries) {
479
- // doc.get will not return virtuals (even with specified options),
480
- // so use lodash to ensure they are included here.
481
- // https://mongoosejs.com/docs/api/document.html#Document.prototype.get()
482
- updates[cachedField] = get(doc, def.path);
483
- }
484
- return updates;
485
- }
486
-
487
- function getCachePaths(definition, filter) {
488
- filter ||= () => true;
489
- const { cache } = definition.search || {};
490
- return Object.entries(cache)
491
- .filter((entry) => {
492
- return filter(...entry);
493
- })
494
- .map((entry) => {
495
- return entry[1].path;
496
- });
497
- }
498
-
499
- // Assertions
500
-
501
- function assertIncludeModule(Model) {
502
- if (!Model.schema.methods.include) {
503
- throw new Error('Include module is required for cached search fields.');
504
- }
505
- }
506
-
507
- function assertAssignModule(Model) {
508
- if (!Model.schema.methods.assign) {
509
- throw new Error('Assign module is required for cached search fields.');
510
- }
344
+ return !!resolveRefPath(schema, path);
511
345
  }
package/src/slug.js CHANGED
@@ -26,20 +26,22 @@ export function applySlug(schema) {
26
26
  );
27
27
  }
28
28
 
29
- function find(Model, str, args, query) {
29
+ function find(Model, str, args, deleted) {
30
30
  const isObjectId = str.length === 24 && ObjectId.isValid(str);
31
31
  // There is a non-zero chance of a slug colliding with an ObjectId but
32
32
  // is exceedingly rare (run of exactly 24 [a-f0-9] chars together
33
33
  // without a hyphen) so this should be acceptable.
34
- if (!query && isObjectId) {
35
- return Model.findById(str, ...args);
34
+ const query = {};
35
+ if (isObjectId) {
36
+ query._id = str;
36
37
  } else {
37
- query = { ...query };
38
- if (isObjectId) {
39
- query._id = str;
40
- } else {
41
- query.slug = str;
42
- }
43
- return Model.findOne(query, ...args);
38
+ query.slug = str;
44
39
  }
40
+ return Model.findOne(
41
+ {
42
+ ...deleted,
43
+ ...query,
44
+ },
45
+ ...args
46
+ );
45
47
  }
package/src/utils.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import mongoose from 'mongoose';
2
2
 
3
+ const { SchemaTypes } = mongoose;
4
+
3
5
  // Mongoose provides an "equals" method on both documents and
4
6
  // ObjectIds, however it does not provide a static method to
5
7
  // compare two unknown values that may be either, so provide
@@ -86,6 +88,31 @@ export function getField(obj, path) {
86
88
  return field || {};
87
89
  }
88
90
 
91
+ // Finds a reference field in a schema and splits
92
+ // the provided path into the local and foreign
93
+ // components of the full path.
94
+ export function resolveRefPath(schema, path) {
95
+ const split = path.split('.');
96
+ for (let i = 1; i < split.length; i++) {
97
+ const base = split.slice(0, i);
98
+ const rest = split.slice(i);
99
+
100
+ let type = schema.path(base.join('.'));
101
+ if (type instanceof SchemaTypes.Array) {
102
+ type = type.caster;
103
+ }
104
+
105
+ if (type instanceof SchemaTypes.ObjectId) {
106
+ const { ref } = type.options;
107
+ return {
108
+ ref,
109
+ local: base.join('.'),
110
+ foreign: rest.join('.'),
111
+ };
112
+ }
113
+ }
114
+ }
115
+
89
116
  // The same as getField but traverses into the final field
90
117
  // as well. In the above example this will return:
91
118
  // { type: 'Number' }, given "product.inventory"
package/src/validation.js CHANGED
@@ -19,7 +19,7 @@ const DATE_TAGS = {
19
19
  export const OBJECT_ID_SCHEMA = yd
20
20
  .string()
21
21
  .mongo()
22
- .message('{field} must be an id.')
22
+ .message('Must be an id.')
23
23
  .tag({
24
24
  'x-schema': 'ObjectId',
25
25
  'x-description':
@@ -40,7 +40,7 @@ const REFERENCE_SCHEMA = yd
40
40
  return obj.id;
41
41
  })
42
42
  )
43
- .message('{field} must be an id or object containing "id" field.')
43
+ .message('Must be an id or object containing an "id" field.')
44
44
  .tag({
45
45
  'x-schema': 'Reference',
46
46
  'x-description': `
@@ -0,0 +1,2 @@
1
+ export function applyCache(schema: any, definition: any): void;
2
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.js"],"names":[],"mappings":"AASA,+DAUC"}
package/types/const.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export namespace SEARCH_DEFAULTS {
2
- const limit: number;
2
+ let limit: number;
3
3
  namespace sort {
4
- const field: string;
5
- const order: string;
4
+ let field: string;
5
+ let order: string;
6
6
  }
7
7
  }
8
8
  export const POPULATE_MAX_DEPTH: 5;
@@ -1 +1 @@
1
- {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.js"],"names":[],"mappings":";;;;;;;AAQA,mCAAoC"}
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.js"],"names":[],"mappings":";;;;;;;AAQA,iCAAkC,CAAC,CAAC"}
@@ -3,28 +3,28 @@ export function checkSelects(doc: any, ret: any): void;
3
3
  export function getParams(modelName: any, arg: any): any;
4
4
  export function getDocumentParams(doc: any, arg: any, options?: {}): any;
5
5
  export const INCLUDE_FIELD_SCHEMA: {
6
- setup: any;
7
- getFields: any;
8
- append(arg: import("@bedrockio/yada/types/object").SchemaMap | import("@bedrockio/yada/types/Schema").default): any;
9
- pick(...names?: string[]): any;
10
- omit(...names?: string[]): any;
11
- format(name: any, fn: any): import("@bedrockio/yada/types/TypeSchema").default;
6
+ setup(): void;
7
+ getFields(): any;
8
+ append(arg: import("@bedrockio/yada/types/object").SchemaMap | import("@bedrockio/yada/types/Schema").default): /*elided*/ any;
9
+ pick(...names?: string[]): /*elided*/ any;
10
+ omit(...names?: string[]): /*elided*/ any;
11
+ format(name: any, fn: any): /*elided*/ any;
12
12
  toString(): any;
13
13
  assertions: any[];
14
14
  meta: {};
15
- required(): any;
16
- default(arg: any): any;
17
- custom(fn: Function): any;
18
- strip(strip: any): any;
19
- allow(...set: any[]): any;
20
- reject(...set: any[]): any;
21
- nullable(): any;
22
- message(message: any): any;
23
- tag(tags: any): any;
24
- description(description: any): any;
25
- options(options: any): any;
15
+ required(): /*elided*/ any;
16
+ default(arg: any): /*elided*/ any;
17
+ custom(fn: Function): /*elided*/ any;
18
+ strip(strip: any): /*elided*/ any;
19
+ allow(...set: any[]): /*elided*/ any;
20
+ reject(...set: any[]): /*elided*/ any;
21
+ nullable(): /*elided*/ any;
22
+ message(message: any): /*elided*/ any;
23
+ tag(tags: any): /*elided*/ any;
24
+ description(description: any): /*elided*/ any;
25
+ options(options: any): /*elided*/ any;
26
26
  validate(value: any, options?: {}): Promise<any>;
27
- clone(meta: any): any;
27
+ clone(meta: any): /*elided*/ any;
28
28
  toOpenApi(extra: any): any;
29
29
  getAnyType(): {
30
30
  type: string[];
@@ -39,20 +39,12 @@ export const INCLUDE_FIELD_SCHEMA: {
39
39
  };
40
40
  expandExtra(extra?: {}): {};
41
41
  inspect(): string;
42
- assertEnum(set: any, allow: any): any;
43
- assert(type: any, fn: any): any;
42
+ assertEnum(set: any, allow: any): /*elided*/ any;
43
+ assert(type: any, fn: any): /*elided*/ any;
44
44
  pushAssertion(assertion: any): void;
45
- transform(fn: any): any;
45
+ transform(fn: any): /*elided*/ any;
46
46
  getSortIndex(type: any): number;
47
47
  runAssertion(assertion: any, value: any, options?: {}): Promise<any>;
48
- enumToOpenApi(): {
49
- type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
50
- enum: any;
51
- oneOf?: undefined;
52
- } | {
53
- oneOf: any[];
54
- type?: undefined;
55
- enum?: undefined;
56
- };
48
+ enumToOpenApi(): any;
57
49
  };
58
50
  //# sourceMappingURL=include.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"include.d.ts","sourceRoot":"","sources":["../src/include.js"],"names":[],"mappings":"AA2BA,gDAuEC;AAMD,uDA4BC;AAGD,yDAIC;AAGD,yEAUC;AApID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKG"}
1
+ {"version":3,"file":"include.d.ts","sourceRoot":"","sources":["../src/include.js"],"names":[],"mappings":"AA2BA,gDAuEC;AAMD,uDA4BC;AAGD,yDAIC;AAaD,yEAUC;AA9ID;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA+CK,CAAC;;;;;;;;;;;;;;;;EA1CH"}
package/types/load.d.ts CHANGED
@@ -11,5 +11,5 @@ export function loadModel(definition: object, name: string): any;
11
11
  * @param {string} dirPath
12
12
  */
13
13
  export function loadModelDir(dirPath: string): mongoose.Models;
14
- import mongoose from "mongoose";
14
+ import mongoose from 'mongoose';
15
15
  //# sourceMappingURL=load.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,sCAJW,MAAM,QACN,MAAM,OAahB;AAED;;;;GAIG;AACH,sCAFW,MAAM,mBAkBhB"}
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,sCAJW,MAAM,QACN,MAAM,OAahB;AAED;;;;GAIG;AACH,sCAFW,MAAM,mBAkBhB;qBA5CoB,UAAU"}
package/types/schema.d.ts CHANGED
@@ -12,7 +12,7 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
12
12
  autoCreate?: boolean;
13
13
  bufferCommands?: boolean;
14
14
  bufferTimeoutMS?: number;
15
- capped?: number | boolean | {
15
+ capped?: boolean | number | {
16
16
  size?: number;
17
17
  max?: number;
18
18
  autoIndexId?: boolean;
@@ -21,7 +21,7 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
21
21
  collectionOptions?: mongoose.mongo.CreateCollectionOptions;
22
22
  timeseries?: mongoose.mongo.TimeSeriesCollectionOptions;
23
23
  expireAfterSeconds?: number;
24
- expires?: string | number;
24
+ expires?: number | string;
25
25
  collection?: string;
26
26
  discriminatorKey?: string;
27
27
  excludeIndexes?: boolean;
@@ -34,9 +34,9 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
34
34
  readConcern?: {
35
35
  level: "local" | "available" | "majority" | "snapshot" | "linearizable";
36
36
  };
37
- writeConcern?: mongoose.mongo.WriteConcern;
37
+ writeConcern?: mongoose.WriteConcern;
38
38
  safe?: boolean | {
39
- w?: string | number;
39
+ w?: number | string;
40
40
  wtimeout?: number;
41
41
  j?: boolean;
42
42
  };
@@ -72,5 +72,5 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
72
72
  overwriteModels?: boolean;
73
73
  }, any, any>;
74
74
  export function normalizeAttributes(arg: any, path?: any[]): any;
75
- import mongoose from "mongoose";
75
+ import mongoose from 'mongoose';
76
76
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.js"],"names":[],"mappings":"AAsBA;;;;;;;GAOG;AACH,yCAJW,MAAM,YACN,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAyChC;AAED,iEAsBC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.js"],"names":[],"mappings":"AAuBA;;;;;;;GAOG;AACH,yCAJW,MAAM,YACN,QAAQ,CAAC,aAAa;;;;;;;YA8C3B,CAAC;WACH,CAAC;mBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;SA8G3B,CAAC;gBAEwB,CAAC;SAChB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAtHV;AAED,iEAsBC;qBA9FoB,UAAU"}
package/types/search.d.ts CHANGED
@@ -1,27 +1,27 @@
1
1
  export function applySearch(schema: any, definition: any): void;
2
2
  export function searchValidation(options?: {}): {
3
- setup: any;
4
- getFields: any;
5
- append(arg: import("@bedrockio/yada/types/object").SchemaMap | import("@bedrockio/yada/types/Schema").default): any;
6
- pick(...names?: string[]): any;
7
- omit(...names?: string[]): any;
8
- format(name: any, fn: any): import("@bedrockio/yada/types/TypeSchema").default;
3
+ setup(): void;
4
+ getFields(): any;
5
+ append(arg: import("@bedrockio/yada/types/object").SchemaMap | import("@bedrockio/yada/types/Schema").default): /*elided*/ any;
6
+ pick(...names?: string[]): /*elided*/ any;
7
+ omit(...names?: string[]): /*elided*/ any;
8
+ format(name: any, fn: any): /*elided*/ any;
9
9
  toString(): any;
10
10
  assertions: any[];
11
11
  meta: {};
12
- required(): any;
13
- default(arg: any): any;
14
- custom(fn: Function): any;
15
- strip(strip: any): any;
16
- allow(...set: any[]): any;
17
- reject(...set: any[]): any;
18
- nullable(): any;
19
- message(message: any): any;
20
- tag(tags: any): any;
21
- description(description: any): any;
22
- options(options: any): any;
12
+ required(): /*elided*/ any;
13
+ default(arg: any): /*elided*/ any;
14
+ custom(fn: Function): /*elided*/ any;
15
+ strip(strip: any): /*elided*/ any;
16
+ allow(...set: any[]): /*elided*/ any;
17
+ reject(...set: any[]): /*elided*/ any;
18
+ nullable(): /*elided*/ any;
19
+ message(message: any): /*elided*/ any;
20
+ tag(tags: any): /*elided*/ any;
21
+ description(description: any): /*elided*/ any;
22
+ options(options: any): /*elided*/ any;
23
23
  validate(value: any, options?: {}): Promise<any>;
24
- clone(meta: any): any;
24
+ clone(meta: any): /*elided*/ any;
25
25
  toOpenApi(extra: any): any;
26
26
  getAnyType(): {
27
27
  type: string[];
@@ -36,20 +36,12 @@ export function searchValidation(options?: {}): {
36
36
  };
37
37
  expandExtra(extra?: {}): {};
38
38
  inspect(): string;
39
- assertEnum(set: any, allow: any): any;
40
- assert(type: any, fn: any): any;
39
+ assertEnum(set: any, allow: any): /*elided*/ any;
40
+ assert(type: any, fn: any): /*elided*/ any;
41
41
  pushAssertion(assertion: any): void;
42
- transform(fn: any): any;
42
+ transform(fn: any): /*elided*/ any;
43
43
  getSortIndex(type: any): number;
44
44
  runAssertion(assertion: any, value: any, options?: {}): Promise<any>;
45
- enumToOpenApi(): {
46
- type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
47
- enum: any;
48
- oneOf?: undefined;
49
- } | {
50
- oneOf: any[];
51
- type?: undefined;
52
- enum?: undefined;
53
- };
45
+ enumToOpenApi(): any;
54
46
  };
55
47
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAgBA,gEA0DC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAsBA,gEAwDC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAA2C,CAAA;;;;;;;;;;;;;;;;EAyB1C"}
@@ -1,6 +1,6 @@
1
1
  export namespace serializeOptions {
2
- const getters: boolean;
3
- const versionKey: boolean;
2
+ let getters: boolean;
3
+ let versionKey: boolean;
4
4
  function transform(doc: any, ret: any, options: any): void;
5
5
  }
6
6
  //# sourceMappingURL=serialization.d.ts.map
@@ -5,7 +5,6 @@
5
5
  * [Link](https://github.com/bedrockio/model#testing)
6
6
  * @returns mongoose.Model
7
7
  */
8
- export function createTestModel(...args: any[]): mongoose.Model<any, unknown, unknown, unknown, any, any>;
8
+ export function createTestModel(...args: any[]): any;
9
9
  export function getTestModelName(): string;
10
- import mongoose from "mongoose";
11
10
  //# sourceMappingURL=testing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,0GAiBC;AAED,2CAEC"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,qDAiBC;AAED,2CAEC"}
package/types/utils.d.ts CHANGED
@@ -1,10 +1,16 @@
1
1
  export function isEqual(a: any, b: any): boolean;
2
- export function isMongooseSchema(obj: any): boolean;
2
+ export function isMongooseSchema(obj: any): obj is mongoose.Schema<any, any, any, any, any, any, any, any, any>;
3
3
  export function isReferenceField(obj: any, path: any): boolean;
4
4
  export function isDateField(obj: any, path: any): boolean;
5
5
  export function isNumberField(obj: any, path: any): boolean;
6
6
  export function isArrayField(obj: any, path: any): boolean;
7
7
  export function isSchemaTypedef(arg: any): boolean;
8
8
  export function getField(obj: any, path: any): any;
9
+ export function resolveRefPath(schema: any, path: any): {
10
+ ref: any;
11
+ local: any;
12
+ foreign: any;
13
+ };
9
14
  export function getInnerField(obj: any, path: any): any;
15
+ import mongoose from 'mongoose';
10
16
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAMA,iDAcC;AAED,oDAEC;AAED,+DAEC;AAED,0DAEC;AAED,4DAEC;AAED,2DAGC;AAOD,mDAGC;AAuBD,mDAYC;AAKD,wDAEC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAQA,iDAcC;AAED,gHAEC;AAED,+DAEC;AAED,0DAEC;AAED,4DAEC;AAED,2DAGC;AAOD,mDAGC;AAuBD,mDAYC;AAKD;;;;EAoBC;AAKD,wDAEC;qBAxHoB,UAAU"}