@warlock.js/cascade 3.0.7 → 3.0.11

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.
@@ -1,7 +1,7 @@
1
1
  import type { GenericObject } from "@mongez/reinforcements";
2
- import { type ModelAggregate } from "./../../model";
3
2
  import { type Aggregate } from "../aggregate";
4
3
  import type { WhereOperator } from "../types";
4
+ import { type ModelAggregate } from "./../../model";
5
5
  type FilterOperator = "bool" | "boolean" | "number" | "inNumber" | "null" | "notNull" | "!null" | "int" | "int>" | "int>=" | "int<" | "int<=" | "in" | "!int" | "integer" | "inInt" | "float" | "double" | "inFloat" | "date" | "inDate" | "date>" | "date>=" | "date<" | "date<=" | "dateBetween" | "dateTime" | "inDateTime" | "dateTime>" | "dateTime>=" | "dateTime<" | "dateTime<=" | "dateTimeBetween" | "location" | WhereOperator;
6
6
  type FilterFunction = (value: any, query: ModelAggregate<any>, context: Record<string, any>) => void;
7
7
  type FilterRule = FilterOperator | FilterFunction | [FilterOperator] | [FilterOperator, string | string[]];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/aggregate/filters/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,KAAK,cAAc,GACf,MAAM,GACN,SAAS,GACT,QAAQ,GACR,UAAU,GACV,MAAM,GACN,SAAS,GACT,OAAO,GACP,KAAK,GACL,MAAM,GACN,OAAO,GACP,MAAM,GACN,OAAO,GACP,IAAI,GACJ,MAAM,GACN,SAAS,GACT,OAAO,GACP,OAAO,GACP,QAAQ,GACR,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,GAC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,EACd,cAAc,EACd,aAAa,EACb,UAAU,EACV,eAAe,GAChB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/aggregate/filters/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,KAAK,cAAc,GACf,MAAM,GACN,SAAS,GACT,QAAQ,GACR,UAAU,GACV,MAAM,GACN,SAAS,GACT,OAAO,GACP,KAAK,GACL,MAAM,GACN,OAAO,GACP,MAAM,GACN,OAAO,GACP,IAAI,GACJ,MAAM,GACN,SAAS,GACT,OAAO,GACP,OAAO,GACP,QAAQ,GACR,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,aAAa,GACb,UAAU,GACV,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,iBAAiB,GACjB,UAAU,GACV,aAAa,CAAC;AAElB,KAAK,cAAc,GAAG,CACpB,KAAK,EAAE,GAAG,EACV,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,EAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KACzB,IAAI,CAAC;AAEV,KAAK,UAAU,GACX,cAAc,GACd,cAAc,GACd,CAAC,cAAc,CAAC,GAChB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAExC,KAAK,eAAe,GAAG;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B,CAAC;AAGF,UAAU,aAAa;IACrB,CAAC,MAAM,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,KAAK,EAAE,GAAG,CAAC;QACX,KAAK,EAAE,SAAS,CAAC;QACjB,OAAO,CAAC,EAAE,aAAa,CAAC;KACzB,GAAG,IAAI,CAAC;CACV;AAED,UAAU,cAAc;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC;CAC9B;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,kBAAkB;IAC1B;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3B;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,EACd,aAAa,EACb,UAAU,EACV,eAAe,GAChB,CAAC"}
package/cjs/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var DeselectPipeline=require('./aggregate/DeselectPipeline.js'),GeoNearPipeline=require('./aggregate/GeoNearPipeline.js'),GroupByPipeline=require('./aggregate/GroupByPipeline.js'),LimitPipeline=require('./aggregate/LimitPipeline.js'),LookupPipeline=require('./aggregate/LookupPipeline.js'),OrWherePipeline=require('./aggregate/OrWherePipeline.js'),SelectPipeline=require('./aggregate/SelectPipeline.js'),SkipPipeline=require('./aggregate/SkipPipeline.js'),SortByPipeline=require('./aggregate/SortByPipeline.js'),SortPipeline=require('./aggregate/SortPipeline.js'),SortRandomPipeline=require('./aggregate/SortRandomPipeline.js'),UnwindPipeline=require('./aggregate/UnwindPipeline.js'),WhereExpression=require('./aggregate/WhereExpression.js'),WhereExpressionPipeline=require('./aggregate/WhereExpressionPipeline.js'),WherePipeline=require('./aggregate/WherePipeline.js'),aggregate=require('./aggregate/aggregate.js'),expressions=require('./aggregate/expressions.js'),parsePipelines=require('./aggregate/parsePipelines.js'),pipeline=require('./aggregate/pipeline.js'),types=require('./aggregate/types.js'),applyFilters=require('./aggregate/filters/apply-filters.js'),blueprint=require('./blueprint/blueprint.js'),modelBlueprint=require('./blueprint/model-blueprint.js'),arrayOf=require('./casts/arrayOf.js'),castEmail=require('./casts/cast-email.js'),castModel=require('./casts/castModel.js'),expiresAfter=require('./casts/expiresAfter.js'),oneOf=require('./casts/oneOf.js'),randomString=require('./casts/random-string.js'),randomInteger=require('./casts/randomInteger.js'),shapedArray=require('./casts/shapedArray.js'),config=require('./config.js'),connection=require('./connection.js'),database=require('./database.js'),migrate=require('./migration/migrate.js'),migrationOffice=require('./migration/migration-office.js'),ModelAggregate=require('./model/ModelAggregate.js'),ModelSync=require('./model/ModelSync.js'),baseModel=require('./model/base-model.js'),crudModel=require('./model/crud-model.js'),joinable=require('./model/joinable.js'),masterMind=require('./model/master-mind.js'),model=require('./model/model.js'),types$1=require('./model/types.js'),query=require('./query/query.js'),connectToDatabase=require('./utils/connectToDatabase.js'),dropAllDatabaseIndexes=require('./utils/dropAllDatabaseIndexes.js'),listDatabaseIndexes=require('./utils/listDatabaseIndexes.js'),onceConnected=require('./utils/onceConnected.js');exports.DeselectPipeline=DeselectPipeline.DeselectPipeline;exports.deselectPipeline=DeselectPipeline.deselectPipeline;exports.GeoNearPipeline=GeoNearPipeline.GeoNearPipeline;exports.geoNearPipeline=GeoNearPipeline.geoNearPipeline;exports.GroupByPipeline=GroupByPipeline.GroupByPipeline;exports.groupByPipeline=GroupByPipeline.groupByPipeline;exports.LimitPipeline=LimitPipeline.LimitPipeline;exports.limitPipeline=LimitPipeline.limitPipeline;exports.LookupPipeline=LookupPipeline.LookupPipeline;exports.lookupPipeline=LookupPipeline.lookupPipeline;exports.OrWherePipeline=OrWherePipeline.OrWherePipeline;exports.orWherePipeline=OrWherePipeline.orWherePipeline;exports.SelectPipeline=SelectPipeline.SelectPipeline;exports.selectPipeline=SelectPipeline.selectPipeline;exports.SkipPipeline=SkipPipeline.SkipPipeline;exports.skipPipeline=SkipPipeline.skipPipeline;exports.SortByPipeline=SortByPipeline.SortByPipeline;exports.sortByPipeline=SortByPipeline.sortByPipeline;exports.SortPipeline=SortPipeline.SortPipeline;exports.sortPipeline=SortPipeline.sortPipeline;exports.SortRandomPipeline=SortRandomPipeline.SortRandomPipeline;exports.sortRandomPipeline=SortRandomPipeline.sortRandomPipeline;exports.UnwindPipeline=UnwindPipeline.UnwindPipeline;exports.unwindPipeline=UnwindPipeline.unwindPipeline;exports.WhereExpression=WhereExpression.WhereExpression;exports.parseValuesInObject=WhereExpression.parseValuesInObject;exports.toOperator=WhereExpression.toOperator;exports.WhereExpressionPipeline=WhereExpressionPipeline.WhereExpressionPipeline;exports.WherePipeline=WherePipeline.WherePipeline;exports.wherePipeline=WherePipeline.wherePipeline;exports.Aggregate=aggregate.Aggregate;exports.$agg=expressions.$agg;exports._divide=expressions._divide;exports._multiply=expressions._multiply;exports._round=expressions._round;exports.addToSet=expressions.addToSet;exports.all=expressions.all;exports.average=expressions.average;exports.avg=expressions.avg;exports.between=expressions.between;exports.booleanCond=expressions.booleanCond;exports.columnName=expressions.columnName;exports.columns=expressions.columns;exports.concat=expressions.concat;exports.concatWith=expressions.concatWith;exports.cond=expressions.cond;exports.condition=expressions.condition;exports.count=expressions.count;exports.dayOfMonth=expressions.dayOfMonth;exports.dayOfWeek=expressions.dayOfWeek;exports.divide=expressions.divide;exports.eq=expressions.eq;exports.equal=expressions.equal;exports.exists=expressions.exists;exports.expr=expressions.expr;exports.first=expressions.first;exports.firstDayOfMonth=expressions.firstDayOfMonth;exports.firstMonth=expressions.firstMonth;exports.firstYear=expressions.firstYear;exports.greaterThan=expressions.greaterThan;exports.greaterThanOrEqual=expressions.greaterThanOrEqual;exports.gt=expressions.gt;exports.gte=expressions.gte;exports.inArray=expressions.inArray;exports.isNull=expressions.isNull;exports.last=expressions.last;exports.lastDayOfMonth=expressions.lastDayOfMonth;exports.lastMonth=expressions.lastMonth;exports.lastYear=expressions.lastYear;exports.lessThan=expressions.lessThan;exports.lessThanOrEqual=expressions.lessThanOrEqual;exports.like=expressions.like;exports.lt=expressions.lt;exports.lte=expressions.lte;exports.max=expressions.max;exports.merge=expressions.merge;exports.mergeWith=expressions.mergeWith;exports.min=expressions.min;exports.month=expressions.month;exports.multiply=expressions.multiply;exports.ne=expressions.ne;exports.nin=expressions.nin;exports.notBetween=expressions.notBetween;exports.notEqual=expressions.notEqual;exports.notExists=expressions.notExists;exports.notIn=expressions.notIn;exports.notInArray=expressions.notInArray;exports.notLike=expressions.notLike;exports.notNull=expressions.notNull;exports.push=expressions.push;exports.regex=expressions.regex;exports.round=expressions.round;exports.size=expressions.size;exports.sum=expressions.sum;exports.week=expressions.week;exports.year=expressions.year;exports.parsePipeline=parsePipelines.parsePipeline;exports.parsePipelines=parsePipelines.parsePipelines;exports.Pipeline=pipeline.Pipeline;exports.whereOperators=types.whereOperators;exports.applyFilters=applyFilters.applyFilters;exports.Blueprint=blueprint.Blueprint;exports.blueprint=blueprint.blueprint;exports.ModelBlueprint=modelBlueprint.ModelBlueprint;exports.modelBlueprint=modelBlueprint.modelBlueprint;exports.arrayOf=arrayOf.arrayOf;exports.castEmail=castEmail.castEmail;exports.castModel=castModel.castModel;exports.expiresAfter=expiresAfter.expiresAfter;exports.castEnum=oneOf.castEnum;exports.oneOf=oneOf.oneOf;exports.randomString=randomString.randomString;exports.randomInteger=randomInteger.randomInteger;Object.defineProperty(exports,'ShapedArrayType',{enumerable:true,get:function(){return shapedArray.ShapedArrayType}});exports.shapedArray=shapedArray.shapedArray;exports.getDatabaseConfig=config.getDatabaseConfig;exports.getDatabaseConfigurations=config.getDatabaseConfigurations;exports.getDatabaseDebugLevel=config.getDatabaseDebugLevel;exports.setDatabaseConfigurations=config.setDatabaseConfigurations;exports.Connection=connection.Connection;exports.connection=connection.connection;exports.Database=database.Database;exports.database=database.database;exports.dropMigrations=migrate.dropMigrations;exports.listMigrations=migrate.listMigrations;exports.migrate=migrate.migrate;exports.MigrationOffice=migrationOffice.MigrationOffice;exports.migrationOffice=migrationOffice.migrationOffice;exports.ModelAggregate=ModelAggregate.ModelAggregate;exports.ModelSync=ModelSync.ModelSync;exports.BaseModel=baseModel.BaseModel;exports.CrudModel=crudModel.CrudModel;exports.Joinable=joinable.Joinable;exports.MasterMind=masterMind.MasterMind;exports.masterMind=masterMind.masterMind;exports.Model=model.Model;exports.declareModel=model.declareModel;Object.defineProperty(exports,'ModelDeleteStrategy',{enumerable:true,get:function(){return types$1.ModelDeleteStrategy}});exports.Query=query.Query;exports.query=query.query;exports.connectToDatabase=connectToDatabase.connectToDatabase;exports.dropAllDatabaseIndexes=dropAllDatabaseIndexes.dropAllDatabaseIndexes;exports.listDatabaseIndexes=listDatabaseIndexes.listDatabaseIndexes;exports.listIndexesForCertainCollections=listDatabaseIndexes.listIndexesForCertainCollections;exports.printCollectionIndexes=listDatabaseIndexes.printCollectionIndexes;exports.onceConnected=onceConnected.onceConnected;//# sourceMappingURL=index.js.map
1
+ 'use strict';var DeselectPipeline=require('./aggregate/DeselectPipeline.js'),GeoNearPipeline=require('./aggregate/GeoNearPipeline.js'),GroupByPipeline=require('./aggregate/GroupByPipeline.js'),LimitPipeline=require('./aggregate/LimitPipeline.js'),LookupPipeline=require('./aggregate/LookupPipeline.js'),OrWherePipeline=require('./aggregate/OrWherePipeline.js'),SelectPipeline=require('./aggregate/SelectPipeline.js'),SkipPipeline=require('./aggregate/SkipPipeline.js'),SortByPipeline=require('./aggregate/SortByPipeline.js'),SortPipeline=require('./aggregate/SortPipeline.js'),SortRandomPipeline=require('./aggregate/SortRandomPipeline.js'),UnwindPipeline=require('./aggregate/UnwindPipeline.js'),WhereExpression=require('./aggregate/WhereExpression.js'),WhereExpressionPipeline=require('./aggregate/WhereExpressionPipeline.js'),WherePipeline=require('./aggregate/WherePipeline.js'),aggregate=require('./aggregate/aggregate.js'),expressions=require('./aggregate/expressions.js'),parsePipelines=require('./aggregate/parsePipelines.js'),pipeline=require('./aggregate/pipeline.js'),types=require('./aggregate/types.js'),applyFilters=require('./aggregate/filters/apply-filters.js'),blueprint=require('./blueprint/blueprint.js'),modelBlueprint=require('./blueprint/model-blueprint.js'),arrayOf=require('./casts/arrayOf.js'),castEmail=require('./casts/cast-email.js'),castModel=require('./casts/castModel.js'),expiresAfter=require('./casts/expiresAfter.js'),oneOf=require('./casts/oneOf.js'),randomString=require('./casts/random-string.js'),randomInteger=require('./casts/randomInteger.js'),shapedArray=require('./casts/shapedArray.js'),config=require('./config.js'),connection=require('./connection.js'),database=require('./database.js'),migrate=require('./migration/migrate.js'),migrationOffice=require('./migration/migration-office.js'),ModelAggregate=require('./model/ModelAggregate.js'),ModelSync=require('./model/ModelSync.js'),baseModel=require('./model/base-model.js'),crudModel=require('./model/crud-model.js'),joinable=require('./model/joinable.js'),masterMind=require('./model/master-mind.js'),model=require('./model/model.js'),types$1=require('./model/types.js'),query=require('./query/query.js'),connectToDatabase=require('./utils/connectToDatabase.js'),dropAllDatabaseIndexes=require('./utils/dropAllDatabaseIndexes.js'),listDatabaseIndexes=require('./utils/listDatabaseIndexes.js'),onceConnected=require('./utils/onceConnected.js');exports.DeselectPipeline=DeselectPipeline.DeselectPipeline;exports.deselectPipeline=DeselectPipeline.deselectPipeline;exports.GeoNearPipeline=GeoNearPipeline.GeoNearPipeline;exports.geoNearPipeline=GeoNearPipeline.geoNearPipeline;exports.GroupByPipeline=GroupByPipeline.GroupByPipeline;exports.groupByPipeline=GroupByPipeline.groupByPipeline;exports.LimitPipeline=LimitPipeline.LimitPipeline;exports.limitPipeline=LimitPipeline.limitPipeline;exports.LookupPipeline=LookupPipeline.LookupPipeline;exports.lookupPipeline=LookupPipeline.lookupPipeline;exports.OrWherePipeline=OrWherePipeline.OrWherePipeline;exports.orWherePipeline=OrWherePipeline.orWherePipeline;exports.SelectPipeline=SelectPipeline.SelectPipeline;exports.selectPipeline=SelectPipeline.selectPipeline;exports.SkipPipeline=SkipPipeline.SkipPipeline;exports.skipPipeline=SkipPipeline.skipPipeline;exports.SortByPipeline=SortByPipeline.SortByPipeline;exports.sortByPipeline=SortByPipeline.sortByPipeline;exports.SortPipeline=SortPipeline.SortPipeline;exports.sortPipeline=SortPipeline.sortPipeline;exports.SortRandomPipeline=SortRandomPipeline.SortRandomPipeline;exports.sortRandomPipeline=SortRandomPipeline.sortRandomPipeline;exports.UnwindPipeline=UnwindPipeline.UnwindPipeline;exports.unwindPipeline=UnwindPipeline.unwindPipeline;exports.WhereExpression=WhereExpression.WhereExpression;exports.parseValuesInObject=WhereExpression.parseValuesInObject;exports.toOperator=WhereExpression.toOperator;exports.WhereExpressionPipeline=WhereExpressionPipeline.WhereExpressionPipeline;exports.WherePipeline=WherePipeline.WherePipeline;exports.wherePipeline=WherePipeline.wherePipeline;exports.Aggregate=aggregate.Aggregate;exports.$agg=expressions.$agg;exports._divide=expressions._divide;exports._multiply=expressions._multiply;exports._round=expressions._round;exports.addToSet=expressions.addToSet;exports.all=expressions.all;exports.average=expressions.average;exports.avg=expressions.avg;exports.between=expressions.between;exports.booleanCond=expressions.booleanCond;exports.columnName=expressions.columnName;exports.columns=expressions.columns;exports.concat=expressions.concat;exports.concatWith=expressions.concatWith;exports.cond=expressions.cond;exports.condition=expressions.condition;exports.count=expressions.count;exports.dayOfMonth=expressions.dayOfMonth;exports.dayOfWeek=expressions.dayOfWeek;exports.divide=expressions.divide;exports.eq=expressions.eq;exports.equal=expressions.equal;exports.exists=expressions.exists;exports.expr=expressions.expr;exports.first=expressions.first;exports.firstDayOfMonth=expressions.firstDayOfMonth;exports.firstMonth=expressions.firstMonth;exports.firstYear=expressions.firstYear;exports.greaterThan=expressions.greaterThan;exports.greaterThanOrEqual=expressions.greaterThanOrEqual;exports.gt=expressions.gt;exports.gte=expressions.gte;exports.inArray=expressions.inArray;exports.isNull=expressions.isNull;exports.last=expressions.last;exports.lastDayOfMonth=expressions.lastDayOfMonth;exports.lastMonth=expressions.lastMonth;exports.lastYear=expressions.lastYear;exports.lessThan=expressions.lessThan;exports.lessThanOrEqual=expressions.lessThanOrEqual;exports.like=expressions.like;exports.lt=expressions.lt;exports.lte=expressions.lte;exports.max=expressions.max;exports.merge=expressions.merge;exports.mergeWith=expressions.mergeWith;exports.min=expressions.min;exports.month=expressions.month;exports.multiply=expressions.multiply;exports.ne=expressions.ne;exports.nin=expressions.nin;exports.notBetween=expressions.notBetween;exports.notEqual=expressions.notEqual;exports.notExists=expressions.notExists;exports.notIn=expressions.notIn;exports.notInArray=expressions.notInArray;exports.notLike=expressions.notLike;exports.notNull=expressions.notNull;exports.push=expressions.push;exports.regex=expressions.regex;exports.round=expressions.round;exports.size=expressions.size;exports.sum=expressions.sum;exports.week=expressions.week;exports.year=expressions.year;exports.parsePipeline=parsePipelines.parsePipeline;exports.parsePipelines=parsePipelines.parsePipelines;exports.Pipeline=pipeline.Pipeline;exports.whereOperators=types.whereOperators;exports.applyFilters=applyFilters.applyFilters;exports.Blueprint=blueprint.Blueprint;exports.blueprint=blueprint.blueprint;exports.ModelBlueprint=modelBlueprint.ModelBlueprint;exports.modelBlueprint=modelBlueprint.modelBlueprint;exports.arrayOf=arrayOf.arrayOf;exports.castEmail=castEmail.castEmail;exports.castModel=castModel.castModel;exports.expiresAfter=expiresAfter.expiresAfter;exports.castEnum=oneOf.castEnum;exports.oneOf=oneOf.oneOf;exports.randomString=randomString.randomString;exports.randomInteger=randomInteger.randomInteger;Object.defineProperty(exports,'ShapedArrayType',{enumerable:true,get:function(){return shapedArray.ShapedArrayType}});exports.shapedArray=shapedArray.shapedArray;exports.getDatabaseConfig=config.getDatabaseConfig;exports.getDatabaseConfigurations=config.getDatabaseConfigurations;exports.getDatabaseDebugLevel=config.getDatabaseDebugLevel;exports.setDatabaseConfigurations=config.setDatabaseConfigurations;exports.Connection=connection.Connection;exports.connection=connection.connection;exports.Database=database.Database;exports.database=database.database;exports.dropMigrations=migrate.dropMigrations;exports.listMigrations=migrate.listMigrations;exports.migrate=migrate.migrate;exports.MigrationOffice=migrationOffice.MigrationOffice;exports.migrationOffice=migrationOffice.migrationOffice;exports.ModelAggregate=ModelAggregate.ModelAggregate;exports.ModelSync=ModelSync.ModelSync;exports.BaseModel=baseModel.BaseModel;exports.CrudModel=crudModel.CrudModel;exports.Joinable=joinable.Joinable;exports.MasterMind=masterMind.MasterMind;exports.masterMind=masterMind.masterMind;exports.Model=model.Model;Object.defineProperty(exports,'ModelDeleteStrategy',{enumerable:true,get:function(){return types$1.ModelDeleteStrategy}});exports.Query=query.Query;exports.query=query.query;exports.connectToDatabase=connectToDatabase.connectToDatabase;exports.dropAllDatabaseIndexes=dropAllDatabaseIndexes.dropAllDatabaseIndexes;exports.listDatabaseIndexes=listDatabaseIndexes.listDatabaseIndexes;exports.listIndexesForCertainCollections=listDatabaseIndexes.listIndexesForCertainCollections;exports.printCollectionIndexes=listDatabaseIndexes.printCollectionIndexes;exports.onceConnected=onceConnected.onceConnected;//# sourceMappingURL=index.js.map
@@ -0,0 +1,448 @@
1
+ import { ObjectId } from "mongodb";
2
+ import { ModelAggregate } from "./ModelAggregate";
3
+ import { ModelSync } from "./ModelSync";
4
+ import { RelationshipWithMany } from "./RelationshipWithMany";
5
+ import { CrudModel } from "./crud-model";
6
+ import { Joinable } from "./joinable";
7
+ import type { CastType, Casts, ChildModel, CustomCasts, Document, ModelDocument } from "./types";
8
+ export type Schema<ModelSchema = Document> = ModelSchema & {
9
+ _id?: ObjectId;
10
+ id?: number;
11
+ createdAt?: Date;
12
+ updatedAt?: Date;
13
+ };
14
+ export declare class Model extends CrudModel {
15
+ /**
16
+ * Model Initial Document data
17
+ */
18
+ initialData: Partial<Schema>;
19
+ /**
20
+ * Model relationships defined using the joinable API.
21
+ *
22
+ * Each key represents a relationship name that can be referenced when running queries.
23
+ * Each value defines how to join another collection to the current model.
24
+ *
25
+ * @example
26
+ * Basic definition:
27
+ * ```ts
28
+ * public static relations = {
29
+ * // Join users collection where local createdBy.id matches user's id
30
+ * author: User.joinable("createdBy.id", "id").single().as("author"),
31
+ * }
32
+ * ```
33
+ *
34
+ * @usage
35
+ * Example of calling:
36
+ * ```ts
37
+ * Post.aggregate().joining("author").get(); // use `joining` method to join the `author` relationship
38
+ * // Where `author` is the name of the relationship defined in the `relations` property
39
+ * ```
40
+ */
41
+ static relations: Record<string, Joinable>;
42
+ /**
43
+ * Model Document data
44
+ */
45
+ data: Schema;
46
+ /**
47
+ * Define Default value data that will be merged with the models' data
48
+ * on the create process
49
+ */
50
+ defaultValue: Partial<Schema>;
51
+ /**
52
+ * A flag to determine if the model is being restored
53
+ */
54
+ protected isRestored: boolean;
55
+ /**
56
+ * Model casts types
57
+ */
58
+ protected casts: Casts;
59
+ /**
60
+ * Sync with list
61
+ */
62
+ syncWith: ModelSync[];
63
+ /**
64
+ * Set custom casts that will be used to cast the model's data are not related to the current value of the collection's column
65
+ *
66
+ * For example: `name` is not a column in the given data, but it will be concatenation of `firstName` and `lastName`
67
+ */
68
+ protected customCasts: CustomCasts<string>;
69
+ /**
70
+ * Guarded fields
71
+ */
72
+ guarded: (keyof ModelDocument)[];
73
+ /**
74
+ * Fillable fields
75
+ */
76
+ filled: (keyof ModelDocument)[];
77
+ /**
78
+ * Embedded columns
79
+ */
80
+ embedded: (keyof Schema)[];
81
+ /**
82
+ * Embed all columns except the given columns
83
+ */
84
+ embedAllExcept: (keyof ModelDocument)[];
85
+ /**
86
+ * Embed all columns except timestamps and created|updated|deleted by columns
87
+ */
88
+ embedAllExceptTimestampsAndUserColumns: boolean;
89
+ /**
90
+ * Created at column
91
+ */
92
+ createdAtColumn: string;
93
+ /**
94
+ * Updated at column
95
+ */
96
+ updatedAtColumn: string;
97
+ /**
98
+ * Deleted at column
99
+ */
100
+ deletedAtColumn: string;
101
+ /**
102
+ * Created by column
103
+ */
104
+ createdByColumn: string;
105
+ /**
106
+ * Updated by column
107
+ */
108
+ updatedByColumn: string;
109
+ /**
110
+ * Deleted by column
111
+ */
112
+ deletedByColumn: string;
113
+ /**
114
+ * Date format
115
+ */
116
+ dateFormat: string;
117
+ /**
118
+ * A flag to determine if the id is auto generated not added manually
119
+ */
120
+ protected autoGeneratedId: boolean;
121
+ /**
122
+ * Is active column
123
+ */
124
+ protected isActiveColumn: string;
125
+ /**
126
+ * Original data
127
+ */
128
+ originalData: Schema;
129
+ /**
130
+ * List of dirty columns
131
+ */
132
+ dirtyColumns: Record<string, {
133
+ oldValue: any;
134
+ newValue: any;
135
+ }>;
136
+ /**
137
+ * Constructor
138
+ */
139
+ constructor(originalData?: Partial<Schema>);
140
+ /**
141
+ * Get save columns which are the casts keys
142
+ */
143
+ get castColumns(): string[];
144
+ /**
145
+ * Get value from original data
146
+ */
147
+ original(key: string, defaultValue?: any): any;
148
+ /**
149
+ * Get all data except the guarded fields
150
+ */
151
+ get publicData(): any;
152
+ /**
153
+ * Get guarded data
154
+ */
155
+ get guardedData(): any;
156
+ /**
157
+ * Get the model's id
158
+ */
159
+ get id(): number;
160
+ /**
161
+ * Check if current model is active
162
+ */
163
+ get isActive(): boolean;
164
+ /**
165
+ * Get mongodb id
166
+ */
167
+ get _id(): ObjectId;
168
+ /**
169
+ * Mark the current model as being restored
170
+ */
171
+ markAsRestored(): void;
172
+ /**
173
+ * Set a column in the model data
174
+ */
175
+ set(column: keyof Schema, value: any): this;
176
+ /**
177
+ * Increment the given column by the given value
178
+ */
179
+ increment(column: keyof Schema, value?: number): this;
180
+ /**
181
+ * Decrement the given column by the given value
182
+ */
183
+ decrement(column: keyof Schema, value?: number): this;
184
+ /**
185
+ * Get initial value of the given column
186
+ */
187
+ getInitial(column: keyof Schema, defaultValue?: any): any;
188
+ /**
189
+ * Get value of the given column
190
+ */
191
+ get<ValueType = any>(column: keyof Schema, defaultValue?: any): ValueType;
192
+ /**
193
+ * Return the value of the given column as a string
194
+ */
195
+ string(column: keyof Schema, defaultValue?: any): string;
196
+ /**
197
+ * Return the value of the given column as an integer
198
+ */
199
+ int(column: keyof Schema, defaultValue?: any): number;
200
+ /**
201
+ * Return the value of the given column as a float
202
+ */
203
+ float(column: keyof Schema, defaultValue?: any): number;
204
+ /**
205
+ * Return the value of the given column as a number
206
+ */
207
+ number(column: keyof Schema, defaultValue?: any): number;
208
+ /**
209
+ * Return the value of the given column as a boolean
210
+ */
211
+ bool(column: keyof Schema, defaultValue?: any): boolean;
212
+ /**
213
+ * Determine whether the given column exists in the document
214
+ */
215
+ has(column: keyof Schema): boolean;
216
+ /**
217
+ * Get all columns except the given ones
218
+ */
219
+ except(columns: (keyof Schema)[]): Document;
220
+ /**
221
+ * Get only the given columns
222
+ */
223
+ only<T extends Document = Document>(columns: (keyof Schema)[]): T;
224
+ /**
225
+ * Get only id
226
+ */
227
+ get onlyId(): Document;
228
+ /**
229
+ * Unset or remove the given columns from the data
230
+ */
231
+ unset(...columns: (keyof Schema)[]): this;
232
+ /**
233
+ * Get the value of the given column and remove it from the data
234
+ */
235
+ pluck(column: keyof Schema): any;
236
+ /**
237
+ * Replace the entire document data with the given new data
238
+ */
239
+ replaceWith(data: Schema): this;
240
+ /**
241
+ * Merge the given documents to current document
242
+ */
243
+ merge(data: Document): this;
244
+ /**
245
+ * Push the given values to the given column
246
+ * If the given column does not exists, it will be created
247
+ * If the given value exists but not an array it will be ignored
248
+ */
249
+ push(column: keyof Schema, ...values: any[]): this;
250
+ /**
251
+ * Push the given values to the given column only if not exists
252
+ */
253
+ pushOnce(column: keyof Schema, ...values: any[]): this;
254
+ /**
255
+ * Add the given values to the beginning of the given column
256
+ * If the given column does not exists, it will be created
257
+ * If the given value exists but not an array it will be ignored
258
+ */
259
+ unshift(column: keyof Schema, ...values: any[]): this;
260
+ /**
261
+ * Add the given values to the beginning of the given column only if not exists
262
+ */
263
+ unshiftOnce(column: keyof Schema, ...values: any[]): this;
264
+ protected prepareDataForCreating(cast?: boolean, triggerEvents?: boolean): Promise<void>;
265
+ /**
266
+ * Perform saving operation either by updating or creating a new record in database
267
+ */
268
+ save(mergedData?: Omit<Schema, "id" | "_id">, { triggerEvents, cast, forceUpdate, }?: {
269
+ triggerEvents?: boolean;
270
+ cast?: boolean;
271
+ forceUpdate?: boolean;
272
+ }): Promise<this>;
273
+ /**
274
+ * Generate and return next id
275
+ */
276
+ generateNextId(): Promise<number>;
277
+ /**
278
+ * Trigger created events
279
+ */
280
+ triggerCreatedEvents(): void;
281
+ /**
282
+ * Trigger updated events
283
+ */
284
+ triggerUpdatedEvents(oldModel: Model): void;
285
+ /**
286
+ * Perform saving but without any events triggers
287
+ */
288
+ silentSaving(mergedData?: Omit<Schema, "id" | "_id">, options?: {
289
+ cast?: boolean;
290
+ }): Promise<this>;
291
+ /**
292
+ * Determine whether the model should be updated or not
293
+ */
294
+ protected shouldUpdate(originalData: Schema, data: Schema): boolean;
295
+ /**
296
+ * Triggered before saving the model either by creating or updating
297
+ */
298
+ protected onSaving(): Promise<void>;
299
+ /**
300
+ * Triggered after saving the model either by creating or updating
301
+ */
302
+ protected onSaved(): Promise<void>;
303
+ /**
304
+ * Triggered before creating the model
305
+ */
306
+ protected onCreating(): Promise<void>;
307
+ /**
308
+ * Triggered after creating the model
309
+ */
310
+ protected onCreated(): Promise<void>;
311
+ /**
312
+ * Triggered before updating the model
313
+ */
314
+ protected onUpdating(): Promise<void>;
315
+ /**
316
+ * Triggered after updating the model
317
+ */
318
+ protected onUpdated(): Promise<void>;
319
+ /**
320
+ * Triggered before deleting the model
321
+ */
322
+ protected onDeleting(): Promise<void>;
323
+ /**
324
+ * Triggered after deleting the model
325
+ */
326
+ protected onDeleted(): Promise<void>;
327
+ /**
328
+ * Cast data before saving
329
+ */
330
+ protected castData(forceUpdate?: boolean): Promise<void>;
331
+ /**
332
+ * Return only the given columns to be used in output
333
+ */
334
+ outputOnly(columns: string[]): this;
335
+ /**
336
+ * Return all columns except the given columns to be used in output
337
+ */
338
+ outputExcept(columns: string[]): this;
339
+ /**
340
+ * Cast the given value based on the given cast type
341
+ */
342
+ protected castValue(value: any, castType: CastType): any;
343
+ /**
344
+ * Check for default values
345
+ */
346
+ protected checkDefaultValues(): void;
347
+ /**
348
+ * Destroy the model and delete it from database collection
349
+ */
350
+ destroy(): Promise<void>;
351
+ /**
352
+ * Determine if the given column is dirty column
353
+ *
354
+ * Dirty columns are columns that their values have been changed from the original data
355
+ */
356
+ isDirty(column?: string): boolean;
357
+ /**
358
+ * Check if current model is a new model
359
+ */
360
+ isNewModel(): boolean;
361
+ /**
362
+ * Get embedded data
363
+ */
364
+ get embeddedData(): any;
365
+ /**
366
+ * Clone the model
367
+ */
368
+ clone(data?: Document): this;
369
+ /**
370
+ * Get relationship with the given model class
371
+ */
372
+ hasMany<T extends Model = Model>(modelClass: typeof Model, column: string): RelationshipWithMany<T>;
373
+ /**
374
+ * Get new aggregate for current model
375
+ */
376
+ static aggregate<T extends Model = Model>(this: ChildModel<T>): ModelAggregate<T>;
377
+ /**
378
+ * @alias aggregate
379
+ */
380
+ static newQuery(): ModelAggregate<Model>;
381
+ /**
382
+ * Get query builder
383
+ * @alias aggregate
384
+ */
385
+ static queryBuilder<T extends Model = Model>(this: ChildModel<T>): ModelAggregate<T>;
386
+ /**
387
+ * Sync with the given model
388
+ */
389
+ static sync(columns: string | string[], embedMethod?: string): ModelSync;
390
+ /**
391
+ * Sync data on saving
392
+ */
393
+ startSyncing(saveMode: "create" | "update", oldModel?: Model): void;
394
+ /**
395
+ * Sync destruction
396
+ * Called when destroy method is called
397
+ */
398
+ syncDestruction(): void;
399
+ /**
400
+ * The syncing model (That calls startSyncing) is being embedded in multiple documents of current model
401
+ * I.e Country.syncMany('cities') while current model is City
402
+ */
403
+ static syncMany(columns: string | string[], embedMethod?: string): ModelSync;
404
+ /**
405
+ * Reassociate a model/object/document with the current model
406
+ * If the model is already associated, it will be updated
407
+ * If not, it will be associated
408
+ * the model/document must have an id
409
+ *
410
+ * If it is a model, you can set the embed method to use
411
+ */
412
+ reassociate(this: Model, column: string, model: Model | ModelDocument | any, embedWith?: string): Model;
413
+ /**
414
+ * Associate a model with the current model
415
+ */
416
+ associate(this: Model, column: string, model: Model | ModelDocument | any, embedWith?: string): Model;
417
+ /**
418
+ * Disassociate a model with the current model
419
+ */
420
+ disassociate(this: Model, column: string, model: Model | ModelDocument | any): Model;
421
+ /**
422
+ * Refresh the model with new data from database
423
+ * This method will update the current data with the new data from database
424
+ */
425
+ refresh(): Promise<this>;
426
+ /**
427
+ * Fetch data from database and return it in a new model
428
+ */
429
+ reload(): Promise<this>;
430
+ /**
431
+ * Make a wrapper to list when models should be updated when only one of the given columns is updated
432
+ */
433
+ syncUpdateWhenChange(columns: string | string[], syncModels: ModelSync[]): ModelSync[];
434
+ /**
435
+ * Get a Joinable instance for current model
436
+ */
437
+ static joinable(
438
+ /**
439
+ * Local field to the current model
440
+ */
441
+ localField?: string,
442
+ /**
443
+ * Foreign field in the joinable model
444
+ */
445
+ foreignField?: string, single?: boolean, as?: string): import("./joinable").JoinableProxy;
446
+ }
447
+ export type ModelType = typeof Model;
448
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAYA,OAAO,EAAoB,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EACV,QAAQ,EACR,KAAK,EACL,UAAU,EAEV,WAAW,EACX,QAAQ,EACR,aAAa,EACd,MAAM,SAAS,CAAC;AAKjB,MAAM,MAAM,MAAM,CAAC,WAAW,GAAG,QAAQ,IAAI,WAAW,GAAG;IACzD,GAAG,CAAC,EA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C;IAepC;;OAEG;IACI,oBAAoB,CACzB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,UAAU,EAAE,SAAS,EAAE;IASzB;;OAEG;WACW,QAAQ;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,OAAO,EAChB,EAAE,CAAC,EAAE,MAAM;CAsBd;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC"}
@@ -1,71 +1,7 @@
1
- 'use strict';var reinforcements=require('@mongez/reinforcements'),supportiveIs=require('@mongez/supportive-is'),timeWizard=require('@mongez/time-wizard'),dayjs=require('dayjs'),mongodb=require('mongodb'),castModel=require('../casts/castModel.js'),oneOf=require('../casts/oneOf.js'),deepDiff=require('../utils/deep-diff.js'),joinableProxy=require('../utils/joinable-proxy.js'),ModelAggregate=require('./ModelAggregate.js'),ModelSync=require('./ModelSync.js'),RelationshipWithMany=require('./RelationshipWithMany.js'),crudModel=require('./crud-model.js'),joinable=require('./joinable.js'),types=require('./types.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var dayjs__default=/*#__PURE__*/_interopDefault(dayjs);/**
2
- * Create a new model
3
- * Please be reminded that this is a quick way to declare a new model
4
- * For full model declaration please inherit from the `Model` class
5
- */
6
- function declareModel({ collection, defaultValues = {}, casts = {}, relations = {}, syncWith = [], embedAllExcept = [], embedded = [], }) {
7
- return class extends Model {
8
- static collection = collection;
9
- /**
10
- * Model relationships defined using the joinable API.
11
- *
12
- * Each key represents a relationship name that can be referenced when running queries.
13
- * Each value defines how to join another collection to the current model.
14
- *
15
- * @example
16
- * Basic definition:
17
- * ```ts
18
- * public static relations = {
19
- * // Join users collection where local createdBy.id matches user's id
20
- * author: User.joinable("createdBy.id", "id").single().as("author"),
21
- * }
22
- * ```
23
- *
24
- * @usage
25
- * Example of calling:
26
- * ```ts
27
- * Post.aggregate().joining("author").get(); // use `joining` method to join the `author` relationship
28
- * // Where `author` is the name of the relationship defined in the `relations` property
29
- * ```
30
- */
31
- static relations = relations;
32
- /**
33
- * Define Default value data that will be merged with the models' data
34
- * on the create process
35
- */
36
- defaultValue = defaultValues;
37
- /**
38
- * A flag to determine if the model is being restored
39
- */
40
- isRestored = false;
41
- /**
42
- * Model casts types
43
- */
44
- casts = casts;
45
- /**
46
- * Sync with list
47
- */
48
- syncWith = syncWith;
49
- /**
50
- * Set custom casts that will be used to cast the model's data are not related to the current value of the collection's column
51
- *
52
- * For example: `name` is not a column in the given data, but it will be concatenation of `firstName` and `lastName`
53
- */
54
- customCasts = {};
55
- /**
56
- * Embedded columns
57
- */
58
- embedded = embedded;
59
- /**
60
- * Embed all columns except the given columns
61
- */
62
- embedAllExcept = embedAllExcept;
63
- };
64
- }
65
- class Model
1
+ 'use strict';var reinforcements=require('@mongez/reinforcements'),supportiveIs=require('@mongez/supportive-is'),timeWizard=require('@mongez/time-wizard'),dayjs=require('dayjs'),mongodb=require('mongodb'),castModel=require('../casts/castModel.js'),oneOf=require('../casts/oneOf.js'),deepDiff=require('../utils/deep-diff.js'),joinableProxy=require('../utils/joinable-proxy.js'),ModelAggregate=require('./ModelAggregate.js'),ModelSync=require('./ModelSync.js'),RelationshipWithMany=require('./RelationshipWithMany.js'),crudModel=require('./crud-model.js'),joinable=require('./joinable.js'),types=require('./types.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var dayjs__default=/*#__PURE__*/_interopDefault(dayjs);class Model
66
2
  // <
67
3
  // ModelDocument extends Document = any,
68
- // ModelSchema extends Schema<ModelDocument> = any,
4
+ // Schema extends Schema<ModelDocument> = any,
69
5
  // >
70
6
  extends crudModel.CrudModel {
71
7
  /**
@@ -1180,4 +1116,4 @@ class Model
1180
1116
  }
1181
1117
  return joinableProxy.joinableProxy(joinable$1);
1182
1118
  }
1183
- }exports.Model=Model;exports.declareModel=declareModel;//# sourceMappingURL=model.js.map
1119
+ }exports.Model=Model;//# sourceMappingURL=model.js.map