Skip to content

Commit

Permalink
build(deps): use @flex-development/[email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
unicornware committed May 25, 2021
1 parent 690f797 commit 36e4e21
Show file tree
Hide file tree
Showing 34 changed files with 144 additions and 130 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Documentation can be viewed [here](src/plugins/mango-finder.plugin.ts).
* @template Q - Parsed URL query object
*/
export interface IMangoFinder<
D extends PlainObject = PlainObject,
D extends ObjectPlain = ObjectPlain,
U extends string = DUID,
P extends MangoSearchParams<D> = MangoSearchParams<D>,
Q extends MangoParsedUrlQuery<D> = MangoParsedUrlQuery<D>
Expand Down Expand Up @@ -233,7 +233,7 @@ Documentation can be viewed [here](src/repositories/mango.repository.ts).
* @template Q - Parsed URL query object
*/
export interface IMangoRepository<
E extends PlainObject = PlainObject,
E extends ObjectPlain = ObjectPlain,
U extends string = DUID,
P extends MangoSearchParams<E> = MangoSearchParams<E>,
Q extends MangoParsedUrlQuery<E> = MangoParsedUrlQuery<E>
Expand Down Expand Up @@ -361,13 +361,13 @@ Documentation can be viewed [here](src/mixins/mango-validator.mixin.ts).
*
* @template E - Entity
*/
export interface IMangoValidator<E extends PlainObject = PlainObject> {
export interface IMangoValidator<E extends ObjectPlain = ObjectPlain> {
readonly enabled: boolean
readonly model: ClassType<E>
readonly tvo: Omit<MangoValidatorOptions, 'enabled'>
readonly validator: typeof transformAndValidate

check<V extends unknown = PlainObject>(value?: V): Promise<E | V>
check<V extends unknown = ObjectPlain>(value?: V): Promise<E | V>
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"@flex-development/exceptions": "2.0.0",
"@flex-development/tutils": "1.0.0",
"@flex-development/tutils": "3.0.0",
"@types/debug": "4.1.5",
"@types/lodash.isboolean": "3.0.6",
"@types/lodash.isempty": "4.4.6",
Expand Down
11 changes: 5 additions & 6 deletions src/dtos/create-entity.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { DUID } from '@/types'
import type { PartialBy, PlainObject } from '@flex-development/tutils'
import type { DeepPick, ObjectPlain, Path } from '@flex-development/tutils'

/**
* @file Data Transfer Objects - CreateEntityDTO
Expand All @@ -10,9 +9,9 @@ import type { PartialBy, PlainObject } from '@flex-development/tutils'
* Data used to create a new entity.
*
* @template E - Entity
* @template U - Name of entity uid field
* @template P - Object paths of dto
*/
export type CreateEntityDTO<
E extends PlainObject = PlainObject,
U extends string = DUID
> = PartialBy<E, U>
E extends ObjectPlain = ObjectPlain,
P extends Path<E> = Path<E>
> = DeepPick<E, P>
11 changes: 6 additions & 5 deletions src/dtos/entity.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DUID } from '@/types'
import type { PlainObject } from '@flex-development/tutils'
import type { ObjectPlain, Path } from '@flex-development/tutils'
import type { CreateEntityDTO } from './create-entity.dto'
import type { PatchEntityDTO } from './patch-entity.dto'

Expand All @@ -12,9 +12,10 @@ import type { PatchEntityDTO } from './patch-entity.dto'
* Data used to create or patch an entity.
*
* @template E - Entity
* @template U - Name of entity uid field
* @template P - Object paths of `CreateEntityDTO` | `PatchEntityDTO`
*/
export type EntityDTO<
E extends PlainObject = PlainObject,
U extends string = DUID
> = CreateEntityDTO<E, U> | PatchEntityDTO<E, U>
E extends ObjectPlain = ObjectPlain,
// @ts-expect-error default uid field for documents
P extends Path<E> = DUID
> = CreateEntityDTO<E, P> | PatchEntityDTO<E, P>
4 changes: 2 additions & 2 deletions src/dtos/mango-finder-options.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MangoFinderOptions } from '@/interfaces'
import type { DUID } from '@/types'
import type { PlainObject } from '@flex-development/tutils'
import type { ObjectPlain } from '@flex-development/tutils'

/**
* @file Data Transfer Object - MangoFinderOptionsDTO
Expand All @@ -14,7 +14,7 @@ import type { PlainObject } from '@flex-development/tutils'
* @template U - Name of document uid field
*/
export interface MangoFinderOptionsDTO<
D extends PlainObject = PlainObject,
D extends ObjectPlain = ObjectPlain,
U extends string = DUID
> {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/dtos/mango-repo-options.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MangoRepoOptions } from '@/interfaces'
import type { DUID } from '@/types'
import type { PlainObject } from '@flex-development/tutils'
import type { ObjectPlain } from '@flex-development/tutils'
import type { MangoFinderOptionsDTO } from './mango-finder-options.dto'

/**
Expand All @@ -15,7 +15,7 @@ import type { MangoFinderOptionsDTO } from './mango-finder-options.dto'
* @template U - Name of entity uid field
*/
export interface MangoRepoOptionsDTO<
E extends PlainObject = PlainObject,
E extends ObjectPlain = ObjectPlain,
U extends string = DUID
> extends MangoFinderOptionsDTO<E, U> {
/**
Expand Down
12 changes: 5 additions & 7 deletions src/dtos/patch-entity.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { DUID } from '@/types'
import type { PlainObject } from '@flex-development/tutils'
import type { CreateEntityDTO } from './create-entity.dto'
import type { DeepPick, ObjectPlain, Path } from '@flex-development/tutils'

/**
* @file Data Transfer Objects - PatchEntityDTO
Expand All @@ -11,9 +9,9 @@ import type { CreateEntityDTO } from './create-entity.dto'
* Data used to patch an entity.
*
* @template E - Entity
* @template U - Name of entity uid field
* @template P - Object paths of dto
*/
export type PatchEntityDTO<
E extends PlainObject = PlainObject,
U extends string = DUID
> = Partial<CreateEntityDTO<E, U>>
E extends ObjectPlain = ObjectPlain,
P extends Path<E> = Path<E>
> = Partial<DeepPick<E, P>>
4 changes: 2 additions & 2 deletions src/interfaces/accumulator-operators.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Expression } from '@/types'
import type { UnknownObject } from '@flex-development/tutils'
import type { ObjectPlain } from '@flex-development/tutils'
import type { CustomAccumulator } from './custom-accumulator.interface'

/**
Expand All @@ -15,7 +15,7 @@ import type { CustomAccumulator } from './custom-accumulator.interface'
* [1]: https://docs.mongodb.com/manual/reference/operator/aggregation/#accumulators---group-
* [2]: https://docs.mongodb.com/manual/reference/operator/aggregation/group
*/
export interface AccumulatorOperators<D extends UnknownObject = UnknownObject> {
export interface AccumulatorOperators<D extends ObjectPlain = ObjectPlain> {
/**
* Returns the result of a user-defined accumulator function.
*
Expand Down
8 changes: 6 additions & 2 deletions src/interfaces/aggregation-operators.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { BSONTypeAlias } from '@/enums/bson-type-alias.enum'
import { BSONTypeCode } from '@/enums/bson-type-code.enum'
import type { Expression } from '@/types'
import type { JSONValue, UnknownObject } from '@flex-development/tutils'
import type {
JSONValue,
ObjectPlain,
ObjectUnknown
} from '@flex-development/tutils'
import type { AccumulatorOperators } from './accumulator-operators.interface'
import type { CustomAccumulator } from './custom-accumulator.interface'

Expand All @@ -19,7 +23,7 @@ import type { CustomAccumulator } from './custom-accumulator.interface'
*
* [1]: https://docs.mongodb.com/manual/reference/operator/aggregation/#alphabetical-listing-of-expression-operators
*/
export interface AggregationOperators<D extends UnknownObject = UnknownObject>
export interface AggregationOperators<D extends ObjectPlain = ObjectUnknown>
extends AccumulatorOperators<D> {
/**
* Support package users loading additional operators.
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/aggregation-stages.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
ProjectStage,
QueryCriteria
} from '@/types'
import type { OneOrMany, PlainObject } from '@flex-development/tutils'
import type { ObjectPlain, OneOrMany } from '@flex-development/tutils'
import type { RawObject } from 'mingo/util'
import type { AccumulatorOperators } from './accumulator-operators.interface'
import type { BucketStageAuto } from './bucket-stage-auto.interface'
Expand All @@ -25,7 +25,7 @@ import type { QueryOperators } from './query-operators.interface'
*
* [1]: https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline
*/
export interface AggregationStages<D extends PlainObject = PlainObject> {
export interface AggregationStages<D extends ObjectPlain = ObjectPlain> {
/**
* Adds new fields to documents.
*
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/bucket-stage-auto.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UnknownObject } from '@flex-development/tutils'
import type { ObjectPlain } from '@flex-development/tutils'
import type { BucketStage } from './bucket-stage.interface'

/**
Expand All @@ -13,7 +13,7 @@ import type { BucketStage } from './bucket-stage.interface'
*
* [1]: https://docs.mongodb.com/manual/reference/operator/aggregation/bucketAuto
*/
export interface BucketStageAuto<D extends UnknownObject = UnknownObject>
export interface BucketStageAuto<D extends ObjectPlain = ObjectPlain>
extends Pick<BucketStage<D>, 'groupBy' | 'output'> {
/**
* A positive 32-bit integer that specifies the number of buckets into which
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/bucket-stage.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Expression } from '@/types'
import type { NumberString, UnknownObject } from '@flex-development/tutils'
import type { NumberString, ObjectPlain } from '@flex-development/tutils'
import type { AccumulatorOperators } from './accumulator-operators.interface'

/**
Expand All @@ -14,7 +14,7 @@ import type { AccumulatorOperators } from './accumulator-operators.interface'
*
* [1]: https://docs.mongodb.com/manual/reference/operator/aggregation/bucket
*/
export interface BucketStage<D extends UnknownObject = UnknownObject> {
export interface BucketStage<D extends ObjectPlain = ObjectPlain> {
/**
* An array of values based on the `groupBy` expression that specify the
* boundaries for each bucket.
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/mango-cache-finder.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PlainObject } from '@flex-development/tutils'
import type { ObjectPlain } from '@flex-development/tutils'

/**
* @file Interface - MangoCacheFinder
Expand All @@ -10,6 +10,6 @@ import type { PlainObject } from '@flex-development/tutils'
*
* @template D - Document (collection object)
*/
export interface MangoCacheFinder<D extends PlainObject = PlainObject> {
export interface MangoCacheFinder<D extends ObjectPlain = ObjectPlain> {
readonly collection: Readonly<D[]>
}
4 changes: 2 additions & 2 deletions src/interfaces/mango-cache-repo.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RepoRoot } from '@/types'
import type { PlainObject } from '@flex-development/tutils'
import type { ObjectPlain } from '@flex-development/tutils'
import type { MangoCacheFinder } from './mango-cache-finder.interface'

/**
Expand All @@ -12,7 +12,7 @@ import type { MangoCacheFinder } from './mango-cache-finder.interface'
*
* @template E - Entity
*/
export interface MangoCacheRepo<E extends PlainObject = PlainObject>
export interface MangoCacheRepo<E extends ObjectPlain = ObjectPlain>
extends MangoCacheFinder<E> {
root: RepoRoot<E>
}
4 changes: 2 additions & 2 deletions src/interfaces/mango-finder-options.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DUID } from '@/types'
import type { PlainObject } from '@flex-development/tutils'
import type { ObjectPlain } from '@flex-development/tutils'
import type { MangoParserOptions } from './mango-parser-options.interface'
import type { MingoOptions } from './mingo-options.interface'

Expand All @@ -15,7 +15,7 @@ import type { MingoOptions } from './mingo-options.interface'
* @template U - Name of document uid field
*/
export interface MangoFinderOptions<
D extends PlainObject = PlainObject,
D extends ObjectPlain = ObjectPlain,
U extends string = DUID
> {
/**
Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/mango-finder.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import type {
UID
} from '@/types'
import type {
ObjectPlain,
OneOrMany,
OrPromise,
PlainObject
OrPromise
} from '@flex-development/tutils'
import type { Debugger } from 'debug'
import mingo from 'mingo'
Expand All @@ -35,7 +35,7 @@ import type { IMangoParser } from './mango-parser.interface'
* @template Q - Parsed URL query object
*/
export interface IMangoFinder<
D extends PlainObject = PlainObject,
D extends ObjectPlain = ObjectPlain,
U extends string = DUID,
P extends MangoSearchParams<D> = MangoSearchParams<D>,
Q extends MangoParsedUrlQuery<D> = MangoParsedUrlQuery<D>
Expand Down
6 changes: 4 additions & 2 deletions src/interfaces/mango-parser-options.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DocumentPath } from '@/types'
import type { OneOrMany, UnknownObject } from '@flex-development/tutils'
import type { ObjectUnknown, OneOrMany } from '@flex-development/tutils'
import type { CustomQSMongoParser } from './custom-qs-mongo-parser.interface'

/**
Expand All @@ -17,7 +17,9 @@ import type { CustomQSMongoParser } from './custom-qs-mongo-parser.interface'
*
* [1]: https://github.com/fox1t/qs-to-mongo#options
*/
export interface MangoParserOptions<D extends UnknownObject = UnknownObject> {
export interface MangoParserOptions<
D extends Record<string, unknown> = ObjectUnknown
> {
/**
* Fields that will be converted to `Date`. If no fields are passed, any valid
* date string will be converted to [ISOString][1].
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/mango-parser.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MangoParsedUrlQuery, MangoSearchParams } from '@/types'
import type { UnknownObject } from '@flex-development/tutils'
import type { ObjectUnknown } from '@flex-development/tutils'
import qsm from 'qs-to-mongo'
import type { ParsedOptions } from 'qs-to-mongo/lib/query/options-to-mongo'
import type { MangoParserOptions } from './mango-parser-options.interface'
Expand All @@ -15,7 +15,7 @@ import type { QueryCriteriaOptions } from './query-criteria-options.interface'
*
* @template D - Document (collection object)
*/
export interface IMangoParser<D extends UnknownObject = UnknownObject> {
export interface IMangoParser<D extends ObjectUnknown = ObjectUnknown> {
readonly parser: typeof qsm
readonly options: MangoParserOptions<D>

Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/mango-repo-options.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DUID } from '@/types'
import type { PlainObject } from '@flex-development/tutils'
import type { ObjectPlain } from '@flex-development/tutils'
import type { MangoFinderOptions } from './mango-finder-options.interface'
import type { MangoValidatorOptions } from './mango-validator-options.interface'

Expand All @@ -15,7 +15,7 @@ import type { MangoValidatorOptions } from './mango-validator-options.interface'
* @template U - Name of entity uid field
*/
export interface MangoRepoOptions<
E extends PlainObject = PlainObject,
E extends ObjectPlain = ObjectPlain,
U extends string = DUID
> extends MangoFinderOptions<E, U> {
/**
Expand Down
15 changes: 10 additions & 5 deletions src/interfaces/mango-repo.interface.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { CreateEntityDTO, EntityDTO, PatchEntityDTO } from '@/dtos'
import type { DUID, MangoParsedUrlQuery, MangoSearchParams, UID } from '@/types'
import type {
ObjectPlain,
OneOrMany,
OrPromise,
PlainObject
Path
} from '@flex-development/tutils'
import type { ClassType } from 'class-transformer-validator'
import type { MangoCacheRepo } from './mango-cache-repo.interface'
Expand All @@ -25,7 +26,7 @@ import type { IMangoValidator } from './mango-validator.interface'
* @template Q - Parsed URL query object
*/
export interface IMangoRepository<
E extends PlainObject = PlainObject,
E extends ObjectPlain = ObjectPlain,
U extends string = DUID,
P extends MangoSearchParams<E> = MangoSearchParams<E>,
Q extends MangoParsedUrlQuery<E> = MangoParsedUrlQuery<E>
Expand All @@ -36,10 +37,14 @@ export interface IMangoRepository<
readonly validator: IMangoValidator<E>

clear(): OrPromise<boolean>
create(dto: CreateEntityDTO<E, U>): OrPromise<E>
create<W extends Path<E>>(dto: CreateEntityDTO<E, W>): OrPromise<E>
delete(uid: OneOrMany<UID>, should_exist?: boolean): OrPromise<UID[]>
euid(): string
patch(uid: UID, dto: PatchEntityDTO<E, U>, rfields?: string[]): OrPromise<E>
patch<W extends Path<E>>(
uid: UID,
dto: PatchEntityDTO<E, W>,
rfields?: string[]
): OrPromise<E>
resetCache(collection?: E[]): OrPromise<MangoCacheRepo<E>>
save(dto: OneOrMany<EntityDTO<E, U>>): OrPromise<E[]>
save<W extends Path<E>>(dto: OneOrMany<EntityDTO<E, W>>): OrPromise<E[]>
}
Loading

0 comments on commit 36e4e21

Please sign in to comment.