Skip to content

Commit

Permalink
dove - upgrade to feathers v5 (#79)
Browse files Browse the repository at this point in the history
* feat: update to feathers 5

* chore: update feathers-utils

* test: fix tests

* fix: allow service.options to be undefined

* test: comment all casl service options

* test: augment ServiceOptions of correct adapter-commons package

* fix!: keep up with recent dove (#77)

* init new

* chore: update dependencies

* chore: update dependencies

* refactor: modernize repo
- unbuild
- vitest
- restricter eslint
- named exports instead of default exports
- export * from

* fix: right filters

* fix(channels): assign ability to connection from authResult

* ci: update coverage & add build job

* test: add lcov to coverage

* test: coverage threshold 90

* fix: around hook check for context.result

* chore: remove console.logs

* chore: update dependencies

* 1.0.0-0

* fix: update dependencies
- feathers-utils: esm
- pre.34: removed $-function
- feathers-sequelize: removed $-function

* 1.0.0-1

* refactor: do not export "HOOKNAME"

* chore: update dependencies & add types & module entry to package.json

* 1.0.0-2

* chore: update dependencies, move to src,

* feat: simplify mergeQuery if possible

* fix: build

* fix: mergeArrays undefined

* docs: badges

* rename master->main

* chore: update dependencies

* docs: ts and import from @casl/ability

* docs: add note for crow version

---------

Co-authored-by: Lukas Hass <[email protected]>
Co-authored-by: fratzinger <[email protected]>
  • Loading branch information
3 people authored Mar 28, 2023
1 parent b1521c0 commit 7a3b7d7
Show file tree
Hide file tree
Showing 119 changed files with 21,379 additions and 15,758 deletions.
57 changes: 36 additions & 21 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{
"root": true,
"env": {
"node": true,
"mocha": true
"node": true
},
"parser": "@typescript-eslint/parser",
"plugins": [
"security",
"@typescript-eslint"
],
"plugins": ["@typescript-eslint", "unicorn", "prettier"],
"extends": [
"eslint:recommended",
"plugin:security/recommended",
"plugin:@typescript-eslint/recommended"
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:prettier/recommended"
],
"rules": {
"quotes": ["warn", "double", "avoid-escape"],
Expand All @@ -22,26 +19,44 @@
"no-console": "off",
"camelcase": "warn",
"require-atomic-updates": "off",
"prefer-destructuring": ["warn", {
"AssignmentExpression": { "object": false, "array": false },
"VariableDeclarator": { "object": true, "array": true }
}, {
"enforceForRenamedProperties": false
}],
"security/detect-object-injection": "off",
"prefer-destructuring": [
"warn",
{
"AssignmentExpression": { "object": false, "array": false },
"VariableDeclarator": { "object": true, "array": true }
},
{
"enforceForRenamedProperties": false
}
],
"object-curly-spacing": ["warn", "always"],
"prefer-const": ["warn"],
"@typescript-eslint/consistent-type-imports": ["warn", { "prefer": "type-imports" }]
"@typescript-eslint/consistent-type-imports": [
"warn",
{ "prefer": "type-imports" }
],
"unicorn/prefer-node-protocol": "warn"
},
"overrides": [
{
"files": ["test/**/*.ts"],
"rules": {
"@typescript-eslint/ban-ts-comment": ["off"],
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-unused-vars": ["off"]
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
],
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
"project": "./tsconfig.json"
}
}
]
}
}

49 changes: 29 additions & 20 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,43 @@ name: Node.js CI
on: [push, pull_request]

jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm i
- run: npm run test

coverage:
needs: [ test ]
name: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: '12'
- run: npm ci
- uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: npm run coverage
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
- run: npm i
- uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: npm run coverage

build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
- run: npm i
- run: npm run build
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
!lib
test/.data/**

# Logs
Expand Down Expand Up @@ -116,7 +115,11 @@ $RECYCLE.BIN/
# dot_env
.env.*

dist
# dist
dist/**

docs/.vitepress/dist
docs/.vitepress/cache

.cache
.temp
13 changes: 0 additions & 13 deletions .mocharc.js

This file was deleted.

27 changes: 0 additions & 27 deletions .nycrc.json

This file was deleted.

47 changes: 15 additions & 32 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**"
],
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/mocha",
"args": [
"--require",
"ts-node/register",
"--timeout",
"999999",
"--colors",
"--recursive"
],
"internalConsoleOptions": "openOnSessionStart",
"env": {
"NODE_ENV": "test",
"TS_NODE_PROJECT": "tsconfig.test.json"
},
"outputCapture": "std",
"skipFiles": [
"<node_internals>/**"
]
},
]
}

"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Current Test File",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
}
]
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Frederik Schmatz
Copyright (c) 2022 Frederik Schmatz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
</p>

[![npm](https://img.shields.io/npm/v/feathers-casl)](https://www.npmjs.com/package/feathers-casl)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/fratzinger/feathers-casl/Node.js%20CI)](https://github.com/fratzinger/feathers-casl/actions/workflows/node.js.yml?query=branch%3Amaster)
[![Github CI](https://github.com/fratzinger/feathers-casl/actions/workflows/node.js.yml/badge.svg)](https://github.com/fratzinger/feathers-casl/actions)
[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/fratzinger/feathers-casl)](https://codeclimate.com/github/fratzinger/feathers-casl)
[![Code Climate coverage](https://img.shields.io/codeclimate/coverage/fratzinger/feathers-casl)](https://codeclimate.com/github/fratzinger/feathers-casl)
[![libraries.io](https://img.shields.io/librariesio/release/npm/feathers-casl)](https://libraries.io/npm/feathers-casl)
[![npm](https://img.shields.io/npm/dm/feathers-casl)](https://www.npmjs.com/package/feathers-casl)
[![GitHub license](https://img.shields.io/github/license/fratzinger/feathers-casl)](https://github.com/fratzinger/feathers-casl/blob/master/LICENSE)
[![GitHub license](https://img.shields.io/github/license/fratzinger/feathers-casl)](https://github.com/fratzinger/feathers-casl/blob/main/LICENSE)
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx)

> NOTE: This is the version for Feathers v5. For Feathers v4 use [feathers-casl v0](https://github.com/fratzinger/feathers-casl/tree/crow)
## About

Add access control with CASL to your feathers application.
Expand All @@ -21,15 +23,15 @@ This project is built for [FeathersJS](http://feathersjs.com). An open source we
It's based on [CASL](https://casl.js.org/) and is a convenient layer to use **CASL** in feathers.js.

## Features
- Fully powered by Feathers 4 & CASL 5
- Written in TypeScript

- Fully powered by Feathers 4 & CASL 6
- Allows permissions for all methods `create`, `find`, `get`, `update`, `patch`, `remove`, or `create`, `read`, `update`, `delete`
- Define permissions not based on methods: `can('view', 'Settings')` (Bring your custom logic)
- Restrict by conditions: `can('create', 'Task', { userId: user.id })`
- Restrict by individual fields: `cannot('update', 'User', ['roleId'])`
- Native support for restrictive `$select`: `can('read', 'User', ['id', 'username'])` -> `$select: ['id', 'username']`
- Support to define abilities for anything (providers, users, roles, 3rd party apps, ...)
- Fully supported adapters: `feathers-knex`, `feathers-memory`, `feathers-mongodb`, `feathers-mongoose`, `feathers-nedb`, `feathers-objection`, `feathers-sequelize`
- Fully supported adapters: `@feathersjs/knex`, `@feathersjs/memory`, `@feathersjs/mongodb`, `feathers-sequelize`, not supported: `feathers-mongoose`, `feathers-nedb`, `feathers-objection`
- Support for dynamic rules stored in your database (Bring your own implementation ;) )
- hooks:
- `checkBasicPermission` hook for client side usage as a before-hook
Expand All @@ -44,23 +46,24 @@ It's based on [CASL](https://casl.js.org/) and is a convenient layer to use **CA
- Baked in support for `@casl/angular`, `@casl/react`, `@casl/vue` and `@casl/aurelia`

## Documentation

You need more information? Please have a look:
https://feathers-casl.netlify.app/

## Installation

```bash
npm i feathers-casl
npm i feathers-casl @casl/ability
```

## Testing

Simply run `npm test` and all your tests in the `test/` directory will be run. It has full support for *Visual Studio Code*. You can use the debugger to set breakpoints.
Simply run `npm test` and all your tests in the `test/` directory will be run. It has full support for _Visual Studio Code_. You can use the debugger to set breakpoints.

## Help

For more information on all the things you can do, visit [FeathersJS](http://docs.feathersjs.com) and [CASL](https://casl.js.org/v5/en/).

## License

Licensed under the [MIT license](LICENSE).
Licensed under the [MIT license](LICENSE).
15 changes: 15 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineBuildConfig } from "unbuild";
import pkg from "./package.json";

export default defineBuildConfig({
entries: ["./src/index"],
outDir: "./dist",
declaration: true,
externals: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
],
rollup: {
emitCJS: true,
},
});
Loading

0 comments on commit 7a3b7d7

Please sign in to comment.