Connecting Pieces: How to Put it All Together

Contents

version: 2020.2.27

When creating new iiidea via the Riiiver App (Android/iOS), the user is asked to select the 3 Pieces that will make up this iiidea. Riiiver emphasizes user choice, and creators can choose to start with any of the T, S, or A Pieces, but it is important to recognize that each Piece has its own input/output type that determines what other Pieces to which it can connect.

For instance, if a user starts with the middle S Piece, then they will only be able to connect to T Pieces that output the type of data that this S Piece wants input, and they will only be able to connect to A Pieces that want the input that this particular S Piece outputs. It's all about connecting outputs and inputs that match, and it's a lot simpler than it sounds.

WiringRule1

In the above image, you can see that we've selected an S that wants no particular input (None), but outputs a Number as its result. If a user were to select this Piece first, the following restrictions would apply:

WiringRule2

A user starting with this S Piece will be able to connect to any T Piece (as no particular input type is specified), but they will only be able to see A Pieces that can receive a Number input. The user will NOT see A Pieces that are expecting other inputs, such as String data. Pieces must connect according to the input/output rules, and the details of those rules are described on this page.


Input/Output Rules

Does this Piece require a specific input/output?

Piece connections depend entirely on matching inputs/outputs, but what about Pieces that don't specify any definite input/output?

  1. Pieces that don't require a specific input (None) can actually connect to any previous Piece. However, this Piece will simply ignore and throw out any data that is input to it before executing its own function.

    WiringRuleInOut1

  2. Pieces with no particular output cannot connect to following Pieces that are awaiting a specific type of input. But if the next Piece is also satisfied with a null input, then outputting nothing works just fine.

    WiringRuleInOut2

  3. In all other cases, the input/output types need to match, with detailed connection rules as follows:

Rules for Connecting Pieces with Active Input/Output

There are 5 types of information that Pieces can be defined to accept as input or distribute as output:

TypeAdditional restrictions?
booleanNo
stringYes
numberYes
objectYes
arrayYes

The first rule of connecting Pieces is simply to plug together matching inputs and outputs (outside of the unique Noneoptions described above). Furthermore, 4 of the 5 types actually have additional conditions that need to be met for a clean match.

Those additional conditions are detailed below, with PieceJSON examples to demonstrate the execution:


boolean

Additional restrictions

None.

PieceJSON Example
"output" : {
    "type" : "object", 
    "properties" : {
         "result" : {
             "type" : "boolean",
             "x-title" : {
                 "en" : "Output whether it succeeds.",
                 "ja" : "正常に終了したかどうか出力"
             }
         }
    }
},
Input/Output Example
{ 
   "result": true
}


string

Additional restrictions
  1. The string input and output formats need to match as well. Refer to the below Format Table when designing your Piece.
  2. If the string formats don't match, then it doesn't matter if both Pieces are expecting string input/output, because they will not be able to connect. The only exception to this is...
  3. When a Piece is expecting a string formatted as text, it can can accept as input any kind of string output by the previous Piece.

Format Table
TypeFormatExampleNotes
stringtext-Can accept any string input without limitation
email-Format in accordance with email standards: RFC 5322, section 3.4.1
date-time2019-06-13T20:20:39+09:00Format as: YYYY-MM-DDThh:mm:ssTZD
date1997-07-16Format as: YYYY-MM-DD
time20:21:10Format as: hh:mm:ss
PieceJSON Example (date-time)
"output" : {
    "type" : "object",
    "properties" : {
        "result" : {
            "type" : "string",
            "format" : "date-time",
            "x-title" : {
                "en" : "Current time(YYYY-MM-DDThh:mm:ssTSD)",
                "ja" : "現在日時(YYYY-MM-DDThh:mm:ssTSD)で出力"
            }
        }
    }
},
Input/Output Example (date-time)
{ 
   "result": "2019-06-13T20:20:39+09:00"
}


number

Additional restrictions

Number type input/output requires that you set a mininum (min) and maximum (max) value. Please only set these min/max values between -1,000,000 and 1,000,000

  1. When the input min value is lower than or equal to the output min value, the Pieces can connect. (For instance: If the input Piece requires a minimum value of 10, and the output Piece only delivers numbers higher than 10, these two Pieces are OK to connect.)
  2. When the input max value is higher than or equal to the output max value, the Pieces can connect. (For instance: If the input Piece only accepts a maximum value of 100, and the output Piece delivers valus up to 1000, these two Pieces are OK to connect. However, in this case only the maximum input value of 100 will be processed.)

TypeNumberRule

In other words, if the total range of output possibilities of a Piece fits completely within the total range of input possibilities expected by the subsequent Piece, then we know that the number can be sent and delivered successfully, and the Pieces can be connected.

PieceJSON Example
"output" : {
    "type" : "object",
    "properties" : {
        "result" : {
            "type" : "number",
            "x-title" : {
                "en" : "Age.",
                "ja" : "年齢を出力"
            },
            "min" : "0",
            "max" : "120" 
        }
    }
},
Input/Output Example
{ 
   "result": 30
}


object

Additional restrictions
  1. The object type input/output allows you to include a number of different types of information in a single Piece; however, the number of objects output by one Piece must match the number of objects expected as input by the next Piece. In the below example, you can see a Piece that outputs 4 unique object data (number - direction, number - distance, string, and boolean).

    TypeObjectRule1

  2. Just as you need to match the same number of object data, you also need to match the names given to each of these objects, so that the Pieces know which output object connects to which input object. In the below example, the titles given to the 4 object data are: directiondistancestoreName、and openHour. Therefore, the next Piece needs to be ready to accept 4 objects with those exact titles.

    TypeObjectRule2

  3. All settings and types for the paired input/output object data also need to match. Please similarly be sure that the white space and order of the values is the same between the input and output object Pieces to facilitate a smooth and snug connection.

  4. If including any of the boolean, string, or number types described on this page above, the rules for each of those individual types need to be met. For example, including a number output in a Piece that also delivers other object data doesn't invalidate the value limits that exist in Pieces that only deliver number data.

PieceJSON Example
"output" : {
    "type" : "object",
    "properties" : {
        "result" : {
            "type" : "object",
            "properties" : {
                "direction" : {
                    "type" : "number",
                    "x-unit" : "degrees",
                    "x-title" : {
                         "en" : "Direction to the store.",
                         "ja" : "お店の方向"
                    },
                    "min" : "0",
                    "max" : "359" 
                },
                "distance" : {
                    "type" : "number",
                    "x-unit" : "m",
                    "x-title" : {
                         "en" : "Distance to the store.",
                         "ja" : "お店までの距離"
                    },
                    "min" : "0",
                    "max" : "5000"
                },
                "storeName" : {
                    "type" : "string",
                    "format" : "text",
                    "x-title" : {
                        "en" : "Store name.",
                        "ja" : "店名"
                    }
                },
                "openHour" : {
                    "type" : "boolean",
                    "x-title" : {
                        "en" : "Output true/false whether the store is open.",
                        "ja" : "開店しているかどうか"
                    }
                }
            }
        }
    }
},

Input/Output Example

"result": {
    "direction": 350, 
    "distance": 1200, 
    "storeName": "Starbucks",
    "openHour": true 
}


array

Additional restrictions
  1. In the above we've discussed the basics and rules for connecting Pieces that are of the same type (booleanstringnumberobject). However, these are all one-to-one connections. With an array type Piece, you can include multiple items of the same type in a single input/output.

    TypeArrayRule1
    Additionally, you can set the mininum (minItems) and maximum (maxItems) amount of items that the Piece can input/output, such that a random amount of items within this range will be input/output. If you do not set these minimums of maximums, then the minItems value will be set to minItems = 0, and the maxItems value will be set to maxItems = 2,147,483,647. This default setting will deliver all items included in the array to the next Piece.

  2. When the input amount of minItems in a receiving Piece is lower than or equal to the output amount of minItems delivered by the previous Piece, connection is possible. (For instance: If the input Piece requires at least 2 input items, and the output Piece delivers 3, these two Pieces are OK to connect. However, only the first 2 outputs will be received.)

  3. Similarly, when the input number of maxItems in a receiving Piece is lower than or equal to the output amount of maxItems delivered by the previous Piece, connection is possible.

    TypeArrayRule2

PieceJSON Example (String-type items)
"output" : {
    "type" : "object",
    "properties" : {
        "result" : {
            "type" : "array",
            "x-title" : {
                "en" : "Output the current time in 1, 2, or 3 different regions.",
                "ja" : "1~3つの地域の時刻を出力"
            },
            "maxItems":3,
            "minItems":1,
            "items":{
                "type": "string",
                "format": "time"
            }
        }
    }
},
Input/Output Example (String-type items)
"result" : { 
    ["10:01:01", "10:05:01", "09:01:01"]
}
PieceJSON Example (Object-type items)
"output" : {
    "type" : "object",
    "properties" : {
        "result" : {
            "type" : "array",
            "x-title" : {
                "en" : "Output all store detail information.",
                "ja" : "お店の方向、距離、店名、開店しているかどうかの中から必要な項目を出力"
            },
            "maxItems":3,
            "minItems":1,
            "items":{
                "type" : "object",
                "properties" : {
                    "direction" : {
                        "type" : "number",
                        "x-unit" : "degrees",
                        "min" : "0",
                        "max" : "359" 
                    },
                    "distance" : {
                        "type" : "number",
                        "x-unit" : "m",
                        "min" : "0",
                        "max" : "5000"
                    },
                    "storeName" : {
                        "type" : "string",
                        "format" : "text"
                    },
                    "openHour" : {
                        "type" : "boolean"
                    }
                }
            }
        }
    }   
},
Input/Output Example (Object-type items)
"result" : {
    [
        { "direction": 350, "distance": 1200, "storeName": "Starbucks", "openHour": true},
        { "direction": 10, "distance": 2500, "storeName": "Cafe", "openHour": false}
    ]
}