From 3466dac3b9309dda313450ea5244845c16f5f2fd Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:30:03 -0400 Subject: [PATCH] feature: adds types and thing type --- types/thing/Thing.md | 97 ++++++++++++++++++++++++++++++++++++++++++++ types/type/Type.md | 26 ++++++++++++ types/type/Types.md | 38 +++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 types/thing/Thing.md create mode 100644 types/type/Type.md create mode 100644 types/type/Types.md diff --git a/types/thing/Thing.md b/types/thing/Thing.md new file mode 100644 index 0000000..88c1aeb --- /dev/null +++ b/types/thing/Thing.md @@ -0,0 +1,97 @@ +# Thing + +A thing is the most basic interface for any real or digital asset. + +## Schema + +The schema is defined by its Type committed on chain. + + +## Example + +A [Type](../type/Type.md) is created with properties that look like this: + +```json +{ + "properties": [ + { + "name": "title", + "type": "String", + "required": true + }, + { + "name": "description", + "type": "md", + "required": false + } + ] +} +``` + +We see that this Type has two properties; a title of type String and a description of type md (Markdown). + +When a Type is created, it also autogenerates basic Widgets for creating and displaying this data, and so our Type looks like: + +```json +"evrything.near": { + "types": { + "Idea": { + "properties": [ + { + "name": "title", + "type": "String", + "required": true + }, + { + "name": "description", + "type": "md", + "required": false + } + ], + "widgets": { + "summary": "Everything.Summary.Idea", + "view": "Everything.View.Idea", + "create": "Everything.Create.Idea" + } + } + } +} +``` + +The autogenerated "create" widget is a basic template and form for creating data of type "evrything.near/type/Idea", which consists of a title and description (a text input and a textarea). + +When data is created via the Everything.Create.Idea widget, it will save to the Social contract: + +```json +{ + "thing": { + "main": "[DATA]" + }, + "index": { + "[DOMAIN]": "{ key: \"main\", \"value\": { \"type\": \"evrything.near/type/Idea\" } })", + }, +} +``` + +Since the Create widget was autogenerated, we know that the DATA will be following the properties of the Type. + +However, we allow this to be free form because maybe the developer doesn't want the data to be permanent and forever on chain. If the developer wants the data to be stored on chain, then DATA would look like this: + +```json +{ + "title": "I have a cool idea!", + "description": "With Types, we could let the user choose where the data is stored, while still keeping it predictable for developers." +} +``` + +But maybe the developer wants the data to follow the Type schema, then be POSTed to a decentralized storage service where it can have some privacy. In this case, it creates the data and saves a reference to the thingId instead: + +```json +{ + "thingId": "thing123456789" +} +``` + +It doesn't matter how or where this data is stored, because the developer can design the view and summary widget to use the thingId to fetch the offchain data. + +The DATA just needs to represent a thing of TYPE, no matter where it is stored. diff --git a/types/type/Type.md b/types/type/Type.md new file mode 100644 index 0000000..e74fe67 --- /dev/null +++ b/types/type/Type.md @@ -0,0 +1,26 @@ +# Type + +Contains the properties, references to widgets necessary to display and create data of this type, and the optional metadata. + +## Schema + +| Key | Type | Description | +|--------------|-----------------------------------|-------------------------------------------------| +| **`""`** | String | Schema describing the properities of a thing and holding references to necessary widgets for displaying and creating data of this type. | +| _`metadata`_ | [Metadata](../common/Metadata.md) | The metadata information describing the type. | + +## Example + +```json +{ + "": "{ \"properties\": [{\"name\": \"title\",\"type\": \"String\",\"required\": true }, {\"name\": \"description\",\"type\": \"md\",\"required\": false },], \"widgets\": {\"summary\": \"evrything.near/widget/Everything.Summary.Idea\",\"view\": \"evrything.near/widget/Everything.View.Idea\",\"create\": \"evrything.near/widget/Everything.Create.Idea\"}};", + "metadata": { + "name": "Idea", + "description": "Idea type for proposals to the everything DAO", + "tags": { + "example": "", + "inline": "" + } + } +} +``` diff --git a/types/type/Types.md b/types/type/Types.md new file mode 100644 index 0000000..d5342dd --- /dev/null +++ b/types/type/Types.md @@ -0,0 +1,38 @@ +# Types + +Types created by the account. + +## Schema + +| Key | Type | Description | +|----------------------|-----------------------|--------------------------------------------------------------| +| **`[type_name]`** | [Type](./Type.md) | Contains the properties, references to widgets necessary to display and create data of this type, and the optional metadata. | + +## Example + +```json +{ + "Idea": { + "": "{ \"properties\": [{\"name\": \"title\",\"type\": \"String\",\"required\": true }, {\"name\": \"description\",\"type\": \"md\",\"required\": false },], \"widgets\": {\"summary\": \"evrything.near/widget/Everything.Summary.Idea\",\"view\": \"evrything.near/widget/Everything.View.Idea\",\"create\": \"evrything.near/widget/Everything.Create.Idea\"}};", + "metadata": { + "name": "Idea", + "description": "Idea type for proposals to the everything DAO", + "tags": { + "example": "", + "inline": "" + } + } + }, + "Event": { + "": "{ \"properties\": [{\"name\": \"title\",\"type\": \"String\",\"required\": true }, {\"name\": \"description\",\"type\": \"md\",\"required\": false }, {\"name\": \"date\",\"type\": \"Date\",\"required\": true }], \"widgets\": {\"summary\": \"evrything.near/widget/Everything.Summary.Event\",\"view\": \"evrything.near/widget/Everything.View.Event\",\"create\": \"evrything.near/widget/Everything.Create.Event\"}};", + "metadata": { + "name": "Event", + "description": "Event type for events approved by everything DAO", + "tags": { + "example": "", + "inline": "" + } + } + } +} +```