Skip to content

Commit

Permalink
chore: refactor proxy builder name
Browse files Browse the repository at this point in the history
BREAKING CHANGE: roll the next major to cause a clean cutover
  • Loading branch information
pleb committed Aug 11, 2022
1 parent d6487d4 commit e37d413
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Then define a builder for that model
```ts
import { randomElement, randomNumberBetween, randomString } from '@makerx/ts-dossier'
import { DataBuilder, proxyBuilder } from '@makerx/ts-dossier'
import { DataBuilder, dossierProxy } from '@makerx/ts-dossier'
import { Shape } from './shape'

class ShapeBuilder extends DataBuilder<Shape> {
Expand All @@ -49,7 +49,7 @@ class ShapeBuilder extends DataBuilder<Shape> {
}
}

export const shapeBuilder = proxyBuilder<ShapeBuilder, Shape>(ShapeBuilder)
export const shapeBuilder = dossierProxy<ShapeBuilder, Shape>(ShapeBuilder)
```

Then define a mother to build known models for testing
Expand Down
8 changes: 4 additions & 4 deletions src/data-builder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepClone } from './deep-clone'

/**
* Data builder is an abstract class builders can inherit to make working with the {@linkplain proxyBuilder} easier.
* Data builder is an abstract class builders can inherit to make working with the {@linkplain dossierProxy} easier.
*
* ```typescript
* export class ShapeBuilder extends DataBuilder<Shape> {
Expand All @@ -18,7 +18,7 @@ import { deepClone } from './deep-clone'
* }
* }
*
* export const shapeBuilder = proxyBuilder<ShapeBuilder, Shape>(ShapeBuilder)
* export const shapeBuilder = dossierProxy<ShapeBuilder, Shape>(ShapeBuilder)
* ```
*/
export abstract class DataBuilder<T> {
Expand Down Expand Up @@ -89,15 +89,15 @@ type DynamicDataBuilder<TDataBuilder, TData extends object> = TDataBuilder & Wit
* }
* }
*
* const shapeBuilder = proxyBuilder<ShapeBuilder, Shape>(ShapeBuilder)
* const shapeBuilder = dossierProxy<ShapeBuilder, Shape>(ShapeBuilder)
*
* const shape = shapeBuilder().withName('Square').withSides(4).withColour('Red').build()
*
* console.log(shape) // Outputs { name: 'Square Intercepted', sides: 4, colour: 'Red' }
* ```
* @param builder The constructor to call to create a new instance of the builder.
*/
export function proxyBuilder<TDataBuilder, TData extends object>(builder: {
export function dossierProxy<TDataBuilder, TData extends object>(builder: {
new (): TDataBuilder
}): () => DynamicDataBuilder<TDataBuilder, TData> {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { DataBuilder, proxyBuilder } from './data-builder'
export { DataBuilder, dossierProxy } from './data-builder'
export {
randomDate,
randomDateBetween,
Expand Down
4 changes: 2 additions & 2 deletions test/builder/mongoose-model-builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataBuilder, proxyBuilder, randomString } from '../../src'
import { DataBuilder, dossierProxy, randomString } from '../../src'
import { MongooseModel } from '../model/mongoose-model'
import { Types } from 'mongoose'

Expand All @@ -15,4 +15,4 @@ export class MongooseModelBuilder extends DataBuilder<MongooseModel> {
}
}

export const mongooseModelBuilder = proxyBuilder<MongooseModelBuilder, MongooseModel>(MongooseModelBuilder)
export const mongooseModelBuilder = dossierProxy<MongooseModelBuilder, MongooseModel>(MongooseModelBuilder)
4 changes: 2 additions & 2 deletions test/builder/shape-builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataBuilder, proxyBuilder, randomElement, randomNumberBetween, randomString } from '../../src'
import { DataBuilder, dossierProxy, randomElement, randomNumberBetween, randomString } from '../../src'
import { Shape } from '../model/shape'

export class ShapeBuilder extends DataBuilder<Shape> {
Expand All @@ -15,4 +15,4 @@ export class ShapeBuilder extends DataBuilder<Shape> {
}
}

export const shapeBuilder = proxyBuilder<ShapeBuilder, Shape>(ShapeBuilder)
export const shapeBuilder = dossierProxy<ShapeBuilder, Shape>(ShapeBuilder)
2 changes: 1 addition & 1 deletion website-generator.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": null,
"description": null,
"gitHubUrl": null,
"soeTags": ["MakerX", "Dossier", "TypeScript", "TS", "Object-Mother", "Data-Builder"],
"soeTags": null,
"miscellaneousPages": null,
"codeDocs": {
"path": "/code-docs"
Expand Down

0 comments on commit e37d413

Please sign in to comment.