Browse Source

Content directory schemas initial: .schema.json files and example inputs

Leszek Wiesner 4 years ago
parent
commit
046e915d29

+ 6 - 0
content-directory-schemas/README.md

@@ -0,0 +1,6 @@
+### Content directory json schemas and inputs
+#### Working in `VSCode`
+1. Create `.vscode` folder inside your working directory (if doesn't already exist)
+1. Copy `vscode-recommended.settings.json` into `.vscode` directory and rename it to `settings.json` (or merge it with the exsisting `settings.json`)
+1. If your working directory is not `content-directory-schema`, modify the `"url"` properties under `"json.schemas"` to match the relative paths from your working directory (ie. if inside root monorepo directory, you will need to add `/content-directory-schema`)
+1. Get the benefit of live-validation of files inside `inputs`! (you must follow the `*Class.json`, `*Schema.json` naming pattern)

+ 4 - 0
content-directory-schemas/inputs/classes/1_LanguageClass.json

@@ -0,0 +1,4 @@
+{
+  "name": "Language",
+  "description": "A language in which the content on the platform may be published"
+}

+ 4 - 0
content-directory-schemas/inputs/classes/2_HttpMediaLocationClass.json

@@ -0,0 +1,4 @@
+{
+  "name": "HttpMediaLocation",
+  "description": "An object describing http location of media object"
+}

+ 4 - 0
content-directory-schemas/inputs/classes/3_JoystreamMediaLocationClass.json

@@ -0,0 +1,4 @@
+{
+  "name": "JoystreamMediaLocation",
+  "description": "An object describing location of media object in a format specific to Joystream platform"
+}

+ 4 - 0
content-directory-schemas/inputs/classes/4_MediaLocationClass.json

@@ -0,0 +1,4 @@
+{
+  "name": "MediaLocationClass",
+  "description": "An object describing how the related media object can be accessed"
+}

+ 4 - 0
content-directory-schemas/inputs/classes/5_ContentCategoryClass.json

@@ -0,0 +1,4 @@
+{
+  "name": "ContentCategory",
+  "description": "A category the content may be published under"
+}

+ 4 - 0
content-directory-schemas/inputs/classes/6_ChannelClass.json

@@ -0,0 +1,4 @@
+{
+  "name": "Channel",
+  "description": "A channel belonging to certain member. Members can publish certain type of content (ie. videos) through channels."
+}

+ 18 - 0
content-directory-schemas/inputs/schemas/1_LanguageSchema.json

@@ -0,0 +1,18 @@
+{
+  "classId": 1,
+  "newProperties": [
+    {
+      "name": "Name",
+      "description": "The name of the language (ie. English)",
+      "required": true,
+      "unique": true,
+      "property_type": { "Single": { "Text": 64 } }
+    },
+    {
+      "name": "Code",
+      "description": "ISO 639-1 code of the language (ie. en)",
+      "required": true,
+      "property_type": { "Single": { "Text": 2 } }
+    }
+  ]
+}

+ 18 - 0
content-directory-schemas/inputs/schemas/2_HttpMediaLocationSchema.json

@@ -0,0 +1,18 @@
+{
+  "classId": 2,
+  "newProperties": [
+    {
+      "name": "url",
+      "description": "The http url pointing to the media",
+      "required": true,
+      "unique": false,
+      "property_type": { "Single": { "Text": 256 } }
+    },
+    {
+      "name": "port",
+      "description": "The port to use when connecting to the http url (defaults to 80)",
+      "required": false,
+      "property_type": { "Single": "Uint16" }
+    }
+  ]
+}

+ 12 - 0
content-directory-schemas/inputs/schemas/3_JoystreamMediaLocationSchema.json

@@ -0,0 +1,12 @@
+{
+  "classId": 3,
+  "newProperties": [
+    {
+      "name": "dataObjectId",
+      "description": "Id of the data object in the Joystream runtime dataDirectory module",
+      "property_type": { "Single": "Uint64" },
+      "required": true,
+      "unique": true
+    }
+  ]
+}

+ 18 - 0
content-directory-schemas/inputs/schemas/4_MediaLocationSchema.json

@@ -0,0 +1,18 @@
+
+{
+  "classId": 4,
+  "newProperties": [
+    {
+      "name": "httpMediaLocation",
+      "description": "A reference to HttpMediaLocation",
+      "required": false,
+      "property_type": { "Single": { "Reference": { "classId": 2, "sameOwner": true } } }
+    },
+    {
+      "name": "joystreamMediaLocation",
+      "description": "A reference to JoystreamMediaLocation",
+      "required": false,
+      "property_type": { "Single": { "Reference": { "classId": 3, "sameOwner": true } } }
+    }
+  ]
+}

+ 19 - 0
content-directory-schemas/inputs/schemas/5_ContentCategorySchema.json

@@ -0,0 +1,19 @@
+
+{
+  "classId": 5,
+  "newProperties": [
+    {
+      "name": "Name",
+      "description": "The name of the category",
+      "required": true,
+      "unique": true,
+      "property_type": { "Single": { "Text": 64 } }
+    },
+    {
+      "name": "Description",
+      "description": "The description of the category",
+      "required": false,
+      "property_type": { "Single": { "Text": 1024 } }
+    }
+  ]
+}

+ 50 - 0
content-directory-schemas/inputs/schemas/6_ChannelSchema.json

@@ -0,0 +1,50 @@
+
+{
+  "classId": 6,
+  "newProperties": [
+    {
+      "name": "title",
+      "description": "The title of the Channel",
+      "required": true,
+      "unique": true,
+      "property_type": { "Single": { "Text": 64 } }
+    },
+    {
+      "name": "description",
+      "description": "The description of a Channel",
+      "required": true,
+      "property_type": { "Single": { "Text": 1024 } }
+    },
+    {
+      "name": "coverPhotoUrl",
+      "description": "Url for Channel's cover (background) photo. Recommended ratio: 16:9.",
+      "required": true,
+      "property_type": { "Single": { "Text": 256 } }
+    },
+    {
+      "name": "avatarPhotoURL",
+      "description": "Channel's avatar photo.",
+      "required": true,
+      "property_type": { "Single": { "Text": 256 } }
+    },
+    {
+      "name": "isPublic",
+      "description": "Flag signaling whether a channel is public.",
+      "required": true,
+      "property_type": { "Single": "Bool" }
+    },
+    {
+      "name": "isCurated",
+      "description": "Flag signaling whether a channel is curated/verified.",
+      "required": true,
+      "property_type": { "Single": "Bool" },
+      "locking_policy": { "is_locked_from_controller": true }
+    },
+    {
+      "name": "language",
+      "description": "The primary langauge of the channel's content",
+      "required": false,
+      "property_type": { "Single": { "Reference": { "classId": 1, "sameOwner": false } } }
+    }
+  ]
+}

+ 167 - 0
content-directory-schemas/schemas/AddClassSchema.schema.json

@@ -0,0 +1,167 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema",
+  "$id": "https://joystream.org/AddClassSchema.schema.json",
+  "title": "AddClassSchema",
+  "description": "JSON schema to describe a new schema for a certain class in Joystream network",
+  "type": "object",
+  "additionalProperties": false,
+  "required": [
+    "classId"
+  ],
+  "anyOf": [
+    { "required": [ "newProperties" ] },
+    { "required": [ "existingProperties" ] }
+  ],
+  "properties": {
+    "classId": { "$ref": "#/definitions/ClassId" },
+    "existingProperties": {
+      "type": "array",
+      "minItems": 1,
+      "uniqueItems": true,
+      "items": { "$ref": "#/definitions/PropertyInSchemIndex" }
+    },
+    "newProperties": {
+      "type": "array",
+      "minItems": 1,
+      "uniqueItems": true,
+      "items": { "$ref": "#/definitions/Property" }
+    }
+  },
+  "definitions": {
+    "ClassId": {
+      "type": "integer",
+      "minimum": 1
+    },
+    "PropertyInSchemIndex": {
+      "type": "integer",
+      "minimum": 0
+    },
+    "DefaultBoolean": {
+      "type": "boolean",
+      "default": false
+    },
+    "Property": {
+      "type": "object",
+      "additionalProperties": false,
+      "required": [
+        "name",
+        "property_type"
+      ],
+      "properties": {
+        "property_type": {
+          "oneOf": [
+            { "$ref": "#/definitions/SinglePropertyVariant" },
+            { "$ref": "#/definitions/VecPropertyVariant" }
+          ]
+        },
+        "name": { "$ref": "#/definitions/PropertyName" },
+        "description": { "$ref": "#/definitions/PropertyDescription" },
+        "required": { "$ref": "#/definitions/DefaultBoolean" },
+        "unique": { "$ref": "#/definitions/DefaultBoolean" },
+        "locking_policy": { "$ref": "#/definitions/LockingPolicy" }
+      }
+    },
+    "PropertyName": {
+      "type": "string",
+      "minLength": 1,
+      "maxLength": 100
+    },
+    "PropertyDescription": {
+      "type": "string",
+      "minLength": 0,
+      "default": ""
+    },
+    "SinglePropertyType": {
+      "oneOf": [
+        {"$ref": "#/definitions/PrimitiveProperty"},
+        {"$ref": "#/definitions/TextProperty"},
+        {"$ref": "#/definitions/HashProperty"},
+        {"$ref": "#/definitions/ReferenceProperty"}
+      ]
+    },
+    "SinglePropertyVariant": {
+      "type": "object",
+      "additionalProperties": false,
+      "required": ["Single"],
+      "properties": {
+        "Single": { "$ref": "#/definitions/SinglePropertyType" }
+      }
+    },
+    "VecPropertyType": {
+      "type": "object",
+      "additionalProperties": false,
+      "required": [
+        "vec_type",
+        "max_length"
+      ],
+      "properties": {
+        "vec_type": { "$ref": "#/definitions/SinglePropertyType" },
+        "max_length": { "$ref": "#/definitions/MaxVecItems" }
+      }
+    },
+    "VecPropertyVariant": {
+      "type": "object",
+      "additionalProperties": false,
+      "required": ["Vector"],
+      "properties": {
+        "Vector": { "$ref": "#/definitions/VecPropertyType" }
+      }
+    },
+    "PrimitiveProperty": {
+      "type": "string",
+      "enum": ["Bool", "Uint16", "Uint32", "Uint64", "Int16", "Int32", "Int64"]
+    },
+    "TextProperty": {
+      "type": "object",
+      "additionalProperties": false,
+      "required": ["Text"],
+      "properties": {
+        "Text": { "$ref": "#/definitions/MaxTextLength" }
+      }
+    },
+    "HashProperty": {
+      "type": "object",
+      "additionalProperties": false,
+      "required": ["Hash"],
+      "properties": {
+        "Hash": { "$ref": "#/definitions/MaxTextLength" }
+      }
+    },
+    "MaxTextLength": {
+      "type": "integer",
+      "minimum": 1,
+      "maximum": 65535
+    },
+    "MaxVecItems": {
+      "type": "integer",
+      "minimum": 1,
+      "maximum": 65535
+    },
+    "ReferenceProperty": {
+      "type": "object",
+      "additionalProperties": false,
+      "required": ["Reference"],
+      "properties": {
+        "Reference": {
+          "type": "object",
+          "additionalProperties": false,
+          "required": [
+            "classId"
+          ],
+          "properties": {
+            "sameOwner": { "$ref": "#/definitions/DefaultBoolean" },
+            "classId": { "$ref": "#/definitions/ClassId" }
+          }
+        }
+      }
+    },
+    "LockingPolicy": {
+      "type": "object",
+      "additionalProperties": false,
+      "properties": {
+        "is_locked_from_maintainer": { "$ref": "#/definitions/DefaultBoolean" },
+        "is_locked_from_controller": { "$ref": "#/definitions/DefaultBoolean" }
+      }
+    }
+  }
+}

+ 45 - 0
content-directory-schemas/schemas/CreateClass.schema.json

@@ -0,0 +1,45 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema",
+  "$id": "https://joystream.org/CreateClass.schema.json",
+  "title": "CreateClass",
+  "description": "JSON schema to describe a new class for Joystream network",
+  "type": "object",
+  "additionalProperties": false,
+  "required": [
+    "name",
+    "description"
+  ],
+  "properties": {
+    "name": {
+      "type": "string",
+      "description": "Name of this class. Required property."
+    },
+    "description": {
+      "type": "string",
+      "description": "Description of this class."
+    },
+    "class_permissions": {
+      "type": "object",
+      "additionalProperties": false,
+      "properties": {
+        "any_member": { "$ref": "#/definitions/DefaultBoolean" },
+        "entity_creation_blocked": { "$ref": "#/definitions/DefaultBoolean" },
+        "all_entity_property_values_locked": { "$ref": "#/definitions/DefaultBoolean" },
+        "maintainers": {
+          "type": "array",
+          "uniqueItems": true,
+          "items": {
+            "type": "number"
+          },
+          "default": []
+        }
+      }
+    }
+  },
+  "definitions": {
+    "DefaultBoolean": {
+      "type": "boolean",
+      "default": false
+    }
+  }
+}

+ 12 - 0
content-directory-schemas/vscode-recommended.settings.json

@@ -0,0 +1,12 @@
+{
+  "json.schemas": [
+    {
+      "fileMatch": ["*Schema.json"],
+      "url": "/schemas/AddClassSchema.schema.json"
+    },
+    {
+      "fileMatch": ["*Class.json"],
+      "url": "/schemas/CreateClass.schema.json"
+    }
+  ]
+}