Skip to content

Commit

Permalink
TDK housekeeping stabilization (do not merge before #50) (#52)
Browse files Browse the repository at this point in the history
* feat(test): add new koko tests and eslint housekeeping

- add new 070-user-group-search-and-share test and docs from the koko test paper
- add new groups api and add those to the tdk client
- add several es-lint rules to the default config and apply those

* fix(artifacts): rebuild artifacts after rebase

* fix(test): fix wrong path

* feat(test): add new koko tests and some test housekeeping

- add new 080-create-space test and docs based on the koko test paper
- add client version guard to protect the test from unsupported client versions
- rename the api tdk package to endpoints, to not have a api.api route which is needed for ocis
- add eslint rule to have linebreaks between class members
- stop using k6 response json method
- add client endpoints for application
- add client endpoints for drive
- add client endpoints for role

* - add missing client demos to the kitchen sink test
- fix static space creation count

* feat(test): add new koko tests and some test housekeeping

- add new 090-add-remove-user-share test and docs based on the koko test paper
- add new share delete client endpoint

* add share.delete to the kitchen sink example

* feat(test): add new koko tests and some test housekeeping
- add koko 030-search-for-filename test and docs
- introduce versionSupported helper and use it instead of plain conditions
- add tag search
- use og jsonpath instead of jsonpath-plus and adjust related helpers
- introduce tag client endpoints
- introduce systemtags and systemtags_relations endpoints
- introduce libregraph org tags endpoints

* fix(cleanup endpoints): cleanup all tdk endpoints

* fix(linting): cleanup eslint config and apply airbnb best practices

* feat(eslint): split up eslint config

* enhancement: cleanup tdk client
this enhancement cleans up the tdk/client endpoint structure and introduces a naming schema which applies to all compatible clouds.

beside the client refactoring it updates all related tests to use that changed api.

* enhancement: cleanup utils tdk package

cleanup, rename and structure available and used utils

* enhancement: add vitest and utils unit tests

integrate vitest, make it possible to run tests on monorepo level via turbo and provide unit tests for the utils package

* fix: circular platform import

mote Platform const out of the client to prevent circular imports

* fix: cleanup tdk auth adapter

cleanup auth adapters and rename the oidc adapter to kopano

* fix: eslint semi rule

remove not needed semicolons

* fix: requestFactory params and queryJson empty value handling

* fix: long chained rebase

cleanup previous pr rebase
  • Loading branch information
fschade authored Apr 18, 2023
1 parent d829745 commit 314b41b
Show file tree
Hide file tree
Showing 148 changed files with 5,576 additions and 4,384 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
"clean": "turbo run clean --no-daemon --parallel && del-cli .pnpm-store node_modules",
"dev": "ROARR_LOG=true turbo run dev --parallel --concurrency 64 --no-daemon | roarr",
"lint": "eslint package.json && syncpack list-mismatches && turbo run lint --no-daemon",
"lint:fix": "eslint package.json --fix && syncpack fix-mismatches && turbo run lint:fix --no-daemon"
"lint:fix": "eslint package.json --fix && syncpack fix-mismatches && turbo run lint:fix --no-daemon",
"test": "turbo run test --no-daemon"
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
"@ownclouders/eslint-config": "workspace:*",
"@roarr/cli": "^5.11.0",
"del-cli": "^5.0.0",
"syncpack": "^9.8.4",
"turbo": "^1.8.8",
"typescript": "^5.0.3"
"turbo": "^1.9.1",
"typescript": "^5.0.4"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
"lint:fix": "pnpm run lint --fix"
},
"dependencies": {
"esbuild": "^0.17.14"
"esbuild": "^0.17.16"
},
"devDependencies": {
"@ownclouders/eslint-config": "workspace:*",
"@ownclouders/tsconfig": "workspace:*",
"@types/node": "^18.15.11",
"concurrently": "^8.0.1",
"del-cli": "^5.0.0",
"typescript": "^5.0.3"
"typescript": "^5.0.4"
}
}
5 changes: 3 additions & 2 deletions packages/esbuild/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { build as _build, BuildOptions, BuildResult } from 'esbuild';
import { build as _build, BuildOptions, BuildResult } from 'esbuild'

export const build = async (config?: BuildOptions): Promise<BuildResult> => {
return _build({
Expand All @@ -8,7 +8,8 @@ export const build = async (config?: BuildOptions): Promise<BuildResult> => {
outdir: 'dist',
format: 'esm',
minify: true,
sourcemap: false,
platform: 'node',
...config
})
};
}
6 changes: 1 addition & 5 deletions packages/eslint-config/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"root": true,
"extends": ["."],
"parser": "espree",
"env": {
"node": true
}
"extends": ["."]
}
111 changes: 26 additions & 85 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,95 +1,36 @@
const sharedExtends = [
require.resolve('./src/prettier.js'),
require.resolve('./src/eslint.js'),
require.resolve('./src/import.js'),
require.resolve('./src/turbo.js'),
require.resolve('./src/simple-import-sort.js')
]

module.exports = {
extends: [
'eslint:recommended',
'prettier',
'turbo',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended'
require.resolve('./src/airbnb-base.js'),
...sharedExtends
],
processor: 'disable/disable',
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json'
},
plugins: [ '@typescript-eslint', 'eslint-plugin-unicorn', 'disable', 'simple-import-sort', 'json-files', 'no-relative-import-paths', 'relative-imports-when-same-folder'],
rules: {
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'import/prefer-default-export': 'off',
'import/extensions': 'off',
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'import/first': 'error',
'import/no-duplicates': 'error',
'space-before-blocks': [ 'error', 'always' ],
'import/newline-after-import': [ 'error', { 'count': 1 } ],
'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 1, 'maxBOF': 0 }],
'import/no-named-as-default': 'error',
'import/no-default-export': 'error',
'import/no-useless-path-segments': 'error',
'import/no-cycle': 'error',
'import/no-self-import': 'error',
'import/no-relative-packages': 'error',
'object-curly-spacing': [ 'error', 'always' ],
'comma-spacing': ['error', { 'before': false, 'after': true }],
'comma-dangle': ['error', 'never'],
'computed-property-spacing': [ 'error', 'always' ],
'no-console': 'off',
'arrow-body-style': ['error', 'always'],
'arrow-parens': ['error', 'always'],
'quotes': ['error', 'single', { 'avoidEscape': true }],
'no-return-assign': 'off',
'function-paren-newline': ['error', 'never'],
'brace-style': 'error',
'class-methods-use-this': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'indent': ['error', 2],
'no-unused-vars': 'off',
'no-underscore-dangle': 'off',
'no-nested-ternary': 'off',
'@typescript-eslint/no-shadow': 'off',
'no-await-in-loop': 'off',
'no-plusplus': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/lines-between-class-members': 'off',
'default-case': 'off',
'no-restricted-syntax': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-loop-func': 'off',
'lines-between-class-members': ['error', 'always'],
'no-continue': 'off',
'no-relative-import-paths/no-relative-import-paths': [
'error',
{ 'allowSameFolder': true, 'rootDir': 'src', 'prefix': '@' }
],
'relative-imports-when-same-folder/no-relative-imports-when-same-folder': 'error'
},
'settings': {
'import/resolver': {
'typescript': {}
}
},
ignorePatterns: ['build.mjs', 'turbowatch.ts', 'vitest.config.ts', '*.test.ts'],
overrides: [
{
files: [ '**/package.json' ],
plugins: [ 'json-files' ],
parser: 'espree',
rules: {
'json-files/sort-package-json': 'error',
'json-files/require-license': 'error',
'json-files/restrict-ranges': 'error',
'json-files/require-unique-dependency-names': 'error',
'relative-imports-when-same-folder/no-relative-imports-when-same-folder': 'off'
files: ['*.ts'],
extends: [
require.resolve('./src/airbnb-base.js'),
require.resolve('./src/airbnb-typescript-base.js'),
require.resolve('./src/no-relative-import-paths.js'),
require.resolve('./src/relative-imports-when-same-folder.js'),
...sharedExtends
],
parserOptions: {
project: './tsconfig.json'
}
},
{
files: [ '**/*.js' ],
parser: 'espree',
rules: {
'relative-imports-when-same-folder/no-relative-imports-when-same-folder': 'off'
}
files: ['*.json'],
extends: [
require.resolve('./src/json-files.js')
]
}
]
};
}
18 changes: 9 additions & 9 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
"lint:fix": "pnpm run lint --fix"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-turbo": "^1.8.8",
"eslint-import-resolver-typescript": "^3.5.4",
"eslint-plugin-disable": "^2.0.3",
"eslint-config-turbo": "^1.9.1",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-json-files": "^2.1.0",
"eslint-plugin-no-relative-import-paths": "^1.5.2",
"eslint-plugin-relative-imports-when-same-folder": "^0.0.4",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unicorn": "^46.0.0"
"eslint-plugin-simple-import-sort": "^10.0.0"
},
"devDependencies": {
"del-cli": "^5.0.0",
"eslint": "^8.37.0",
"typescript": "^5.0.3"
"eslint": "^8.38.0",
"typescript": "^5.0.4"
}
}
3 changes: 3 additions & 0 deletions packages/eslint-config/src/airbnb-base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['airbnb-base'],
}
3 changes: 3 additions & 0 deletions packages/eslint-config/src/airbnb-typescript-base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['airbnb-typescript/base'],
}
14 changes: 14 additions & 0 deletions packages/eslint-config/src/eslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
rules: {
'max-len': ['error', 150],
'arrow-body-style': ['error', 'always'],
'semi': ['error', 'never'],
'arrow-parens': ['error', 'always'],
'brace-style': ['error', '1tbs', { allowSingleLine: false }],
'object-curly-spacing': [ 'error', 'always' ],
'quotes': ['error', 'single', { 'avoidEscape': true }],
'comma-spacing': ['error', { 'before': false, 'after': true }],
'comma-dangle': ['error', 'never'],
'no-console': 'off'
}
}
14 changes: 14 additions & 0 deletions packages/eslint-config/src/import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
extends: ['plugin:import/recommended'],
rules: {
'import/extensions': 'off',
'import/no-unresolved': 'off',
'import/prefer-default-export': 'off',
'import/no-duplicates': 'error',
'import/newline-after-import': ['error', { count: 1 }],
'import/no-default-export': 'error',
'import/no-useless-path-segments': 'error',
'import/no-cycle': 'error',
'import/no-self-import': 'error'
}
}
10 changes: 10 additions & 0 deletions packages/eslint-config/src/json-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
plugins: ['json-files'],
rules: {
'json-files/sort-package-json': 'error',
'json-files/require-license': 'error',
'json-files/restrict-ranges': 'error',
'json-files/require-unique-dependency-names': 'error',
'relative-imports-when-same-folder/no-relative-imports-when-same-folder': 'off',
},
}
9 changes: 9 additions & 0 deletions packages/eslint-config/src/no-relative-import-paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
plugins: ['no-relative-import-paths'],
rules: {
'no-relative-import-paths/no-relative-import-paths': [
'error',
{ 'allowSameFolder': true, 'rootDir': 'src', 'prefix': '@' }
]
}
}
3 changes: 3 additions & 0 deletions packages/eslint-config/src/prettier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['prettier'],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: ['relative-imports-when-same-folder'],
rules: {
'relative-imports-when-same-folder/no-relative-imports-when-same-folder': 'error'
}
}
7 changes: 7 additions & 0 deletions packages/eslint-config/src/simple-import-sort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
plugins: ['simple-import-sort'],
rules: {
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
}
}
3 changes: 3 additions & 0 deletions packages/eslint-config/src/turbo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['turbo'],
}
15 changes: 12 additions & 3 deletions packages/k6-tdk/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
"extends": ["@ownclouders"],
"overrides": [
{
"files": [
"src/**/*"
]
"files": ["src/client/**/*"],
"rules": {
// has to return different values because of ocis, nc and occ compatibility / incompatibility
"consistent-return": "off"
}
},
{
"files": ["src/endpoints/**/*", "src/client/xml.ts"],
"rules": {
// has some `strange` naming conventions e.g. 'METHOD__description_what_it_does', 'POST_create_user'
"@typescript-eslint/naming-convention": "off"
}
}
]
}
31 changes: 31 additions & 0 deletions packages/k6-tdk/config/vitest.mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { vi } from 'vitest'

vi.mock('k6/http', () => {
return {
CookieJar: vi.fn()
}
})

vi.mock('k6/encoding', () => {
return {}
})

vi.mock('k6', () => {
return {}
})

vi.mock('https://jslib.k6.io/url/1.0.0/index.js', () => {
return {
URLSearchParams: URLSearchParams
}
})

vi.mock('k6/experimental/timers', () => {
return {}
})

vi.mock('https://jslib.k6.io/k6-utils/1.2.0/index.js', () => {
return {
randomString: vi.fn()
}
})
15 changes: 9 additions & 6 deletions packages/k6-tdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"clean:vendor": "del-cli .turbo node_modules",
"dev": "turbowatch",
"lint": "eslint package.json 'src/**/*.ts'",
"lint:fix": "pnpm run lint --fix"
"lint:fix": "pnpm run lint --fix",
"test": "vitest run"
},
"dependencies": {
"jsonpath": "^1.1.1",
Expand All @@ -84,14 +85,16 @@
"@ownclouders/tsconfig": "workspace:*",
"@ownclouders/turbowatch": "workspace:*",
"@types/jsonpath": "^0.2.0",
"@types/k6": "^0.43.2",
"@types/k6": "^0.43.3",
"@types/lodash-es": "^4.17.7",
"@types/node": "^18.15.11",
"concurrently": "^8.0.1",
"del-cli": "^5.0.0",
"esbuild": "^0.17.14",
"eslint": "^8.37.0",
"turbowatch": "^2.20.0",
"typescript": "^5.0.3"
"esbuild": "^0.17.16",
"eslint": "^8.38.0",
"turbowatch": "^2.21.0",
"typescript": "^5.0.4",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.30.1"
}
}
Loading

0 comments on commit 314b41b

Please sign in to comment.