0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

feat: add search package utils (#3819)

* chore: add search package

* feat: add search package utils

* feat: add search package utils

* fix order dependencies
This commit is contained in:
Juan Picado 2023-05-14 12:22:02 +02:00 committed by GitHub
parent fdd7d963ca
commit 15e58d988c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 1013 additions and 17 deletions

View file

@ -0,0 +1,5 @@
---
'@verdaccio/search': minor
---
feat: add search package utilities

View file

@ -166,7 +166,7 @@
"postinstall": "husky install",
"local:registry": "pnpm --filter ...@verdaccio/local-publish start",
"local:snapshots": "changeset version --snapshot",
"local:publish": "cross-env npm_config_registry=http://localhost:4873 pnpm ci:publish -- --no-git-tag",
"local:publish": "cross-env npm_config_registry=http://localhost:4873 changeset publish --no-git-tag",
"local:publish:release": "concurrently \"pnpm local:registry\" \"pnpm local:publish\""
},
"pnpm": {

3
packages/search/.babelrc Normal file
View file

@ -0,0 +1,3 @@
{
"extends": "../../.babelrc"
}

View file

@ -0,0 +1,729 @@
# @verdaccio/proxy
## 6.0.0-6-next.46
### Patch Changes
- @verdaccio/core@6.0.0-6-next.68
- @verdaccio/config@6.0.0-6-next.68
- @verdaccio/local-storage@11.0.0-6-next.38
- @verdaccio/utils@6.0.0-6-next.36
- @verdaccio/logger@6.0.0-6-next.36
## 6.0.0-6-next.45
### Patch Changes
- Updated dependencies [16e38df8]
- @verdaccio/config@6.0.0-6-next.67
- @verdaccio/core@6.0.0-6-next.67
- @verdaccio/local-storage@11.0.0-6-next.37
- @verdaccio/utils@6.0.0-6-next.35
- @verdaccio/logger@6.0.0-6-next.35
## 6.0.0-6-next.44
### Patch Changes
- @verdaccio/core@6.0.0-6-next.66
- @verdaccio/logger@6.0.0-6-next.34
- @verdaccio/local-storage@11.0.0-6-next.36
- @verdaccio/config@6.0.0-6-next.66
- @verdaccio/utils@6.0.0-6-next.34
## 6.0.0-6-next.43
### Patch Changes
- Updated dependencies [a1da1130]
- @verdaccio/core@6.0.0-6-next.65
- @verdaccio/config@6.0.0-6-next.65
- @verdaccio/local-storage@11.0.0-6-next.35
- @verdaccio/utils@6.0.0-6-next.33
- @verdaccio/logger@6.0.0-6-next.33
## 6.0.0-6-next.42
### Patch Changes
- Updated dependencies [974cd8c1]
- @verdaccio/core@6.0.0-6-next.64
- @verdaccio/config@6.0.0-6-next.64
- @verdaccio/local-storage@11.0.0-6-next.34
- @verdaccio/utils@6.0.0-6-next.32
- @verdaccio/logger@6.0.0-6-next.32
## 6.0.0-6-next.41
### Patch Changes
- Updated dependencies [ddb6a223]
- Updated dependencies [dc571aab]
- @verdaccio/config@6.0.0-6-next.63
- @verdaccio/core@6.0.0-6-next.63
- @verdaccio/local-storage@11.0.0-6-next.33
- @verdaccio/utils@6.0.0-6-next.31
- @verdaccio/logger@6.0.0-6-next.31
## 6.0.0-6-next.40
### Patch Changes
- Updated dependencies [378e907d]
- @verdaccio/core@6.0.0-6-next.62
- @verdaccio/logger@6.0.0-6-next.30
- @verdaccio/local-storage@11.0.0-6-next.32
- @verdaccio/config@6.0.0-6-next.62
- @verdaccio/utils@6.0.0-6-next.30
## 6.0.0-6-next.39
### Patch Changes
- Updated dependencies [d167f92e]
- @verdaccio/config@6.0.0-6-next.61
- @verdaccio/local-storage@11.0.0-6-next.31
- @verdaccio/core@6.0.0-6-next.61
- @verdaccio/utils@6.0.0-6-next.29
- @verdaccio/logger@6.0.0-6-next.29
## 6.0.0-6-next.38
### Minor Changes
- 45c03819: refactor: render html middleware
### Patch Changes
- Updated dependencies [45c03819]
- @verdaccio/config@6.0.0-6-next.60
- @verdaccio/local-storage@11.0.0-6-next.30
- @verdaccio/core@6.0.0-6-next.60
- @verdaccio/logger@6.0.0-6-next.28
- @verdaccio/utils@6.0.0-6-next.28
## 6.0.0-6-next.37
### Patch Changes
- Updated dependencies [65f88b82]
- @verdaccio/logger@6.0.0-6-next.27
- @verdaccio/local-storage@11.0.0-6-next.29
- @verdaccio/core@6.0.0-6-next.59
- @verdaccio/config@6.0.0-6-next.59
- @verdaccio/utils@6.0.0-6-next.27
## 6.0.0-6-next.36
### Patch Changes
- @verdaccio/core@6.0.0-6-next.58
- @verdaccio/config@6.0.0-6-next.58
- @verdaccio/local-storage@11.0.0-6-next.28
- @verdaccio/utils@6.0.0-6-next.26
- @verdaccio/logger@6.0.0-6-next.26
## 6.0.0-6-next.35
### Patch Changes
- @verdaccio/local-storage@11.0.0-6-next.27
- @verdaccio/core@6.0.0-6-next.57
- @verdaccio/config@6.0.0-6-next.57
- @verdaccio/logger@6.0.0-6-next.25
- @verdaccio/utils@6.0.0-6-next.25
## 6.0.0-6-next.34
### Patch Changes
- Updated dependencies [a1986e09]
- @verdaccio/utils@6.0.0-6-next.24
- @verdaccio/config@6.0.0-6-next.56
- @verdaccio/local-storage@11.0.0-6-next.26
- @verdaccio/core@6.0.0-6-next.56
- @verdaccio/logger@6.0.0-6-next.24
## 6.0.0-6-next.33
### Patch Changes
- Updated dependencies [9718e033]
- @verdaccio/config@6.0.0-6-next.55
- @verdaccio/core@6.0.0-6-next.55
- @verdaccio/utils@6.0.0-6-next.23
- @verdaccio/local-storage@11.0.0-6-next.25
- @verdaccio/logger@6.0.0-6-next.23
## 6.0.0-6-next.32
### Patch Changes
- Updated dependencies [ef88da3b]
- @verdaccio/config@6.0.0-6-next.54
- @verdaccio/core@6.0.0-6-next.54
- @verdaccio/logger@6.0.0-6-next.22
- @verdaccio/local-storage@11.0.0-6-next.24
- @verdaccio/utils@6.0.0-6-next.22
## 6.0.0-6-next.31
### Patch Changes
- @verdaccio/core@6.0.0-6-next.53
- @verdaccio/logger@6.0.0-6-next.21
- @verdaccio/local-storage@11.0.0-6-next.23
- @verdaccio/config@6.0.0-6-next.53
- @verdaccio/utils@6.0.0-6-next.21
## 6.0.0-6-next.30
### Patch Changes
- @verdaccio/core@6.0.0-6-next.52
- @verdaccio/config@6.0.0-6-next.52
- @verdaccio/logger@6.0.0-6-next.20
- @verdaccio/local-storage@11.0.0-6-next.22
- @verdaccio/utils@6.0.0-6-next.20
## 6.0.0-6-next.29
### Patch Changes
- Updated dependencies [4b29d715]
- @verdaccio/config@6.0.0-6-next.51
- @verdaccio/core@6.0.0-6-next.51
- @verdaccio/local-storage@11.0.0-6-next.21
- @verdaccio/logger@6.0.0-6-next.19
- @verdaccio/utils@6.0.0-6-next.19
## 6.0.0-6-next.28
### Patch Changes
- @verdaccio/core@6.0.0-6-next.50
- @verdaccio/config@6.0.0-6-next.50
- @verdaccio/logger@6.0.0-6-next.18
- @verdaccio/local-storage@11.0.0-6-next.20
- @verdaccio/utils@6.0.0-6-next.18
## 6.0.0-6-next.27
### Patch Changes
- @verdaccio/local-storage@11.0.0-6-next.19
- @verdaccio/core@6.0.0-6-next.49
- @verdaccio/config@6.0.0-6-next.49
- @verdaccio/logger@6.0.0-6-next.17
- @verdaccio/utils@6.0.0-6-next.17
## 6.0.0-6-next.26
### Patch Changes
- Updated dependencies [43f32687]
- Updated dependencies [9fc2e796]
- Updated dependencies [62c24b63]
- @verdaccio/core@6.0.0-6-next.48
- @verdaccio/config@6.0.0-6-next.48
- @verdaccio/local-storage@11.0.0-6-next.18
- @verdaccio/utils@6.0.0-6-next.16
- @verdaccio/logger@6.0.0-6-next.16
## 6.0.0-6-next.25
### Patch Changes
- @verdaccio/core@6.0.0-6-next.47
- @verdaccio/config@6.0.0-6-next.47
- @verdaccio/logger@6.0.0-6-next.15
- @verdaccio/local-storage@11.0.0-6-next.17
- @verdaccio/utils@6.0.0-6-next.15
## 6.0.0-6-next.24
### Patch Changes
- Updated dependencies [b849128d]
- @verdaccio/core@6.0.0-6-next.8
- @verdaccio/config@6.0.0-6-next.17
- @verdaccio/logger@6.0.0-6-next.14
- @verdaccio/local-storage@11.0.0-6-next.16
- @verdaccio/utils@6.0.0-6-next.14
## 6.0.0-6-next.23
### Patch Changes
- 351aeeaa: fix(deps): @verdaccio/utils should be a prod dep of local-storage
- Updated dependencies [351aeeaa]
- @verdaccio/core@6.0.0-6-next.7
- @verdaccio/logger@6.0.0-6-next.13
- @verdaccio/local-storage@11.0.0-6-next.15
- @verdaccio/config@6.0.0-6-next.16
- @verdaccio/utils@6.0.0-6-next.13
## 6.0.0-6-next.22
### Patch Changes
- Updated dependencies [37274e4c]
- @verdaccio/local-storage@11.0.0-6-next.14
- @verdaccio/core@6.0.0-6-next.6
- @verdaccio/logger@6.0.0-6-next.12
## 6.0.0-6-next.21
### Major Changes
- 292c0a37: feat!: replace deprecated request dependency by got
This is a big refactoring of the core, fetching dependencies, improve code, more tests and better stability. This is essential for the next release, will take some time but would allow modularize more the core.
## Notes
- Remove deprecated `request` by other `got`, retry improved, custom Agent ( got does not include it built-in)
- Remove `async` dependency from storage (used by core) it was linked with proxy somehow safe to remove now
- Refactor with promises instead callback wherever is possible
- ~Document the API~
- Improve testing, integration tests
- Bugfix
- Clean up old validations
- Improve performance
## 💥 Breaking changes
- Plugin API methods were callbacks based are returning promises, this will break current storage plugins, check documentation for upgrade.
- Write Tarball, Read Tarball methods parameters change, a new set of options like `AbortController` signals are being provided to the `addAbortSignal` can be internally used with Streams when a request is aborted. eg: `addAbortSignal(signal, fs.createReadStream(pathName));`
- `@verdaccio/streams` stream abort support is legacy is being deprecated removed
- Remove AWS and Google Cloud packages for future refactoring [#2574](https://github.com/verdaccio/verdaccio/pull/2574).
### Patch Changes
- Updated dependencies [292c0a37]
- Updated dependencies [a3a209b5]
- Updated dependencies [00d1d2a1]
- @verdaccio/config@6.0.0-6-next.15
- @verdaccio/core@6.0.0-6-next.6
- @verdaccio/logger@6.0.0-6-next.12
- @verdaccio/local-storage@11.0.0-6-next.13
- @verdaccio/utils@6.0.0-6-next.12
## 6.0.0-6-next.20
### Patch Changes
- Updated dependencies [d43894e8]
- Updated dependencies [d08fe29d]
- @verdaccio/config@6.0.0-6-next.14
- @verdaccio/local-storage@11.0.0-6-next.12
- @verdaccio/core@6.0.0-6-next.5
- @verdaccio/streams@11.0.0-6-next.5
- @verdaccio/logger@6.0.0-6-next.11
## 6.0.0-6-next.19
### Major Changes
- 82cb0f2b: feat!: config.logs throw an error, logging config not longer accept array or logs property
### 💥 Breaking change
This is valid
```yaml
log: { type: stdout, format: pretty, level: http }
```
This is invalid
```yaml
logs: { type: stdout, format: pretty, level: http }
```
or
```yaml
logs:
- [{ type: stdout, format: pretty, level: http }]
```
### Minor Changes
- 5167bb52: feat: ui search support for remote, local and private packages
The command `npm search` search globally and return all matches, with this improvement the user interface
is powered with the same capabilities.
The UI also tag where is the origin the package with a tag, also provide the latest version and description of the package.
### Patch Changes
- Updated dependencies [82cb0f2b]
- Updated dependencies [5167bb52]
- @verdaccio/config@6.0.0-6-next.13
- @verdaccio/core@6.0.0-6-next.5
- @verdaccio/logger@6.0.0-6-next.11
- @verdaccio/local-storage@11.0.0-6-next.12
- @verdaccio/utils@6.0.0-6-next.11
- @verdaccio/streams@11.0.0-6-next.5
## 6.0.0-6-next.18
### Patch Changes
- Updated dependencies [b78f3525]
- @verdaccio/logger@6.0.0-6-next.10
## 6.0.0-6-next.17
### Patch Changes
- Updated dependencies [730b5d8c]
- @verdaccio/logger@6.0.0-6-next.9
## 6.0.0-6-next.16
### Patch Changes
- Updated dependencies [a828271d]
- Updated dependencies [24b9be02]
- Updated dependencies [e75c0a3b]
- Updated dependencies [b13a3fef]
- @verdaccio/local-storage@11.0.0-6-next.11
- @verdaccio/utils@6.0.0-6-next.10
- @verdaccio/core@6.0.0-6-next.4
- @verdaccio/logger@6.0.0-6-next.8
- @verdaccio/config@6.0.0-6-next.12
- @verdaccio/streams@11.0.0-6-next.5
## 6.0.0-6-next.15
### Patch Changes
- Updated dependencies [f86c31ed]
- @verdaccio/utils@6.0.0-6-next.9
- @verdaccio/config@6.0.0-6-next.11
- @verdaccio/local-storage@11.0.0-6-next.10
## 6.0.0-6-next.14
### Patch Changes
- Updated dependencies [6c1eb021]
- @verdaccio/core@6.0.0-6-next.3
- @verdaccio/logger@6.0.0-6-next.7
- @verdaccio/config@6.0.0-6-next.10
- @verdaccio/local-storage@11.0.0-6-next.10
- @verdaccio/utils@6.0.0-6-next.8
## 6.0.0-6-next.13
### Minor Changes
- b702ea36: abort search request support for proxy
- 154b2ecd: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
### Patch Changes
- Updated dependencies [794af76c]
- Updated dependencies [154b2ecd]
- @verdaccio/config@6.0.0-6-next.9
- @verdaccio/core@6.0.0-6-next.2
- @verdaccio/streams@11.0.0-6-next.5
- @verdaccio/logger@6.0.0-6-next.6
- @verdaccio/utils@6.0.0-6-next.7
- @verdaccio/local-storage@11.0.0-6-next.9
## 6.0.0-6-next.12
### Patch Changes
- Updated dependencies [2c594910]
- @verdaccio/logger@6.0.0-6-next.5
## 6.0.0-6-next.11
### Major Changes
- 459b6fa7: refactor: search v1 endpoint and local-database
- refactor search `api v1` endpoint, improve performance
- remove usage of `async` dependency https://github.com/verdaccio/verdaccio/issues/1225
- refactor method storage class
- create new module `core` to reduce the ammount of modules with utilities
- use `undici` instead `node-fetch`
- use `fastify` instead `express` for functional test
### Breaking changes
- plugin storage API changes
- remove old search endpoint (return 404)
- filter local private packages at plugin level
The storage api changes for methods `get`, `add`, `remove` as promise base. The `search` methods also changes and recieves a `query` object that contains all query params from the client.
```ts
export interface IPluginStorage<T> extends IPlugin {
add(name: string): Promise<void>;
remove(name: string): Promise<void>;
get(): Promise<any>;
init(): Promise<void>;
getSecret(): Promise<string>;
setSecret(secret: string): Promise<any>;
getPackageStorage(packageInfo: string): IPackageStorage;
search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;
saveToken(token: Token): Promise<any>;
deleteToken(user: string, tokenKey: string): Promise<any>;
readTokens(filter: TokenFilter): Promise<Token[]>;
}
```
### Patch Changes
- Updated dependencies [459b6fa7]
- @verdaccio/config@6.0.0-6-next.8
- @verdaccio/commons-api@11.0.0-6-next.4
- @verdaccio/core@6.0.0-6-next.1
- @verdaccio/local-storage@11.0.0-6-next.8
- @verdaccio/streams@11.0.0-6-next.4
- @verdaccio/utils@6.0.0-6-next.6
- @verdaccio/logger@6.0.0-6-next.4
## 6.0.0-6-next.10
### Patch Changes
- Updated dependencies [df0da3d6]
- @verdaccio/local-storage@11.0.0-6-next.7
## 6.0.0-6-next.9
### Patch Changes
- Updated dependencies [d2c65da9]
- @verdaccio/utils@6.0.0-6-next.5
- @verdaccio/config@6.0.0-6-next.7
## 6.0.0-6-next.8
### Patch Changes
- Updated dependencies [1b217fd3]
- @verdaccio/config@6.0.0-6-next.6
- @verdaccio/local-storage@11.0.0-6-next.6
## 6.0.0-6-next.7
### Patch Changes
- Updated dependencies [1810ed0d]
- Updated dependencies [648575aa]
- @verdaccio/config@6.0.0-6-next.5
- @verdaccio/utils@6.0.0-6-next.4
## 6.0.0-6-next.6
### Patch Changes
- Updated dependencies [5c5057fc]
- @verdaccio/config@6.0.0-6-next.4
- @verdaccio/logger@6.0.0-6-next.4
- @verdaccio/local-storage@11.0.0-6-next.5
- @verdaccio/streams@11.0.0-alpha.3
## 6.0.0-6-next.5
### Patch Changes
- Updated dependencies [cb2281a5]
- @verdaccio/local-storage@11.0.0-6-next.5
## 5.0.0-alpha.4
### Patch Changes
- fecbb9be: chore: add release step to private regisry on merge changeset pr
- Updated dependencies [fecbb9be]
- @verdaccio/local-storage@10.0.0-alpha.4
- @verdaccio/config@5.0.0-alpha.3
- @verdaccio/commons-api@10.0.0-alpha.3
- @verdaccio/streams@10.0.0-alpha.3
- @verdaccio/logger@5.0.0-alpha.3
- @verdaccio/utils@5.0.0-alpha.3
## 5.0.0-alpha.3
### Minor Changes
- 54c58d1e: feat: add server rate limit protection to all request
To modify custom values, use the server settings property.
```markdown
server:
## https://www.npmjs.com/package/express-rate-limit#configuration-options
rateLimit:
windowMs: 1000
max: 10000
```
The values are intended to be high, if you want to improve security of your server consider
using different values.
### Patch Changes
- Updated dependencies [54c58d1e]
- @verdaccio/config@5.0.0-alpha.2
- @verdaccio/commons-api@10.0.0-alpha.2
- @verdaccio/local-storage@10.0.0-alpha.3
- @verdaccio/streams@10.0.0-alpha.2
- @verdaccio/logger@5.0.0-alpha.2
- @verdaccio/utils@5.0.0-alpha.2
## 5.0.0-alpha.2
### Patch Changes
- Updated dependencies [2a327c4b]
- @verdaccio/local-storage@10.0.0-alpha.2
## 5.0.0-alpha.1
### Major Changes
- d87fa026: feat!: experiments config renamed to flags
- The `experiments` configuration is renamed to `flags`. The functionality is exactly the same.
```js
flags: token: false;
search: false;
```
- The `self_path` property from the config file is being removed in favor of `config_file` full path.
- Refactor `config` module, better types and utilities
- da1ee9c8: - Replace signature handler for legacy tokens by removing deprecated crypto.createDecipher by createCipheriv
- Introduce environment variables for legacy tokens
### Code Improvements
- Add debug library for improve developer experience
### Breaking change
- The new signature invalidates all previous tokens generated by Verdaccio 4 or previous versions.
- The secret key must have 32 characters long.
### New environment variables
- `VERDACCIO_LEGACY_ALGORITHM`: Allows to define the specific algorithm for the token signature which by default is `aes-256-ctr`
- `VERDACCIO_LEGACY_ENCRYPTION_KEY`: By default, the token stores in the database, but using this variable allows to get it from memory
### Minor Changes
- 26b494cb: feat: add typescript project references settings
Reading https://ebaytech.berlin/optimizing-multi-package-apps-with-typescript-project-references-d5c57a3b4440 I realized I can use project references to solve the issue to pre-compile modules on develop mode.
It allows to navigate (IDE) trough the packages without need compile the packages.
Add two `tsconfig`, one using the previous existing configuration that is able to produce declaration files (`tsconfig.build`) and a new one `tsconfig` which is enables [_projects references_](https://www.typescriptlang.org/docs/handbook/project-references.html).
### Patch Changes
- ae52ba35: refactor: migrate request to node-fetch at hooks package
- b57b4338: Enable prerelease mode with **changesets**
- 31af0164: ESLint Warnings Fixed
Related to issue #1461
- max-len: most of the sensible max-len errors are fixed
- no-unused-vars: most of these types of errors are fixed by deleting not needed declarations
- @typescript-eslint/no-unused-vars: same as above
- Updated dependencies [d87fa026]
- Updated dependencies [da1ee9c8]
- Updated dependencies [26b494cb]
- Updated dependencies [b57b4338]
- Updated dependencies [add778d5]
- Updated dependencies [31af0164]
- @verdaccio/config@5.0.0-alpha.1
- @verdaccio/commons-api@10.0.0-alpha.1
- @verdaccio/local-storage@10.0.0-alpha.1
- @verdaccio/streams@10.0.0-alpha.1
- @verdaccio/logger@5.0.0-alpha.1
- @verdaccio/utils@5.0.0-alpha.1
## 5.0.0-alpha.1
### Major Changes
- d87fa0268: feat!: experiments config renamed to flags
- The `experiments` configuration is renamed to `flags`. The functionality is exactly the same.
```js
flags: token: false;
search: false;
```
- The `self_path` property from the config file is being removed in favor of `config_file` full path.
- Refactor `config` module, better types and utilities
- da1ee9c82: - Replace signature handler for legacy tokens by removing deprecated crypto.createDecipher by createCipheriv
- Introduce environment variables for legacy tokens
### Code Improvements
- Add debug library for improve developer experience
### Breaking change
- The new signature invalidates all previous tokens generated by Verdaccio 4 or previous versions.
- The secret key must have 32 characters long.
### New environment variables
- `VERDACCIO_LEGACY_ALGORITHM`: Allows to define the specific algorithm for the token signature which by default is `aes-256-ctr`
- `VERDACCIO_LEGACY_ENCRYPTION_KEY`: By default, the token stores in the database, but using this variable allows to get it from memory
### Minor Changes
- 26b494cbd: feat: add typescript project references settings
Reading https://ebaytech.berlin/optimizing-multi-package-apps-with-typescript-project-references-d5c57a3b4440 I realized I can use project references to solve the issue to pre-compile modules on develop mode.
It allows to navigate (IDE) trough the packages without need compile the packages.
Add two `tsconfig`, one using the previous existing configuration that is able to produce declaration files (`tsconfig.build`) and a new one `tsconfig` which is enables [_projects references_](https://www.typescriptlang.org/docs/handbook/project-references.html).
### Patch Changes
- ae52ba352: refactor: migrate request to node-fetch at hooks package
- b57b43388: Enable prerelease mode with **changesets**
- 31af01641: ESLint Warnings Fixed
Related to issue #1461
- max-len: most of the sensible max-len errors are fixed
- no-unused-vars: most of these types of errors are fixed by deleting not needed declarations
- @typescript-eslint/no-unused-vars: same as above
- Updated dependencies [d87fa0268]
- Updated dependencies [da1ee9c82]
- Updated dependencies [26b494cbd]
- Updated dependencies [b57b43388]
- Updated dependencies [add778d55]
- Updated dependencies [31af01641]
- @verdaccio/config@5.0.0-alpha.1
- @verdaccio/commons-api@10.0.0-alpha.0
- @verdaccio/local-storage@10.0.0-alpha.0
- @verdaccio/streams@10.0.0-alpha.0
- @verdaccio/logger@5.0.0-alpha.1
- @verdaccio/utils@5.0.0-alpha.1

29
packages/search/README.md Normal file
View file

@ -0,0 +1,29 @@
# @verdaccio/search
Search utilities
```bash
npm install @verdaccio/search
```
[![backers](https://opencollective.com/verdaccio/tiers/backer/badge.svg?label=Backer&color=brightgreen)](https://opencollective.com/verdaccio)
[![stackshare](https://img.shields.io/badge/Follow%20on-StackShare-blue.svg?logo=stackshare&style=flat)](https://stackshare.io/verdaccio)
[![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/verdaccio/localized.svg)](https://crowdin.com/project/verdaccio)
[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/verdaccio/verdaccio)](https://www.tickgit.com/browse?repo=github.com/verdaccio/verdaccio)
[![Twitter followers](https://img.shields.io/twitter/follow/verdaccio_npm.svg?style=social&label=Follow)](https://twitter.com/verdaccio_npm)
[![Github](https://img.shields.io/github/stars/verdaccio/verdaccio.svg?style=social&label=Stars)](https://github.com/verdaccio/verdaccio/stargazers)
## Donations
Verdaccio is run by **volunteers**; nobody is working full-time on it. If you find this project to be useful and would like to support its development, consider making a donation - **your logo might end up in this readme.** 😉
**[Donate](https://opencollective.com/verdaccio)** 💵👍🏻 starting from _\$1/month_ or just one single contribution.
### License
Verdaccio is [MIT licensed](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
The Verdaccio documentation and logos (excluding /thanks, e.g., .md, .png, .sketch) files within the /assets folder) is
[Creative Commons licensed](https://github.com/verdaccio/verdaccio/blob/master/LICENSE-docs).

View file

@ -0,0 +1,12 @@
const config = require('../../jest/config');
module.exports = Object.assign({}, config, {
coverageThreshold: {
global: {
branches: 79,
functions: 94,
lines: 87,
statements: 87,
},
},
});

View file

@ -0,0 +1,51 @@
{
"name": "@verdaccio/search",
"version": "6.0.0-6-next.1",
"description": "verdaccio search utitlity tools",
"main": "./build/dist.js",
"types": "build/index.d.ts",
"author": {
"name": "Juan Picado",
"email": "juanpicado19@gmail.com"
},
"repository": {
"type": "https",
"url": "https://github.com/verdaccio/verdaccio"
},
"license": "MIT",
"homepage": "https://verdaccio.org",
"keywords": [
"private",
"package",
"repository",
"registry",
"enterprise",
"modules",
"proxy",
"server",
"verdaccio"
],
"engines": {
"node": ">=12",
"npm": ">=6"
},
"scripts": {
"clean": "rimraf ./build",
"test": "echo 1",
"type-check": "tsc --noEmit -p tsconfig.build.json",
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
"build": "esbuild src/index.ts --bundle --outfile=build/dist.js --platform=node --target=node12 && pnpm run build:types"
},
"devDependencies": {
"@types/node": "16.18.10",
"@verdaccio/types": "workspace:11.0.0-6-next.25",
"@orama/orama": "1.0.0-beta.16",
"debug": "4.3.4",
"esbuild": "0.14.10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/verdaccio"
}
}

View file

@ -0,0 +1 @@
export { default as SearchMemoryIndexer } from './indexer';

View file

@ -0,0 +1,113 @@
import { create, insert, remove, search } from '@orama/orama';
import buildDebug from 'debug';
import { Version } from '@verdaccio/types';
const debug = buildDebug('verdaccio:search:indexer');
type Results = any;
class SearchMemoryIndexer {
private database: any | undefined;
private storage: any;
/**
* Set up the {Storage}
* @param {*} storage An storage reference.
*/
public configureStorage(storage): void {
this.storage = storage;
}
/**
* Performs a query to the indexer.
* If the keyword is a * it returns all local elements
* otherwise performs a search
* @param {*} q the keyword
* @return {Array} list of results.
*/
public async query(term: string): Promise<Results | void> {
if (this.database) {
debug('searching %s at indexer', term);
const searchResult = await search(this.database, {
term,
properties: '*',
});
return searchResult;
}
}
/**
* Add a new element to index
* @param {*} pkg the package
*/
public async add(pkg: Version): Promise<void> {
if (this.database) {
const name = pkg.name;
debug('adding item %s to the indexer', name);
insert(this.database, {
id: name,
name: name,
description: pkg.description,
version: `v${pkg.version}`,
keywords: pkg.keywords,
author: pkg._npmUser ? pkg._npmUser.name : '???',
});
}
}
/**
* Remove an element from the index.
* @param {*} name the id element
*/
public async remove(name: string): Promise<void> {
if (this.database) {
debug('removing item %s to the indexer', name);
await remove(this.database, name);
}
}
/**
* Force a re-index.
*/
public reindex(): void {
debug('reindexing search indexer');
this.storage?.getLocalDatabase((error, packages): void => {
if (error) {
// that function shouldn't produce any
throw error;
}
let i = packages.length;
if (i === 0) {
debug('no packages to index');
}
while (i--) {
const pkg = packages[i];
debug('indexing package %s', pkg?.name);
this.add(pkg);
}
debug('reindexed search indexer');
});
}
public async init() {
this.database = await create({
schema: {
id: 'string',
name: 'string',
description: 'string',
keywords: 'string',
version: 'string',
readme: 'string',
},
});
this.reindex();
}
}
export default new SearchMemoryIndexer();
export { Results };

View file

@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./build"
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.test.ts"]
}

View file

@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.reference.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./build",
"noImplicitAny": false
},
"include": ["src/**/*.ts", "types/*.d.ts"],
"references": [
{
"path": "../config"
},
{
"path": "../core/core"
},
{
"path": "../logger/logger"
},
{
"path": "../utils"
}
]
}

10
packages/search/types/patch.d.ts vendored Normal file
View file

@ -0,0 +1,10 @@
declare module 'jest-matcher-utils';
declare module 'pretty-format' {
export type Plugin = any;
export type CompareKeys = any;
}
declare module '@jest/schemas' {
export type SnapshotFormat = any;
}
declare module '@szmarczak/http-timer';

View file

@ -693,7 +693,7 @@ importers:
version: 0.23.25(typescript@4.9.4)
typedoc-plugin-missing-exports:
specifier: latest
version: 2.0.0(typedoc@0.23.25)
version: 1.0.0(typedoc@0.23.25)
packages/core/file-locking:
dependencies:
@ -1450,6 +1450,24 @@ importers:
specifier: 7.5.0
version: 7.5.0
packages/search:
devDependencies:
'@orama/orama':
specifier: 1.0.0-beta.16
version: 1.0.0-beta.16
'@types/node':
specifier: 16.18.10
version: 16.18.10
'@verdaccio/types':
specifier: workspace:11.0.0-6-next.25
version: link:../core/types
debug:
specifier: 4.3.4
version: 4.3.4(supports-color@6.1.0)
esbuild:
specifier: 0.14.10
version: 0.14.10
packages/server/express:
dependencies:
'@verdaccio/api':
@ -7983,6 +8001,11 @@ packages:
resolution: {integrity: sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q==}
dev: true
/@orama/orama@1.0.0-beta.16:
resolution: {integrity: sha512-mmjP9+w7EgnpyLLs/vIPHsNKwreTsHAkPK44JQ62kRYseatHT5VEL/5nr/duBAReEZVbqMFst1jVJCHsucXr3g==}
engines: {node: '>= 16.0.0'}
dev: true
/@pmmmwh/react-refresh-webpack-plugin@0.5.10(@types/webpack@5.28.1)(react-refresh@0.11.0)(webpack@5.82.1):
resolution: {integrity: sha512-j0Ya0hCFZPd4x40qLzbhGsh9TMtdb+CJQiso+WxLOPNasohq9cc5SNUcwsZaRH6++Xh91Xkm/xHCkuIiIu0LUA==}
engines: {node: '>= 10.13'}
@ -8650,7 +8673,7 @@ packages:
'@storybook/semver': 7.3.2
'@storybook/store': 6.5.16(react-dom@18.2.0)(react@18.2.0)
'@storybook/theming': 6.5.16(react-dom@18.2.0)(react@18.2.0)
'@types/node': 16.18.23
'@types/node': 16.18.10
babel-loader: 8.3.0(@babel/core@7.21.4)(webpack@5.82.1)
babel-plugin-named-exports-order: 0.0.2
browser-assert: 1.2.1
@ -9177,7 +9200,7 @@ packages:
'@storybook/node-logger': 6.5.16
'@storybook/theming': 6.5.16(react-dom@18.2.0)(react@18.2.0)
'@storybook/ui': 6.5.16(react-dom@18.2.0)(react@18.2.0)
'@types/node': 16.18.23
'@types/node': 16.18.10
babel-loader: 8.3.0(@babel/core@7.21.4)(webpack@5.82.1)
case-sensitive-paths-webpack-plugin: 2.4.0
chalk: 4.1.2
@ -9359,7 +9382,7 @@ packages:
'@storybook/semver': 7.3.2
'@storybook/store': 6.5.16(react-dom@18.2.0)(react@18.2.0)
'@types/estree': 0.0.51
'@types/node': 16.18.23
'@types/node': 16.18.10
'@types/webpack-env': 1.18.0
acorn: 7.4.1
acorn-jsx: 5.3.2(acorn@7.4.1)
@ -10234,10 +10257,6 @@ packages:
/@types/node@16.18.10:
resolution: {integrity: sha512-XU1+v7h81p7145ddPfjv7jtWvkSilpcnON3mQ+bDi9Yuf7OI56efOglXRyXWgQ57xH3fEQgh7WOJMncRHVew5w==}
/@types/node@16.18.23:
resolution: {integrity: sha512-XAMpaw1s1+6zM+jn2tmw8MyaRDIJfXxqmIQIS0HfoGYPuf7dUWeiUKopwq13KFX9lEp1+THGtlaaYx39Nxr58g==}
dev: true
/@types/node@17.0.45:
resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==}
dev: false
@ -25806,14 +25825,6 @@ packages:
typedoc: 0.23.25(typescript@4.9.4)
dev: true
/typedoc-plugin-missing-exports@2.0.0(typedoc@0.23.25):
resolution: {integrity: sha512-t0QlKCm27/8DaheJkLo/gInSNjzBXgSciGhoLpL6sLyXZibm7SuwJtHvg4qXI2IjJfFBgW9mJvvszpoxMyB0TA==}
peerDependencies:
typedoc: 0.24.x
dependencies:
typedoc: 0.23.25(typescript@4.9.4)
dev: true
/typedoc@0.23.25(typescript@4.9.4):
resolution: {integrity: sha512-O1he153qVyoCgJYSvIyY3bPP1wAJTegZfa6tL3APinSZhJOf8CSd8F/21M6ex8pUY/fuY6n0jAsT4fIuMGA6sA==}
engines: {node: '>= 14.14'}