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

Feature: use request #39

Open
wants to merge 64 commits into
base: feat/get-meta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
2a80324
feat(use-request): add useRequest
JuraJuki Aug 25, 2020
8aa565a
Merge branch 'feat/hook-tests' into feat/attributes-obj-removal
JuraJuki Sep 4, 2020
0fc053a
feat(attributes-obj-removal): adds attributes {} removal checks
JuraJuki Sep 4, 2020
28cc2a7
Merge remote-tracking branch 'origin/master' into feat/use-request
JuraJuki Sep 7, 2020
4818bf1
feat(use-request): useRequestHookTests
JuraJuki Sep 7, 2020
002c56e
feat(use-request): extract apiService, Aardvark class, fix useRequest…
JuraJuki Sep 7, 2020
725be6c
Merge branch 'master' into feat/attributes-obj-removal
Sep 8, 2020
0c6f49b
feat(attributes-obj-removal): code review fix
JuraJuki Sep 9, 2020
2b66ef5
Merge remote-tracking branch 'origin/feat/attributes-obj-removal' int…
JuraJuki Sep 9, 2020
2916860
Merge remote-tracking branch 'origin/master' into feat/attributes-obj…
JuraJuki Sep 9, 2020
ed526dc
feat(tsdx-docs): extract tsdx-readme
JuraJuki Sep 9, 2020
37ca9ff
fix(github-actions-install): change main.yml yarn to npm
JuraJuki Sep 9, 2020
c2b353b
Merge pull request #57 from bornfight/feat/tsdx-docs
Sep 9, 2020
27f1b3b
fix(github-actions-install): rollback main.yml add yarn.lock
JuraJuki Sep 10, 2020
98d6d64
Merge branch 'master' into feat/attributes-obj-removal
JuraJuki Sep 11, 2020
c00291f
feat(attributes-obj-removal): fix failing lint, tests
JuraJuki Sep 11, 2020
3f97e75
Merge remote-tracking branch 'origin/feat/attributes-obj-removal' int…
JuraJuki Sep 11, 2020
212efad
feat(attributes-removal): add CustomModelPropertiesMapper
renatoruk Sep 11, 2020
4286193
feat(attributes-obj-removal): fix attributes with CustomModelProperti…
JuraJuki Sep 11, 2020
fa28b03
feat(attributes-obj-removal): remove ignores
JuraJuki Sep 11, 2020
089e878
feat(attributes-removal): add casting to any for undefined
renatoruk Sep 11, 2020
4bdb5ff
Merge pull request #47 from bornfight/feat/attributes-obj-removal
JuraJuki Sep 11, 2020
2f4696c
Merge branch 'master' into fix/github-actions-install
Sep 11, 2020
09a4c50
Merge pull request #58 from bornfight/fix/github-actions-install
Sep 11, 2020
f2dbfd9
feat(__clientGeneratedEntity-test): add test & conditional for __clie…
JuraJuki Sep 14, 2020
2069363
feat(__clientGeneratedEntity-test): set attributes to undefined if em…
JuraJuki Sep 14, 2020
6e0e496
Merge pull request #60 from bornfight/feat/__clientGeneratedEntity-test
Sep 14, 2020
aca9c6f
feat(preserve-request-trailing-slash): add key to apiActionHandler co…
JuraJuki Sep 14, 2020
0fac6f1
feat(preserve-request-trailing-slash): change inital type to bool
JuraJuki Sep 14, 2020
2d8208f
feat(preserve-request-trailing-slash): add test
JuraJuki Sep 14, 2020
a8c6853
Merge pull request #61 from bornfight/feat/preserve-trailing-slash
Sep 14, 2020
3f34c30
build(package.json): set private to false
renatoruk Sep 15, 2020
627cc60
1.0.0-beta.0
renatoruk Sep 15, 2020
c53ac75
Add codecov reporting to github main workflow
Sep 15, 2020
0c6e0c7
Merge pull request #62 from bornfight/renatoruk-patch-1
Sep 15, 2020
7ee92dd
build(package.json): remove publishConfig
renatoruk Sep 15, 2020
451888b
Merge remote-tracking branch 'origin/master'
renatoruk Sep 15, 2020
7a994c7
1.0.0-beta.1
renatoruk Sep 15, 2020
0955069
Add codecov badge
Sep 15, 2020
f07afa0
fix(page-params): square brackets syntax
JuraJuki Sep 18, 2020
746b533
Merge branch 'master' into fix/page-params
JuraJuki Sep 18, 2020
be893a2
fix(page-params): fix tests
JuraJuki Sep 18, 2020
c376a6e
Merge remote-tracking branch 'origin/fix/page-params' into fix/page-p…
JuraJuki Sep 18, 2020
b3942ab
feat(json-api-query): enable custom page size and number attribute
renatoruk Sep 21, 2020
012c672
Merge pull request #69 from bornfight/fix/page-params
Sep 21, 2020
bad930a
1.0.0-beta.2
JuraJuki Sep 21, 2020
4cec494
fix(jsonApiReducer): delete-requests
JuraJuki Sep 22, 2020
1a5821e
fix(jsonApiReducer): remove optional chaining
JuraJuki Sep 23, 2020
62d1dce
fix(jsonApiReducer): remove item from store after delete action
JuraJuki Sep 23, 2020
c16d134
Update variable names and types
JuraJuki Sep 23, 2020
ec84c14
fix(jsonApiReducer): add identifiers import
JuraJuki Sep 23, 2020
7b9b2f3
Merge pull request #71 from bornfight/fix/jsonApiReducer/delete-requests
JuraJuki Sep 23, 2020
1663b01
1.0.0-beta.3
JuraJuki Sep 23, 2020
a840a13
fix(nested-attributes-obj): add test for relationship's relationship-…
JuraJuki Sep 24, 2020
1979f08
fix(nested-attributes-obj): add removal of relationships empty attrib…
JuraJuki Oct 5, 2020
1e4d8dd
fix(nested-attributes-obj): update removal function
JuraJuki Oct 6, 2020
5f98004
fix(nested-attributes-obj): fix test, apply removal func
JuraJuki Oct 6, 2020
a6aaabd
fix(nested-attributes-obj): update readme, fix conditional
JuraJuki Oct 6, 2020
992546a
Create codeql-analysis.yml
Oct 7, 2020
a3d7cbf
fix(nested-attributes-obj): add test with attributes
JuraJuki Oct 9, 2020
df75d29
Merge pull request #73 from bornfight/fix/nested-attributes-obj
JuraJuki Oct 9, 2020
20b16e5
1.0.0-beta.4
JuraJuki Oct 9, 2020
5833c48
Merge remote-tracking branch 'origin/master' into feat/get-meta
JuraJuki Oct 20, 2020
f31af77
Merge branch 'feat/get-meta' into feat/use-request
JuraJuki Oct 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"

on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 19 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['javascript']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
env:
CI: true

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1

- name: Build
run: yarn build
env:
Expand Down
185 changes: 15 additions & 170 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# Aardvark
**Data consumption React hooks for JSON:API specification**

[![codecov](https://codecov.io/gh/bornfight/aardvark/branch/master/graph/badge.svg)](https://codecov.io/gh/bornfight/aardvark)

TypeScript friendly

Install with the following command:

```
yarn add @bornfight/aardvark
or
npm install @bornfight/aardvark
```

## GET hooks
### useGet
Immediately fetches data when called. It returns fetched record, loading state and the operation name.
Expand Down Expand Up @@ -83,7 +94,10 @@ hook parameters:
- actionHandler

create function parameters (pick one):
- model object and includeNames
- model object and includeNames:
- model is connected to actionHandler's entity
- includeNames determine the recognition of model's relationships. It is used with dot notation for nested relationships. E.g. includeNames=["car.owner.document"]

or
- rawData object

Expand Down Expand Up @@ -226,172 +240,3 @@ export class CarSelector extends BaseApiSelector<CarJSONAModel> {
super("car");
}}
```


# TSDX React User Guide

Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.

> This TSDX setup is meant for developing React components (not apps!) that can be published to NPM. If you’re looking to build an app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`.

> If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)

## Commands

TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.

The recommended workflow is to run TSDX in one terminal:

```bash
npm start # or yarn start
```

This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.

Then run the example inside another:

```bash
cd example
npm i # or yarn to install dependencies
npm start # or yarn start
```

The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, [we use Parcel's aliasing](https://github.com/palmerhq/tsdx/pull/88/files).

To do a one-off build, use `npm run build` or `yarn build`.

To run tests, use `npm test` or `yarn test`.

## Configuration

Code quality is [set up for you](https://github.com/palmerhq/tsdx/pull/45/files) with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.

### Jest

Jest tests are set up to run with `npm test` or `yarn test`. This runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.

#### Setup Files

This is the folder structure we set up for you:

```shell
/example
index.html
index.tsx # test your component here in a demo app
package.json
tsconfig.json
/src
index.tsx # EDIT THIS
/test
blah.test.tsx # EDIT THIS
.gitignore
package.json
README.md # EDIT THIS
tsconfig.json
```

#### React Testing Library

We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.

### Rollup

TSDX uses [Rollup v1.x](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.

### TypeScript

`tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.

## Continuous Integration

### Travis

_to be completed_

### Circle

_to be completed_

## Optimizations

Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:

```js
// ./types/index.d.ts
declare var __DEV__: boolean;

// inside your code...
if (__DEV__) {
console.log('foo');
}
```

You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.

## Module Formats

CJS, ESModules, and UMD module formats are supported.

The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.

## Using the Playground

```bash
cd example
npm i # or yarn to install dependencies
npm start # or yarn start
```

The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**!

## Deploying the Playground

The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):

```bash
cd example # if not already in the example folder
npm run build # builds to dist
netlify deploy # deploy the dist folder
```

Alternatively, if you already have a git repo connected, you can set up continuous deployment with Netlify:

```bash
netlify init
# build command: yarn build && cd example && yarn && yarn build
# directory to deploy: example/dist
# pick yes for netlify.toml
```

## Named Exports

Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.

## Including Styles

There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.

For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.

## Publishing to NPM

We recommend using [np](https://github.com/sindresorhus/np).

## Usage with Lerna

When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.

The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.

Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.

```diff
"alias": {
- "react": "../node_modules/react",
- "react-dom": "../node_modules/react-dom"
+ "react": "../../../node_modules/react",
+ "react-dom": "../../../node_modules/react-dom"
},
```

An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)
Loading