-
Notifications
You must be signed in to change notification settings - Fork 0
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
chore: updates and tidy ups #79
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,70 @@ | ||
# PlanX Core | ||
|
||
This package is a declarative boundary between the data access layer (GraphQL/Hasura/Postgres) and the PlanX domain. | ||
This package is a declarative wrapper for the core data structures and operations of [PlanX](https://github.com/theopensystemslab/planx-new). | ||
|
||
## Running locally | ||
It also includes data processing functions for the various export formats of PlanX application data. | ||
|
||
## Structure | ||
|
||
The package is structured by functional responsibility. Here is a summary of what each directory contains: | ||
|
||
./src | ||
├── requests # a data access client exposing declarative interfaces for common database operations | ||
├── models # a set of functions and classes that encapsulate the functionality of domain objects | ||
├── exports # data processing functions to convert application data into third-party data formats | ||
├── templates # data processing functions to convert application data into various document formats | ||
└── types # a set of Typescript types for the exported functions and structures of this package | ||
|
||
## Conventions | ||
|
||
Requests: | ||
|
||
- `CoreDomainClient` sets up individual resource clients which each expose a declarative interface for operations on that resource. | ||
- Functions or methods that begin with an underscore (e.g `$admin.session._destroy`) are intended as development/test utilities and do not represent actions that should be a part of application code. | ||
- Instances of `CoreDomainClient` should be named `$<ROLE>` to indicate the permission set it has been granted, e.g. `$api` or `$public` | ||
|
||
Models: | ||
|
||
- Rich data structures which have implicit rules around how data should be read or manipulated are best represented as classes which encapsulate behaviours in methods. | ||
- Simple data structures which have few or no rules around how data should be read or manipulated are best represented as simple objects/arrays with a clear type definition. | ||
|
||
Exports / Templates: | ||
|
||
- Prefer stream processing where possible. | ||
|
||
Types: | ||
|
||
- Following the [robustness principle](https://en.wikipedia.org/wiki/Robustness_principle), types should generally be represented as an `interface` for inputs and as a `type` for outputs with a known structure. | ||
|
||
## Local Development | ||
|
||
- Install [pnpm](https://pnpm.io) globally if you don't have it already `npm i pnpm -g` | ||
- Install dependencies `pnpm i` | ||
|
||
Other useful package scripts: | ||
|
||
* `pnpm test`: run the test suite | ||
* `pnpm check`: check and fix type and linting errors | ||
* `pnpm build`: build the package | ||
- `pnpm build`: generate package exports and examples | ||
|
||
- `pnpm check`: scan for type and style errors | ||
- `pnpm lint`: scan for style errors | ||
- `pnpm lint:fix`: fix style errors | ||
|
||
- `pnpm test`: run unit tests | ||
- `pnpm test:coverage`: run unit tests with coverage report | ||
|
||
## Debugging | ||
### Debugging | ||
|
||
Setting the environment variable `DEBUG` to any truthy value turns on the console output for debugging (useful for setup and teardown issues). | ||
|
||
## Publishing | ||
|
||
This node package is published via Github and can be referenced in a `package.json`, like so: | ||
This node package is published via Github and can be referenced in a `pnpm` style `package.json` file, like so: | ||
|
||
"dependencies": { | ||
"@opensystemslab/planx-core": "git://github.com/theopensystemslab/planx-core.git#commit-ish", | ||
"@opensystemslab/planx-core": "github:theopensystemslab/planx-core#commit-ish", | ||
... | ||
} | ||
|
||
## License | ||
|
||
This repository is licensed under the [Open Government License v3](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/). | ||
This repository is licensed under the [The Mozilla Public License (MPL) Version 2](https://github.com/theopensystemslab/planx-core/blob/main/LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
process.env.HASURA_GRAPHQL_ADMIN_SECRET = "👻"; | ||
process.env.HASURA_GRAPHQL_URL = "👻"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest version of eslint upgrades this warning to "error" so I'm downgrading here until #78 is merged.