Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into greenkeeper/rollup-…
Browse files Browse the repository at this point in the history
…plugin-commonjs-9.0.0
  • Loading branch information
andersonba committed Mar 18, 2018
2 parents 26a9a4b + a85a4ad commit 14f7b6f
Show file tree
Hide file tree
Showing 43 changed files with 1,841 additions and 807 deletions.
1 change: 1 addition & 0 deletions .ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Change Log

## [1.17.0](https://github.com/andersonba/yve-bot/tree/1.17.0) (2018-03-17)
[Full Changelog](https://github.com/andersonba/yve-bot/compare/1.16.0...1.17.0)

**Implemented enhancements:**

- feature: support for textarea using multiline prop [\#111](https://github.com/andersonba/yve-bot/issues/111)
- create/extend rule types with short mode [\#110](https://github.com/andersonba/yve-bot/issues/110)
- feature: skip rule based on conditional [\#104](https://github.com/andersonba/yve-bot/issues/104)

**Merged pull requests:**

- Add multline prop to support textarea [\#113](https://github.com/andersonba/yve-bot/pull/113) ([cristianossd](https://github.com/cristianossd))
- Implementing skip property [\#108](https://github.com/andersonba/yve-bot/pull/108) ([cristianossd](https://github.com/cristianossd))

## [1.16.0](https://github.com/andersonba/yve-bot/tree/1.16.0) (2018-03-08)
[Full Changelog](https://github.com/andersonba/yve-bot/compare/1.15.0...1.16.0)

**Fixed bugs:**

- fix rollup to build UI bundle without core [\#109](https://github.com/andersonba/yve-bot/issues/109)

## [1.15.0](https://github.com/andersonba/yve-bot/tree/1.15.0) (2018-03-05)
[Full Changelog](https://github.com/andersonba/yve-bot/compare/1.13.0...1.15.0)

Expand Down
4 changes: 3 additions & 1 deletion docs/_sass/chat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
display: block;
width: 100%;
color: #333;
min-height: 53px;
resize: none;

&:focus {
outline: none;
Expand All @@ -158,7 +160,7 @@
font-family: 'Roboto', sans-serif;
position: absolute;
right: 10px;
top: 16px;
top: 17px;
background: transparent;
color: #685C79;
border: 0;
Expand Down
9 changes: 5 additions & 4 deletions docs/docs/choosing-the-bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ title: Choosing the Bundle

YveBot have two bundles. Make your choice:

| Bundle | Description | Browser | Node |
|--------|-------------|---------|------|
| UI | A pre-defined wrapper over the *Core* that implements a basic UI chat conversation. You will only have to create a stylesheet file. | X
| Core | Minimal code to configure your bot. | X | X
| Bundle | Description | Browser | Node | Webpack |
|--------|-------------|---------|------|---------|
| Core | Bot engine. | X | X | X
| UI | A pre-defined wrapper over the *Core* that implements a basic Chat UI conversation. | X | | X
| Web | Bundle for browser. It's union of *Core* and *UI*. | X | | X


[Next: UI API]({{ site.baseurl }}/docs/ui){:.btn}
46 changes: 19 additions & 27 deletions docs/docs/customize.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,40 @@ title: Customize types, validators and actions

Creating custom types, validations and actions for your bot.

## Custom types
## Custom Types

Create types of messages that your bot will use. Examples: City and username autocomplete acessing a database.
Create types of messages that your bot will use as user input. Examples: City and username autocomplete acessing a database.

**Object configuration:**
- **transform** - transforms answer with async function
- **validators** - configures the validators

- **executors** - an array of objects with transform and validators;
- **transform** - transforms answer with async function
- **validators** - configures the validators

#### Extends

Extends from an existing type
#### Define

```javascript
bot.types.extend('CustomString', 'String', {
executors: [{
transform: (answer, rule, bot) => {},
validators: [],
bot.types.define('Username', {
transform: answer => fetch('/find-username-by-id', {
body: JSON.stringify({ id: answer }),
}),
validators: [{
number: true,
warning: 'Invalid user id',
}],
});
```

#### Define
#### Extends

Create a type from zero
Extends from an existing type

```javascript
bot.types.define('Username', {
executors: [{
transform: answer => fetch('/find-username-by-id', {
body: JSON.stringify({ id: answer }),
}),
validators: [{
number: true,
warning: 'Invalid user id',
}],
}]
bot.types.extend('ZipCode', 'Number', {
transform: (num) => friendlyZip(num),
validators: [],
});
```

## Custom actions
## Custom Actions

Create actions that your bot will interact. Examples: Sending email or requesting a hook url.

Expand All @@ -71,7 +63,7 @@ bot.actions.define('welcomeEmail', async (actionOptions, bot) => {
- templateName: first-step-done.html
```

## Custom validators
## Custom Validators

Create validators to be used in your messages. Examples: Color picker.

Expand Down
18 changes: 8 additions & 10 deletions docs/docs/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ Enhance your chat with custom extensions and load just what you're going to use.
Autocomplete-like for chat conversation.


### How to import?
### How do I use?

##### Node / React
```javascript
import YveBot from 'yve-bot';
import 'yve-bot/ext/types/TypeName';
```

##### Browser with UI bundle
##### Using on Browser
```html
<script src="//cdn.jsdelivr.net/npm/yve-bot@latest/ui.js"></script>
<script src="//cdn.jsdelivr.net/npm/yve-bot@latest/web.js"></script>
<script src="//cdn.jsdelivr.net/npm/yve-bot@latest/ext/types/TypeName"></script>
```


##### Node / React
```javascript
import YveBot from 'yve-bot/ui';
import 'yve-bot/ext/types/TypeName';
```

[Next: Examples]({{ site.baseurl }}/docs/examples){:.btn}
2 changes: 1 addition & 1 deletion docs/docs/flows.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Flows: Grouping rules
title: "Flows: Grouping rules"
---

# Flows: Grouping rules
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ The simplest way to build a smart and customized rule-based bot conversation. Yv
Check the available bundles bellow.


### UI - A ready Chat UI
A simple component to be used in your website. (browser-only)
### UI - Simple Chat Component
A extensible component to be used in your website. (browser-only)

```html
<script src="//cdn.jsdelivr.net/npm/yve-bot/ui.js"></script>
<script src="//cdn.jsdelivr.net/npm/yve-bot/web.js"></script>
<script>
new YveBot(rules, { target: '.Chat' }).start();
</script>
```

### Core - Bot engine
Integrate with server-side (eg: websocket, facebook, etc...) or create your own UI. (node/browser)
Integrate with server-side (eg: websocket, facebook, etc...) or create your own chat component over the engine.

```bash
npm install yve-bot
yarn add yve-bot
```

```javascript
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/playground.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ title: Playground
<script src="https://cdn.jsdelivr.net/npm/codemirror@5.31.0/lib/codemirror.js"></script>
<script src="https://cdn.jsdelivr.net/npm/codemirror@5.31.0/mode/yaml/yaml.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.9.1/js-yaml.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/yve-bot/ui.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/yve-bot/web.min.js"></script>

<script>
var editor = CodeMirror.fromTextArea(document.getElementById('editor'), {
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ You can define a rule using two styles
| actions | `[]` | array[[RuleAction](#ruleaction)] | Executes an action after bot's message
| preActions | `[]` | array[[RuleAction](#ruleaction)] | Executes an action before bot's message
| postActions | `[]` | array[[RuleAction](#ruleaction)] | Executes an action after user's answer
| skip | `false` | `boolean | (output, rule, bot) => boolean` | Skip rule based on conditional function
| multiline | `true` | `boolean` | Enable multiline input text, otherwise use single line input
| exit | `false` | boolean | Terminates the conversation on this rule

# FormattedMessage
Expand Down Expand Up @@ -144,5 +146,4 @@ _** validators are used ONLY in the first executor from rule's type_
|----------|-----------|-------------|
| timeout | number | Executes setTimeout


[Next: Flows: Grouping rules]({{ site.baseurl }}/docs/flows){:.btn}
10 changes: 7 additions & 3 deletions docs/docs/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ title: UI API

Create bots without re-implement the chat conversation UI components. This browser lib is a wrapper over the Core bundle.

## Initializing
## Using on Browser
```html
<script src="//cdn.jsdelivr.net/npm/yve-bot/ui.js"></script>
<script src="//cdn.jsdelivr.net/npm/yve-bot/web.js"></script>

<script>
var rules = [...];
Expand All @@ -20,11 +20,15 @@ Create bots without re-implement the chat conversation UI components. This brows
</script>
```

or using React
## Using with Bundlers
(eg: compiling React app with webpack)

```javascript
import YveBotUI from 'yve-bot/ui';
```

## API

| Argument | Default | Type | Description |
|----------|---------|------|-------------|
| rules | - | array[Rule] | Array of Rule
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ include_index_menu: false
</div>
</div>

<script src="//cdn.jsdelivr.net/npm/yve-bot@latest/ui.js"></script>
<script src="//cdn.jsdelivr.net/npm/yve-bot@latest/web.js"></script>
<script src="assets/js/chat.js"></script>
4 changes: 4 additions & 0 deletions examples/chat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@

- message: What city do you live in?
name: city
multiline: false
type: String

- message: I'll skip this message
skip: true

- message: Thanks, wait a moment.

- sleep: 4000
Expand Down
2 changes: 1 addition & 1 deletion examples/socket.io/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div id="output"></div>

<script src="/socket.io/socket.io.js"></script>
<script src="/ui.js"></script>
<script src="/web.js"></script>
<script src="/client.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion examples/socket.io/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ io.on('connection', chat => {
app.use(bodyParser.json());
app.use('/', express.static(__dirname));
app.use('/chat.css', express.static(__dirname + '/../web/chat.css'));
app.use('/ui.js', express.static(__dirname + '/../../lib/ui.js'));
app.use('/web.js', express.static(__dirname + '/../../lib/web.js'));

server.listen(3000, () => {
console.log('Yve server example listening on port 3000');
Expand Down
8 changes: 7 additions & 1 deletion examples/web/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ form {
bottom: 0;
width: 100%;
}
form input {
form input, form textarea {
border: 0;
padding: 10px;
width: 83%;
margin-right: .5%;
font-size: 13px;
}
form textarea {
resize: none;
height: auto;
min-height: 36px;
vertical-align: middle;
}
form button {
width: 15%;
background-color: transparent;
Expand Down
2 changes: 1 addition & 1 deletion examples/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<script src="https://code.jquery.com/jquery-2.1.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.9.1/js-yaml.min.js"></script>
<script src="/ui.js"></script>
<script src="/web.js"></script>
<script src="/types/StringSearch.js"></script>
<script src="/client.js"></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion examples/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const app = express();

app.use('/', express.static(__dirname));
app.use('/chat.yaml', express.static(__dirname + '/../chat.yaml'));
app.use('/ui.js', express.static(__dirname + '/../../lib/ui.js'));
app.use('/web.js', express.static(__dirname + '/../../lib/web.js'));
app.use('/types', express.static(__dirname + '/../../lib/ext/types'));

app.listen(3000, () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/core.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/ui.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/web.js

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yve-bot",
"version": "1.15.0",
"version": "1.17.0",
"description": "Smart rule-based bot",
"main": "core.js",
"module": "core.js",
Expand All @@ -16,6 +16,7 @@
"test:bundle": "bundlesize",
"lint": "tslint 'src/**/*.ts'",
"clean": "rimraf lib && rimraf compiled",
"bundleAnalyzer": "BUNDLE_ANALYZER=1 rollup -c rollup.config.ts",
"prebuild": "yarn clean",
"build": "rollup -c rollup.config.ts && rimraf compiled",
"watch": "rollup -c rollup.config.ts -w"
Expand All @@ -32,11 +33,12 @@
"jest": "^22.0.1",
"lodash-es": "^4.17.4",
"rimraf": "^2.6.2",
"rollup": "^0.56.2",
"rollup": "^0.57.0",
"rollup-analyzer": "^1.1.0",
"rollup-plugin-commonjs": "^9.0.0",
"rollup-plugin-json": "^2.3.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-typescript2": "^0.11.1",
"rollup-plugin-typescript2": "^0.12.0",
"rollup-plugin-uglify": "^3.0.0",
"ts-jest": "^22.0.0",
"ts-node": "^5.0.0",
Expand Down Expand Up @@ -74,11 +76,15 @@
"bundlesize": [
{
"path": "./lib/core.js",
"maxSize": "11 kB"
"maxSize": "9 kB"
},
{
"path": "./lib/ui.js",
"maxSize": "13 kB"
"maxSize": "2.5 kB"
},
{
"path": "./lib/web.js",
"maxSize": "11 kB"
},
{
"path": "./lib/ext/types/StringSearch.js",
Expand Down
Loading

0 comments on commit 14f7b6f

Please sign in to comment.