Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(attributes)!: moved constructor logic into create method #188

Merged
merged 34 commits into from
Jan 28, 2022

Conversation

nandi95
Copy link
Collaborator

@nandi95 nandi95 commented Jan 28, 2022

πŸ”— Linked issue

#187

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

nandi95 and others added 30 commits October 28, 2021 16:28
## Fix
* fix: added the expected type key to `isObjectLiteral`  method
* fix: added type argument to `Arrayable` interface
* fix(model-collection): added missing toArray call
  * Issue stemming from not adding the call in the refactor commit
    bb8817c
* fix(internal): fix `_relationType` type
* fix: fixed typing issue from MaybeArray update
    * commit: 8369c5e

## Refactor
* refactor: updated `_allAreObjects` method to use existing helper
* refactor(deps-dev): use jest timers
  * removed jest-date-mock and use the jest built in fake timers
* refactor(deps-dev): use jest timers
  * committing missing logic from previous commit
* refactor(deps-dev): use jest timers
  * committing missing logic from previous commit
* refactor(model-collection)!: made internal methods more predictable
  * These methods are protected so should not be breaking but marking it as such just in case
* refactor(model): simplify replicate method

## Feature
* feat(services): made API accept a promise from initRequest method
* feat(model): improved return typing of `replicate` and `find`
* feat(api-calls): added requestMiddleware
    * This allows for transforming the requests before being passed to the ApiCaller
* feat(relations): `for` method now accepts model constructors
* feat: added utility types
* feat: exported utility types
* feat: added ExtractArguments and DeepPartial type utility types
* feat(events): added event emitter
    * Resolves upfrontjs#23
* feat(collection): added overrides for more exact type inference
* feat(relations): updated argument option of `addRelation` method
    * Added model array as possible argument
* feat(relations): add argument type to `addRelation` method
  * Added Collection of models as a possible argument type

## Documentation
* docs: correct some inaccuracies
* docs: fixed toc
* docs: removed duplication
* docs: fixed small documentation issues
* docs: added teaser code example
* docs: added link to releases page as change-log

## Test
* test(internal): simplified test helper
* test(model-collection): use types for testing `isModelCollection`
* test: added more test types to the helper array
## Style
* style: small inconsequential changes
  * spacing
  * property description
  * removed debugging log
* style: fixed eslint issues
* style: ignored eslint issues

## Chore
* chore(deps-dev): updated dependencies
  * @commitlint/config-conventional
  * @commitlint/prompt-cli
  * @commitlint/types
  * @semantic-release/git
  * @types/lodash
  * @types/semantic-release
  * @typescript-eslint/eslint-plugin
  * @typescript-eslint/parser
  * commitlint
  * eslint-plugin-jest
  * rollup
  * semantic-release
  * typedoc
* chore: incremented version
* chore(deps-dev): updated dependencies
  * @commitlint/prompt-cli
  * @rollup/plugin-typescript
  * @types/lodash
  * @typescript-eslint/eslint-plugin
  * @typescript-eslint/parser
  * commitlint
  * eslint-plugin-import
  * eslint-plugin-jest
  * husky
  * lint-staged
  * typedoc
  * typescript
* chore: updated bug issue template
* chore(deps-dev): updated dependencies
  * lint-staged
  * rollup
  * typedoc
  
## Refactor
* refactor: updated arguments to use MaybeArray utility type
## Docs
* docs: fix incorrect info
* docs: added recipe
  * Example on how to extend the model
* docs(services): updated ApiResponseHandler signatures
  Changes missed in:
  1e0b58f
* docs: added remote pagination to recipes
* docs: clarified back-end compatibility
* docs: extended recipe with static method
* docs: simplified examples
* docs: added supporter section
* docs: added clarifications
* docs: added typescript tip for ApiResponse
  * Showed how to use module augmentation to extend the ApiResponse
* docs: added reference to module augmentation docs
* docs: added clarification
* docs(attributes): added missing comma
* docs: updated cookbook example to be more comprehensive


## Chore
* chore: converted todo into an issue
* chore: fixed .gitignore targeting
* chore(deps-dev): updated dependencies
  * @semantic-release/git
  * @types/semantic-release
  * eslint-plugin-import
  * rollup
  * typedoc
* chore: incremented version
* chore: fixed incorrect bug report yml file
* chore: added pull request template
* chore: added search terms to the bug report template
* chore: moved todo out into an issue
  * linked @upfrontjs/frameworkupfrontjs#151
* chore(deps-dev): updated non breaking dependencies
  * typescript
  * typedoc
  * rollup
  * semantic-release
  * @types/lodash
  * @types/uuid
* chore(deps-dev): updated breaking dependencies
  * @typescript-eslint/eslint-plugin
  * @typescript-eslint/parser
  * eslint
  * eslint-plugin-jest
  * @commitlint/config-conventional
  * @commitlint/prompt-cli
  * @commitlint/types
  * lint-staged
* chore(deps-dev): updated dependencies
  * @typescript-eslint/eslint-plugin
  * @typescript-eslint/parser
  * eslint
  * qs
  * rollup
  * commitlint
* chore(deps-dev): lock typescript to 4.4.4
  * Locking for the time being as 4.5.2 breaks the global config set typing.
  * The type is meant to be widened by the passed in value but,
  * on get it reckons it's an unknown value
## Feature
* feat(query-builder): widened `formatQueryParameters` argument's type 
  * added string indexing to allow arbitrary values to be assigned to `parameters` argument
* feat(api-calls): added type argument to handle and call methods
* feat(services)!: updated handling of non 200 responses
  * Throw response/error on client and server errors
  * Ignore informational, redirect and no content responses
* feat(api-calls): added data unwrapping
* feat(query-builder): added `page` method
* feat(query-builder): hardened type handling of numeric query parameters
* feat: added more utility types
  * Added KeysMatching and KeysNotMatching types
* feat(global-config): updated type argument to accept arbitrary values
* feat(attributes): added type support for keys defined on the model
* feat(attributes): added missing type arguments
  * 7cf3ca6
* feat(api-calls)!: set _lastSyncedAt to cast to the set datetime value
* feat: wip - worked on type inference of attributes
* feat: added type arguments where applicable
* feat!: updated `Jsonable` to return a json as opposed to string
  * The naming intended to return a json not a string.
  * Stringified version is only meant for saving or transferring data
* feat(internal): added type arguments to methods in ModelCollection
* feat(model): added toString method to the model
  * This will give a understandable format when juggling types
* feat: added UnionToIntersection helper type
* feat(query-builder): added type argument for static methods
* feat(attributes): added `setServerStringCase` internal helper
* feat(api-calls)!: moved data unwrapping into dedicated method
  * This way the user gets the the raw response exposed while utilising the model's call method
  * Furthermore as this is now public and all methods called them anyways,
  * moved the resetEndpoint and resetQueryParameters methods into the call method
* feat(model): added `new` method
  * With this the user don't have to leave the model to construct a new instance.

## Test
* test(internal): simplified test response customisation
* test: increased test coverage
* test(events): increased test coverage of EventEmitter
* test: fixed type-hinting in test
* test: fixed failing query building tests
* test: fixed failing type in test

#Refactor
* refactor(internal): simplified getting the response model
* refactor(attributes)!: from casting method removed attributes argument
  * Technically breaking change but it's is considered an internal method.
* refactor(attributes): simplified date time casting
  * casting to date time logic has been moved into a single method
  * Furthermore, when using the built in Date, an error will be thrown on invalid values
* refactor(helpers)!: renamed `isConstructableUserClass` function
  * `isUserLandClass` seems shorter while keeping the meaning
* refactor(events): updated to use built-in Parameters type

## Fix
* fix(services)!: removed data unwrapping from `ApiResponseHandler`
  * Response may include other keys such as `links`, `meta`
  and with the previous logic this would have been lost
* fix(timestamps): access attribute name dynamically
  * Updated accessing timestamp names from class reference to constructor reference
* fix(attributes): `set` on AttributeCaster have to return a value
  * This isn't a breaking change as `void` is assignable to `unknown`  
* fix(attributes)!: set index signature to `unknown`
  * Harden the user's type safety by updating from any to unknown
* fix(attributes): resolved remaining typing issues
  * Fixed lingering issues missed in:
  * 66f5631
* fix!: fix `getName` returning wrong value after mangling for production
  * This isn't a breaking change but marking as such so people who do keep up with the release notes
    will not accidentally skim over it.
* fix: removed unnecessary properties from ApiResponse type
  * This might be breaking typing for people using non-null assertion on Response properties
* fix!: remove redundant ExtractArguments type
  * This is can be replaced by the built-in Parameters type
* fix(query-builder)!: updated built-in column name casting
  * Fixed the column names to be in the expected serverAttributeCasing

## Continuous Integration
* ci: adjust names and remove redundant cache actions
* ci: ensure package is tested on the latest and LTS versions
* ci: removed unnecessary argument
* ci: run tests run on package updates too
* ci: renamed action's name
* ci: added api docs deployment action
* ci: ensure both commit messages and PR titles are linted

## Performance
* perf(model): improved `replicate` logic
  * with 1 warm up run, over 4 tries with 100,000 loops the average time:
  * with arguments: decreased by 177ms
  * without arguments: increased 20.75ms

## Style
* style(attributes): removed unused code
## Feature
* feat(model): added `clone` method

## Fix
* fix(model): added missing argument type to the `new` method

## Documentaion
* docs: fixed documentation inaccuracies
* docs: added missing `call` documentation
* docs(relations): updated wording of internal property
* docs: added missing type arguments in examples

## Chore
* chore(deps-dev): updated dependencies
  * @types/lodash
  * rollup
* chore: incremented version
* chore: fix bug_report yml
## Docs
* docs: fix/add missing updates
* docs: small updates

## Chore
* chore: updated issue templates
* chore(deps-dev): updated typescript version
* chore(deps-dev): updated dependencies
    * @typescript-eslint/eslint-plugin
    * @typescript-eslint/parser
    * eslint
    * lint-staged
    * rollup
    * typescript
* chore: incremented package version

## Fix
* fix(api-calls)!: updated multi word model endpoint guessing
* fix(global-config): fixed `set` typing
    * Overloads also greatly simplified the signature

## CI
* ci: force staging of files
## Fix
* fix: updated distinct to match sql syntax

## Chore
* chore(deps-dev): updated non-breaking dependencies
  * @typescript-eslint/eslint-plugin
  * @typescript-eslint/parser
  * eslint
  * eslint-plugin-import
  * eslint-plugin-jest
  * lint-staged
  * rollup
* chore(deps-dev): updated breaking dependencies
* chore: incremented package version

## Style
* style: fixed eslint warnings

## Performance
* perf(model): removed redundant object in assignment

## Docs
* docs: fixed example's return type
## Docs
* docs: updated pagination recipe
* docs: corrected pagination example
  * The exists method has taken the `_lastSyncedAt` property into account and here it was not set before
* docs: adjust wording in doc blocks
* docs(services): noted `handleError` is now async
* docs(query-builder): added documentation for `resetQueryParameters`
* docs: fixed grammar mistakes
* docs(factory): updated examples to be in-line with mocks
* docs(api-calls): updated methods to preferred uppercase
* docs: updated recipe to use the new typing
* docs(timestamps): updated attribute name getter method names
    * Linked: 114176e
* docs: fixed typo in test name
* docs: updated pagination recipe to handle model constructors
* docs(api-calls): updated to uppercase method names
  * Updated all method argument to `call` to uppercase for consistency
* docs: fixed examples
* docs(api-calls): updated method name to uppercase
  * change missed from 03486f1

## Perf
* perf(query-builder): simplified withs deduplication

## Feature
* feat(services): made handleError async on ApiResponseHandler
* feat(api-calls): added default type argument
  * While this is invalid, from the outside TS still figures the current `this` correctly
* feat(query-builder): changed `resetQueryParameters` access to public
* feat(api-calls): export `Method` type
* feat(services): widened request type on ApiResponse
* feat(services): added HEAD request handling
* feat(services): improve typings of services call and handle method
* feat(attributes): improved `Attributes` type inference
    * Resolves upfrontjs#154
* feat(attributes): improved `only` method's typing
* feat(attributes): improved `except` typing
* feat(attributes): improved typings on attribute management methods
    * Following have been updated:
      `getOriginal`
      `getRawOriginal`
      `getChanges`
      `getDeletedAttributes`
      `getNewAttributes`
* feat: updated static methods returning models to infer type from `this`
* feat: updated some static inference to not use error ignoring
    * Updates related to: 63ed0be
* feat(model): added `create` method
    * This allows to constructing a model more fluently

## Fix
* fix(model): updated missed distinctBy in the clone method
* fix(attributes): fixed casting methods typing to accept mixed values
* fix(api-calls): pass the response attributes to the constructor
  * This also cleans up the code a little
* fix(services): normalised fetch methods
  * `patch` could failed with lowercase method name
* fix(api-calls): updated typing to be inclusive of each other on `get`
* fix(relations): fixed `addRelation` typing to accept subclass of a model
* fix: fixed outstanding eslint and typing errors
* fix(model-collection): fixed wrong typing of `toJSON`
    * Issue introduced in b4d6db4
* fix(**BREAKING CHANGE**): renamed timestamp name methods
  * Renamed the following:
    `getDeletedAtColumn` -> `getDeletedAtName`
    `getCreatedAtColumn` -> `getCreatedAtName`
    `getUpdatedAtColumn` -> `getUpdatedAtName`

## Test
* test(timestamps): tested `restore` accepting server deletedAt value
* test: added initial baseEndpoint in testing
* test(services): added missing test updates
    * Updates missed from a07b22a
* test(attributes): fixed failing guarding tests
* test(services): added missing test updates
    * Updates missed from a07b22a
* test(relations): updated testing to use the new typings
* test(model): updated to use new typings
* test(api-calls): added missing data unwrap test
* test(api-calls): added missing endpoint getter test

## Refactor
* refactor(services): simplified `handleError` in response handler
* refactor(attributes): simplified `getAttribute` override typing
* refactor(factory): update return types of mock factories
* refactor(model-collection): updated `toJSON` typing
  * updated `toJSON` typing to track the model's `toJSON`

## Chore
* chore: incremented package version
* chore: added new eslint rule
* chore: moved todos into github
* chore(deps): updated non-breaking dependencies
  * @commitlint/prompt-cli
  * @types/uuid
  * @typescript-eslint/eslint-plugin
  * @typescript-eslint/parser
  * commitlint
  * eslint
  * eslint-plugin-jest
  * lint-staged
  * qs
  * rollup
  * typedoc
  * typescript
* chore(deps-dev): updated breaking change dependencies
  * semantic-release

## Style
* style: fixed eslint issues

## Continuous Integration
* ci: added matrix values explanation
…Data is used (upfrontjs#184)

## Continuous Integration 
* ci: fix deploy command
* ci: also update on readme updates
* ci: fix api docs deployment
* chore: added api docs files ignores

## Fix
* fix(services): removed setting Content-Type on FormData
  * Removed as no boundary was calculated and this allows fetch to figure it out in its own.
  * https://fetch.spec.whatwg.org/#ref-for-formdata%E2%91%A1

## Chore 
* chore: incremented package version

## Test
* test(services): removed content type test when using form data
  * fetch mock doesn't implement automatic header setting
This will allow setting up descriptors for default values
Resolves upfrontjs#186
@nandi95 nandi95 added bug Something isn't working has workaround There is a way to achieve the aim breaking change This a breaking change to the api labels Jan 28, 2022
@nandi95 nandi95 merged commit 239e932 into upfrontjs:main Jan 28, 2022
@nandi95 nandi95 deleted the feat/various branch January 28, 2022 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This a breaking change to the api bug Something isn't working has workaround There is a way to achieve the aim
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant