Skip to content

Commit

Permalink
Rename the Project
Browse files Browse the repository at this point in the history
  • Loading branch information
widoz committed Jul 20, 2024
1 parent 3a5a51a commit 1a68941
Show file tree
Hide file tree
Showing 68 changed files with 286 additions and 286 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
'@wordpress/i18n-text-domain': [
'error',
{
allowedTextDomain: 'wp-entities-search',
allowedTextDomain: 'kensaku',
},
],
'@typescript-eslint/array-type': [ 'error', { default: 'generic' } ],
Expand Down
2 changes: 1 addition & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"development": {
"phpVersion": "8.1",
"mappings": {
"wp-content/plugins/wp-entities-search": "."
"wp-content/plugins/kensaku": "."
}
}
},
Expand Down
14 changes: 7 additions & 7 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { BaseEntityRecords, Context } from '@wordpress/core-data';

import type { Set } from '../sources/client/src';

export default EntitiesSearch;
export default Kensaku;

// TODO Try to convert it to a module.
declare namespace EntitiesSearch {
declare namespace Kensaku {
type Post<C extends Context = 'view'> = BaseEntityRecords.Post<C>;
type PostType<C extends Context = 'view'> = BaseEntityRecords.Type<C>;
type Taxonomy<C extends Context = 'view'> = BaseEntityRecords.Taxonomy<C>;
Expand All @@ -23,7 +23,7 @@ declare namespace EntitiesSearch {
Readonly<{
exclude: Set<string | number>;
include: Set<string | number>;
fields: EntitiesSearch.SearchQueryFields;
fields: Kensaku.SearchQueryFields;
[p: string]: unknown;
}>
> {}
Expand All @@ -42,7 +42,7 @@ declare namespace EntitiesSearch {
type SearchEntitiesFunction<E, K> = (
phrase: string,
kind: Kind<K>,
queryArguments?: EntitiesSearch.QueryArguments<E>
queryArguments?: Kensaku.QueryArguments<E>
) => Promise<Options<E>>;

type SingularControl<V> = {
Expand Down Expand Up @@ -104,7 +104,7 @@ declare namespace EntitiesSearch {
*/
// TODO Better to convert the SearchQueryFields to a Set.
type SearchQueryFields = ReadonlyArray<
keyof EntitiesSearch.SearchEntityFields
keyof Kensaku.SearchEntityFields
>;

/*
Expand All @@ -113,7 +113,7 @@ declare namespace EntitiesSearch {
interface EntitiesState<
E,
K,
OptionSet = Set<EntitiesSearch.ControlOption<E>>
OptionSet = Set<Kensaku.ControlOption<E>>
> extends Readonly<{
entities: Entities<E>;
kind: Kind<K>;
Expand Down Expand Up @@ -150,7 +150,7 @@ declare namespace EntitiesSearch {
}
| {
type: 'UPDATE_ENTITIES_OPTIONS_FOR_NEW_KIND';
entitiesOptions: Set<EntitiesSearch.ControlOption<E>>;
entitiesOptions: Set<Kensaku.ControlOption<E>>;
kind: EntitiesState<E, K>['kind'];
}
| {
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Wp Entities Search
# Kensaku

> A WordPress package to search Entities including Rest API Endpoints and React Components
[![JS Quality Assurance](https://github.com/spaghetti-dojo/wp-entities-search/actions/workflows/js-qa.yml/badge.svg)](https://github.com/spaghetti-dojo/wp-entities-search/actions/workflows/js-qa.yml)
[![PHP Quality Assurance](https://github.com/spaghetti-dojo/wp-entities-search/actions/workflows/php-qa.yml/badge.svg)](https://github.com/spaghetti-dojo/wp-entities-search/actions/workflows/php-qa.yml)
[![JS Quality Assurance](https://github.com/spaghetti-dojo/kensaku/actions/workflows/js-qa.yml/badge.svg)](https://github.com/spaghetti-dojo/kensaku/actions/workflows/js-qa.yml)
[![PHP Quality Assurance](https://github.com/spaghetti-dojo/kensaku/actions/workflows/php-qa.yml/badge.svg)](https://github.com/spaghetti-dojo/kensaku/actions/workflows/php-qa.yml)

This package is a library exposing reusable Components and Utilities to help you build Entities searching and storage.

Expand All @@ -12,7 +12,7 @@ more Post Types but also, to search for Terms belonging to one or more Taxonomie

## Documentation

Go to [documentation](./docs) or visit the site [wp-entities-search](https://spaghetti-dojo.github.io/wp-entities-search/).
Go to [documentation](./docs) or visit the site [kensaku](https://spaghetti-dojo.github.io/kensaku/).

## License

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "spaghetti-dojo/wp-entities-search",
"name": "spaghetti-dojo/kensaku",
"description": "A WordPress package to search Entities including Rest API Endpoints and React Components",
"type": "library",
"license": "GPL-2.0-or-later",
"autoload": {
"psr-4": {
"SpaghettiDojo\\Wp\\EntitiesSearch\\": "sources/server/src/"
"SpaghettiDojo\\Kensaku\\": "sources/server/src/"
}
},
"authors": [
Expand Down
12 changes: 6 additions & 6 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
title: Wp Entities Search
title: Kensaku
description: >-
A WordPress package to search Entities including Rest API Endpoints and React Components
url: "https://spaghetti-dojo.github.io/wp-entities-search"
baseurl: "/wp-entities-search"
url: "https://spaghetti-dojo.github.io/kensaku"
baseurl: "/kensaku"

remote_theme: just-the-docs/just-the-docs

aux_links:
"Wp Entities Search on Github":
- "https://github.com/spaghetti-dojo/wp-entities-search"
"Kensaku on Github":
- "https://github.com/spaghetti-dojo/kensaku"

aux_links_new_tab: true

nav_external_links:
- title: Go to the Repository
url: https://github.com/spaghetti-dojo/wp-entities-search
url: https://github.com/spaghetti-dojo/kensaku
opens_in_new_tab: true

back_to_top: true
Expand Down
10 changes: 5 additions & 5 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ The package provide then the following functions to interact with the WordPress

This function is a wrapper for the Search Endpoint of the WordPress API. It will return a `Set` of entities matching the search query.

The possible query arguments are specified by the `EntitiesSearch.QueryArguments` type, an interface you can expand to add more arguments.
The possible query arguments are specified by the `Kensaku.QueryArguments` type, an interface you can expand to add more arguments.

This function is not directly consumed by the components, and it is not intended to be used internally. The idea is to follow the Tell don't Ask principle and let the consumer specify how to search the Entities.

Below a possible example of its usage related to a component:

```tsx
// my-component.tsx
type Search = EntitiesSearch.SearchEntitiesFunction<string, string>;
type Search = Kensaku.SearchEntitiesFunction<string, string>;
type Props = {
search: Search
}
Expand All @@ -48,7 +48,7 @@ const MyComponent (props: Props) => {
}

// index.tsx
import {searchEntities} from 'wp-entities-search';
import {searchEntities} from 'kensaku';

root.render(<MyComponent search={searchEntities} />);
```
Expand All @@ -60,7 +60,7 @@ The function accept four parameters
- `type` - The root type. We have two built-int supported types `post`, `term`.
- `subtype` - The subtype of the entity. For example, if the `type` is `post`, the `subtype` can be `page`, `post`, etc. WordPress exclude automatically the `attachment` subtype.
- `phrase` - The search phrase. This becomes the `s` parameter for the Search Endpoint.
- `queryArguments` - All the supported and extra query arguments. The `EntitiesSearch.QueryArguments` type is an interface you can expand to add more arguments.
- `queryArguments` - All the supported and extra query arguments. The `Kensaku.QueryArguments` type is an interface you can expand to add more arguments.

### Return

Expand All @@ -77,7 +77,7 @@ The `searchEntities` will automatically abort the requests with the same paramet
## `searchEntitiesOptions`

This function is a wrapper for the `searchEntites` which perform a small additional task you might want to do quite ofter after retrieving the entities that is
to convert the entities to `EntitiesSearch.ControlOptions`. The argument taken are the same of the `searchEntities`.
to convert the entities to `Kensaku.ControlOptions`. The argument taken are the same of the `searchEntities`.

### `createSearchEntitiesOptions`

Expand Down
12 changes: 6 additions & 6 deletions docs/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ nav_order: 4

# Components

The Wp Entities Search provides a set of components you can use to build your search UI.
Kensaku provides a set of components you can use to build your search UI.

We have to distinguish between two types of components:

Expand Down Expand Up @@ -57,7 +57,7 @@ possible to use a search function in conjunction with a `search` field.
An example of its usage is:

```jsx
import { CompositeEntitiesByKind } from 'wp-entities-search';
import { CompositeEntitiesByKind } from 'kensaku';

export function MyComponent(props) {
const entities = {
Expand Down Expand Up @@ -146,7 +146,7 @@ In the example below we only allow to select the entities belonging to the `page
the user to switch between them.

```jsx
import { CompositeEntitiesByKind } from 'wp-entities-search';
import { CompositeEntitiesByKind } from 'kensaku';

export function MyComponent(props) {
const entities = {
Expand Down Expand Up @@ -228,11 +228,11 @@ Therefore, the preset simplify and take care of some parts that you would have t

- `entitiesFinder` - The function which perform the search of the contextual entities. You can use the `createSearchEntitiesOptions` function by passing the `root` value such as `term` or `post`.
- `className` - For better customization you can pass your own custom classes.
- `entities` - A `EntitiesSearch.Entities` set of selected entities. For when you want some entities already selected.
- `entities` - A `Kensaku.Entities` set of selected entities. For when you want some entities already selected.
- `onChangeEntities` - A task to perform when the selection change due to a user interaction.
- `entitiesComponent` - The component to use to render the control ui for the entities.
- `kind` - The predefined set of kind (e.g. post-types or taxonomies) you want to have already selected.
- `kindOptions` - A collection of `EntitiesSearch.ControlOption` among which the user can choose to retrieve the entities from.
- `kindOptions` - A collection of `Kensaku.ControlOption` among which the user can choose to retrieve the entities from.
- `onChangeKind` - A task to perform when the selection change due to a user interaction.
- `kindComponent` - The component to use to render the control ui for the kinds.
- `entitiesFields` - Additional fields you want to retrieve and have available within your `entitiesComponent` and `kindComponent`. For more info read the [Control Option](./control-option.md) documentation.
Expand All @@ -246,7 +246,7 @@ The Singular Components always get a single value, therefore you have to conside
the `Set`.

```jsx
import { CompositeEntitiesByKind } from 'wp-entities-search';
import { CompositeEntitiesByKind } from 'kensaku';

export function MyComponent(props) {
return <CompositeEntitiesByKind
Expand Down
8 changes: 4 additions & 4 deletions docs/control-option.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ An additional data structure is part of the `EnrichedControlOption` interface im
not consumed within any of the _Base_ or _Composite_ components of the project, it is there to permit the third parties
to customize the UI.

The `extra` property is of type `EntitiesSearch.Record`; it can hold a heterogeneous set of properties, we do not check
The `extra` property is of type `Kensaku.Record`; it can hold a heterogeneous set of properties, we do not check
against values or types, this is up to the consumer.

## About the Value
Expand All @@ -27,7 +27,7 @@ The `value` is a generic type to give the possibility to customize the shape of
implement they own components, and therefore we do not want to pose any restriction.

Nonetheless, the possible types the `value` can assume within the project Components is `string | number`;
see `EntitiesSearch.Value` type for more info.
see `Kensaku.Value` type for more info.

## How to use the Extra Property

Expand Down Expand Up @@ -65,10 +65,10 @@ searchEntities: async (
```

Then you can access the extra properties within your component since the `CompositeEntitiesByKind` will pass
the `entities` of type `EntitiesSearch.BaseControl< E >` to the children.
the `entities` of type `Kensaku.BaseControl< E >` to the children.

```jsx
(entities: EntitiesSearch.BaseControl< E >) => {
(entities: Kensaku.BaseControl< E >) => {
return <MyComponent {...entities} />;
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ nav_order: 2
The first thing to do is to clone the repository and install the dependencies:

```bash
$ git clone [email protected]:spaghetti-dojo/wp-entities-search.git
$ cd wp-entities-search
$ git clone [email protected]:spaghetti-dojo/kensaku.git
$ cd kensaku
$ composer install
$ yarn install
```
Expand Down
6 changes: 3 additions & 3 deletions docs/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ nav_order: 6

# Hooks

The Wp Entities Search expose some hooks to help you to work with the search and the rest calls.
Kensaku expose some hooks to help you to work with the search and the rest calls.

- `useEntitiesOptionsStorage`
- `useEntitiesRecords`
Expand Down Expand Up @@ -64,7 +64,7 @@ endpoint.
The following example is retrieving the list of the `postType`s from the server.

```ts
const entitiesRecords = useEntityRecords<EntitiesSearch.PostType<'edit'>>(
const entitiesRecords = useEntityRecords<Kensaku.PostType<'edit'>>(
'root',
'postType',
{ per_page: -1 }
Expand Down Expand Up @@ -94,5 +94,5 @@ It requires a function `searchEntities` to perform the search to the server, the
query for the new entities values. In the future there'll be the possibility to reuse the storage directly from within
the hook reducing the amount of parameters, and for last the `dispatch`, necessary to update the shared state.

When the state update fail for any reason an action `wp-entities-search.on-search.error` is fired. You can hook into it
When the state update fail for any reason an action `kensaku.on-search.error` is fired. You can hook into it
and consume the given `error` instance. More on this in the [logging](./logging.md) documentation.
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The JavaScript implementation is composed of a set of utilities and React compon
To install the package as part of the composer dependencies of your project, run the following command:

```bash
composer require spaghetti-dojo/wp-entities-search
composer require spaghetti-dojo/kensaku
```

## NPM
Expand Down
4 changes: 2 additions & 2 deletions docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ For instance, below you can see an example of one of the actions error logging.

```ts
addAction(
'wp-entities-search.on-change-entities.error',
'wp-entities-search/wp-on-change-entities.error',
'kensaku.on-change-entities.error',
'kensaku/wp-on-change-entities.error',
(error) => {
console.error(
`Composite Entities by Kind - on Change Entities: ${
Expand Down
2 changes: 1 addition & 1 deletion docs/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: home
title: Wp Entities Search
title: Kensaku
permalink: /
nav_order: 0
---
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "wp-entities-search",
"name": "kensaku",
"description": "A WordPress package to search Entities including Rest API Endpoints and React Components",
"author": "guido scialfa <[email protected]>",
"main": "./build/index.js",
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<arg name="colors"/>
<arg name="extensions" value="php,inc"/>

<config name="text_domain" value="wp-entities-search"/>
<config name="text_domain" value="kensaku"/>
<config name="testVersion" value="8.1-"/>
<config name="ignore_warnings_on_exit" value="1"/>

Expand Down
12 changes: 6 additions & 6 deletions plugin.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

/**
* Plugin Name: Wp Entities Search
* Plugin Name: Kensaku
* Author: Guido Scialfa
* Description: The WordPress plugin to develop the Wp Search Entities library.
* Description: The WordPress plugin to develop the Kensaku entities search library.
* Author URI: https://guidoscialfa.com/
*/

declare(strict_types=1);

namespace SpaghettiDojo\Wp\EntitiesSearch;
namespace SpaghettiDojo\Kensaku;

use Inpsyde\Modularity;
use SpaghettiDojo\Wp\EntitiesSearch;
use SpaghettiDojo\Kensaku;

function package(): Modularity\Package
{
Expand All @@ -33,7 +33,7 @@ function autoload(string $projectRoot): void

if (!$package) {
autoload($projectRoot);
$package = EntitiesSearch\Library::new(\plugin_dir_url(__FILE__))->package();
$package = Kensaku\Library::new(\plugin_dir_url(__FILE__))->package();
}

return $package;
Expand All @@ -42,6 +42,6 @@ function autoload(string $projectRoot): void
\add_action(
'plugins_loaded',
fn() => package()
->addModule(EntitiesSearch\Modules\E2e\Module::new())
->addModule(Kensaku\Modules\E2e\Module::new())
->boot()
);
Loading

0 comments on commit 1a68941

Please sign in to comment.