@graphand/core
Advanced tools
Comparing version 0.3.16 to 0.4.1
@@ -92,2 +92,1 @@ "use strict"; | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./default-fields"), exports); |
@@ -270,3 +270,3 @@ "use strict"; | ||
const i = this; | ||
return new PromiseModel_1.default([(resolve) => resolve(i)], this.model, this._id); | ||
return new PromiseModel_1.default([(resolve) => resolve(i)], this.model, String(this._id)); | ||
} | ||
@@ -451,3 +451,3 @@ to(format) { | ||
(0, fieldDecorator_1.fieldDecorator)(field_types_1.default.ID), | ||
__metadata("design:type", Object) | ||
__metadata("design:type", String) | ||
], Model.prototype, "_id", void 0); | ||
@@ -454,0 +454,0 @@ __decorate([ |
@@ -104,3 +104,3 @@ "use strict"; | ||
(0, fieldDecorator_1.fieldDecorator)(field_types_1.default.BOOLEAN, { default: false }), | ||
__metadata("design:type", Object) | ||
__metadata("design:type", Boolean) | ||
], DataModel.prototype, "isPage", void 0); | ||
@@ -107,0 +107,0 @@ __decorate([ |
@@ -63,7 +63,7 @@ "use strict"; | ||
(0, fieldDecorator_1.fieldDecorator)(field_types_1.default.NUMBER, { default: 86400 }), | ||
__metadata("design:type", Object) | ||
__metadata("design:type", Number) | ||
], Project.prototype, "accessTokenLifetime", void 0); | ||
__decorate([ | ||
(0, fieldDecorator_1.fieldDecorator)(field_types_1.default.NUMBER, { default: 2592000 }), | ||
__metadata("design:type", Object) | ||
__metadata("design:type", Number) | ||
], Project.prototype, "refreshTokenLifetime", void 0); | ||
@@ -70,0 +70,0 @@ __decorate([ |
@@ -66,3 +66,3 @@ "use strict"; | ||
(0, fieldDecorator_1.fieldDecorator)(field_types_1.default.BOOLEAN), | ||
__metadata("design:type", Object) | ||
__metadata("design:type", Boolean) | ||
], Role.prototype, "admin", void 0); | ||
@@ -69,0 +69,0 @@ __decorate([ |
@@ -42,2 +42,1 @@ import Model from "./lib/Model"; | ||
export * from "./types"; | ||
export * from "./default-fields"; |
@@ -10,4 +10,2 @@ import ModelEnvScopes from "../enums/model-env-scopes"; | ||
import Validator from "./Validator"; | ||
import { FieldDateDefinition, FieldIdDefinition } from "../fields"; | ||
import { ExecutorCtx } from "../global"; | ||
declare class Model { | ||
@@ -30,6 +28,6 @@ static extendable: boolean; | ||
__doc: DocumentDefinition; | ||
_id: FieldIdDefinition; | ||
_createdAt: FieldDateDefinition; | ||
_createdBy: any; | ||
_updatedAt: FieldDateDefinition; | ||
_id: FieldDefinitionId; | ||
_createdAt: FieldDefinitionDate; | ||
_createdBy: FieldDefinitionRelation; | ||
_updatedAt: FieldDefinitionDate; | ||
_updatedBy: any; | ||
@@ -36,0 +34,0 @@ constructor(doc?: any); |
@@ -8,3 +8,3 @@ import Model from "./Model"; | ||
get count(): number; | ||
getIds(): any[]; | ||
getIds(): string[]; | ||
toArray(): T[]; | ||
@@ -11,0 +11,0 @@ toJSON(): { |
import Model from "../lib/Model"; | ||
import ModelEnvScopes from "../enums/model-env-scopes"; | ||
import Role from "./Role"; | ||
import { FieldRelationDefinition, FieldTextDefinition } from "../fields"; | ||
import User from "./User"; | ||
@@ -13,11 +12,11 @@ import { ValidatorsDefinition } from "../types"; | ||
static validators: ValidatorsDefinition; | ||
firstname: FieldTextDefinition; | ||
lastname: FieldTextDefinition; | ||
email: FieldTextDefinition; | ||
password: FieldTextDefinition; | ||
role: FieldRelationDefinition<{ | ||
firstname: FieldDefinitionText; | ||
lastname: FieldDefinitionText; | ||
email: FieldDefinitionText; | ||
password: FieldDefinitionText; | ||
role: FieldDefinitionRelation<{ | ||
model: Role; | ||
multiple: false; | ||
}>; | ||
user: FieldRelationDefinition<{ | ||
user: FieldDefinitionRelation<{ | ||
model: User; | ||
@@ -24,0 +23,0 @@ multiple: false; |
import Model from "../lib/Model"; | ||
import ModelEnvScopes from "../enums/model-env-scopes"; | ||
import { FieldsDefinition, ValidatorsDefinition } from "../types"; | ||
import { FieldBooleanDefinition, FieldJSONDefinition, FieldTextDefinition } from "../fields"; | ||
declare class DataModel extends Model { | ||
@@ -11,9 +10,9 @@ static __name: string; | ||
static validators: ValidatorsDefinition; | ||
name: FieldTextDefinition; | ||
slug: FieldTextDefinition; | ||
fields: FieldJSONDefinition<FieldsDefinition>; | ||
validators: FieldJSONDefinition<ValidatorsDefinition>; | ||
isPage: FieldBooleanDefinition; | ||
configKey: FieldTextDefinition; | ||
name: FieldDefinitionText; | ||
slug: FieldDefinitionText; | ||
fields: FieldDefinitionJSON<FieldsDefinition>; | ||
validators: FieldDefinitionJSON<ValidatorsDefinition>; | ||
isPage: FieldDefinitionBoolean; | ||
configKey: FieldDefinitionText; | ||
} | ||
export default DataModel; |
import Model from "../lib/Model"; | ||
import ModelEnvScopes from "../enums/model-env-scopes"; | ||
import { FieldRelationDefinition, FieldTextDefinition } from "../fields"; | ||
import { ValidatorsDefinition } from "../types"; | ||
@@ -11,4 +10,4 @@ declare class Environment extends Model { | ||
static validators: ValidatorsDefinition; | ||
name: FieldTextDefinition; | ||
base: FieldRelationDefinition<{ | ||
name: FieldDefinitionText; | ||
base: FieldDefinitionRelation<{ | ||
model: Environment; | ||
@@ -15,0 +14,0 @@ multiple: false; |
import Model from "../lib/Model"; | ||
import ModelEnvScopes from "../enums/model-env-scopes"; | ||
import { FieldRelationDefinition, FieldTextDefinition } from "../fields"; | ||
import { ValidatorsDefinition } from "../types"; | ||
@@ -11,5 +10,5 @@ import User from "./User"; | ||
static validators: ValidatorsDefinition; | ||
name: FieldTextDefinition; | ||
slug: FieldTextDefinition; | ||
users: FieldRelationDefinition<{ | ||
name: FieldDefinitionText; | ||
slug: FieldDefinitionText; | ||
users: FieldDefinitionRelation<{ | ||
model: User; | ||
@@ -16,0 +15,0 @@ multiple: true; |
import Model from "../lib/Model"; | ||
import ModelEnvScopes from "../enums/model-env-scopes"; | ||
import Organization from "./Organization"; | ||
import { FieldNumberDefinition, FieldRelationDefinition, FieldTextDefinition } from "../fields"; | ||
import Account from "./Account"; | ||
@@ -12,12 +11,12 @@ import { ValidatorsDefinition } from "../types"; | ||
static validators: ValidatorsDefinition; | ||
name: FieldTextDefinition; | ||
slug: FieldTextDefinition; | ||
plan: FieldTextDefinition; | ||
organization: FieldRelationDefinition<{ | ||
name: FieldDefinitionText; | ||
slug: FieldDefinitionText; | ||
plan: FieldDefinitionText; | ||
organization: FieldDefinitionRelation<{ | ||
model: Organization; | ||
multiple: false; | ||
}>; | ||
accessTokenLifetime: FieldNumberDefinition; | ||
refreshTokenLifetime: FieldNumberDefinition; | ||
owner: FieldRelationDefinition<{ | ||
accessTokenLifetime: FieldDefinitionNumber; | ||
refreshTokenLifetime: FieldDefinitionNumber; | ||
owner: FieldDefinitionRelation<{ | ||
model: Account; | ||
@@ -24,0 +23,0 @@ multiple: false; |
import Model from "../lib/Model"; | ||
import ModelEnvScopes from "../enums/model-env-scopes"; | ||
import { FieldsRestriction, Rule, ValidatorsDefinition } from "../types"; | ||
import { FieldBooleanDefinition, FieldJSONDefinition, FieldRelationDefinition, FieldTextDefinition } from "../fields"; | ||
declare class Role extends Model { | ||
@@ -11,10 +10,10 @@ static __name: string; | ||
static validators: ValidatorsDefinition; | ||
slug: FieldTextDefinition; | ||
admin: FieldBooleanDefinition; | ||
inherits: FieldRelationDefinition<{ | ||
slug: FieldDefinitionText; | ||
admin: FieldDefinitionBoolean; | ||
inherits: FieldDefinitionRelation<{ | ||
model: Role; | ||
multiple: true; | ||
}>; | ||
rules: FieldJSONDefinition<Array<Rule>>; | ||
fieldsRestrictions: FieldJSONDefinition<Array<FieldsRestriction>>; | ||
rules: FieldDefinitionJSON<Array<Rule>>; | ||
fieldsRestrictions: FieldDefinitionJSON<Array<FieldsRestriction>>; | ||
getRulesInherited(): Promise<Array<Rule>>; | ||
@@ -21,0 +20,0 @@ getFieldsRestrictionsInherited(): Promise<Array<FieldsRestriction>>; |
import Model from "../lib/Model"; | ||
import ModelEnvScopes from "../enums/model-env-scopes"; | ||
import Role from "./Role"; | ||
import { FieldDateDefinition, FieldRelationDefinition, FieldTextDefinition } from "../fields"; | ||
import { ValidatorsDefinition } from "../types"; | ||
@@ -12,5 +11,5 @@ declare class Token extends Model { | ||
static validators: ValidatorsDefinition; | ||
name: FieldTextDefinition; | ||
expiration: FieldDateDefinition; | ||
role: FieldRelationDefinition<{ | ||
name: FieldDefinitionText; | ||
expiration: FieldDefinitionDate; | ||
role: FieldDefinitionRelation<{ | ||
model: Role; | ||
@@ -17,0 +16,0 @@ multiple: false; |
import Model from "../lib/Model"; | ||
import ModelEnvScopes from "../enums/model-env-scopes"; | ||
import { FieldTextDefinition } from "../fields"; | ||
import { ValidatorsDefinition } from "../types"; | ||
@@ -11,5 +10,5 @@ declare class User extends Model { | ||
static validators: ValidatorsDefinition; | ||
email: FieldTextDefinition; | ||
password: FieldTextDefinition; | ||
email: FieldDefinitionText; | ||
password: FieldDefinitionText; | ||
} | ||
export default User; |
@@ -10,3 +10,4 @@ import Model from "./lib/Model"; | ||
import ValidationError from "./lib/ValidationError"; | ||
import { ExecutorCtx } from "./global"; | ||
import PromiseModel from "./lib/PromiseModel"; | ||
import PromiseModelList from "./lib/PromiseModelList"; | ||
export type DefaultFieldDefinitionOptions<T extends FieldTypes> = T extends FieldTypes.TEXT ? { | ||
@@ -29,7 +30,30 @@ multiple: false; | ||
} : {}; | ||
type PromiseModelOn<T extends Model> = PromiseModel<T> & {}; | ||
type string_ = string & Partial<any>; | ||
type FieldTextDefinitionSingleType<Options extends string[], Creatable extends boolean = true, DefaultType extends any = string_> = Options extends string[] ? Creatable extends false ? Options[number] : FieldTextDefinitionSingleType<Options, false> | DefaultType : FieldTextDefinitionSingleType<[], Creatable, string>; | ||
export type DefaultFieldIdDefinition<D extends FieldDefinitionOptions<FieldTypes.ID>> = string; | ||
export type DefaultFieldTextDefinition<D extends FieldDefinitionOptions<FieldTypes.TEXT>> = (D["multiple"] extends true ? FieldTextDefinitionSingleType<D["options"], D["creatable"]>[] : FieldTextDefinitionSingleType<D["options"], D["creatable"]>) | undefined; | ||
export type DefaultFieldBooleanDefinition<D extends FieldDefinitionOptions<FieldTypes.BOOLEAN>> = boolean | undefined; | ||
export type DefaultFieldNumberDefinition<D extends FieldDefinitionOptions<FieldTypes.NUMBER>> = number | undefined; | ||
export type DefaultFieldDateDefinition<D extends FieldDefinitionOptions<FieldTypes.DATE>> = Date | undefined; | ||
export type DefaultFieldJSONDefinition<D extends FieldDefinitionOptions<FieldTypes.JSON>> = D | any | undefined; | ||
export type DefaultFieldRelationDefinition<D extends FieldDefinitionOptions<FieldTypes.RELATION>> = (D["multiple"] extends true ? ModelList<D["model"]> | PromiseModelList<D["model"]> : D["model"] | PromiseModelOn<D["model"]>) | undefined; | ||
export type SortDirection = 1 | -1 | "asc" | "desc" | "ascending" | "descending" | { | ||
$meta: string; | ||
}; | ||
export type Sort = string | Exclude<SortDirection, { | ||
$meta: string; | ||
}> | string[] | { | ||
[key: string]: SortDirection; | ||
} | Map<string, SortDirection> | [string, SortDirection][] | [string, SortDirection]; | ||
export type Filter = Record<string, any>; | ||
export type PopulatePath = string | { | ||
path: string; | ||
filter?: Filter; | ||
populate?: Populate; | ||
}; | ||
export type Populate = PopulatePath | PopulatePath[] | Record<string, any>; | ||
export type JSONQuery = { | ||
filter?: any; | ||
populate?: any; | ||
sort?: any; | ||
socket?: string; | ||
filter?: Filter; | ||
sort?: Sort; | ||
count?: boolean; | ||
@@ -41,2 +65,3 @@ ids?: string[]; | ||
pageSize?: number; | ||
populate?: Populate; | ||
}; | ||
@@ -215,1 +240,2 @@ export type AdapterFetcherModelDefinition<T extends typeof Model = typeof Model> = { | ||
export type IdentityString = string; | ||
export {}; |
@@ -7,3 +7,3 @@ module.exports = { | ||
clearMocks: true, | ||
modulePathIgnorePatterns: ["dist"], | ||
modulePathIgnorePatterns: ["dist", ".idea", "node_modules", "src/__jest__"], | ||
}; |
{ | ||
"name": "@graphand/core", | ||
"version": "0.3.16", | ||
"version": "0.4.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/graphand/core", |
@@ -1,1 +0,44 @@ | ||
export type ExecutorCtx = any; | ||
import { | ||
DefaultFieldBooleanDefinition, | ||
DefaultFieldDefinitionOptions, | ||
DefaultFieldIdDefinition, | ||
DefaultFieldTextDefinition, | ||
DefaultFieldRelationDefinition, | ||
DefaultFieldNumberDefinition, | ||
DefaultFieldDateDefinition, | ||
DefaultFieldJSONDefinition, | ||
FieldDefinitionOptions, | ||
} from "./types"; | ||
import FieldTypes from "./enums/field-types"; | ||
declare global { | ||
export type ExecutorCtx = any; | ||
export type FieldDefinitionId< | ||
D extends FieldDefinitionOptions<FieldTypes.ID> = DefaultFieldDefinitionOptions<FieldTypes.ID> | ||
> = DefaultFieldIdDefinition<D>; | ||
export type FieldDefinitionText< | ||
D extends FieldDefinitionOptions<FieldTypes.TEXT> = DefaultFieldDefinitionOptions<FieldTypes.TEXT> | ||
> = DefaultFieldTextDefinition<D>; | ||
export type FieldDefinitionBoolean< | ||
D extends FieldDefinitionOptions<FieldTypes.BOOLEAN> = DefaultFieldDefinitionOptions<FieldTypes.BOOLEAN> | ||
> = DefaultFieldBooleanDefinition<D>; | ||
export type FieldDefinitionNumber< | ||
D extends FieldDefinitionOptions<FieldTypes.NUMBER> = DefaultFieldDefinitionOptions<FieldTypes.NUMBER> | ||
> = DefaultFieldNumberDefinition<D>; | ||
export type FieldDefinitionDate< | ||
D extends FieldDefinitionOptions<FieldTypes.DATE> = DefaultFieldDefinitionOptions<FieldTypes.DATE> | ||
> = DefaultFieldDateDefinition<D>; | ||
export type FieldDefinitionJSON< | ||
D extends FieldDefinitionOptions<FieldTypes.JSON> = DefaultFieldDefinitionOptions<FieldTypes.JSON> | ||
> = DefaultFieldJSONDefinition<D>; | ||
export type FieldDefinitionRelation< | ||
D extends FieldDefinitionOptions<FieldTypes.RELATION> = DefaultFieldDefinitionOptions<FieldTypes.RELATION> | ||
> = DefaultFieldRelationDefinition<D>; | ||
} |
@@ -81,2 +81,1 @@ import Model from "./lib/Model"; | ||
export * from "./types"; | ||
export * from "./default-fields"; |
@@ -6,3 +6,2 @@ import Model from "./Model"; | ||
import Adapter from "./Adapter"; | ||
import { ExecutorCtx } from "../global"; | ||
import CoreError from "./CoreError"; | ||
@@ -9,0 +8,0 @@ import ErrorCodes from "../enums/error-codes"; |
@@ -22,3 +22,2 @@ import ModelEnvScopes from "../enums/model-env-scopes"; | ||
import Validator from "./Validator"; | ||
import { FieldDateDefinition, FieldIdDefinition } from "../fields"; | ||
import { | ||
@@ -34,3 +33,2 @@ createFieldFromDefinition, | ||
import ErrorCodes from "../enums/error-codes"; | ||
import { ExecutorCtx } from "../global"; | ||
@@ -58,12 +56,12 @@ class Model { | ||
@fieldDecorator(FieldTypes.ID) | ||
_id: FieldIdDefinition; | ||
_id: FieldDefinitionId; | ||
@fieldDecorator(FieldTypes.DATE) | ||
_createdAt: FieldDateDefinition; | ||
_createdAt: FieldDefinitionDate; | ||
@fieldDecorator(FieldTypes.IDENTITY) | ||
_createdBy; | ||
_createdBy: FieldDefinitionRelation; | ||
@fieldDecorator(FieldTypes.DATE) | ||
_updatedAt: FieldDateDefinition; | ||
_updatedAt: FieldDefinitionDate; | ||
@@ -389,3 +387,7 @@ @fieldDecorator(FieldTypes.IDENTITY) | ||
const i = this; | ||
return new PromiseModel([(resolve) => resolve(i)], this.model, this._id); | ||
return new PromiseModel( | ||
[(resolve) => resolve(i)], | ||
this.model, | ||
String(this._id) | ||
); | ||
} | ||
@@ -634,3 +636,3 @@ | ||
const ctx: ExecutorCtx = { ...(bindCtx || {}), adapter, fn, retryToken }; | ||
const ctx = { ...(bindCtx || {}), adapter, fn, retryToken } as ExecutorCtx; | ||
@@ -637,0 +639,0 @@ const hookPayloadBefore: HookCallbackArgs<"before", A, M> = { args, ctx }; |
@@ -8,3 +8,2 @@ import Model from "../lib/Model"; | ||
import ValidatorTypes from "../enums/validator-types"; | ||
import { FieldRelationDefinition, FieldTextDefinition } from "../fields"; | ||
import User from "./User"; | ||
@@ -34,15 +33,15 @@ import { ValidatorsDefinition } from "../types"; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
firstname: FieldTextDefinition; | ||
firstname: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
lastname: FieldTextDefinition; | ||
lastname: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
email: FieldTextDefinition; | ||
email: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
password: FieldTextDefinition; | ||
password: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.RELATION, { ref: "roles", multiple: false }) | ||
role: FieldRelationDefinition<{ | ||
role: FieldDefinitionRelation<{ | ||
model: Role; | ||
@@ -53,3 +52,3 @@ multiple: false; | ||
@fieldDecorator(FieldTypes.RELATION, { ref: "users", multiple: false }) | ||
user: FieldRelationDefinition<{ | ||
user: FieldDefinitionRelation<{ | ||
model: User; | ||
@@ -56,0 +55,0 @@ multiple: false; |
@@ -8,7 +8,2 @@ import Model from "../lib/Model"; | ||
import ValidatorTypes from "../enums/validator-types"; | ||
import { | ||
FieldBooleanDefinition, | ||
FieldJSONDefinition, | ||
FieldTextDefinition, | ||
} from "../fields"; | ||
@@ -31,6 +26,6 @@ @modelDecorator() | ||
@fieldDecorator(FieldTypes.TEXT) | ||
name: FieldTextDefinition; | ||
name: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
slug: FieldTextDefinition; | ||
slug: FieldDefinitionText; | ||
@@ -63,3 +58,3 @@ @fieldDecorator(FieldTypes.JSON, { | ||
}) | ||
fields: FieldJSONDefinition<FieldsDefinition>; | ||
fields: FieldDefinitionJSON<FieldsDefinition>; | ||
@@ -88,11 +83,11 @@ @fieldDecorator(FieldTypes.JSON, { | ||
}) | ||
validators: FieldJSONDefinition<ValidatorsDefinition>; | ||
validators: FieldDefinitionJSON<ValidatorsDefinition>; | ||
@fieldDecorator(FieldTypes.BOOLEAN, { default: false }) | ||
isPage: FieldBooleanDefinition; | ||
isPage: FieldDefinitionBoolean; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
configKey: FieldTextDefinition; | ||
configKey: FieldDefinitionText; | ||
} | ||
export default DataModel; |
@@ -6,3 +6,2 @@ import Model from "../lib/Model"; | ||
import FieldTypes from "../enums/field-types"; | ||
import { FieldRelationDefinition, FieldTextDefinition } from "../fields"; | ||
import ValidatorTypes from "../enums/validator-types"; | ||
@@ -30,3 +29,3 @@ import { ValidatorsDefinition } from "../types"; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
name: FieldTextDefinition; | ||
name: FieldDefinitionText; | ||
@@ -37,3 +36,3 @@ @fieldDecorator(FieldTypes.RELATION, { | ||
}) | ||
base: FieldRelationDefinition<{ | ||
base: FieldDefinitionRelation<{ | ||
model: Environment; | ||
@@ -40,0 +39,0 @@ multiple: false; |
@@ -6,3 +6,2 @@ import Model from "../lib/Model"; | ||
import FieldTypes from "../enums/field-types"; | ||
import { FieldRelationDefinition, FieldTextDefinition } from "../fields"; | ||
import { ValidatorsDefinition } from "../types"; | ||
@@ -29,9 +28,9 @@ import User from "./User"; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
name: FieldTextDefinition; | ||
name: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
slug: FieldTextDefinition; | ||
slug: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.RELATION, { ref: "users", multiple: true }) | ||
users: FieldRelationDefinition<{ | ||
users: FieldDefinitionRelation<{ | ||
model: User; | ||
@@ -38,0 +37,0 @@ multiple: true; |
@@ -7,7 +7,2 @@ import Model from "../lib/Model"; | ||
import Organization from "./Organization"; | ||
import { | ||
FieldNumberDefinition, | ||
FieldRelationDefinition, | ||
FieldTextDefinition, | ||
} from "../fields"; | ||
import Account from "./Account"; | ||
@@ -35,9 +30,9 @@ import { ValidatorsDefinition } from "../types"; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
name: FieldTextDefinition; | ||
name: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
slug: FieldTextDefinition; | ||
slug: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.TEXT, { default: "free" }) | ||
plan: FieldTextDefinition; | ||
plan: FieldDefinitionText; | ||
@@ -48,3 +43,3 @@ @fieldDecorator(FieldTypes.RELATION, { | ||
}) | ||
organization: FieldRelationDefinition<{ | ||
organization: FieldDefinitionRelation<{ | ||
model: Organization; | ||
@@ -55,6 +50,6 @@ multiple: false; | ||
@fieldDecorator(FieldTypes.NUMBER, { default: 86400 }) | ||
accessTokenLifetime: FieldNumberDefinition; | ||
accessTokenLifetime: FieldDefinitionNumber; | ||
@fieldDecorator(FieldTypes.NUMBER, { default: 2592000 }) | ||
refreshTokenLifetime: FieldNumberDefinition; | ||
refreshTokenLifetime: FieldDefinitionNumber; | ||
@@ -65,3 +60,3 @@ @fieldDecorator(FieldTypes.RELATION, { | ||
}) | ||
owner: FieldRelationDefinition<{ | ||
owner: FieldDefinitionRelation<{ | ||
model: Account; | ||
@@ -68,0 +63,0 @@ multiple: false; |
@@ -8,8 +8,2 @@ import Model from "../lib/Model"; | ||
import RuleActions from "../enums/rule-actions"; | ||
import { | ||
FieldBooleanDefinition, | ||
FieldJSONDefinition, | ||
FieldRelationDefinition, | ||
FieldTextDefinition, | ||
} from "../fields"; | ||
import ValidatorTypes from "../enums/validator-types"; | ||
@@ -32,6 +26,6 @@ | ||
@fieldDecorator(FieldTypes.TEXT) | ||
slug: FieldTextDefinition; | ||
slug: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.BOOLEAN) | ||
admin: FieldBooleanDefinition; | ||
admin: FieldDefinitionBoolean; | ||
@@ -42,3 +36,3 @@ @fieldDecorator(FieldTypes.RELATION, { | ||
}) | ||
inherits: FieldRelationDefinition<{ | ||
inherits: FieldDefinitionRelation<{ | ||
model: Role; | ||
@@ -69,3 +63,3 @@ multiple: true; | ||
}) | ||
rules: FieldJSONDefinition<Array<Rule>>; | ||
rules: FieldDefinitionJSON<Array<Rule>>; | ||
@@ -96,3 +90,3 @@ @fieldDecorator(FieldTypes.JSON, { | ||
}) | ||
fieldsRestrictions: FieldJSONDefinition<Array<FieldsRestriction>>; | ||
fieldsRestrictions: FieldDefinitionJSON<Array<FieldsRestriction>>; | ||
@@ -99,0 +93,0 @@ async getRulesInherited(): Promise<Array<Rule>> { |
@@ -7,7 +7,2 @@ import Model from "../lib/Model"; | ||
import Role from "./Role"; | ||
import { | ||
FieldDateDefinition, | ||
FieldRelationDefinition, | ||
FieldTextDefinition, | ||
} from "../fields"; | ||
import { ValidatorsDefinition } from "../types"; | ||
@@ -29,6 +24,6 @@ import ValidatorTypes from "../enums/validator-types"; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
name: FieldTextDefinition; | ||
name: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.DATE) | ||
expiration: FieldDateDefinition; | ||
expiration: FieldDefinitionDate; | ||
@@ -39,3 +34,3 @@ @fieldDecorator(FieldTypes.RELATION, { | ||
}) | ||
role: FieldRelationDefinition<{ | ||
role: FieldDefinitionRelation<{ | ||
model: Role; | ||
@@ -42,0 +37,0 @@ multiple: false; |
@@ -6,3 +6,2 @@ import Model from "../lib/Model"; | ||
import FieldTypes from "../enums/field-types"; | ||
import { FieldTextDefinition } from "../fields"; | ||
import ValidatorTypes from "../enums/validator-types"; | ||
@@ -32,8 +31,8 @@ import { ValidatorsDefinition } from "../types"; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
email: FieldTextDefinition; | ||
email: FieldDefinitionText; | ||
@fieldDecorator(FieldTypes.TEXT) | ||
password: FieldTextDefinition; | ||
password: FieldDefinitionText; | ||
} | ||
export default User; |
@@ -108,3 +108,3 @@ import Adapter from "./lib/Adapter"; | ||
const [first] = this.thisCache; | ||
const [first] = Array.from(this.thisCache); | ||
@@ -149,3 +149,3 @@ if (update.$set) { | ||
const [first] = this.thisCache; | ||
const [first] = Array.from(this.thisCache); | ||
this.thisCache.delete(first); | ||
@@ -152,0 +152,0 @@ return Promise.resolve(true); |
@@ -10,3 +10,4 @@ import Model from "./lib/Model"; | ||
import ValidationError from "./lib/ValidationError"; | ||
import { ExecutorCtx } from "./global"; | ||
import PromiseModel from "./lib/PromiseModel"; | ||
import PromiseModelList from "./lib/PromiseModelList"; | ||
@@ -42,7 +43,94 @@ export type DefaultFieldDefinitionOptions<T extends FieldTypes> = | ||
type PromiseModelOn<T extends Model> = PromiseModel<T> & {}; | ||
type string_ = string & Partial<any>; | ||
type FieldTextDefinitionSingleType< | ||
Options extends string[], | ||
Creatable extends boolean = true, | ||
DefaultType extends any = string_ | ||
> = Options extends string[] | ||
? Creatable extends false | ||
? Options[number] | ||
: FieldTextDefinitionSingleType<Options, false> | DefaultType | ||
: FieldTextDefinitionSingleType<[], Creatable, string>; | ||
export type DefaultFieldIdDefinition< | ||
D extends FieldDefinitionOptions<FieldTypes.ID> | ||
> = string; | ||
export type DefaultFieldTextDefinition< | ||
D extends FieldDefinitionOptions<FieldTypes.TEXT> | ||
> = | ||
| (D["multiple"] extends true | ||
? FieldTextDefinitionSingleType<D["options"], D["creatable"]>[] | ||
: FieldTextDefinitionSingleType<D["options"], D["creatable"]>) | ||
| undefined; | ||
export type DefaultFieldBooleanDefinition< | ||
D extends FieldDefinitionOptions<FieldTypes.BOOLEAN> | ||
> = boolean | undefined; | ||
export type DefaultFieldNumberDefinition< | ||
D extends FieldDefinitionOptions<FieldTypes.NUMBER> | ||
> = number | undefined; | ||
export type DefaultFieldDateDefinition< | ||
D extends FieldDefinitionOptions<FieldTypes.DATE> | ||
> = Date | undefined; | ||
export type DefaultFieldJSONDefinition< | ||
D extends FieldDefinitionOptions<FieldTypes.JSON> | ||
> = D | any | undefined; | ||
export type DefaultFieldRelationDefinition< | ||
D extends FieldDefinitionOptions<FieldTypes.RELATION> | ||
> = | ||
| (D["multiple"] extends true | ||
? ModelList<D["model"]> | PromiseModelList<D["model"]> | ||
: D["model"] | PromiseModelOn<D["model"]>) | ||
| undefined; | ||
export type SortDirection = | ||
| 1 | ||
| -1 | ||
| "asc" | ||
| "desc" | ||
| "ascending" | ||
| "descending" | ||
| { | ||
$meta: string; | ||
}; | ||
export type Sort = | ||
| string | ||
| Exclude< | ||
SortDirection, | ||
{ | ||
$meta: string; | ||
} | ||
> | ||
| string[] | ||
| { | ||
[key: string]: SortDirection; | ||
} | ||
| Map<string, SortDirection> | ||
| [string, SortDirection][] | ||
| [string, SortDirection]; | ||
export type Filter = Record<string, any>; | ||
export type PopulatePath = | ||
| string | ||
| { | ||
path: string; | ||
filter?: Filter; | ||
populate?: Populate; | ||
}; | ||
export type Populate = PopulatePath | PopulatePath[] | Record<string, any>; | ||
export type JSONQuery = { | ||
filter?: any; | ||
populate?: any; | ||
sort?: any; | ||
socket?: string; | ||
filter?: Filter; | ||
sort?: Sort; | ||
count?: boolean; | ||
@@ -54,2 +142,3 @@ ids?: string[]; | ||
pageSize?: number; | ||
populate?: Populate; | ||
}; | ||
@@ -56,0 +145,0 @@ |
@@ -18,3 +18,4 @@ { | ||
"preserveConstEnums": true, | ||
"declarationDir": "dist/types" | ||
"declarationDir": "dist/types", | ||
"downlevelIteration": true, | ||
}, | ||
@@ -21,0 +22,0 @@ "include": ["src"], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
293206
8418
122